]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1003] Repackage sources from org.apache.maven.archiva.. to org.apache.archiva...
authorOlivier Lamy <olamy@apache.org>
Fri, 16 Sep 2011 13:28:30 +0000 (13:28 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 16 Sep 2011 13:28:30 +0000 (13:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171542 13f79535-47bb-0310-9956-ffa450edef68

206 files changed:
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractRepositoryBasedAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/BrowseAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/GlobalResults.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/MergeAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/SearchAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/SchedulerAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/SystemStatusAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/AbstractAppearanceAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/OrganisationInfoAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AddProxyConnectorAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractManagedRepositoriesAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractRemoteRepositoriesAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteRemoteRepositoryAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/RepositoriesAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/RepositoryGroupsAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/SortRepositoriesAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AddAdminRepoConsumerClosure.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumerComparator.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/reports/GenerateReportAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/reports/ViewAuditLogReportAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractRepositoryBasedAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/GlobalResults.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/OrganisationInfoAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRemoteRepositoriesAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AddAdminRepoConsumerClosure.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AdminRepositoryConsumerComparator.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/DeleteArtifactAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-checksumSearch-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-filteredSearch-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-quickSearch-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/UploadAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance.properties [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance_en.properties [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureRepositoryAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureSyncedRepositoryAction-addSelectedSyncedRepository-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureSyncedRepositoryAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryAction-validation.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/DeleteArtifactAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-checksumSearch-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-filteredSearch-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-quickSearch-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/UploadAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance.properties [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance_en.properties [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction-addSelectedSyncedRepository-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryAction-validation.xml [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractActionTestCase.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractWebworkTestCase.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AuditEventArgumentsMatcher.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/BrowseActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/DeleteArtifactActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/SearchActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/UploadActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AbstractManagedRepositoryActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DefaultActionValidatorManagerFactory.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/RepositoriesActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/SortRepositoriesActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/reports/GenerateReportActionTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AuditEventArgumentsMatcher.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/BrowseActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoryActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DefaultActionValidatorManagerFactory.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/log4j.xml
archiva-modules/archiva-web/archiva-webapp/src/test/tomcat/log4j.xml

diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java
new file mode 100644 (file)
index 0000000..4bd9f3d
--- /dev/null
@@ -0,0 +1,355 @@
+package org.apache.archiva.web.action;\r
+\r
+/*\r
+ * Licensed to the Apache Software Foundation (ASF) under one\r
+ * or more contributor license agreements.  See the NOTICE file\r
+ * distributed with this work for additional information\r
+ * regarding copyright ownership.  The ASF licenses this file\r
+ * to you under the Apache License, Version 2.0 (the\r
+ * "License"); you may not use this file except in compliance\r
+ * with the License.  You may obtain a copy of the License at\r
+ *\r
+ *  http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing,\r
+ * software distributed under the License is distributed on an\r
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
+ * KIND, either express or implied.  See the License for the\r
+ * specific language governing permissions and limitations\r
+ * under the License.\r
+ */\r
+\r
+import com.opensymphony.xwork2.ActionContext;\r
+import com.opensymphony.xwork2.ActionSupport;\r
+import org.apache.archiva.admin.model.AuditInformation;\r
+import org.apache.archiva.audit.AuditEvent;\r
+import org.apache.archiva.audit.AuditListener;\r
+import org.apache.archiva.audit.Auditable;\r
+import org.apache.archiva.metadata.repository.RepositorySessionFactory;\r
+import org.apache.archiva.security.ArchivaXworkUser;\r
+import org.apache.commons.lang.StringUtils;\r
+import org.apache.struts2.ServletActionContext;\r
+import org.apache.struts2.interceptor.SessionAware;\r
+import org.codehaus.plexus.redback.users.User;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.context.ApplicationContext;\r
+\r
+import javax.annotation.PostConstruct;\r
+import javax.inject.Inject;\r
+import javax.inject.Named;\r
+import javax.servlet.http.HttpServletRequest;\r
+import java.util.ArrayList;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+/**\r
+ * LogEnabled and SessionAware ActionSupport\r
+ */\r
+public abstract class AbstractActionSupport\r
+    extends ActionSupport\r
+    implements SessionAware, Auditable\r
+{\r
+    protected Map<?, ?> session;\r
+\r
+    protected Logger log = LoggerFactory.getLogger( getClass() );\r
+\r
+    @Inject\r
+    private List<AuditListener> auditListeners = new ArrayList<AuditListener>();\r
+\r
+\r
+    @Inject\r
+    @Named( value = "repositorySessionFactory" )\r
+    protected RepositorySessionFactory repositorySessionFactory;\r
+\r
+    @Inject\r
+    protected ApplicationContext applicationContext;\r
+\r
+    private String principal;\r
+\r
+    @PostConstruct\r
+    public void initialize()\r
+    {\r
+        // no op\r
+    }\r
+\r
+    @SuppressWarnings( "unchecked" )\r
+    public void setSession( Map map )\r
+    {\r
+        this.session = map;\r
+    }\r
+\r
+    public void addAuditListener( AuditListener listener )\r
+    {\r
+        this.auditListeners.add( listener );\r
+    }\r
+\r
+    public void clearAuditListeners()\r
+    {\r
+        this.auditListeners.clear();\r
+    }\r
+\r
+    public void removeAuditListener( AuditListener listener )\r
+    {\r
+        this.auditListeners.remove( listener );\r
+    }\r
+\r
+    protected void triggerAuditEvent( String repositoryId, String resource, String action )\r
+    {\r
+        AuditEvent event = new AuditEvent( repositoryId, getPrincipal(), resource, action );\r
+        event.setRemoteIP( getRemoteAddr() );\r
+\r
+        for ( AuditListener listener : auditListeners )\r
+        {\r
+            listener.auditEvent( event );\r
+        }\r
+    }\r
+\r
+    protected void triggerAuditEvent( String resource, String action )\r
+    {\r
+        AuditEvent event = new AuditEvent( null, getPrincipal(), resource, action );\r
+        event.setRemoteIP( getRemoteAddr() );\r
+\r
+        for ( AuditListener listener : auditListeners )\r
+        {\r
+            listener.auditEvent( event );\r
+        }\r
+    }\r
+\r
+    protected void triggerAuditEvent( String action )\r
+    {\r
+        AuditEvent event = new AuditEvent( null, getPrincipal(), null, action );\r
+        event.setRemoteIP( getRemoteAddr() );\r
+\r
+        for ( AuditListener listener : auditListeners )\r
+        {\r
+            listener.auditEvent( event );\r
+        }\r
+    }\r
+\r
+    private String getRemoteAddr()\r
+    {\r
+        HttpServletRequest request = ServletActionContext.getRequest();\r
+        return request != null ? request.getRemoteAddr() : null;\r
+    }\r
+\r
+    @SuppressWarnings( "unchecked" )\r
+    protected String getPrincipal()\r
+    {\r
+        if ( principal != null )\r
+        {\r
+            return principal;\r
+        }\r
+        return ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );\r
+    }\r
+\r
+    void setPrincipal( String principal )\r
+    {\r
+        this.principal = principal;\r
+    }\r
+\r
+    public void setAuditListeners( List<AuditListener> auditListeners )\r
+    {\r
+        this.auditListeners = auditListeners;\r
+    }\r
+\r
+    public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )\r
+    {\r
+        this.repositorySessionFactory = repositorySessionFactory;\r
+    }\r
+\r
+    protected <T> Map<String, T> getBeansOfType( Class<T> clazz )\r
+    {\r
+        //TODO do some caching here !!!\r
+        // olamy : with plexus we get only roleHint\r
+        // as per convention we named spring bean role#hint remove role# if exists\r
+        Map<String, T> springBeans = applicationContext.getBeansOfType( clazz );\r
+\r
+        Map<String, T> beans = new HashMap<String, T>( springBeans.size() );\r
+\r
+        for ( Map.Entry<String, T> entry : springBeans.entrySet() )\r
+        {\r
+            String key = StringUtils.substringAfterLast( entry.getKey(), "#" );\r
+            beans.put( key, entry.getValue() );\r
+        }\r
+        return beans;\r
+    }\r
+\r
+\r
+    protected AuditInformation getAuditInformation()\r
+    {\r
+        AuditInformation auditInformation = new AuditInformation( new SimpleUser( getPrincipal() ), getRemoteAddr() );\r
+\r
+        return auditInformation;\r
+    }\r
+\r
+    /**\r
+     * dummy information for audit events\r
+     * @since 1.4\r
+     */\r
+    private static class SimpleUser\r
+        implements User\r
+    {\r
+\r
+        private String principal;\r
+\r
+        protected SimpleUser( String principal )\r
+        {\r
+            this.principal = principal;\r
+        }\r
+\r
+        public Object getPrincipal()\r
+        {\r
+            return this.principal;\r
+        }\r
+\r
+        public String getUsername()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setUsername( String name )\r
+        {\r
+\r
+        }\r
+\r
+        public String getFullName()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setFullName( String name )\r
+        {\r
+\r
+        }\r
+\r
+        public String getEmail()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setEmail( String address )\r
+        {\r
+\r
+        }\r
+\r
+        public String getPassword()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setPassword( String rawPassword )\r
+        {\r
+\r
+        }\r
+\r
+        public String getEncodedPassword()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setEncodedPassword( String encodedPassword )\r
+        {\r
+\r
+        }\r
+\r
+        public Date getLastPasswordChange()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setLastPasswordChange( Date passwordChangeDate )\r
+        {\r
+\r
+        }\r
+\r
+        public List<String> getPreviousEncodedPasswords()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setPreviousEncodedPasswords( List<String> encodedPasswordList )\r
+        {\r
+\r
+        }\r
+\r
+        public void addPreviousEncodedPassword( String encodedPassword )\r
+        {\r
+\r
+        }\r
+\r
+        public boolean isPermanent()\r
+        {\r
+            return false;\r
+        }\r
+\r
+        public void setPermanent( boolean permanent )\r
+        {\r
+\r
+        }\r
+\r
+        public boolean isLocked()\r
+        {\r
+            return false;\r
+        }\r
+\r
+        public void setLocked( boolean locked )\r
+        {\r
+\r
+        }\r
+\r
+        public boolean isPasswordChangeRequired()\r
+        {\r
+            return false;\r
+        }\r
+\r
+        public void setPasswordChangeRequired( boolean changeRequired )\r
+        {\r
+\r
+        }\r
+\r
+        public boolean isValidated()\r
+        {\r
+            return false;\r
+        }\r
+\r
+        public void setValidated( boolean valid )\r
+        {\r
+\r
+        }\r
+\r
+        public int getCountFailedLoginAttempts()\r
+        {\r
+            return 0;\r
+        }\r
+\r
+        public void setCountFailedLoginAttempts( int count )\r
+        {\r
+\r
+        }\r
+\r
+        public Date getAccountCreationDate()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setAccountCreationDate( Date date )\r
+        {\r
+\r
+        }\r
+\r
+        public Date getLastLoginDate()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public void setLastLoginDate( Date date )\r
+        {\r
+\r
+        }\r
+    }\r
+\r
+\r
+}\r
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractRepositoryBasedAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractRepositoryBasedAction.java
new file mode 100644 (file)
index 0000000..60a19b2
--- /dev/null
@@ -0,0 +1,64 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.security.AccessDeniedException;
+import org.apache.archiva.security.ArchivaSecurityException;
+import org.apache.archiva.security.PrincipalNotFoundException;
+import org.apache.archiva.security.UserRepositories;
+
+import javax.inject.Inject;
+import java.util.Collections;
+import java.util.List;
+
+public class AbstractRepositoryBasedAction
+    extends AbstractActionSupport
+{
+
+    @Inject
+    private UserRepositories userRepositories;
+
+    protected List<String> getObservableRepos()
+    {
+        try
+        {
+            List<String> ids = userRepositories.getObservableRepositoryIds( getPrincipal() );
+            return ids == null ? Collections.<String>emptyList() : ids;
+        }
+        catch ( PrincipalNotFoundException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( AccessDeniedException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( ArchivaSecurityException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        return Collections.emptyList();
+    }
+
+    public void setUserRepositories( UserRepositories userRepositories )
+    {
+        this.userRepositories = userRepositories;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/BrowseAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/BrowseAction.java
new file mode 100644 (file)
index 0000000..09d180a
--- /dev/null
@@ -0,0 +1,393 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.repository.MetadataResolutionException;
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Browse the repository.
+ *
+ * @todo implement repository selectors (all or specific repository)
+ */
+@Controller( "browseAction" )
+@Scope( "prototype" )
+public class BrowseAction
+    extends AbstractRepositoryBasedAction
+{
+    private String groupId;
+
+    private String artifactId;
+
+    private String repositoryId;
+
+    private ProjectVersionMetadata sharedModel;
+
+    private Collection<String> namespaces;
+
+    private Collection<String> projectIds;
+
+    private Collection<String> projectVersions;
+
+    public String browse()
+        throws MetadataResolutionException
+    {
+        List<String> selectedRepos = getObservableRepos();
+        if ( CollectionUtils.isEmpty( selectedRepos ) )
+        {
+            return GlobalResults.ACCESS_TO_NO_REPOS;
+        }
+
+        Set<String> namespaces = new LinkedHashSet<String>();
+
+        // TODO: this logic should be optional, particularly remembering we want to keep this code simple
+        //       it is located here to avoid the content repository implementation needing to do too much for what
+        //       is essentially presentation code
+        Set<String> namespacesToCollapse;
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataResolver metadataResolver = repositorySession.getResolver();
+            namespacesToCollapse = new LinkedHashSet<String>();
+            for ( String repoId : selectedRepos )
+            {
+                namespacesToCollapse.addAll( metadataResolver.resolveRootNamespaces( repositorySession, repoId ) );
+            }
+
+            for ( String n : namespacesToCollapse )
+            {
+                // TODO: check performance of this
+                namespaces.add( collapseNamespaces( repositorySession, metadataResolver, selectedRepos, n ) );
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        this.namespaces = getSortedList( namespaces );
+        return SUCCESS;
+    }
+
+    private String collapseNamespaces( RepositorySession repositorySession, MetadataResolver metadataResolver,
+                                       Collection<String> repoIds, String n )
+        throws MetadataResolutionException
+    {
+        Set<String> subNamespaces = new LinkedHashSet<String>();
+        for ( String repoId : repoIds )
+        {
+            subNamespaces.addAll( metadataResolver.resolveNamespaces( repositorySession, repoId, n ) );
+        }
+        if ( subNamespaces.size() != 1 )
+        {
+            log.debug( "{} is not collapsible as it has sub-namespaces: {}", n, subNamespaces );
+            return n;
+        }
+        else
+        {
+            for ( String repoId : repoIds )
+            {
+                Collection<String> projects = metadataResolver.resolveProjects( repositorySession, repoId, n );
+                if ( projects != null && !projects.isEmpty() )
+                {
+                    log.debug( "{} is not collapsible as it has projects", n );
+                    return n;
+                }
+            }
+            return collapseNamespaces( repositorySession, metadataResolver, repoIds,
+                                       n + "." + subNamespaces.iterator().next() );
+        }
+    }
+
+    public String browseGroup()
+        throws MetadataResolutionException
+    {
+        if ( StringUtils.isEmpty( groupId ) )
+        {
+            // TODO: i18n
+            addActionError( "You must specify a group ID to browse" );
+            return ERROR;
+        }
+
+        List<String> selectedRepos = getObservableRepos();
+        if ( CollectionUtils.isEmpty( selectedRepos ) )
+        {
+            return GlobalResults.ACCESS_TO_NO_REPOS;
+        }
+
+        Set<String> projects = new LinkedHashSet<String>();
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        Set<String> namespaces;
+        try
+        {
+            MetadataResolver metadataResolver = repositorySession.getResolver();
+
+            Set<String> namespacesToCollapse = new LinkedHashSet<String>();
+            for ( String repoId : selectedRepos )
+            {
+                namespacesToCollapse.addAll( metadataResolver.resolveNamespaces( repositorySession, repoId, groupId ) );
+
+                projects.addAll( metadataResolver.resolveProjects( repositorySession, repoId, groupId ) );
+            }
+
+            // TODO: this logic should be optional, particularly remembering we want to keep this code simple
+            //       it is located here to avoid the content repository implementation needing to do too much for what
+            //       is essentially presentation code
+            namespaces = new LinkedHashSet<String>();
+            for ( String n : namespacesToCollapse )
+            {
+                // TODO: check performance of this
+                namespaces.add(
+                    collapseNamespaces( repositorySession, metadataResolver, selectedRepos, groupId + "." + n ) );
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        this.namespaces = getSortedList( namespaces );
+        this.projectIds = getSortedList( projects );
+        return SUCCESS;
+    }
+
+    private ArrayList<String> getSortedList( Set<String> set )
+    {
+        ArrayList<String> list = new ArrayList<String>( set );
+        Collections.sort( list );
+        return list;
+    }
+
+    public String browseArtifact()
+        throws MetadataResolutionException
+    {
+        if ( StringUtils.isEmpty( groupId ) )
+        {
+            // TODO: i18n
+            addActionError( "You must specify a group ID to browse" );
+            return ERROR;
+        }
+
+        if ( StringUtils.isEmpty( artifactId ) )
+        {
+            // TODO: i18n
+            addActionError( "You must specify a artifact ID to browse" );
+            return ERROR;
+        }
+
+        List<String> selectedRepos = getObservableRepos();
+        if ( CollectionUtils.isEmpty( selectedRepos ) )
+        {
+            return GlobalResults.ACCESS_TO_NO_REPOS;
+        }
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataResolver metadataResolver = repositorySession.getResolver();
+
+            Set<String> versions = new LinkedHashSet<String>();
+            for ( String repoId : selectedRepos )
+            {
+                versions.addAll(
+                    metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId, artifactId ) );
+            }
+
+            // TODO: sort by known version ordering method
+            this.projectVersions = new ArrayList<String>( versions );
+
+            populateSharedModel( repositorySession, metadataResolver, selectedRepos, versions );
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        return SUCCESS;
+    }
+
+    private void populateSharedModel( RepositorySession repositorySession, MetadataResolver metadataResolver,
+                                      Collection<String> selectedRepos, Collection<String> projectVersions )
+    {
+        sharedModel = new ProjectVersionMetadata();
+
+        MavenProjectFacet mavenFacet = new MavenProjectFacet();
+        mavenFacet.setGroupId( groupId );
+        mavenFacet.setArtifactId( artifactId );
+        sharedModel.addFacet( mavenFacet );
+
+        boolean isFirstVersion = true;
+
+        for ( String version : projectVersions )
+        {
+            ProjectVersionMetadata versionMetadata = null;
+            for ( String repoId : selectedRepos )
+            {
+                if ( versionMetadata == null )
+                {
+                    try
+                    {
+                        versionMetadata =
+                            metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId, artifactId,
+                                                                    version );
+                    }
+                    catch ( MetadataResolutionException e )
+                    {
+                        log.error(
+                            "Skipping invalid metadata while compiling shared model for " + groupId + ":" + artifactId
+                                + " in repo " + repoId + ": " + e.getMessage() );
+                    }
+                }
+            }
+
+            if ( versionMetadata == null )
+            {
+                continue;
+            }
+
+            if ( isFirstVersion )
+            {
+                sharedModel = versionMetadata;
+                sharedModel.setId( null );
+            }
+            else
+            {
+                MavenProjectFacet versionMetadataMavenFacet =
+                    (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
+                if ( versionMetadataMavenFacet != null )
+                {
+                    if ( mavenFacet.getPackaging() != null && !StringUtils.equalsIgnoreCase( mavenFacet.getPackaging(),
+                                                                                             versionMetadataMavenFacet.getPackaging() ) )
+                    {
+                        mavenFacet.setPackaging( null );
+                    }
+                }
+
+                if ( sharedModel.getName() != null && !StringUtils.equalsIgnoreCase( sharedModel.getName(),
+                                                                                     versionMetadata.getName() ) )
+                {
+                    sharedModel.setName( "" );
+                }
+
+                if ( sharedModel.getDescription() != null && !StringUtils.equalsIgnoreCase(
+                    sharedModel.getDescription(), versionMetadata.getDescription() ) )
+                {
+                    sharedModel.setDescription( null );
+                }
+
+                if ( sharedModel.getIssueManagement() != null && versionMetadata.getIssueManagement() != null
+                    && !StringUtils.equalsIgnoreCase( sharedModel.getIssueManagement().getUrl(),
+                                                      versionMetadata.getIssueManagement().getUrl() ) )
+                {
+                    sharedModel.setIssueManagement( null );
+                }
+
+                if ( sharedModel.getCiManagement() != null && versionMetadata.getCiManagement() != null
+                    && !StringUtils.equalsIgnoreCase( sharedModel.getCiManagement().getUrl(),
+                                                      versionMetadata.getCiManagement().getUrl() ) )
+                {
+                    sharedModel.setCiManagement( null );
+                }
+
+                if ( sharedModel.getOrganization() != null && versionMetadata.getOrganization() != null
+                    && !StringUtils.equalsIgnoreCase( sharedModel.getOrganization().getName(),
+                                                      versionMetadata.getOrganization().getName() ) )
+                {
+                    sharedModel.setOrganization( null );
+                }
+
+                if ( sharedModel.getUrl() != null && !StringUtils.equalsIgnoreCase( sharedModel.getUrl(),
+                                                                                    versionMetadata.getUrl() ) )
+                {
+                    sharedModel.setUrl( null );
+                }
+            }
+
+            isFirstVersion = false;
+        }
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public Collection<String> getNamespaces()
+    {
+        return namespaces;
+    }
+
+    public String getRepositoryId()
+    {
+
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+
+        this.repositoryId = repositoryId;
+    }
+
+    public ProjectVersionMetadata getSharedModel()
+    {
+        return sharedModel;
+    }
+
+    public Collection<String> getProjectIds()
+    {
+        return projectIds;
+    }
+
+    public Collection<String> getProjectVersions()
+    {
+        return projectVersions;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java
new file mode 100644 (file)
index 0000000..09a332e
--- /dev/null
@@ -0,0 +1,470 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.Auditable;
+import org.apache.archiva.checksum.ChecksumAlgorithm;
+import org.apache.archiva.checksum.ChecksummedFile;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepositoryException;
+import org.apache.archiva.metadata.repository.MetadataResolutionException;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.repository.events.RepositoryListener;
+import org.apache.archiva.security.AccessDeniedException;
+import org.apache.archiva.security.ArchivaSecurityException;
+import org.apache.archiva.security.PrincipalNotFoundException;
+import org.apache.archiva.security.UserRepositories;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.common.utils.VersionComparator;
+import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.archiva.model.VersionedReference;
+import org.apache.archiva.repository.ContentNotFoundException;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryException;
+import org.apache.archiva.repository.RepositoryNotFoundException;
+import org.apache.archiva.repository.metadata.MetadataTools;
+import org.apache.archiva.repository.metadata.RepositoryMetadataException;
+import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
+import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
+/**
+ * Delete an artifact. Metadata will be updated if one exists, otherwise it would be created.
+ */
+@Controller( "deleteArtifactAction" )
+@Scope( "prototype" )
+public class DeleteArtifactAction
+    extends AbstractActionSupport
+    implements Validateable, Preparable, Auditable
+{
+    /**
+     * The groupId of the artifact to be deleted.
+     */
+    private String groupId;
+
+    /**
+     * The artifactId of the artifact to be deleted.
+     */
+    private String artifactId;
+
+    /**
+     * The version of the artifact to be deleted.
+     */
+    private String version;
+
+    /**
+     * The repository where the artifact is to be deleted.
+     */
+    private String repositoryId;
+
+    /**
+     * List of managed repositories to delete from.
+     */
+    private List<String> managedRepos;
+
+    @Inject
+    private UserRepositories userRepositories;
+
+    @Inject
+    private RepositoryContentFactory repositoryFactory;
+
+    @Inject
+    private List<RepositoryListener> listeners;
+
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
+
+    @PostConstruct
+    public void initialize()
+    {
+        super.initialize();
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public List<String> getManagedRepos()
+    {
+        return managedRepos;
+    }
+
+    public void setManagedRepos( List<String> managedRepos )
+    {
+        this.managedRepos = managedRepos;
+    }
+
+    public void prepare()
+    {
+        managedRepos = getManagableRepos();
+    }
+
+    public String input()
+    {
+        return INPUT;
+    }
+
+    private void reset()
+    {
+        // reset the fields so the form is clear when 
+        // the action returns to the jsp page
+        groupId = "";
+        artifactId = "";
+        version = "";
+        repositoryId = "";
+    }
+
+    public String doDelete()
+    {
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
+
+            TimeZone timezone = TimeZone.getTimeZone( "UTC" );
+            DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
+            fmt.setTimeZone( timezone );
+            ManagedRepository repoConfig = getManagedRepositoryAdmin().getManagedRepository( repositoryId );
+
+            VersionedReference ref = new VersionedReference();
+            ref.setArtifactId( artifactId );
+            ref.setGroupId( groupId );
+            ref.setVersion( version );
+            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
+
+            String path = repository.toMetadataPath( ref );
+            int index = path.lastIndexOf( '/' );
+            path = path.substring( 0, index );
+            File targetPath = new File( repoConfig.getLocation(), path );
+
+            if ( !targetPath.exists() )
+            {
+                throw new ContentNotFoundException( groupId + ":" + artifactId + ":" + version );
+            }
+
+            // TODO: this should be in the storage mechanism so that it is all tied together
+            // delete from file system
+            repository.deleteVersion( ref );
+
+            File metadataFile = getMetadata( targetPath.getAbsolutePath() );
+            ArchivaRepositoryMetadata metadata = getMetadata( metadataFile );
+
+            updateMetadata( metadata, metadataFile, lastUpdatedTimestamp );
+
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            Collection<ArtifactMetadata> artifacts =
+                metadataRepository.getArtifacts( repositoryId, groupId, artifactId, version );
+
+            for ( ArtifactMetadata artifact : artifacts )
+            {
+                // TODO: mismatch between artifact (snapshot) version and project (base) version here
+                if ( artifact.getVersion().equals( version ) )
+                {
+                    metadataRepository.removeArtifact( artifact.getRepositoryId(), artifact.getNamespace(),
+                                                       artifact.getProject(), artifact.getVersion(), artifact.getId() );
+
+                    // TODO: move into the metadata repository proper - need to differentiate attachment of
+                    //       repository metadata to an artifact
+                    for ( RepositoryListener listener : listeners )
+                    {
+                        listener.deleteArtifact( metadataRepository, repository.getId(), artifact.getNamespace(),
+                                                 artifact.getProject(), artifact.getVersion(), artifact.getId() );
+                    }
+
+                    triggerAuditEvent( repositoryId, path, AuditEvent.REMOVE_FILE );
+                }
+            }
+            repositorySession.save();
+        }
+        catch ( ContentNotFoundException e )
+        {
+            addActionError( "Artifact does not exist: " + e.getMessage() );
+            return ERROR;
+        }
+        catch ( RepositoryNotFoundException e )
+        {
+            addActionError( "Target repository cannot be found: " + e.getMessage() );
+            return ERROR;
+        }
+        catch ( RepositoryException e )
+        {
+            addActionError( "Repository exception: " + e.getMessage() );
+            return ERROR;
+        }
+        catch ( MetadataResolutionException e )
+        {
+            addActionError( "Repository exception: " + e.getMessage() );
+            return ERROR;
+        }
+        catch ( MetadataRepositoryException e )
+        {
+            addActionError( "Repository exception: " + e.getMessage() );
+            return ERROR;
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "RepositoryAdmin exception: " + e.getMessage() );
+            return ERROR;
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version
+            + "\' was successfully deleted from repository \'" + repositoryId + "\'";
+
+        addActionMessage( msg );
+
+        reset();
+        return SUCCESS;
+    }
+
+    private File getMetadata( String targetPath )
+    {
+        String artifactPath = targetPath.substring( 0, targetPath.lastIndexOf( File.separatorChar ) );
+
+        return new File( artifactPath, MetadataTools.MAVEN_METADATA );
+    }
+
+    private ArchivaRepositoryMetadata getMetadata( File metadataFile )
+        throws RepositoryMetadataException
+    {
+        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
+        if ( metadataFile.exists() )
+        {
+            metadata = RepositoryMetadataReader.read( metadataFile );
+        }
+        return metadata;
+    }
+
+    /**
+     * Update artifact level metadata. Creates one if metadata does not exist after artifact deletion.
+     *
+     * @param metadata
+     */
+    private void updateMetadata( ArchivaRepositoryMetadata metadata, File metadataFile, Date lastUpdatedTimestamp )
+        throws RepositoryMetadataException
+    {
+        List<String> availableVersions = new ArrayList<String>();
+        String latestVersion = "";
+
+        if ( metadataFile.exists() )
+        {
+            if ( metadata.getAvailableVersions() != null )
+            {
+                availableVersions = metadata.getAvailableVersions();
+
+                if ( availableVersions.size() > 0 )
+                {
+                    Collections.sort( availableVersions, VersionComparator.getInstance() );
+
+                    if ( availableVersions.contains( version ) )
+                    {
+                        availableVersions.remove( availableVersions.indexOf( version ) );
+                    }
+                    if ( availableVersions.size() > 0 )
+                    {
+                        latestVersion = availableVersions.get( availableVersions.size() - 1 );
+                    }
+                }
+            }
+        }
+
+        if ( metadata.getGroupId() == null )
+        {
+            metadata.setGroupId( groupId );
+        }
+        if ( metadata.getArtifactId() == null )
+        {
+            metadata.setArtifactId( artifactId );
+        }
+
+        if ( !VersionUtil.isSnapshot( version ) )
+        {
+            if ( metadata.getReleasedVersion() != null && metadata.getReleasedVersion().equals( version ) )
+            {
+                metadata.setReleasedVersion( latestVersion );
+            }
+        }
+
+        metadata.setLatestVersion( latestVersion );
+        metadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
+        metadata.setAvailableVersions( availableVersions );
+
+        RepositoryMetadataWriter.write( metadata, metadataFile );
+        ChecksummedFile checksum = new ChecksummedFile( metadataFile );
+        checksum.fixChecksums( algorithms );
+    }
+
+    public void validate()
+    {
+        try
+        {
+            if ( !userRepositories.isAuthorizedToDeleteArtifacts( getPrincipal(), repositoryId ) )
+            {
+                addActionError( "User is not authorized to delete artifacts in repository '" + repositoryId + "'." );
+            }
+
+            if ( ( version.length() > 0 ) && ( !VersionUtil.isVersion( version ) ) )
+            {
+                addActionError( "Invalid version." );
+            }
+        }
+        catch ( AccessDeniedException e )
+        {
+            addActionError( e.getMessage() );
+        }
+        catch ( ArchivaSecurityException e )
+        {
+            addActionError( e.getMessage() );
+        }
+
+        // trims all request parameter values, since the trailing/leading white-spaces are ignored during validation.
+        trimAllRequestParameterValues();
+    }
+
+    private List<String> getManagableRepos()
+    {
+        try
+        {
+            return userRepositories.getManagableRepositoryIds( getPrincipal() );
+        }
+        catch ( PrincipalNotFoundException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( AccessDeniedException e )
+        {
+            log.warn( e.getMessage(), e );
+            // TODO: pass this onto the screen.
+        }
+        catch ( ArchivaSecurityException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        return Collections.emptyList();
+    }
+
+    private void trimAllRequestParameterValues()
+    {
+        if ( StringUtils.isNotEmpty( groupId ) )
+        {
+            groupId = groupId.trim();
+        }
+
+        if ( StringUtils.isNotEmpty( artifactId ) )
+        {
+            artifactId = artifactId.trim();
+        }
+
+        if ( StringUtils.isNotEmpty( version ) )
+        {
+            version = version.trim();
+        }
+
+        if ( StringUtils.isNotEmpty( repositoryId ) )
+        {
+            repositoryId = repositoryId.trim();
+        }
+    }
+
+    public List<RepositoryListener> getListeners()
+    {
+        return listeners;
+    }
+
+    public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
+    {
+        this.repositoryFactory = repositoryFactory;
+    }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/GlobalResults.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/GlobalResults.java
new file mode 100644 (file)
index 0000000..ec00087
--- /dev/null
@@ -0,0 +1,30 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * GlobalResults - constants for global result definitions. 
+ *
+ * @version $Id$
+ */
+public class GlobalResults
+{
+    public static final String ACCESS_TO_NO_REPOS = "access_to_no_repos";
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/MergeAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/MergeAction.java
new file mode 100644 (file)
index 0000000..52fc932
--- /dev/null
@@ -0,0 +1,349 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.Auditable;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.filter.Filter;
+import org.apache.archiva.metadata.repository.filter.IncludesFilter;
+import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
+import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.stagerepository.merge.Maven2RepositoryMerger;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ *
+ */
+@Controller( "mergeAction" )
+@Scope( "prototype" )
+public class MergeAction
+    extends AbstractActionSupport
+    implements Validateable, Preparable, Auditable
+{
+
+    @Inject
+    @Named( value = "repositoryMerger#maven2" )
+    private Maven2RepositoryMerger repositoryMerger;
+
+    @Inject
+    protected ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    @Inject
+    @Named( value = "archivaTaskScheduler#repository" )
+    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
+
+    private ManagedRepository repository;
+
+    private String repoid;
+
+    private String sourceRepoId;
+
+    private final String action = "merge";
+
+    private final String hasConflicts = "CONFLICTS";
+
+    private List<ArtifactMetadata> conflictSourceArtifacts;
+
+    private List<ArtifactMetadata> conflictSourceArtifactsToBeDisplayed;
+
+    public String getConflicts()
+    {
+        try
+        {
+            sourceRepoId = repoid + "-stage";
+            ManagedRepository targetRepoConfig = managedRepositoryAdmin.getManagedRepository( sourceRepoId );
+
+            if ( targetRepoConfig != null )
+            {
+                return hasConflicts;
+            }
+            else
+            {
+                return ERROR;
+            }
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "RepositoryAdminException " + e.getMessage() );
+            return ERROR;
+        }
+    }
+
+    public String doMerge()
+    {
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
+
+            if ( repository.isReleases() && !repository.isSnapshots() )
+            {
+                mergeWithOutSnapshots( metadataRepository, sourceArtifacts, sourceRepoId, repoid );
+            }
+            else
+            {
+                repositoryMerger.merge( metadataRepository, sourceRepoId, repoid );
+
+                for ( ArtifactMetadata metadata : sourceArtifacts )
+                {
+                    triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
+                }
+            }
+
+            scanRepository();
+
+            addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
+
+            return SUCCESS;
+        }
+        catch ( Exception e )
+        {
+            log.error( e.getMessage(), e );
+            addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
+            return ERROR;
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+    }
+
+    public String mergeBySkippingConflicts()
+    {
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
+            sourceArtifacts.removeAll( conflictSourceArtifacts );
+
+            if ( repository.isReleases() && !repository.isSnapshots() )
+            {
+                mergeWithOutSnapshots( metadataRepository, sourceArtifacts, sourceRepoId, repoid );
+            }
+            else
+            {
+
+                Filter<ArtifactMetadata> artifactsWithOutConflicts =
+                    new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
+                repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactsWithOutConflicts );
+                for ( ArtifactMetadata metadata : sourceArtifacts )
+                {
+                    triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
+                }
+            }
+
+            scanRepository();
+
+            addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
+
+            return SUCCESS;
+        }
+        catch ( Exception e )
+        {
+            log.error( e.getMessage(), e );
+            addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
+            return ERROR;
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+    }
+
+    public String mergeWithOutConlficts()
+    {
+        sourceRepoId = repoid + "-stage";
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            conflictSourceArtifacts =
+                repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
+        }
+        catch ( Exception e )
+        {
+            addActionError( "Error occurred while merging the repositories." );
+            return ERROR;
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
+
+        return SUCCESS;
+    }
+
+    public ManagedRepository getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( ManagedRepository repository )
+    {
+        this.repository = repository;
+    }
+
+    public void prepare()
+        throws Exception
+    {
+        sourceRepoId = repoid + "-stage";
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            conflictSourceArtifacts =
+                repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        this.repository = managedRepositoryAdmin.getManagedRepository( repoid );
+        setConflictSourceArtifactsToBeDisplayed( conflictSourceArtifacts );
+    }
+
+    public String getSourceRepoId()
+    {
+        return sourceRepoId;
+    }
+
+    public void setSourceRepoId( String sourceRepoId )
+    {
+        this.sourceRepoId = sourceRepoId;
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+
+    public List<ArtifactMetadata> getConflictSourceArtifacts()
+    {
+        return conflictSourceArtifacts;
+    }
+
+    public void setConflictSourceArtifacts( List<ArtifactMetadata> conflictSourceArtifacts )
+    {
+        this.conflictSourceArtifacts = conflictSourceArtifacts;
+    }
+
+    public List<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed()
+    {
+        return conflictSourceArtifactsToBeDisplayed;
+    }
+
+    public void setConflictSourceArtifactsToBeDisplayed( List<ArtifactMetadata> conflictSourceArtifacts )
+        throws Exception
+    {
+        this.conflictSourceArtifactsToBeDisplayed = new ArrayList<ArtifactMetadata>();
+        HashMap<String, ArtifactMetadata> map = new HashMap<String, ArtifactMetadata>();
+        for ( ArtifactMetadata metadata : conflictSourceArtifacts )
+        {
+            String metadataId =
+                metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion();
+            map.put( metadataId, metadata );
+        }
+        conflictSourceArtifactsToBeDisplayed.addAll( map.values() );
+    }
+
+    private void mergeWithOutSnapshots( MetadataRepository metadataRepository, List<ArtifactMetadata> sourceArtifacts,
+                                        String sourceRepoId, String repoid )
+        throws Exception
+    {
+        List<ArtifactMetadata> artifactsWithOutSnapshots = new ArrayList<ArtifactMetadata>();
+        for ( ArtifactMetadata metadata : sourceArtifacts )
+        {
+
+            if ( metadata.getProjectVersion().contains( "SNAPSHOT" ) )
+            {
+                artifactsWithOutSnapshots.add( metadata );
+            }
+            else
+            {
+                triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
+            }
+
+        }
+        sourceArtifacts.removeAll( artifactsWithOutSnapshots );
+
+        Filter<ArtifactMetadata> artifactListWithOutSnapShots = new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
+        repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots );
+    }
+
+    private void scanRepository()
+    {
+        RepositoryTask task = new RepositoryTask();
+        task.setRepositoryId( repoid );
+        task.setScanAll( true );
+
+        if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoid ) )
+        {
+            log.info( "Repository [" + repoid + "] task was already queued." );
+        }
+        else
+        {
+            try
+            {
+                log.info( "Your request to have repository [" + repoid + "] be indexed has been queued." );
+                repositoryTaskScheduler.queueTask( task );
+            }
+            catch ( TaskQueueException e )
+            {
+                log.warn(
+                    "Unable to queue your request to have repository [" + repoid + "] be indexed: " + e.getMessage() );
+            }
+        }
+    }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/SearchAction.java
new file mode 100644 (file)
index 0000000..13c74ca
--- /dev/null
@@ -0,0 +1,587 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.indexer.search.RepositorySearch;
+import org.apache.archiva.indexer.search.RepositorySearchException;
+import org.apache.archiva.indexer.search.SearchFields;
+import org.apache.archiva.indexer.search.SearchResultHit;
+import org.apache.archiva.indexer.search.SearchResultLimits;
+import org.apache.archiva.indexer.search.SearchResults;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import javax.inject.Inject;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Search all indexed fields by the given criteria.
+ */
+@Controller( "searchAction" )
+@Scope( "prototype" )
+public class SearchAction
+    extends AbstractRepositoryBasedAction
+    implements Preparable
+{
+
+    @Inject
+    protected ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    /**
+     * Query string.
+     */
+    private String q;
+
+    /**
+     * The Search Results.
+     */
+    private SearchResults results;
+
+    private static final String RESULTS = "results";
+
+    private static final String ARTIFACT = "artifact";
+
+    private List<ArtifactMetadata> databaseResults;
+
+    private int currentPage = 0;
+
+    private int totalPages;
+
+    private boolean searchResultsOnly;
+
+    private String completeQueryString;
+
+    private static final String COMPLETE_QUERY_STRING_SEPARATOR = ";";
+
+    private List<String> managedRepositoryList = new ArrayList<String>();
+
+    private String groupId;
+
+    private String artifactId;
+
+    private String version;
+
+    private String className;
+
+    private int rowCount = 30;
+
+    private String repositoryId;
+
+    private boolean fromFilterSearch;
+
+    private boolean filterSearch = false;
+
+    private boolean fromResultsPage;
+
+    @Inject
+    private RepositorySearch nexusSearch;
+
+    private Map<String, String> searchFields;
+
+    private String infoMessage;
+
+    public boolean isFromResultsPage()
+    {
+        return fromResultsPage;
+    }
+
+    public void setFromResultsPage( boolean fromResultsPage )
+    {
+        this.fromResultsPage = fromResultsPage;
+    }
+
+    public boolean isFromFilterSearch()
+    {
+        return fromFilterSearch;
+    }
+
+    public void setFromFilterSearch( boolean fromFilterSearch )
+    {
+        this.fromFilterSearch = fromFilterSearch;
+    }
+
+    public void prepare()
+    {
+        managedRepositoryList = getObservableRepos();
+
+        if ( managedRepositoryList.size() > 0 )
+        {
+            managedRepositoryList.add( "all" );
+        }
+
+        searchFields = new LinkedHashMap<String, String>();
+        searchFields.put( "groupId", "Group ID" );
+        searchFields.put( "artifactId", "Artifact ID" );
+        searchFields.put( "version", "Version" );
+        searchFields.put( "className", "Class/Package Name" );
+        searchFields.put( "rowCount", "Row Count" );
+
+        super.clearErrorsAndMessages();
+        clearSearchFields();
+    }
+
+    private void clearSearchFields()
+    {
+        repositoryId = "";
+        artifactId = "";
+        groupId = "";
+        version = "";
+        className = "";
+        rowCount = 30;
+        currentPage = 0;
+    }
+
+    // advanced search MRM-90 -- filtered search
+    public String filteredSearch()
+        throws MalformedURLException
+    {
+        if ( ( groupId == null || "".equals( groupId ) ) && ( artifactId == null || "".equals( artifactId ) )
+            && ( className == null || "".equals( className ) ) && ( version == null || "".equals( version ) ) )
+        {
+            addActionError( "Advanced Search - At least one search criteria must be provided." );
+            return INPUT;
+        }
+
+        fromFilterSearch = true;
+
+        if ( CollectionUtils.isEmpty( managedRepositoryList ) )
+        {
+            return GlobalResults.ACCESS_TO_NO_REPOS;
+        }
+
+        SearchResultLimits limits = new SearchResultLimits( currentPage );
+        limits.setPageSize( rowCount );
+        List<String> selectedRepos = new ArrayList<String>();
+
+        if ( repositoryId == null || StringUtils.isBlank( repositoryId ) || "all".equals(
+            StringUtils.stripToEmpty( repositoryId ) ) )
+        {
+            selectedRepos = getObservableRepos();
+        }
+        else
+        {
+            selectedRepos.add( repositoryId );
+        }
+
+        if ( CollectionUtils.isEmpty( selectedRepos ) )
+        {
+            return GlobalResults.ACCESS_TO_NO_REPOS;
+        }
+
+        SearchFields searchFields = new SearchFields( groupId, artifactId, version, null, className, selectedRepos );
+
+        log.debug( "filteredSearch with searchFields {}", searchFields );
+
+        // TODO: add packaging in the list of fields for advanced search (UI)?
+        try
+        {
+            results = getNexusSearch().search( getPrincipal(), searchFields, limits );
+        }
+        catch ( RepositorySearchException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+
+        if ( results.isEmpty() )
+        {
+            addActionError( "No results found" );
+            return INPUT;
+        }
+
+        totalPages = results.getTotalHits() / limits.getPageSize();
+
+        if ( ( results.getTotalHits() % limits.getPageSize() ) != 0 )
+        {
+            totalPages = totalPages + 1;
+        }
+
+        for ( SearchResultHit hit : results.getHits() )
+        {
+            // fix version ?
+            //hit.setVersion( VersionUtil.getBaseVersion( version ) );
+
+        }
+
+        return SUCCESS;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public String quickSearch()
+        throws MalformedURLException
+    {
+        /* TODO: give action message if indexing is in progress.
+         * This should be based off a count of 'unprocessed' artifacts.
+         * This (yet to be written) routine could tell the user that X (unprocessed) artifacts are not yet
+         * present in the full text search.
+         */
+
+        assert q != null && q.length() != 0;
+
+        fromFilterSearch = false;
+
+        SearchResultLimits limits = new SearchResultLimits( currentPage );
+
+        List<String> selectedRepos = getObservableRepos();
+        if ( CollectionUtils.isEmpty( selectedRepos ) )
+        {
+            return GlobalResults.ACCESS_TO_NO_REPOS;
+        }
+
+        log.debug( "quickSearch with selectedRepos {} query {}", selectedRepos, q );
+
+        try
+        {
+            if ( searchResultsOnly && !completeQueryString.equals( "" ) )
+            {
+                results =
+                    getNexusSearch().search( getPrincipal(), selectedRepos, q, limits, parseCompleteQueryString() );
+            }
+            else
+            {
+                completeQueryString = "";
+                results = getNexusSearch().search( getPrincipal(), selectedRepos, q, limits, null );
+            }
+        }
+        catch ( RepositorySearchException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+
+        if ( results.isEmpty() )
+        {
+            addActionError( "No results found" );
+            return INPUT;
+        }
+
+        totalPages = results.getTotalHits() / limits.getPageSize();
+
+        if ( ( results.getTotalHits() % limits.getPageSize() ) != 0 )
+        {
+            totalPages = totalPages + 1;
+        }
+
+        if ( !isEqualToPreviousSearchTerm( q ) )
+        {
+            buildCompleteQueryString( q );
+        }
+
+        return SUCCESS;
+    }
+
+    public String findArtifact()
+        throws Exception
+    {
+        // TODO: give action message if indexing is in progress
+
+        if ( StringUtils.isBlank( q ) )
+        {
+            addActionError( "Unable to search for a blank checksum" );
+            return INPUT;
+        }
+
+        databaseResults = new ArrayList<ArtifactMetadata>();
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            for ( String repoId : getObservableRepos() )
+            {
+                databaseResults.addAll( metadataRepository.getArtifactsByChecksum( repoId, q ) );
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        if ( databaseResults.isEmpty() )
+        {
+            addActionError( "No results found" );
+            return INPUT;
+        }
+
+        if ( databaseResults.size() == 1 )
+        {
+            // 1 hit? return it's information directly!
+            return ARTIFACT;
+        }
+
+        return RESULTS;
+    }
+
+    public String doInput()
+    {
+        return INPUT;
+    }
+
+    private void buildCompleteQueryString( String searchTerm )
+    {
+        if ( searchTerm.indexOf( COMPLETE_QUERY_STRING_SEPARATOR ) != -1 )
+        {
+            searchTerm = StringUtils.remove( searchTerm, COMPLETE_QUERY_STRING_SEPARATOR );
+        }
+
+        if ( completeQueryString == null || "".equals( completeQueryString ) )
+        {
+            completeQueryString = searchTerm;
+        }
+        else
+        {
+            completeQueryString = completeQueryString + COMPLETE_QUERY_STRING_SEPARATOR + searchTerm;
+        }
+    }
+
+    private List<String> parseCompleteQueryString()
+    {
+        List<String> parsedCompleteQueryString = new ArrayList<String>();
+        String[] parsed = StringUtils.split( completeQueryString, COMPLETE_QUERY_STRING_SEPARATOR );
+        CollectionUtils.addAll( parsedCompleteQueryString, parsed );
+
+        return parsedCompleteQueryString;
+    }
+
+    private boolean isEqualToPreviousSearchTerm( String searchTerm )
+    {
+        if ( !"".equals( completeQueryString ) )
+        {
+            String[] parsed = StringUtils.split( completeQueryString, COMPLETE_QUERY_STRING_SEPARATOR );
+            if ( StringUtils.equalsIgnoreCase( searchTerm, parsed[parsed.length - 1] ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public String getQ()
+    {
+        return q;
+    }
+
+    public void setQ( String q )
+    {
+        this.q = q;
+    }
+
+    public SearchResults getResults()
+    {
+        return results;
+    }
+
+    public List<ArtifactMetadata> getDatabaseResults()
+    {
+        return databaseResults;
+    }
+
+    public void setCurrentPage( int page )
+    {
+        this.currentPage = page;
+    }
+
+    public int getCurrentPage()
+    {
+        return currentPage;
+    }
+
+    public int getTotalPages()
+    {
+        return totalPages;
+    }
+
+    public void setTotalPages( int totalPages )
+    {
+        this.totalPages = totalPages;
+    }
+
+    public boolean isSearchResultsOnly()
+    {
+        return searchResultsOnly;
+    }
+
+    public void setSearchResultsOnly( boolean searchResultsOnly )
+    {
+        this.searchResultsOnly = searchResultsOnly;
+    }
+
+    public String getCompleteQueryString()
+    {
+        return completeQueryString;
+    }
+
+    public void setCompleteQueryString( String completeQueryString )
+    {
+        this.completeQueryString = completeQueryString;
+    }
+
+    public Map<String, ManagedRepository> getManagedRepositories() throws RepositoryAdminException
+    {
+        return managedRepositoryAdmin.getManagedRepositoriesAsMap();
+    }
+
+    // wtf : does nothing ??
+    public void setManagedRepositories( Map<String, ManagedRepository> managedRepositories )
+    {
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public int getRowCount()
+    {
+        return rowCount;
+    }
+
+    public void setRowCount( int rowCount )
+    {
+        this.rowCount = rowCount;
+    }
+
+    public boolean isFilterSearch()
+    {
+        return filterSearch;
+    }
+
+    public void setFilterSearch( boolean filterSearch )
+    {
+        this.filterSearch = filterSearch;
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public List<String> getManagedRepositoryList()
+    {
+        return managedRepositoryList;
+    }
+
+    public void setManagedRepositoryList( List<String> managedRepositoryList )
+    {
+        this.managedRepositoryList = managedRepositoryList;
+    }
+
+    public String getClassName()
+    {
+        return className;
+    }
+
+    public void setClassName( String className )
+    {
+        this.className = className;
+    }
+
+    public RepositorySearch getNexusSearch()
+    {
+        if ( nexusSearch == null )
+        {
+            WebApplicationContext wac =
+                WebApplicationContextUtils.getRequiredWebApplicationContext( ServletActionContext.getServletContext() );
+            nexusSearch = wac.getBean( "nexusSearch", RepositorySearch.class );
+        }
+        return nexusSearch;
+    }
+
+    public void setNexusSearch( RepositorySearch nexusSearch )
+    {
+        this.nexusSearch = nexusSearch;
+    }
+
+    public Map<String, String> getSearchFields()
+    {
+        return searchFields;
+    }
+
+    public void setSearchFields( Map<String, String> searchFields )
+    {
+        this.searchFields = searchFields;
+    }
+
+    public String getInfoMessage()
+    {
+        return infoMessage;
+    }
+
+    public void setInfoMessage( String infoMessage )
+    {
+        this.infoMessage = infoMessage;
+    }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java
new file mode 100644 (file)
index 0000000..92d2cea
--- /dev/null
@@ -0,0 +1,739 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.metadata.generic.GenericMetadataFacet;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.Dependency;
+import org.apache.archiva.metadata.model.MailingList;
+import org.apache.archiva.metadata.model.MetadataFacet;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepositoryException;
+import org.apache.archiva.metadata.repository.MetadataResolutionException;
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
+import org.apache.archiva.reports.RepositoryProblemFacet;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryException;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import javax.inject.Inject;
+
+/**
+ * Browse the repository.
+ *
+ * TODO change name to ShowVersionedAction to conform to terminology.
+ *
+ */
+@SuppressWarnings( "serial" )
+@Controller( "showArtifactAction" )
+@Scope( "prototype" )
+public class ShowArtifactAction
+    extends AbstractRepositoryBasedAction
+    implements Validateable
+{
+    /* .\ Not Exposed \._____________________________________________ */
+
+    @Inject
+    private RepositoryContentFactory repositoryFactory;
+
+    /* .\ Exposed Output Objects \.__________________________________ */
+
+    private String groupId;
+
+    private String artifactId;
+
+    private String version;
+
+    private String repositoryId;
+
+    /**
+     * The model of this versioned project.
+     */
+    private ProjectVersionMetadata model;
+
+    /**
+     * The list of artifacts that depend on this versioned project.
+     */
+    private List<ProjectVersionReference> dependees;
+
+    private List<MailingList> mailingLists;
+
+    private List<Dependency> dependencies;
+
+    private Map<String, List<ArtifactDownloadInfo>> artifacts;
+
+    private boolean dependencyTree = false;
+
+    private String deleteItem;
+
+    private Map<String, String> genericMetadata;
+
+    private String propertyName;
+
+    private String propertyValue;
+
+    /**
+     * Show the versioned project information tab. TODO: Change name to 'project' - we are showing project versions
+     * here, not specific artifact information (though that is rendered in the download box).
+     */
+    public String artifact()
+    {
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            return handleArtifact( repositorySession );
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+    }
+
+    private String handleArtifact( RepositorySession session )
+    {
+        // In the future, this should be replaced by the repository grouping mechanism, so that we are only making
+        // simple resource requests here and letting the resolver take care of it
+        ProjectVersionMetadata versionMetadata = getProjectVersionMetadata( session );
+
+        if ( versionMetadata == null )
+        {
+            addActionError( "Artifact not found" );
+            return ERROR;
+        }
+
+        if ( versionMetadata.isIncomplete() )
+        {
+            addIncompleteModelWarning( "Artifact metadata is incomplete." );
+        }
+
+        model = versionMetadata;
+
+        return SUCCESS;
+    }
+
+    private ProjectVersionMetadata getProjectVersionMetadata( RepositorySession session )
+    {
+        ProjectVersionMetadata versionMetadata = null;
+        artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();
+
+        List<String> repos = getObservableRepos();
+        
+        MetadataResolver metadataResolver = session.getResolver();
+        for ( String repoId : repos )
+        {
+            if ( versionMetadata == null )
+            {
+                // we don't want the implementation being that intelligent - so another resolver to do the
+                // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
+                try
+                {
+                    versionMetadata = metadataResolver.resolveProjectVersion( session, repoId, groupId, artifactId,
+                                                                              version );
+                    if ( versionMetadata != null )
+                    {
+                        MetadataFacet repoProbFacet;
+                        if ( (repoProbFacet = versionMetadata.getFacet( RepositoryProblemFacet.FACET_ID ) ) != null )
+                        {
+                            addIncompleteModelWarning( "Artifact metadata is incomplete: " + ( ( RepositoryProblemFacet) repoProbFacet ).getProblem() );
+                            //set metadata to complete so that no additional 'Artifact metadata is incomplete' warning is logged
+                            versionMetadata.setIncomplete( false );
+                        }
+                    }
+                    
+                }
+                catch ( MetadataResolutionException e )
+                {
+                    addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );
+                    
+                    // TODO: need a consistent way to construct this - same in ArchivaMetadataCreationConsumer
+                    versionMetadata = new ProjectVersionMetadata();
+                    versionMetadata.setId( version );
+                }
+                if ( versionMetadata != null )
+                {
+                    repositoryId = repoId;
+
+                    List<ArtifactMetadata> artifacts;
+                    try
+                    {
+                        artifacts = new ArrayList<ArtifactMetadata>( metadataResolver.resolveArtifacts( session, repoId,
+                                                                                                        groupId,
+                                                                                                        artifactId,
+                                                                                                        version ) );
+                    }
+                    catch ( MetadataResolutionException e )
+                    {
+                        addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );
+                        artifacts = Collections.emptyList();
+                    }
+                    Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
+                    {
+                        public int compare( ArtifactMetadata o1, ArtifactMetadata o2 )
+                        {
+                            // sort by version (reverse), then ID
+                            // TODO: move version sorting into repository handling (maven2 specific), and perhaps add a
+                            // way to get latest instead
+                            int result = new DefaultArtifactVersion( o2.getVersion() ).compareTo(
+                                new DefaultArtifactVersion( o1.getVersion() ) );
+                            return result != 0 ? result : o1.getId().compareTo( o2.getId() );
+                        }
+                    } );
+
+                    for ( ArtifactMetadata artifact : artifacts )
+                    {
+                        List<ArtifactDownloadInfo> l = this.artifacts.get( artifact.getVersion() );
+                        if ( l == null )
+                        {
+                            l = new ArrayList<ArtifactDownloadInfo>();
+                            this.artifacts.put( artifact.getVersion(), l );
+                        }
+                        l.add( new ArtifactDownloadInfo( artifact ) );
+                    }
+                }
+            }
+        }
+
+        return versionMetadata;
+    }
+    
+    private void addIncompleteModelWarning( String warningMessage )
+    {
+        addActionError( warningMessage );
+        //"The model may be incomplete due to a previous error in resolving information. Refer to the repository problem reports for more information." );
+    }
+
+    /**
+     * Show the artifact information tab.
+     */
+    public String dependencies()
+    {
+        String result = artifact();
+
+        this.dependencies = model.getDependencies();
+
+        return result;
+    }
+
+    /**
+     * Show the mailing lists information tab.
+     */
+    public String mailingLists()
+    {
+        String result = artifact();
+
+        this.mailingLists = model.getMailingLists();
+
+        return result;
+    }
+
+    /**
+     * Show the reports tab.
+     */
+    public String reports()
+    {
+        // TODO: hook up reports on project
+
+        return SUCCESS;
+    }
+
+    /**
+     * Show the dependees (other artifacts that depend on this project) tab.
+     */
+    public String dependees()
+        throws MetadataResolutionException
+    {
+        List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>();
+        // TODO: what if we get duplicates across repositories?
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataResolver metadataResolver = repositorySession.getResolver();
+            for ( String repoId : getObservableRepos() )
+            {
+                // TODO: what about if we want to see this irrespective of version?
+                references.addAll( metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId,
+                                                                              artifactId, version ) );
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        this.dependees = references;
+
+        // TODO: may need to note on the page that references will be incomplete if the other artifacts are not yet
+        // stored in the content repository
+        // (especially in the case of pre-population import)
+
+        return artifact();
+    }
+
+    /**
+     * Show the dependencies of this versioned project tab.
+     */
+    public String dependencyTree()
+    {
+        // temporarily use this as we only need the model for the tag to perform, but we should be resolving the
+        // graph here instead
+
+        // TODO: may need to note on the page that tree will be incomplete if the other artifacts are not yet stored in
+        // the content repository
+        // (especially in the case of pre-population import)
+
+        // TODO: a bit ugly, should really be mapping all these results differently now
+        this.dependencyTree = true;
+
+        return artifact();
+    }
+
+    public String projectMetadata()
+    {
+        String result = artifact();
+
+        if ( model.getFacet( GenericMetadataFacet.FACET_ID ) != null )
+        {
+            genericMetadata = model.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+        }
+
+        if ( genericMetadata == null )
+        {
+            genericMetadata = new HashMap<String, String>();
+        }
+
+        return result;
+    }
+
+    public String addMetadataProperty()
+    {
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        ProjectVersionMetadata projectMetadata;
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            projectMetadata = getProjectVersionMetadata( repositorySession );
+            if ( projectMetadata == null )
+            {
+                addActionError( "Artifact not found" );
+                return ERROR;
+            }
+
+            if ( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) == null )
+            {
+                genericMetadata = new HashMap<String, String>();
+            }
+            else
+            {
+                genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+            }
+
+            if ( propertyName == null || "".equals( propertyName.trim() ) || propertyValue == null || "".equals(
+                propertyValue.trim() ) )
+            {
+                model = projectMetadata;
+                addActionError( "Property Name and Property Value are required." );
+                return INPUT;
+            }
+
+            genericMetadata.put( propertyName, propertyValue );
+
+            try
+            {
+                updateProjectMetadata( projectMetadata, metadataRepository );
+                repositorySession.save();
+            }
+            catch ( MetadataRepositoryException e )
+            {
+                log.warn( "Unable to persist modified project metadata after adding entry: " + e.getMessage(), e );
+                addActionError(
+                    "Unable to add metadata item to underlying content storage - consult application logs." );
+                return ERROR;
+            }
+
+            // TODO: why re-retrieve?
+            projectMetadata = getProjectVersionMetadata( repositorySession );
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+
+        model = projectMetadata;
+
+        propertyName = "";
+        propertyValue = "";
+
+        return SUCCESS;
+    }
+
+    public String deleteMetadataEntry()
+    {
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            ProjectVersionMetadata projectMetadata = getProjectVersionMetadata( repositorySession );
+
+            if ( projectMetadata == null )
+            {
+                addActionError( "Artifact not found" );
+                return ERROR;
+            }
+
+            if ( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) != null )
+            {
+                genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+
+                if ( !StringUtils.isEmpty( deleteItem ) )
+                {
+                    genericMetadata.remove( deleteItem );
+
+                    try
+                    {
+                        updateProjectMetadata( projectMetadata, metadataRepository );
+                        repositorySession.save();
+                    }
+                    catch ( MetadataRepositoryException e )
+                    {
+                        log.warn( "Unable to persist modified project metadata after removing entry: " + e.getMessage(),
+                                  e );
+                        addActionError(
+                            "Unable to remove metadata item to underlying content storage - consult application logs." );
+                        return ERROR;
+                    }
+
+                    // TODO: why re-retrieve?
+                    projectMetadata = getProjectVersionMetadata( repositorySession );
+
+                    genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+
+                    model = projectMetadata;
+
+                    addActionMessage( "Property successfully deleted." );
+                }
+
+                deleteItem = "";
+            }
+            else
+            {
+                addActionError( "No generic metadata facet for this artifact." );
+                return ERROR;
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        return SUCCESS;
+    }
+
+    private void updateProjectMetadata( ProjectVersionMetadata projectMetadata, MetadataRepository metadataRepository )
+        throws MetadataRepositoryException
+    {
+        GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
+        genericMetadataFacet.fromProperties( genericMetadata );
+
+        projectMetadata.addFacet( genericMetadataFacet );
+
+        metadataRepository.updateProjectVersion( repositoryId, groupId, artifactId, projectMetadata );
+    }
+
+    @Override
+    public void validate()
+    {
+        if ( StringUtils.isBlank( groupId ) )
+        {
+            addActionError( "You must specify a group ID to browse" );
+        }
+
+        if ( StringUtils.isBlank( artifactId ) )
+        {
+            addActionError( "You must specify a artifact ID to browse" );
+        }
+
+        if ( StringUtils.isBlank( version ) )
+        {
+            addActionError( "You must specify a version to browse" );
+        }
+    }
+
+    public ProjectVersionMetadata getModel()
+    {
+        return model;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public List<MailingList> getMailingLists()
+    {
+        return mailingLists;
+    }
+
+    public List<Dependency> getDependencies()
+    {
+        return dependencies;
+    }
+
+    public List<ProjectVersionReference> getDependees()
+    {
+        return dependees;
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public Map<String, List<ArtifactDownloadInfo>> getArtifacts()
+    {
+        return artifacts;
+    }
+
+    public Collection<String> getSnapshotVersions()
+    {
+        return artifacts.keySet();
+    }
+
+    public boolean isDependencyTree()
+    {
+        return dependencyTree;
+    }
+
+    public void setDeleteItem( String deleteItem )
+    {
+        this.deleteItem = deleteItem;
+    }
+
+    public Map<String, String> getGenericMetadata()
+    {
+        return genericMetadata;
+    }
+
+    public void setGenericMetadata( Map<String, String> genericMetadata )
+    {
+        this.genericMetadata = genericMetadata;
+    }
+
+    public String getPropertyName()
+    {
+        return propertyName;
+    }
+
+    public void setPropertyName( String propertyName )
+    {
+        this.propertyName = propertyName;
+    }
+
+    public String getPropertyValue()
+    {
+        return propertyValue;
+    }
+
+    public void setPropertyValue( String propertyValue )
+    {
+        this.propertyValue = propertyValue;
+    }
+
+    public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
+    {
+        this.repositoryFactory = repositoryFactory;
+    }
+
+    // TODO: move this into the artifact metadata itself via facets where necessary
+
+    public class ArtifactDownloadInfo
+    {
+        private String type;
+
+        private String namespace;
+
+        private String project;
+
+        private String size;
+
+        private String id;
+
+        private String repositoryId;
+
+        private String version;
+
+        private String path;
+
+        public ArtifactDownloadInfo( ArtifactMetadata artifact )
+        {
+            repositoryId = artifact.getRepositoryId();
+
+            // TODO: use metadata resolver capability instead - maybe the storage path could be stored in the metadata
+            // though keep in mind the request may not necessarily need to reflect the storage
+            ManagedRepositoryContent repo;
+            try
+            {
+                repo = repositoryFactory.getManagedRepositoryContent( repositoryId );
+            }
+            catch ( RepositoryException e )
+            {
+                throw new RuntimeException( e );
+            }
+
+            ArtifactReference ref = new ArtifactReference();
+            ref.setArtifactId( artifact.getProject() );
+            ref.setGroupId( artifact.getNamespace() );
+            ref.setVersion( artifact.getVersion() );
+            path = repo.toPath( ref );
+            path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifact.getId();
+
+            // TODO: need to accommodate Maven 1 layout too. Non-maven repository formats will need to generate this
+            // facet (perhaps on the fly) if wanting to display the Maven 2 elements on the Archiva pages
+            String type = null;
+            MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID );
+            if ( facet != null )
+            {
+                type = facet.getType();
+            }
+            this.type = type;
+
+            namespace = artifact.getNamespace();
+            project = artifact.getProject();
+
+            // TODO: find a reusable formatter for this
+            double s = artifact.getSize();
+            String symbol = "b";
+            if ( s > 1024 )
+            {
+                symbol = "K";
+                s /= 1024;
+
+                if ( s > 1024 )
+                {
+                    symbol = "M";
+                    s /= 1024;
+
+                    if ( s > 1024 )
+                    {
+                        symbol = "G";
+                        s /= 1024;
+                    }
+                }
+            }
+
+            DecimalFormat df = new DecimalFormat( "#,###.##", new DecimalFormatSymbols( Locale.US) );
+            size = df.format( s ) + " " + symbol;
+            id = artifact.getId();
+            version = artifact.getVersion();
+        }
+
+        public String getNamespace()
+        {
+            return namespace;
+        }
+
+        public String getType()
+        {
+            return type;
+        }
+
+        public String getProject()
+        {
+            return project;
+        }
+
+        public String getSize()
+        {
+            return size;
+        }
+
+        public String getId()
+        {
+            return id;
+        }
+
+        public String getVersion()
+        {
+            return version;
+        }
+
+        public String getRepositoryId()
+        {
+            return repositoryId;
+        }
+
+        public String getPath()
+        {
+            return path;
+        }
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java
new file mode 100644 (file)
index 0000000..ae2cdd5
--- /dev/null
@@ -0,0 +1,713 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.Auditable;
+import org.apache.archiva.checksum.ChecksumAlgorithm;
+import org.apache.archiva.checksum.ChecksummedFile;
+import org.apache.archiva.scheduler.ArchivaTaskScheduler;
+import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.security.AccessDeniedException;
+import org.apache.archiva.security.ArchivaSecurityException;
+import org.apache.archiva.security.PrincipalNotFoundException;
+import org.apache.archiva.security.UserRepositories;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.common.utils.VersionComparator;
+import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.model.SnapshotVersion;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryException;
+import org.apache.archiva.repository.RepositoryNotFoundException;
+import org.apache.archiva.repository.metadata.MetadataTools;
+import org.apache.archiva.repository.metadata.RepositoryMetadataException;
+import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
+import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.plexus.util.IOUtil;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
+/**
+ * Upload an artifact using Jakarta file upload in webwork. If set by the user a pom will also be generated. Metadata
+ * will also be updated if one exists, otherwise it would be created.
+ */
+@SuppressWarnings( "serial" )
+@Controller( "uploadAction" )
+@Scope( "prototype" )
+public class UploadAction
+    extends AbstractActionSupport
+    implements Validateable, Preparable, Auditable
+{
+    /**
+     * The groupId of the artifact to be deployed.
+     */
+    private String groupId;
+
+    /**
+     * The artifactId of the artifact to be deployed.
+     */
+    private String artifactId;
+
+    /**
+     * The version of the artifact to be deployed.
+     */
+    private String version;
+
+    /**
+     * The packaging of the artifact to be deployed.
+     */
+    private String packaging;
+
+    /**
+     * The classifier of the artifact to be deployed.
+     */
+    private String classifier;
+
+    /**
+     * The temporary file representing the artifact to be deployed.
+     */
+    private File artifactFile;
+
+    /**
+     * The temporary file representing the pom to be deployed alongside the artifact.
+     */
+    private File pomFile;
+
+    /**
+     * The repository where the artifact is to be deployed.
+     */
+    private String repositoryId;
+
+    /**
+     * Flag whether to generate a pom for the artifact or not.
+     */
+    private boolean generatePom;
+
+    /**
+     * List of managed repositories to deploy to.
+     */
+    private List<String> managedRepoIdList;
+
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    @Inject
+    private UserRepositories userRepositories;
+
+    @Inject
+    private ArchivaAdministration archivaAdministration;
+
+    @Inject
+    private RepositoryContentFactory repositoryFactory;
+
+    @Inject
+    @Named( value = "archivaTaskScheduler#repository" )
+    private ArchivaTaskScheduler scheduler;
+
+    private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
+
+    public void setArtifact( File file )
+    {
+        this.artifactFile = file;
+    }
+
+    public void setArtifactContentType( String contentType )
+    {
+        StringUtils.trim( contentType );
+    }
+
+    public void setArtifactFileName( String filename )
+    {
+        StringUtils.trim( filename );
+    }
+
+    public void setPom( File file )
+    {
+        this.pomFile = file;
+    }
+
+    public void setPomContentType( String contentType )
+    {
+        StringUtils.trim( contentType );
+    }
+
+    public void setPomFileName( String filename )
+    {
+        StringUtils.trim( filename );
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = StringUtils.trim( groupId );
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = StringUtils.trim( artifactId );
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = StringUtils.trim( version );
+    }
+
+    public String getPackaging()
+    {
+        return packaging;
+    }
+
+    public void setPackaging( String packaging )
+    {
+        this.packaging = StringUtils.trim( packaging );
+    }
+
+    public String getClassifier()
+    {
+        return classifier;
+    }
+
+    public void setClassifier( String classifier )
+    {
+        this.classifier = StringUtils.trim( classifier );
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public boolean isGeneratePom()
+    {
+        return generatePom;
+    }
+
+    public void setGeneratePom( boolean generatePom )
+    {
+        this.generatePom = generatePom;
+    }
+
+    public List<String> getManagedRepoIdList()
+    {
+        return managedRepoIdList;
+    }
+
+    public void setManagedRepoIdList( List<String> managedRepoIdList )
+    {
+        this.managedRepoIdList = managedRepoIdList;
+    }
+
+    public void prepare()
+    {
+        managedRepoIdList = getManagableRepos();
+    }
+
+    public String input()
+    {
+        return INPUT;
+    }
+
+    private void reset()
+    {
+        // reset the fields so the form is clear when 
+        // the action returns to the jsp page
+        groupId = "";
+        artifactId = "";
+        version = "";
+        packaging = "";
+        classifier = "";
+        artifactFile = null;
+        pomFile = null;
+        repositoryId = "";
+        generatePom = false;
+    }
+
+    public String doUpload()
+    {
+        try
+        {
+            ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repositoryId );
+
+            ArtifactReference artifactReference = new ArtifactReference();
+            artifactReference.setArtifactId( artifactId );
+            artifactReference.setGroupId( groupId );
+            artifactReference.setVersion( version );
+            artifactReference.setClassifier( classifier );
+            artifactReference.setType( packaging );
+
+            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
+
+            String artifactPath = repository.toPath( artifactReference );
+
+            int lastIndex = artifactPath.lastIndexOf( '/' );
+
+            String path = artifactPath.substring( 0, lastIndex );
+            File targetPath = new File( repoConfig.getLocation(), path );
+
+            Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
+            int newBuildNumber = -1;
+            String timestamp = null;
+
+            File versionMetadataFile = new File( targetPath, MetadataTools.MAVEN_METADATA );
+            ArchivaRepositoryMetadata versionMetadata = getMetadata( versionMetadataFile );
+
+            if ( VersionUtil.isSnapshot( version ) )
+            {
+                TimeZone timezone = TimeZone.getTimeZone( "UTC" );
+                DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
+                fmt.setTimeZone( timezone );
+                timestamp = fmt.format( lastUpdatedTimestamp );
+                if ( versionMetadata.getSnapshotVersion() != null )
+                {
+                    newBuildNumber = versionMetadata.getSnapshotVersion().getBuildNumber() + 1;
+                }
+                else
+                {
+                    newBuildNumber = 1;
+                }
+            }
+
+            if ( !targetPath.exists() )
+            {
+                targetPath.mkdirs();
+            }
+
+            String filename = artifactPath.substring( lastIndex + 1 );
+            if ( VersionUtil.isSnapshot( version ) )
+            {
+                filename = filename.replaceAll( "SNAPSHOT", timestamp + "-" + newBuildNumber );
+            }
+
+            boolean fixChecksums =
+                !( archivaAdministration.getKnownContentConsumers().contains( "create-missing-checksums" ) );
+
+            try
+            {
+                File targetFile = new File( targetPath, filename );
+                if ( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() )
+                {
+                    addActionError(
+                        "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed." );
+                    return ERROR;
+                }
+                else
+                {
+                    copyFile( artifactFile, targetPath, filename, fixChecksums );
+                    triggerAuditEvent( repository.getId(), path + "/" + filename, AuditEvent.UPLOAD_FILE );
+                    queueRepositoryTask( repository.getId(), targetFile );
+                }
+            }
+            catch ( IOException ie )
+            {
+                addActionError( "Error encountered while uploading file: " + ie.getMessage() );
+                return ERROR;
+            }
+
+            String pomFilename = filename;
+            if ( classifier != null && !"".equals( classifier ) )
+            {
+                pomFilename = StringUtils.remove( pomFilename, "-" + classifier );
+            }
+            pomFilename = FilenameUtils.removeExtension( pomFilename ) + ".pom";
+
+            if ( generatePom )
+            {
+                try
+                {
+                    File generatedPomFile = createPom( targetPath, pomFilename );
+                    triggerAuditEvent( repoConfig.getId(), path + "/" + pomFilename, AuditEvent.UPLOAD_FILE );
+                    if ( fixChecksums )
+                    {
+                        fixChecksums( generatedPomFile );
+                    }
+                    queueRepositoryTask( repoConfig.getId(), generatedPomFile );
+                }
+                catch ( IOException ie )
+                {
+                    addActionError( "Error encountered while writing pom file: " + ie.getMessage() );
+                    return ERROR;
+                }
+            }
+
+            if ( pomFile != null && pomFile.length() > 0 )
+            {
+                try
+                {
+                    copyFile( pomFile, targetPath, pomFilename, fixChecksums );
+                    triggerAuditEvent( repoConfig.getId(), path + "/" + pomFilename, AuditEvent.UPLOAD_FILE );
+                    queueRepositoryTask( repoConfig.getId(), new File( targetPath, pomFilename ) );
+                }
+                catch ( IOException ie )
+                {
+                    addActionError( "Error encountered while uploading pom file: " + ie.getMessage() );
+                    return ERROR;
+                }
+
+            }
+
+            // explicitly update only if metadata-updater consumer is not enabled!
+            if ( !archivaAdministration.getKnownContentConsumers().contains( "metadata-updater" ) )
+            {
+                updateProjectMetadata( targetPath.getAbsolutePath(), lastUpdatedTimestamp, timestamp, newBuildNumber,
+                                       fixChecksums );
+
+                if ( VersionUtil.isSnapshot( version ) )
+                {
+                    updateVersionMetadata( versionMetadata, versionMetadataFile, lastUpdatedTimestamp, timestamp,
+                                           newBuildNumber, fixChecksums );
+                }
+            }
+
+            String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version
+                + "\' was successfully deployed to repository \'" + repositoryId + "\'";
+
+            addActionMessage( msg );
+
+            reset();
+            return SUCCESS;
+        }
+        catch ( RepositoryNotFoundException re )
+        {
+            addActionError( "Target repository cannot be found: " + re.getMessage() );
+            return ERROR;
+        }
+        catch ( RepositoryException rep )
+        {
+            addActionError( "Repository exception: " + rep.getMessage() );
+            return ERROR;
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "RepositoryAdmin exception: " + e.getMessage() );
+            return ERROR;
+        }
+    }
+
+    private void fixChecksums( File file )
+    {
+        ChecksummedFile checksum = new ChecksummedFile( file );
+        checksum.fixChecksums( algorithms );
+    }
+
+    private void copyFile( File sourceFile, File targetPath, String targetFilename, boolean fixChecksums )
+        throws IOException
+    {
+        FileOutputStream out = new FileOutputStream( new File( targetPath, targetFilename ) );
+        FileInputStream input = new FileInputStream( sourceFile );
+
+        try
+        {
+            IOUtils.copy( input, out );
+        }
+        finally
+        {
+            out.close();
+            input.close();
+        }
+
+        if ( fixChecksums )
+        {
+            fixChecksums( new File( targetPath, targetFilename ) );
+        }
+    }
+
+    private File createPom( File targetPath, String filename )
+        throws IOException
+    {
+        Model projectModel = new Model();
+        projectModel.setModelVersion( "4.0.0" );
+        projectModel.setGroupId( groupId );
+        projectModel.setArtifactId( artifactId );
+        projectModel.setVersion( version );
+        projectModel.setPackaging( packaging );
+
+        File pomFile = new File( targetPath, filename );
+        MavenXpp3Writer writer = new MavenXpp3Writer();
+        FileWriter w = new FileWriter( pomFile );
+        try
+        {
+            writer.write( w, projectModel );
+        }
+        finally
+        {
+            IOUtil.close( w );
+        }
+
+        return pomFile;
+    }
+
+    private ArchivaRepositoryMetadata getMetadata( File metadataFile )
+        throws RepositoryMetadataException
+    {
+        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
+        if ( metadataFile.exists() )
+        {
+            metadata = RepositoryMetadataReader.read( metadataFile );
+        }
+        return metadata;
+    }
+
+
+    /**
+     * Update version level metadata for snapshot artifacts. If it does not exist, create the metadata and fix checksums
+     * if necessary.
+     */
+    private void updateVersionMetadata( ArchivaRepositoryMetadata metadata, File metadataFile,
+                                        Date lastUpdatedTimestamp, String timestamp, int buildNumber,
+                                        boolean fixChecksums )
+        throws RepositoryMetadataException
+    {
+        if ( !metadataFile.exists() )
+        {
+            metadata.setGroupId( groupId );
+            metadata.setArtifactId( artifactId );
+            metadata.setVersion( version );
+        }
+
+        if ( metadata.getSnapshotVersion() == null )
+        {
+            metadata.setSnapshotVersion( new SnapshotVersion() );
+        }
+
+        metadata.getSnapshotVersion().setBuildNumber( buildNumber );
+        metadata.getSnapshotVersion().setTimestamp( timestamp );
+        metadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
+
+        RepositoryMetadataWriter.write( metadata, metadataFile );
+
+        if ( fixChecksums )
+        {
+            fixChecksums( metadataFile );
+        }
+    }
+
+    /**
+     * Update artifact level metadata. If it does not exist, create the metadata and fix checksums if necessary.
+     */
+    private void updateProjectMetadata( String targetPath, Date lastUpdatedTimestamp, String timestamp, int buildNumber,
+                                        boolean fixChecksums )
+        throws RepositoryMetadataException
+    {
+        List<String> availableVersions = new ArrayList<String>();
+        String latestVersion = version;
+
+        File projectDir = new File( targetPath ).getParentFile();
+        File projectMetadataFile = new File( projectDir, MetadataTools.MAVEN_METADATA );
+
+        ArchivaRepositoryMetadata projectMetadata = getMetadata( projectMetadataFile );
+
+        if ( projectMetadataFile.exists() )
+        {
+            availableVersions = projectMetadata.getAvailableVersions();
+
+            Collections.sort( availableVersions, VersionComparator.getInstance() );
+
+            if ( !availableVersions.contains( version ) )
+            {
+                availableVersions.add( version );
+            }
+
+            latestVersion = availableVersions.get( availableVersions.size() - 1 );
+        }
+        else
+        {
+            availableVersions.add( version );
+
+            projectMetadata.setGroupId( groupId );
+            projectMetadata.setArtifactId( artifactId );
+        }
+
+        if ( projectMetadata.getGroupId() == null )
+        {
+            projectMetadata.setGroupId( groupId );
+        }
+
+        if ( projectMetadata.getArtifactId() == null )
+        {
+            projectMetadata.setArtifactId( artifactId );
+        }
+
+        projectMetadata.setLatestVersion( latestVersion );
+        projectMetadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
+        projectMetadata.setAvailableVersions( availableVersions );
+
+        if ( !VersionUtil.isSnapshot( version ) )
+        {
+            projectMetadata.setReleasedVersion( latestVersion );
+        }
+
+        RepositoryMetadataWriter.write( projectMetadata, projectMetadataFile );
+
+        if ( fixChecksums )
+        {
+            fixChecksums( projectMetadataFile );
+        }
+    }
+
+    public void validate()
+    {
+        try
+        {
+            // is this enough check for the repository permission?
+            if ( !userRepositories.isAuthorizedToUploadArtifacts( getPrincipal(), repositoryId ) )
+            {
+                addActionError( "User is not authorized to upload in repository " + repositoryId );
+            }
+
+            if ( artifactFile == null || artifactFile.length() == 0 )
+            {
+                addActionError( "Please add a file to upload." );
+            }
+
+            if ( version == null || !VersionUtil.isVersion( version ) )
+            {
+                addActionError( "Invalid version." );
+            }
+        }
+        catch ( PrincipalNotFoundException pe )
+        {
+            addActionError( pe.getMessage() );
+        }
+        catch ( ArchivaSecurityException ae )
+        {
+            addActionError( ae.getMessage() );
+        }
+    }
+
+    private List<String> getManagableRepos()
+    {
+        try
+        {
+            return userRepositories.getManagableRepositoryIds( getPrincipal() );
+        }
+        catch ( PrincipalNotFoundException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( AccessDeniedException e )
+        {
+            log.warn( e.getMessage(), e );
+            // TODO: pass this onto the screen.
+        }
+        catch ( ArchivaSecurityException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        return Collections.emptyList();
+    }
+
+    private void queueRepositoryTask( String repositoryId, File localFile )
+    {
+        RepositoryTask task = new RepositoryTask();
+        task.setRepositoryId( repositoryId );
+        task.setResourceFile( localFile );
+        task.setUpdateRelatedArtifacts( true );
+        task.setScanAll( true );
+
+        try
+        {
+            scheduler.queueTask( task );
+        }
+        catch ( TaskQueueException e )
+        {
+            log.error( "Unable to queue repository task to execute consumers on resource file ['" + localFile.getName()
+                           + "']." );
+        }
+    }
+
+    public void setScheduler( ArchivaTaskScheduler scheduler )
+    {
+        this.scheduler = scheduler;
+    }
+
+    public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
+    {
+        this.repositoryFactory = repositoryFactory;
+    }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+
+    public ArchivaAdministration getArchivaAdministration()
+    {
+        return archivaAdministration;
+    }
+
+    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
+    {
+        this.archivaAdministration = archivaAdministration;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/SchedulerAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/SchedulerAction.java
new file mode 100644 (file)
index 0000000..b1aed4c
--- /dev/null
@@ -0,0 +1,134 @@
+package org.apache.archiva.web.action.admin;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
+import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * Configures the application.
+ */
+@Controller( "schedulerAction" )
+@Scope( "prototype" )
+public class SchedulerAction
+    extends AbstractActionSupport
+    implements SecureAction
+{
+
+    @Inject
+    @Named( value = "archivaTaskScheduler#repository" )
+    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
+
+    private String repoid;
+
+    private boolean scanAll;
+
+    public String scanRepository()
+    {
+        if ( StringUtils.isBlank( repoid ) )
+        {
+            addActionError( "Cannot run indexer on blank repository id." );
+            return SUCCESS;
+        }
+
+        RepositoryTask task = new RepositoryTask();
+        task.setRepositoryId( repoid );
+        task.setScanAll( scanAll );
+
+        if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoid ) )
+        {
+            addActionError( "Repository [" + repoid + "] task was already queued." );
+        }
+        else
+        {
+            try
+            {
+                addActionMessage( "Your request to have repository [" + repoid + "] be indexed has been queued." );
+                repositoryTaskScheduler.queueTask( task );
+            }
+            catch ( TaskQueueException e )
+            {
+                addActionError(
+                    "Unable to queue your request to have repository [" + repoid + "] be indexed: " + e.getMessage() );
+            }
+        }
+
+        // Return to the repositories screen.
+        return SUCCESS;
+    }
+
+    @Override
+    public void addActionMessage( String aMessage )
+    {
+        super.addActionMessage( aMessage );
+        log.info( "[ActionMessage] " + aMessage );
+    }
+
+    @Override
+    public void addActionError( String anErrorMessage )
+    {
+        super.addActionError( anErrorMessage );
+        log.warn( "[ActionError] " + anErrorMessage );
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_RUN_INDEXER, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+
+    public boolean getScanAll()
+    {
+        return scanAll;
+    }
+
+    public void setScanAll( boolean scanAll )
+    {
+        this.scanAll = scanAll;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/SystemStatusAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/SystemStatusAction.java
new file mode 100644 (file)
index 0000000..93f898a
--- /dev/null
@@ -0,0 +1,138 @@
+package org.apache.archiva.web.action.admin;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.repository.scanner.RepositoryScanner;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.codehaus.plexus.cache.Cache;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import java.util.Map;
+
+/**
+ * Shows system status information for the administrator.
+ *
+ * @version $Id$
+ */
+@Controller( "systemStatus" )
+@Scope( "prototype" )
+public class SystemStatusAction
+    extends AbstractActionSupport
+    implements SecureAction
+{
+
+    private Map<String, TaskQueue> queues;
+
+    private Map<String, Cache> caches;
+
+    @Inject
+    private RepositoryScanner scanner;
+
+    private String memoryStatus;
+
+    private String cacheKey;
+
+    @PostConstruct
+    public void initialize()
+    {
+        super.initialize();
+        queues = getBeansOfType( TaskQueue.class );
+        caches = getBeansOfType( Cache.class );
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public String execute()
+    {
+        Runtime runtime = Runtime.getRuntime();
+        runtime.gc();
+        long total = runtime.totalMemory();
+        long used = total - runtime.freeMemory();
+        long max = runtime.maxMemory();
+        memoryStatus = formatMemory( used ) + "/" + formatMemory( total ) + " (Max: " + formatMemory( max ) + ")";
+
+        return SUCCESS;
+    }
+    
+    public String flush()
+    {
+        if( !StringUtils.isEmpty( cacheKey ) )
+        {
+            Cache cache = caches.get( cacheKey );
+            cache.clear();
+        }
+
+        return SUCCESS;
+    }
+
+    private static String formatMemory( long l )
+    {
+        return l / ( 1024 * 1024 ) + "M";
+    }
+
+    public String getMemoryStatus()
+    {
+        return memoryStatus;
+    }
+
+    public RepositoryScanner getScanner()
+    {
+        return scanner;
+    }
+
+    public Map<String, Cache> getCaches()
+    {
+        return caches;
+    }
+
+    public Map<String, TaskQueue> getQueues()
+    {
+        return queues;
+    }
+
+    public String getCacheKey()
+    {
+        return cacheKey;
+    }
+
+    public void setCacheKey( String cacheKey )
+    {
+        this.cacheKey = cacheKey;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/AbstractAppearanceAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/AbstractAppearanceAction.java
new file mode 100644 (file)
index 0000000..eca6b27
--- /dev/null
@@ -0,0 +1,101 @@
+package org.apache.archiva.web.action.admin.appearance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.beans.OrganisationInformation;
+import org.apache.archiva.web.action.AbstractActionSupport;
+
+import javax.inject.Inject;
+
+/**
+ * AbstractAppearanceAction
+ *
+ * @version $Id$
+ */
+public abstract class AbstractAppearanceAction
+    extends AbstractActionSupport
+    implements Preparable
+{
+
+    @Inject
+    protected ArchivaAdministration archivaAdministration;
+
+    private String organisationLogo;
+
+    private String organisationUrl;
+
+    private String organisationName;
+
+    public String getOrganisationLogo()
+    {
+        return organisationLogo;
+    }
+
+    public String getOrganisationName()
+    {
+        return organisationName;
+    }
+
+    public String getOrganisationUrl()
+    {
+        return organisationUrl;
+    }
+
+    public void setOrganisationLogo( String organisationLogo )
+    {
+        this.organisationLogo = organisationLogo;
+    }
+
+    public void setOrganisationName( String organisationName )
+    {
+        this.organisationName = organisationName;
+    }
+
+    public void setOrganisationUrl( String organisationUrl )
+    {
+        this.organisationUrl = organisationUrl;
+    }
+
+    public void prepare()
+        throws Exception
+    {
+
+        OrganisationInformation orgInfo = archivaAdministration.getOrganisationInformation();
+        if ( orgInfo != null )
+        {
+            setOrganisationLogo( orgInfo.getLogoLocation() );
+            setOrganisationName( orgInfo.getName() );
+            setOrganisationUrl( orgInfo.getUrl() );
+        }
+
+    }
+
+    public ArchivaAdministration getArchivaAdministration()
+    {
+        return archivaAdministration;
+    }
+
+    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
+    {
+        this.archivaAdministration = archivaAdministration;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java
new file mode 100644 (file)
index 0000000..8cb81a2
--- /dev/null
@@ -0,0 +1,90 @@
+package org.apache.archiva.web.action.admin.appearance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.OrganisationInformation;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $
+ */
+@Controller( "editOrganisationInfo" )
+@Scope( "prototype" )
+public class EditOrganisationInfoAction
+    extends AbstractAppearanceAction
+    implements SecureAction, Validateable
+{
+    @Override
+    public String execute()
+        throws RepositoryAdminException
+    {
+
+        OrganisationInformation orgInfo = archivaAdministration.getOrganisationInformation();
+
+        orgInfo.setLogoLocation( getOrganisationLogo() );
+        orgInfo.setName( getOrganisationName() );
+        orgInfo.setUrl( getOrganisationUrl() );
+
+        archivaAdministration.setOrganisationInformation( orgInfo );
+        return SUCCESS;
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+        return bundle;
+    }
+
+    public void validate()
+    {
+        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
+        trimAllRequestParameterValues();
+    }
+
+    private void trimAllRequestParameterValues()
+    {
+        if ( StringUtils.isNotEmpty( super.getOrganisationName() ) )
+        {
+            super.setOrganisationName( super.getOrganisationName().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( super.getOrganisationUrl() ) )
+        {
+            super.setOrganisationUrl( super.getOrganisationUrl().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( super.getOrganisationLogo() ) )
+        {
+            super.setOrganisationLogo( super.getOrganisationLogo().trim() );
+        }
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/OrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/appearance/OrganisationInfoAction.java
new file mode 100644 (file)
index 0000000..b8ed832
--- /dev/null
@@ -0,0 +1,34 @@
+package org.apache.archiva.web.action.admin.appearance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * Stores the organisation information for displaying on the page.
+ */
+@Controller( "organisationInfo" )
+@Scope( "prototype" )
+public class OrganisationInfoAction
+    extends AbstractAppearanceAction
+{
+    // no op
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java
new file mode 100644 (file)
index 0000000..bb35f75
--- /dev/null
@@ -0,0 +1,145 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+
+import javax.inject.Inject;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AbstractProxyConnectorAction
+ *
+ * @version $Id$
+ */
+public abstract class AbstractProxyConnectorAction
+    extends AbstractActionSupport
+    implements SecureAction
+{
+    public static final String DIRECT_CONNECTION = "(direct connection)";
+
+    @Inject
+    private ProxyConnectorAdmin proxyConnectorAdmin;
+
+    @Inject
+    private RemoteRepositoryAdmin remoteRepositoryAdmin;
+
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+
+    protected void addProxyConnector( ProxyConnector proxyConnector )
+        throws RepositoryAdminException
+    {
+        getProxyConnectorAdmin().addProxyConnector( proxyConnector, getAuditInformation() );
+    }
+
+    protected ProxyConnector findProxyConnector( String sourceId, String targetId )
+        throws RepositoryAdminException
+    {
+        if ( StringUtils.isBlank( sourceId ) )
+        {
+            return null;
+        }
+
+        if ( StringUtils.isBlank( targetId ) )
+        {
+            return null;
+        }
+
+        return getProxyConnectorAdmin().getProxyConnector( sourceId, targetId );
+    }
+
+    protected Map<String, List<ProxyConnector>> createProxyConnectorMap()
+        throws RepositoryAdminException
+    {
+        return getProxyConnectorAdmin().getProxyConnectorAsMap();
+    }
+
+    protected void removeConnector( String sourceId, String targetId )
+        throws RepositoryAdminException
+    {
+        ProxyConnector proxyConnector = findProxyConnector( sourceId, targetId );
+        if ( proxyConnector != null )
+        {
+            getProxyConnectorAdmin().deleteProxyConnector( proxyConnector, getAuditInformation() );
+        }
+    }
+
+    protected void removeProxyConnector( ProxyConnector connector )
+        throws RepositoryAdminException
+    {
+        getProxyConnectorAdmin().deleteProxyConnector( connector, getAuditInformation() );
+    }
+
+
+    public ProxyConnectorAdmin getProxyConnectorAdmin()
+    {
+        return proxyConnectorAdmin;
+    }
+
+    public void setProxyConnectorAdmin( ProxyConnectorAdmin proxyConnectorAdmin )
+    {
+        this.proxyConnectorAdmin = proxyConnectorAdmin;
+    }
+
+    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
+    {
+        return remoteRepositoryAdmin;
+    }
+
+    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
+    {
+        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
+    }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
new file mode 100644 (file)
index 0000000..a599842
--- /dev/null
@@ -0,0 +1,518 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.NetworkProxy;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.policies.DownloadErrorPolicy;
+import org.apache.archiva.policies.Policy;
+import org.apache.archiva.policies.PostDownloadPolicy;
+import org.apache.archiva.policies.PreDownloadPolicy;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AbstractProxyConnectorFormAction - generic fields and methods for either add or edit actions related with the
+ * Proxy Connector.
+ *
+ * @version $Id$
+ */
+public abstract class AbstractProxyConnectorFormAction
+    extends AbstractProxyConnectorAction
+    implements Preparable
+{
+
+
+    private Map<String, PreDownloadPolicy> preDownloadPolicyMap;
+
+    private Map<String, PostDownloadPolicy> postDownloadPolicyMap;
+
+    private Map<String, DownloadErrorPolicy> downloadErrorPolicyMap;
+
+    private List<String> proxyIdOptions;
+
+    private List<String> managedRepoIdList;
+
+    private List<String> remoteRepoIdList;
+
+    /**
+     * The map of policies that are available to be set.
+     */
+    private Map<String, Policy> policyMap;
+
+    /**
+     * The property key to add or remove.
+     */
+    private String propertyKey;
+
+    /**
+     * The property value to add.
+     */
+    private String propertyValue;
+
+    /**
+     * The blacklist pattern to add.
+     */
+    private String blackListPattern;
+
+    /**
+     * The whitelist pattern to add.
+     */
+    private String whiteListPattern;
+
+    /**
+     * The pattern to add or remove (black or white).
+     */
+    private String pattern;
+
+    /**
+     * The model for this action.
+     */
+    protected ProxyConnector connector;
+
+    @Inject
+    private NetworkProxyAdmin networkProxyAdmin;
+
+    @PostConstruct
+    public void initialize()
+    {
+        super.initialize();
+        this.preDownloadPolicyMap = getBeansOfType( PreDownloadPolicy.class );
+        this.postDownloadPolicyMap = getBeansOfType( PostDownloadPolicy.class );
+        this.downloadErrorPolicyMap = getBeansOfType( DownloadErrorPolicy.class );
+    }
+
+    protected List<String> escapePatterns( List<String> patterns )
+    {
+        List<String> escapedPatterns = new ArrayList<String>();
+        if ( patterns != null )
+        {
+            for ( String pattern : patterns )
+            {
+                escapedPatterns.add( StringUtils.replace( pattern, "\\", "\\\\" ) );
+            }
+        }
+
+        return escapedPatterns;
+    }
+
+    protected List<String> unescapePatterns( List<String> patterns )
+    {
+        List<String> rawPatterns = new ArrayList<String>();
+        if ( patterns != null )
+        {
+            for ( String pattern : patterns )
+            {
+                rawPatterns.add( StringUtils.replace( pattern, "\\\\", "\\" ) );
+            }
+        }
+
+        return rawPatterns;
+    }
+
+    private String escapePattern( String pattern )
+    {
+        return StringUtils.replace( pattern, "\\", "\\\\" );
+    }
+
+    public String addBlackListPattern()
+    {
+        String pattern = getBlackListPattern();
+
+        if ( StringUtils.isBlank( pattern ) )
+        {
+            addActionError( "Cannot add a blank black list pattern." );
+        }
+
+        if ( !hasActionErrors() )
+        {
+            getConnector().getBlackListPatterns().add( escapePattern( pattern ) );
+            setBlackListPattern( null );
+        }
+
+        return INPUT;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public String addProperty()
+    {
+        String key = getPropertyKey();
+        String value = getPropertyValue();
+
+        if ( StringUtils.isBlank( key ) )
+        {
+            addActionError( "Unable to add property with blank key." );
+        }
+
+        if ( StringUtils.isBlank( value ) )
+        {
+            addActionError( "Unable to add property with blank value." );
+        }
+
+        if ( !hasActionErrors() )
+        {
+            getConnector().getProperties().put( key, value );
+            setPropertyKey( null );
+            setPropertyValue( null );
+        }
+
+        return INPUT;
+    }
+
+    public String addWhiteListPattern()
+    {
+        String pattern = getWhiteListPattern();
+
+        if ( StringUtils.isBlank( pattern ) )
+        {
+            addActionError( "Cannot add a blank white list pattern." );
+        }
+
+        if ( !hasActionErrors() )
+        {
+            getConnector().getWhiteListPatterns().add( escapePattern( pattern ) );
+            setWhiteListPattern( null );
+        }
+
+        return INPUT;
+    }
+
+    public String getBlackListPattern()
+    {
+        return blackListPattern;
+    }
+
+    public ProxyConnector getConnector()
+    {
+        return connector;
+    }
+
+    public List<String> getManagedRepoIdList()
+    {
+        return managedRepoIdList;
+    }
+
+    public String getPattern()
+    {
+        return pattern;
+    }
+
+    public Map<String, Policy> getPolicyMap()
+    {
+        return policyMap;
+    }
+
+    public String getPropertyKey()
+    {
+        return propertyKey;
+    }
+
+    public String getPropertyValue()
+    {
+        return propertyValue;
+    }
+
+    public List<String> getProxyIdOptions()
+    {
+        return proxyIdOptions;
+    }
+
+    public List<String> getRemoteRepoIdList()
+    {
+        return remoteRepoIdList;
+    }
+
+    public String getWhiteListPattern()
+    {
+        return whiteListPattern;
+    }
+
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        proxyIdOptions = createNetworkProxyOptions();
+        managedRepoIdList = createManagedRepoOptions();
+        remoteRepoIdList = createRemoteRepoOptions();
+        policyMap = createPolicyMap();
+    }
+
+    public String removeBlackListPattern()
+    {
+        String pattern = getPattern();
+
+        if ( StringUtils.isBlank( pattern ) )
+        {
+            addActionError( "Cannot remove a blank black list pattern." );
+        }
+
+        if ( !getConnector().getBlackListPatterns().contains( pattern )
+            && !getConnector().getBlackListPatterns().contains( StringUtils.replace( pattern, "\\", "\\\\" ) ) )
+        {
+            addActionError( "Non-existant black list pattern [" + pattern + "], no black list pattern removed." );
+        }
+
+        if ( !hasActionErrors() )
+        {
+            getConnector().getBlackListPatterns().remove( escapePattern( pattern ) );
+        }
+
+        setBlackListPattern( null );
+        setPattern( null );
+
+        return INPUT;
+    }
+
+    public String removeProperty()
+    {
+        String key = getPropertyKey();
+
+        if ( StringUtils.isBlank( key ) )
+        {
+            addActionError( "Unable to remove property with blank key." );
+        }
+
+        if ( !getConnector().getProperties().containsKey( key ) )
+        {
+            addActionError( "Non-existant property key [" + pattern + "], no property was removed." );
+        }
+
+        if ( !hasActionErrors() )
+        {
+            getConnector().getProperties().remove( key );
+        }
+
+        setPropertyKey( null );
+        setPropertyValue( null );
+
+        return INPUT;
+    }
+
+    public String removeWhiteListPattern()
+    {
+        String pattern = getPattern();
+
+        if ( StringUtils.isBlank( pattern ) )
+        {
+            addActionError( "Cannot remove a blank white list pattern." );
+        }
+
+        if ( !getConnector().getWhiteListPatterns().contains( pattern )
+            && !getConnector().getWhiteListPatterns().contains( StringUtils.replace( pattern, "\\", "\\\\" ) ) )
+        {
+            addActionError( "Non-existant white list pattern [" + pattern + "], no white list pattern removed." );
+        }
+
+        if ( !hasActionErrors() )
+        {
+            getConnector().getWhiteListPatterns().remove( escapePattern( pattern ) );
+        }
+
+        setWhiteListPattern( null );
+        setPattern( null );
+
+        return INPUT;
+    }
+
+    public void setBlackListPattern( String blackListPattern )
+    {
+        this.blackListPattern = blackListPattern;
+    }
+
+    public void setConnector( ProxyConnector connector )
+    {
+        this.connector = connector;
+    }
+
+    public void setManagedRepoIdList( List<String> managedRepoIdList )
+    {
+        this.managedRepoIdList = managedRepoIdList;
+    }
+
+    public void setPattern( String pattern )
+    {
+        this.pattern = pattern;
+    }
+
+    public void setPolicyMap( Map<String, Policy> policyMap )
+    {
+        this.policyMap = policyMap;
+    }
+
+    public void setPropertyKey( String propertyKey )
+    {
+        this.propertyKey = propertyKey;
+    }
+
+    public void setPropertyValue( String propertyValue )
+    {
+        this.propertyValue = propertyValue;
+    }
+
+    public void setProxyIdOptions( List<String> proxyIdOptions )
+    {
+        this.proxyIdOptions = proxyIdOptions;
+    }
+
+    public void setRemoteRepoIdList( List<String> remoteRepoIdList )
+    {
+        this.remoteRepoIdList = remoteRepoIdList;
+    }
+
+    public void setWhiteListPattern( String whiteListPattern )
+    {
+        this.whiteListPattern = whiteListPattern;
+    }
+
+    protected List<String> createManagedRepoOptions()
+        throws RepositoryAdminException
+    {
+        return new ArrayList<String>( getManagedRepositoryAdmin().getManagedRepositoriesAsMap().keySet() );
+    }
+
+    protected List<String> createNetworkProxyOptions()
+        throws RepositoryAdminException
+    {
+        List<String> options = new ArrayList<String>();
+
+        options.add( DIRECT_CONNECTION );
+        options.addAll( getNetworkProxiesKeys() );
+
+        return options;
+    }
+
+    private Collection<String> getNetworkProxiesKeys()
+        throws RepositoryAdminException
+    {
+        List<NetworkProxy> networkProxies = networkProxyAdmin.getNetworkProxies();
+        if ( networkProxies == null || networkProxies.isEmpty() )
+        {
+            return Collections.emptyList();
+        }
+        List<String> keys = new ArrayList<String>( networkProxies.size() );
+        for ( NetworkProxy networkProxy : networkProxies )
+        {
+            keys.add( networkProxy.getId() );
+        }
+        return keys;
+
+    }
+
+    protected Map<String, Policy> createPolicyMap()
+    {
+        Map<String, Policy> policyMap = new HashMap<String, Policy>();
+
+        policyMap.putAll( preDownloadPolicyMap );
+        policyMap.putAll( postDownloadPolicyMap );
+        policyMap.putAll( downloadErrorPolicyMap );
+
+        return policyMap;
+    }
+
+    protected List<String> createRemoteRepoOptions()
+        throws RepositoryAdminException
+    {
+        return new ArrayList<String>( getRemoteRepositoryAdmin().getRemoteRepositoriesAsMap().keySet() );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    protected void validateConnector()
+    {
+        if ( connector.getPolicies() == null )
+        {
+            addActionError( "Policies must be set." );
+        }
+        else
+        {
+            // Validate / Fix policy settings arriving from browser.
+            for ( Map.Entry<String, Policy> entry : getPolicyMap().entrySet() )
+            {
+                String policyId = entry.getKey();
+                Policy policy = entry.getValue();
+                List<String> options = policy.getOptions();
+
+                if ( !connector.getPolicies().containsKey( policyId ) )
+                {
+                    addActionError( "Policy [" + policyId + "] must be set (missing id)." );
+                    continue;
+                }
+
+                Map<String, String> properties = connector.getProperties();
+                for ( Map.Entry<String, String> entry2 : properties.entrySet() )
+                {
+                    Object value = entry2.getValue();
+                    if ( value.getClass().isArray() )
+                    {
+                        String[] arr = (String[]) value;
+                        properties.put( entry2.getKey(), arr[0] );
+                    }
+                }
+
+                // Ugly hack to compensate for ugly browsers.
+                Object o = connector.getPolicies().get( policyId );
+                String value;
+                if ( o.getClass().isArray() )
+                {
+                    String arr[] = (String[]) o;
+                    value = arr[0];
+                }
+                else
+                {
+                    value = (String) o;
+                }
+
+                connector.getPolicies().put( policyId, value );
+
+                if ( StringUtils.isBlank( value ) )
+                {
+                    addActionError( "Policy [" + policyId + "] must be set (missing value)." );
+                    continue;
+                }
+
+                if ( !options.contains( value ) )
+                {
+                    addActionError(
+                        "Value of [" + value + "] is invalid for policy [" + policyId + "], valid values: " + options );
+                    continue;
+                }
+            }
+        }
+    }
+
+    public NetworkProxyAdmin getNetworkProxyAdmin()
+    {
+        return networkProxyAdmin;
+    }
+
+    public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
+    {
+        this.networkProxyAdmin = networkProxyAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AddProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/AddProxyConnectorAction.java
new file mode 100644 (file)
index 0000000..382edce
--- /dev/null
@@ -0,0 +1,98 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * AddProxyConnectorAction
+ *
+ * @version $Id$
+ */
+@Controller( "addProxyConnectorAction" )
+@Scope( "prototype" )
+public class AddProxyConnectorAction
+    extends AbstractProxyConnectorFormAction
+{
+    @Override
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        super.prepare();
+        connector = new ProxyConnector();
+    }
+
+    @Override
+    public String input()
+    {
+        if ( connector != null )
+        {
+            // MRM-1135
+            connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
+            connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
+        }
+
+        return INPUT;
+    }
+
+    public String commit()
+        throws RepositoryAdminException
+    {
+        /* Too complex for webwork's ${Action}-validation.xml techniques.
+         * Not appropriate for use with webwork's implements Validatable, as that validates regardless of
+         * the request method, such as .addProperty() or .addWhiteList().
+         * 
+         * This validation is ultimately only useful on this one request method.
+         */
+        String sourceId = connector.getSourceRepoId();
+        String targetId = connector.getTargetRepoId();
+
+        ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
+        if ( otherConnector != null )
+        {
+            addActionError(
+                "Unable to add proxy connector, as one already exists with source repository id [" + sourceId
+                    + "] and target repository id [" + targetId + "]." );
+        }
+
+        validateConnector();
+
+        if ( hasActionErrors() )
+        {
+            return INPUT;
+        }
+
+        if ( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
+        {
+            connector.setProxyId( null );
+        }
+
+        // MRM-1135
+        connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
+        connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
+
+        addProxyConnector( connector );
+        return SUCCESS;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java
new file mode 100644 (file)
index 0000000..5cc6417
--- /dev/null
@@ -0,0 +1,112 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * DeleteProxyConnectorAction
+ *
+ * @version $Id$
+ */
+@Controller( "deleteProxyConnectorAction" )
+@Scope( "prototype" )
+public class DeleteProxyConnectorAction
+    extends AbstractProxyConnectorAction
+{
+    private String source;
+
+    private String target;
+
+    private ProxyConnector proxyConfig;
+
+    public String confirmDelete()
+        throws RepositoryAdminException
+    {
+        this.proxyConfig = findProxyConnector( source, target );
+
+        // Not set? Then there is nothing to delete.
+        if ( this.proxyConfig == null )
+        {
+            addActionError(
+                "Unable to delete proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String delete()
+        throws RepositoryAdminException
+    {
+        this.proxyConfig = findProxyConnector( source, target );
+
+        // Not set? Then there is nothing to delete.
+        if ( this.proxyConfig == null )
+        {
+            addActionError(
+                "Unable to delete proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
+            return ERROR;
+        }
+
+        if ( hasActionErrors() )
+        {
+            return ERROR;
+        }
+
+        getProxyConnectorAdmin().deleteProxyConnector( proxyConfig, getAuditInformation() );
+        addActionMessage( "Successfully removed proxy connector [" + source + " , " + target + " ]" );
+
+        setSource( null );
+        setTarget( null );
+
+        return SUCCESS;
+    }
+
+    public String getSource()
+    {
+        return source;
+    }
+
+    public void setSource( String id )
+    {
+        this.source = id;
+    }
+
+    public String getTarget()
+    {
+        return target;
+    }
+
+    public void setTarget( String id )
+    {
+        this.target = id;
+    }
+
+    public ProxyConnector getProxyConfig()
+    {
+        return proxyConfig;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java
new file mode 100644 (file)
index 0000000..8ef74b1
--- /dev/null
@@ -0,0 +1,107 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * DisableProxyConnectorAction
+ */
+@Controller( "disableProxyConnectorAction" )
+@Scope( "prototype" )
+public class DisableProxyConnectorAction
+    extends AbstractProxyConnectorAction
+{
+    private String source;
+
+    private String target;
+
+    private ProxyConnector proxyConfig;
+
+    public String confirmDisable()
+        throws RepositoryAdminException
+    {
+        this.proxyConfig = findProxyConnector( source, target );
+
+        // Not set? Then there is nothing to delete.
+        if ( this.proxyConfig == null )
+        {
+            addActionError(
+                "Unable to disable proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String disable()
+        throws RepositoryAdminException
+    {
+        this.proxyConfig = findProxyConnector( source, target );
+
+        // Not set? Then there is nothing to delete.
+        if ( this.proxyConfig == null )
+        {
+            addActionError(
+                "Unable to disable proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
+            return ERROR;
+        }
+
+        if ( hasActionErrors() )
+        {
+            return ERROR;
+        }
+
+        proxyConfig.setDisabled( true );
+
+        addActionMessage( "Successfully disabled proxy connector [" + source + " , " + target + " ]" );
+
+        setSource( null );
+        setTarget( null );
+
+        getProxyConnectorAdmin().updateProxyConnector( proxyConfig, getAuditInformation() );
+        return SUCCESS;
+    }
+
+    public String getSource()
+    {
+        return source;
+    }
+
+    public void setSource( String source )
+    {
+        this.source = source;
+    }
+
+    public String getTarget()
+    {
+        return target;
+    }
+
+    public void setTarget( String target )
+    {
+        this.target = target;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java
new file mode 100644 (file)
index 0000000..e3d6003
--- /dev/null
@@ -0,0 +1,125 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * EditProxyConnectorAction
+ *
+ * @version $Id$
+ */
+@Controller( "editProxyConnectorAction" )
+@Scope( "prototype" )
+public class EditProxyConnectorAction
+    extends AbstractProxyConnectorFormAction
+{
+    /**
+     * The proxy connector source id to edit. (used with {@link #target})
+     */
+    private String source;
+
+    /**
+     * The proxy connector target id to edit. (used with {@link #source})
+     */
+    private String target;
+
+    @Override
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        super.prepare();
+
+        connector = findProxyConnector( source, target );
+    }
+
+    public String input()
+    {
+        if ( connector == null )
+        {
+            addActionError(
+                "Unable to edit non existant proxy connector with source [" + source + "] and target [" + target
+                    + "]" );
+            return ERROR;
+        }
+
+        if ( connector != null )
+        {
+            // MRM-1135
+            connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
+            connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
+        }
+
+        return INPUT;
+    }
+
+    public String commit()
+        throws RepositoryAdminException
+    {
+        validateConnector();
+
+        if ( hasActionErrors() )
+        {
+            return INPUT;
+        }
+
+        String sourceId = connector.getSourceRepoId();
+        String targetId = connector.getTargetRepoId();
+
+        ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
+        if ( otherConnector != null )
+        {
+            // Remove the previous connector.
+            removeProxyConnector( otherConnector );
+        }
+
+        if ( hasActionErrors() )
+        {
+            return INPUT;
+        }
+
+        addProxyConnector( connector );
+        return SUCCESS;
+    }
+
+    public String getSource()
+    {
+        return source;
+    }
+
+    public void setSource( String source )
+    {
+        this.source = source;
+    }
+
+    public String getTarget()
+    {
+        return target;
+    }
+
+    public void setTarget( String target )
+    {
+        this.target = target;
+    }
+
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java
new file mode 100644 (file)
index 0000000..5a000a3
--- /dev/null
@@ -0,0 +1,107 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * EnableProxyConnectorAction
+ */
+@Controller( "enableProxyConnectorAction" )
+@Scope( "prototype" )
+public class EnableProxyConnectorAction
+    extends AbstractProxyConnectorAction
+{
+    private String source;
+
+    private String target;
+
+    private ProxyConnector proxyConfig;
+
+    public String confirmEnable()
+        throws RepositoryAdminException
+    {
+        this.proxyConfig = findProxyConnector( source, target );
+
+        // Not set? Then there is nothing to delete.
+        if ( this.proxyConfig == null )
+        {
+            addActionError(
+                "Unable to enable proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String enable() throws RepositoryAdminException
+    {
+        this.proxyConfig = findProxyConnector( source, target );
+
+        // Not set? Then there is nothing to delete.
+        if ( this.proxyConfig == null )
+        {
+            addActionError(
+                "Unable to enabled proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
+            return ERROR;
+        }
+
+        if ( hasActionErrors() )
+        {
+            return ERROR;
+        }
+
+        proxyConfig.setDisabled( false );
+
+        getProxyConnectorAdmin().updateProxyConnector( proxyConfig, getAuditInformation() );
+
+        addActionMessage( "Successfully enabled proxy connector [" + source + " , " + target + " ]" );
+
+        setSource( null );
+        setTarget( null );
+
+        return SUCCESS;
+    }
+
+    public String getSource()
+    {
+        return source;
+    }
+
+    public void setSource( String source )
+    {
+        this.source = source;
+    }
+
+    public String getTarget()
+    {
+        return target;
+    }
+
+    public void setTarget( String target )
+    {
+        this.target = target;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java
new file mode 100644 (file)
index 0000000..8f5ccbd
--- /dev/null
@@ -0,0 +1,84 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.AbstractRepository;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ProxyConnectorsAction
+ *
+ * @version $Id$
+ */
+@Controller( "proxyConnectorsAction" )
+@Scope( "prototype" )
+public class ProxyConnectorsAction
+    extends AbstractProxyConnectorAction
+    implements Preparable
+{
+    private Map<String, AbstractRepository> repoMap;
+
+    /**
+     * boolean to indicate that remote repo is present. Used for Add Link
+     */
+    private boolean remoteRepoExists = false;
+
+    /**
+     * Map of Proxy Connectors.
+     */
+    private Map<String, List<ProxyConnector>> proxyConnectorMap;
+
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        repoMap = new HashMap<String, AbstractRepository>();
+        repoMap.putAll( getRemoteRepositoryAdmin().getRemoteRepositoriesAsMap() );
+        // FIXME olamy : are we sure we want Managed too ???
+        repoMap.putAll( getManagedRepositoryAdmin().getManagedRepositoriesAsMap() );
+
+        proxyConnectorMap = createProxyConnectorMap();
+
+        remoteRepoExists = getRemoteRepositoryAdmin().getRemoteRepositories().size() > 0;
+    }
+
+    public Map<String, AbstractRepository> getRepoMap()
+    {
+        return repoMap;
+    }
+
+    public Map<String, List<ProxyConnector>> getProxyConnectorMap()
+    {
+        return proxyConnectorMap;
+    }
+
+    // FIXME olamy should be is !
+    public boolean getRemoteRepoExists()
+    {
+        return remoteRepoExists;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java
new file mode 100644 (file)
index 0000000..7aa2865
--- /dev/null
@@ -0,0 +1,148 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import java.util.List;
+
+/**
+ * SortProxyConnectorsAction -
+ *
+ * @version $Id$
+ */
+@Controller( "sortProxyConnectorsAction" )
+@Scope( "prototype" )
+public class SortProxyConnectorsAction
+    extends AbstractProxyConnectorAction
+{
+    private String source;
+
+    private String target;
+
+    public String getSource()
+    {
+        return source;
+    }
+
+    public String getTarget()
+    {
+        return target;
+    }
+
+    public void setSource( String id )
+    {
+        this.source = id;
+    }
+
+    public void setTarget( String id )
+    {
+        this.target = id;
+    }
+
+    public String sortDown()
+        throws RepositoryAdminException
+    {
+        List<ProxyConnector> connectors = createProxyConnectorMap().get( source );
+
+        int idx = findTargetConnector( connectors, target );
+
+        if ( idx >= 0 )
+        {
+            incrementConnectorOrder( connectors, idx );
+            decrementConnectorOrder( connectors, idx + 1 );
+        }
+
+        for ( ProxyConnector proxyConnector : connectors )
+        {
+            getProxyConnectorAdmin().updateProxyConnector( proxyConnector, getAuditInformation() );
+        }
+        return SUCCESS;
+    }
+
+    public String sortUp()
+        throws RepositoryAdminException
+    {
+        List<ProxyConnector> connectors = createProxyConnectorMap().get( source );
+
+        int idx = findTargetConnector( connectors, target );
+
+        if ( idx >= 0 )
+        {
+            decrementConnectorOrder( connectors, idx );
+            incrementConnectorOrder( connectors, idx - 1 );
+        }
+
+        for ( ProxyConnector proxyConnector : connectors )
+        {
+            getProxyConnectorAdmin().updateProxyConnector( proxyConnector, getAuditInformation() );
+        }
+        return SUCCESS;
+    }
+
+    private void decrementConnectorOrder( List<ProxyConnector> connectors, int idx )
+    {
+        if ( !validIndex( connectors, idx ) )
+        {
+            // Do nothing.
+            return;
+        }
+
+        int order = connectors.get( idx ).getOrder();
+        connectors.get( idx ).setOrder( Math.max( 1, order - 1 ) );
+    }
+
+    private int findTargetConnector( List<ProxyConnector> connectors, String targetRepoId )
+    {
+        int idx = ( -1 );
+
+        for ( int i = 0; i < connectors.size(); i++ )
+        {
+            if ( StringUtils.equals( targetRepoId, connectors.get( i ).getTargetRepoId() ) )
+            {
+                idx = i;
+                break;
+            }
+        }
+
+        return idx;
+    }
+
+    private void incrementConnectorOrder( List<ProxyConnector> connectors, int idx )
+    {
+        if ( !validIndex( connectors, idx ) )
+        {
+            // Do nothing.
+            return;
+        }
+
+        int order = connectors.get( idx ).getOrder();
+        connectors.get( idx ).setOrder( order + 1 );
+    }
+
+    private boolean validIndex( List<ProxyConnector> connectors, int idx )
+    {
+        return ( idx >= 0 ) && ( idx < connectors.size() );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java
new file mode 100644 (file)
index 0000000..073924a
--- /dev/null
@@ -0,0 +1,222 @@
+package org.apache.archiva.web.action.admin.legacy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * Add a LegacyArtifactPath to archiva configuration
+ *
+ * @since 1.1
+ */
+@Controller( "addLegacyArtifactPathAction" )
+@Scope( "prototype" )
+public class AddLegacyArtifactPathAction
+    extends AbstractActionSupport
+    implements Preparable, Validateable
+{
+
+    @Inject
+    private ArchivaAdministration archivaAdministration;
+
+    @Inject
+    @Named( value = "managedRepositoryContent#legacy" )
+    private ManagedRepositoryContent repositoryContent;
+
+
+    private LegacyArtifactPath legacyArtifactPath;
+
+    private String groupId;
+
+    private String artifactId;
+
+    private String version;
+
+    private String classifier;
+
+    private String type;
+
+
+    public void prepare()
+    {
+        this.legacyArtifactPath = new LegacyArtifactPath();
+    }
+
+    public String input()
+    {
+        return INPUT;
+    }
+
+    public String commit()
+    {
+        this.legacyArtifactPath.setArtifact(
+            this.groupId + ":" + this.artifactId + ":" + this.version + ":" + this.classifier + ":" + this.type );
+
+        // Check the proposed Artifact macthes the path
+        ArtifactReference artifact = new ArtifactReference();
+
+        artifact.setGroupId( this.groupId );
+        artifact.setArtifactId( this.artifactId );
+        artifact.setClassifier( this.classifier );
+        artifact.setVersion( this.version );
+        artifact.setType( this.type );
+
+        String path = repositoryContent.toPath( artifact );
+        if ( !path.equals( this.legacyArtifactPath.getPath() ) )
+        {
+            addActionError( "artifact reference does not match the initial path : " + path );
+            return ERROR;
+        }
+
+        try
+        {
+            getArchivaAdministration().addLegacyArtifactPath( legacyArtifactPath, getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            log.error( e.getMessage(), e );
+            addActionError( "Error occured " + e.getMessage() );
+            return INPUT;
+        }
+        return SUCCESS;
+    }
+
+    public LegacyArtifactPath getLegacyArtifactPath()
+    {
+        return legacyArtifactPath;
+    }
+
+    public void setLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
+    {
+        this.legacyArtifactPath = legacyArtifactPath;
+    }
+
+    public void validate()
+    {
+        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
+        trimAllRequestParameterValues();
+    }
+
+    private void trimAllRequestParameterValues()
+    {
+        if ( StringUtils.isNotEmpty( legacyArtifactPath.getPath() ) )
+        {
+            legacyArtifactPath.setPath( legacyArtifactPath.getPath().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( groupId ) )
+        {
+            groupId = groupId.trim();
+        }
+
+        if ( StringUtils.isNotEmpty( artifactId ) )
+        {
+            artifactId = artifactId.trim();
+        }
+
+        if ( StringUtils.isNotEmpty( version ) )
+        {
+            version = version.trim();
+        }
+
+        if ( StringUtils.isNotEmpty( classifier ) )
+        {
+            classifier = classifier.trim();
+        }
+
+        if ( StringUtils.isNotEmpty( type ) )
+        {
+            type = type.trim();
+        }
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public String getClassifier()
+    {
+        return classifier;
+    }
+
+    public void setClassifier( String classifier )
+    {
+        this.classifier = classifier;
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    public ArchivaAdministration getArchivaAdministration()
+    {
+        return archivaAdministration;
+    }
+
+    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
+    {
+        this.archivaAdministration = archivaAdministration;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java
new file mode 100644 (file)
index 0000000..a36e89e
--- /dev/null
@@ -0,0 +1,80 @@
+package org.apache.archiva.web.action.admin.legacy;\r
+\r
+/*\r
+ * Licensed to the Apache Software Foundation (ASF) under one\r
+ * or more contributor license agreements.  See the NOTICE file\r
+ * distributed with this work for additional information\r
+ * regarding copyright ownership.  The ASF licenses this file\r
+ * to you under the Apache License, Version 2.0 (the\r
+ * "License"); you may not use this file except in compliance\r
+ * with the License.  You may obtain a copy of the License at\r
+ *\r
+ *  http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing,\r
+ * software distributed under the License is distributed on an\r
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
+ * KIND, either express or implied.  See the License for the\r
+ * specific language governing permissions and limitations\r
+ * under the License.\r
+ */\r
+\r
+import org.apache.archiva.admin.model.RepositoryAdminException;\r
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;\r
+import org.apache.archiva.web.action.AbstractActionSupport;\r
+import org.springframework.context.annotation.Scope;\r
+import org.springframework.stereotype.Controller;\r
+\r
+import javax.inject.Inject;\r
+\r
+/**\r
+ * Delete a LegacyArtifactPath to archiva configuration\r
+ *\r
+ * @since 1.1\r
+ */\r
+@Controller( "deleteLegacyArtifactPathAction" )\r
+@Scope( "prototype" )\r
+public class DeleteLegacyArtifactPathAction\r
+    extends AbstractActionSupport\r
+{\r
+\r
+    @Inject\r
+    private ArchivaAdministration archivaAdministration;\r
+\r
+    private String path;\r
+\r
+    public String delete()\r
+    {\r
+        log.info( "remove [" + path + "] from legacy artifact path resolution" );\r
+        try\r
+        {\r
+            getArchivaAdministration().deleteLegacyArtifactPath( path, getAuditInformation() );\r
+        }\r
+        catch ( RepositoryAdminException e )\r
+        {\r
+            log.error( e.getMessage(), e );\r
+            addActionError( "Exception during delete " + e.getMessage() );\r
+        }\r
+        return SUCCESS;\r
+    }\r
+\r
+    public String getPath()\r
+    {\r
+        return path;\r
+    }\r
+\r
+    public void setPath( String path )\r
+    {\r
+        this.path = path;\r
+    }\r
+\r
+    public ArchivaAdministration getArchivaAdministration()\r
+    {\r
+        return archivaAdministration;\r
+    }\r
+\r
+    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )\r
+    {\r
+        this.archivaAdministration = archivaAdministration;\r
+    }\r
+}\r
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java
new file mode 100644 (file)
index 0000000..e1709a5
--- /dev/null
@@ -0,0 +1,106 @@
+package org.apache.archiva.web.action.admin.legacy;\r
+\r
+/*\r
+ * Licensed to the Apache Software Foundation (ASF) under one\r
+ * or more contributor license agreements.  See the NOTICE file\r
+ * distributed with this work for additional information\r
+ * regarding copyright ownership.  The ASF licenses this file\r
+ * to you under the Apache License, Version 2.0 (the\r
+ * "License"); you may not use this file except in compliance\r
+ * with the License.  You may obtain a copy of the License at\r
+ *\r
+ *  http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing,\r
+ * software distributed under the License is distributed on an\r
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
+ * KIND, either express or implied.  See the License for the\r
+ * specific language governing permissions and limitations\r
+ * under the License.\r
+ */\r
+\r
+import com.opensymphony.xwork2.Preparable;\r
+import org.apache.archiva.admin.model.RepositoryAdminException;\r
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;\r
+import org.apache.archiva.admin.model.beans.LegacyArtifactPath;\r
+import org.apache.archiva.security.common.ArchivaRoleConstants;\r
+import org.apache.archiva.web.util.ContextUtils;\r
+import org.apache.archiva.web.action.AbstractActionSupport;\r
+import org.apache.struts2.interceptor.ServletRequestAware;\r
+import org.codehaus.plexus.redback.rbac.Resource;\r
+import org.codehaus.redback.integration.interceptor.SecureAction;\r
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;\r
+import org.codehaus.redback.integration.interceptor.SecureActionException;\r
+import org.springframework.context.annotation.Scope;\r
+import org.springframework.stereotype.Controller;\r
+\r
+import javax.inject.Inject;\r
+import javax.servlet.http.HttpServletRequest;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+/**\r
+ * Shows the LegacyArtifactPath Tab for the administrator.\r
+ *\r
+ * @since 1.1\r
+ */\r
+@Controller( "legacyArtifactPathAction" )\r
+@Scope( "prototype" )\r
+public class LegacyArtifactPathAction\r
+    extends AbstractActionSupport\r
+    implements SecureAction, ServletRequestAware, Preparable\r
+{\r
+\r
+    @Inject\r
+    private ArchivaAdministration archivaAdministration;\r
+\r
+    private List<LegacyArtifactPath> legacyArtifactPaths;\r
+\r
+    /**\r
+     * Used to construct the repository WebDAV URL in the repository action.\r
+     */\r
+    private String baseUrl;\r
+\r
+    public void setServletRequest( HttpServletRequest request )\r
+    {\r
+        // TODO: is there a better way to do this?\r
+        this.baseUrl = ContextUtils.getBaseURL( request, "repository" );\r
+    }\r
+\r
+    public SecureActionBundle getSecureActionBundle()\r
+        throws SecureActionException\r
+    {\r
+        SecureActionBundle bundle = new SecureActionBundle();\r
+\r
+        bundle.setRequiresAuthentication( true );\r
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );\r
+\r
+        return bundle;\r
+    }\r
+\r
+    public void prepare()\r
+        throws RepositoryAdminException\r
+    {\r
+        legacyArtifactPaths = new ArrayList<LegacyArtifactPath>( getArchivaAdministration().getLegacyArtifactPaths() );\r
+    }\r
+\r
+    public List<LegacyArtifactPath> getLegacyArtifactPaths()\r
+    {\r
+        return legacyArtifactPaths;\r
+    }\r
+\r
+    public String getBaseUrl()\r
+    {\r
+        return baseUrl;\r
+    }\r
+\r
+    public ArchivaAdministration getArchivaAdministration()\r
+    {\r
+        return archivaAdministration;\r
+    }\r
+\r
+    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )\r
+    {\r
+        this.archivaAdministration = archivaAdministration;\r
+    }\r
+}\r
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java
new file mode 100644 (file)
index 0000000..d533147
--- /dev/null
@@ -0,0 +1,239 @@
+package org.apache.archiva.web.action.admin.networkproxies;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.NetworkProxy;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+
+/**
+ * ConfigureNetworkProxyAction
+ *
+ * @version $Id$
+ */
+@Controller( "configureNetworkProxyAction" )
+@Scope( "prototype" )
+public class ConfigureNetworkProxyAction
+    extends AbstractActionSupport
+    implements SecureAction, Preparable, Validateable
+{
+
+    @Inject
+    private NetworkProxyAdmin networkProxyAdmin;
+
+    private String mode;
+
+    private String proxyid;
+
+    private NetworkProxy proxy;
+
+    public String add()
+    {
+        this.mode = "add";
+        return INPUT;
+    }
+
+    public String confirm()
+    {
+        return INPUT;
+    }
+
+    public String delete()
+        throws RepositoryAdminException
+    {
+
+        String id = getProxyid();
+        if ( StringUtils.isBlank( id ) )
+        {
+            addActionError( "Unable to delete network proxy with blank id." );
+            return SUCCESS;
+        }
+
+        NetworkProxy networkProxy = getNetworkProxyAdmin().getNetworkProxy( id );
+        if ( networkProxy == null )
+        {
+            addActionError( "Unable to remove network proxy, proxy with id [" + id + "] not found." );
+            return SUCCESS;
+        }
+
+        getNetworkProxyAdmin().deleteNetworkProxy( id, getAuditInformation() );
+        addActionMessage( "Successfully removed network proxy [" + id + "]" );
+        return SUCCESS;
+    }
+
+    public String edit()
+    {
+        this.mode = "edit";
+        return INPUT;
+    }
+
+    public String getMode()
+    {
+        return mode;
+    }
+
+    public NetworkProxy getProxy()
+    {
+        return proxy;
+    }
+
+    public String getProxyid()
+    {
+        return proxyid;
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public String input()
+    {
+        return INPUT;
+    }
+
+    public void prepare()
+        throws Exception
+    {
+        String id = getProxyid();
+
+        if ( StringUtils.isNotBlank( id ) )
+        {
+            proxy = findNetworkProxy( id );
+        }
+
+        if ( proxy == null )
+        {
+            proxy = new NetworkProxy();
+        }
+    }
+
+    public String save()
+        throws RepositoryAdminException
+    {
+        String mode = getMode();
+
+        String id = getProxy().getId();
+
+        if ( StringUtils.equalsIgnoreCase( "edit", mode ) )
+        {
+            getNetworkProxyAdmin().updateNetworkProxy( proxy, getAuditInformation() );
+        }
+        else
+        {
+            getNetworkProxyAdmin().addNetworkProxy( proxy, getAuditInformation() );
+        }
+
+        return SUCCESS;
+    }
+
+    public void validate()
+    {
+        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
+        trimAllRequestParameterValues();
+    }
+
+    public void setMode( String mode )
+    {
+        this.mode = mode;
+    }
+
+    public void setProxy( NetworkProxy proxy )
+    {
+        this.proxy = proxy;
+    }
+
+    public void setProxyid( String proxyid )
+    {
+        this.proxyid = proxyid;
+    }
+
+
+    private NetworkProxy findNetworkProxy( String id )
+        throws RepositoryAdminException
+    {
+        return getNetworkProxyAdmin().getNetworkProxy( id );
+    }
+
+    private void removeNetworkProxy( String id )
+        throws RepositoryAdminException
+    {
+        getNetworkProxyAdmin().deleteNetworkProxy( id, getAuditInformation() );
+    }
+
+
+    private void trimAllRequestParameterValues()
+    {
+        if ( StringUtils.isNotEmpty( proxy.getId() ) )
+        {
+            proxy.setId( proxy.getId().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( proxy.getHost() ) )
+        {
+            proxy.setHost( proxy.getHost().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( proxy.getPassword() ) )
+        {
+            proxy.setPassword( proxy.getPassword().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( proxy.getProtocol() ) )
+        {
+            proxy.setProtocol( proxy.getProtocol().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( proxy.getUsername() ) )
+        {
+            proxy.setUsername( proxy.getUsername().trim() );
+        }
+    }
+
+    public NetworkProxyAdmin getNetworkProxyAdmin()
+    {
+        return networkProxyAdmin;
+    }
+
+    public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
+    {
+        this.networkProxyAdmin = networkProxyAdmin;
+    }
+}
+
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java
new file mode 100644 (file)
index 0000000..455d2e5
--- /dev/null
@@ -0,0 +1,90 @@
+package org.apache.archiva.web.action.admin.networkproxies;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.beans.NetworkProxy;
+import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import java.util.List;
+
+/**
+ * NetworkProxiesAction
+ *
+ * @version $Id$
+ */
+@Controller( "networkProxiesAction" )
+@Scope( "prototype" )
+public class NetworkProxiesAction
+    extends AbstractActionSupport
+    implements Preparable, SecureAction
+{
+
+    @Inject
+    private NetworkProxyAdmin networkProxyAdmin;
+
+    private List<NetworkProxy> networkProxies;
+
+    public void prepare()
+        throws Exception
+    {
+        networkProxies = getNetworkProxyAdmin().getNetworkProxies();
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public List<NetworkProxy> getNetworkProxies()
+    {
+        return networkProxies;
+    }
+
+    public void setNetworkProxies( List<NetworkProxy> networkProxies )
+    {
+        this.networkProxies = networkProxies;
+    }
+
+    public NetworkProxyAdmin getNetworkProxyAdmin()
+    {
+        return networkProxyAdmin;
+    }
+
+    public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
+    {
+        this.networkProxyAdmin = networkProxyAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractManagedRepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractManagedRepositoriesAction.java
new file mode 100644 (file)
index 0000000..f3d34a9
--- /dev/null
@@ -0,0 +1,33 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Abstract ManagedRepositories Action.
+ * <p/>
+ * Place for all generic methods used in Managed Repository Administration.
+ *
+ * @version $Id$
+ */
+public abstract class AbstractManagedRepositoriesAction
+    extends AbstractRepositoriesAdminAction
+{
+    public static final String CONFIRM = "confirm";
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractRemoteRepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractRemoteRepositoriesAction.java
new file mode 100644 (file)
index 0000000..2bfb322
--- /dev/null
@@ -0,0 +1,46 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
+
+import javax.inject.Inject;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * AbstractRemoteRepositoriesAction
+ *
+ * @version $Id$
+ */
+public class AbstractRemoteRepositoriesAction
+    extends AbstractRepositoriesAdminAction
+{
+    @Inject
+    private RemoteRepositoryAdmin remoteRepositoryAdmin;
+
+    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
+    {
+        return remoteRepositoryAdmin;
+    }
+
+    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
+    {
+        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java
new file mode 100644 (file)
index 0000000..f1ba9f6
--- /dev/null
@@ -0,0 +1,86 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.RepositoryCommonValidator;
+import org.apache.archiva.audit.Auditable;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+
+import javax.inject.Inject;
+
+/**
+ * Abstract AdminRepositories Action base.
+ * <p/>
+ * Base class for all repository administrative functions.
+ * This should be neutral to the type of action (add/edit/delete) and type of repo (managed/remote)
+ *
+ * @version $Id$
+ */
+public abstract class AbstractRepositoriesAdminAction
+    extends AbstractActionSupport
+    implements SecureAction, Auditable
+{
+
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    @Inject
+    private RepositoryCommonValidator repositoryCommonValidator;
+
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+
+    public RepositoryCommonValidator getRepositoryCommonValidator()
+    {
+        return repositoryCommonValidator;
+    }
+
+    public void setRepositoryCommonValidator( RepositoryCommonValidator repositoryCommonValidator )
+    {
+        this.repositoryCommonValidator = repositoryCommonValidator;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java
new file mode 100644 (file)
index 0000000..8850798
--- /dev/null
@@ -0,0 +1,152 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import java.io.File;
+
+/**
+ * AddManagedRepositoryAction
+ *
+ * @version $Id$
+ */
+@Controller( "addManagedRepositoryAction" )
+@Scope( "prototype" )
+public class AddManagedRepositoryAction
+    extends AbstractManagedRepositoriesAction
+    implements Preparable, Validateable
+{
+
+    private ManagedRepository repository;
+
+    private boolean stageNeeded;
+
+    private String action = "addRepository";
+
+    public void prepare()
+    {
+        this.repository = new ManagedRepository();
+        this.repository.setReleases( false );
+        this.repository.setScanned( false );
+        this.repository.setBlockRedeployments( false );
+    }
+
+    public String input()
+    {
+        this.repository.setReleases( true );
+        this.repository.setScanned( true );
+        this.repository.setBlockRedeployments( true );
+
+        return INPUT;
+    }
+
+    public String confirmAdd()
+    {
+        return save();
+    }
+
+    public String commit()
+    {
+        repository.setLocation( getRepositoryCommonValidator().removeExpressions( repository.getLocation() ) );
+
+        File location = new File( repository.getLocation() );
+        if ( location.exists() )
+        {
+            return CONFIRM;
+        }
+
+        return save();
+    }
+
+    private String save()
+    {
+        String result = SUCCESS;
+        try
+        {
+            getManagedRepositoryAdmin().addManagedRepository( repository, stageNeeded, getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            log.error( e.getMessage(), e );
+            addActionError( "Check your server logs, Repository Administration Exception: " + e.getMessage() );
+            result = INPUT;
+        }
+
+        return result;
+    }
+
+    @Override
+    public void validate()
+    {
+        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
+        trimAllRequestParameterValues();
+    }
+
+    private void trimAllRequestParameterValues()
+    {
+        if ( StringUtils.isNotEmpty( repository.getId() ) )
+        {
+            repository.setId( repository.getId().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( repository.getName() ) )
+        {
+            repository.setName( repository.getName().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( repository.getLocation() ) )
+        {
+            repository.setLocation( repository.getLocation().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( repository.getIndexDirectory() ) )
+        {
+            repository.setIndexDirectory( repository.getIndexDirectory().trim() );
+        }
+    }
+
+    public ManagedRepository getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( ManagedRepository repository )
+    {
+        this.repository = repository;
+    }
+
+
+    public void setStageNeeded( boolean stageNeeded )
+    {
+        this.stageNeeded = stageNeeded;
+    }
+
+    public String getAction()
+    {
+        return action;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java
new file mode 100644 (file)
index 0000000..bc01b2f
--- /dev/null
@@ -0,0 +1,82 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * AddRemoteRepositoryAction
+ *
+ * @version $Id$
+ */
+@Controller( "addRemoteRepositoryAction" )
+@Scope( "prototype" )
+public class AddRemoteRepositoryAction
+    extends AbstractRemoteRepositoriesAction
+    implements Preparable, Validateable
+{
+    /**
+     * The model for this action.
+     */
+    private RemoteRepository repository;
+
+    public void prepare()
+    {
+        this.repository = new RemoteRepository();
+    }
+
+    public String input()
+    {
+        return INPUT;
+    }
+
+    public String commit()
+    {
+
+        String result = SUCCESS;
+        try
+        {
+            getRemoteRepositoryAdmin().addRemoteRepository( repository, getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "RepositoryAdminException: " + e.getMessage() );
+            result = INPUT;
+        }
+
+        return result;
+    }
+
+
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java
new file mode 100644 (file)
index 0000000..b1bc697
--- /dev/null
@@ -0,0 +1,124 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * DeleteManagedRepositoryAction
+ *
+ * @version $Id$
+ */
+@Controller( "deleteManagedRepositoryAction" )
+@Scope( "prototype" )
+public class DeleteManagedRepositoryAction
+    extends AbstractManagedRepositoriesAction
+    implements Preparable
+{
+
+
+    private ManagedRepository repository;
+
+    private ManagedRepository stagingRepository;
+
+    private String repoid;
+
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        if ( StringUtils.isNotBlank( repoid ) )
+        {
+            this.repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
+            this.stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
+        }
+    }
+
+    public String confirmDelete()
+    {
+        if ( StringUtils.isBlank( repoid ) )
+        {
+            addActionError( "Unable to delete managed repository: repository id was blank." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String deleteEntry()
+    {
+        return deleteRepository( false );
+    }
+
+    public String deleteContents()
+    {
+        return deleteRepository( true );
+    }
+
+    private String deleteRepository( boolean deleteContents )
+    {
+        ManagedRepository existingRepository = repository;
+        if ( existingRepository == null )
+        {
+            addActionError( "A repository with that id does not exist" );
+            return ERROR;
+        }
+
+        String result = SUCCESS;
+
+        try
+        {
+            getManagedRepositoryAdmin().deleteManagedRepository( existingRepository.getId(), getAuditInformation(),
+                                                                 deleteContents );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError(
+                "Unable to delete repository, content may already be partially removed: " + e.getMessage() );
+            log.error( e.getMessage(), e );
+            result = ERROR;
+        }
+        return result;
+    }
+
+    public ManagedRepository getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( ManagedRepository repository )
+    {
+        this.repository = repository;
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteRemoteRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteRemoteRepositoryAction.java
new file mode 100644 (file)
index 0000000..c70c25f
--- /dev/null
@@ -0,0 +1,106 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * DeleteRemoteRepositoryAction
+ *
+ * @version $Id$
+ */
+@Controller( "deleteRemoteRepositoryAction" )
+@Scope( "prototype" )
+public class DeleteRemoteRepositoryAction
+    extends AbstractRemoteRepositoriesAction
+    implements Preparable
+{
+    private RemoteRepository repository;
+
+    private String repoid;
+
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        if ( StringUtils.isNotBlank( repoid ) )
+        {
+            this.repository = getRemoteRepositoryAdmin().getRemoteRepository( repoid );
+        }
+    }
+
+    public String confirmDelete()
+    {
+        if ( StringUtils.isBlank( repoid ) )
+        {
+            addActionError( "Unable to delete remote repository: repository id was blank." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String delete()
+    {
+        String result = SUCCESS;
+        RemoteRepository existingRepository = repository;
+        if ( existingRepository == null )
+        {
+            addActionError( "A repository with that id does not exist" );
+            return ERROR;
+        }
+
+        try
+        {
+            getRemoteRepositoryAdmin().deleteRemoteRepository( existingRepository.getId(), getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "RepositoryAdminException: " + e.getMessage() );
+            result = ERROR;
+        }
+        return result;
+    }
+
+
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java
new file mode 100644 (file)
index 0000000..0ce76ab
--- /dev/null
@@ -0,0 +1,120 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RepositoryGroup;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+
+/**
+ * DeleteRepositoryGroupAction
+ */
+@Controller( "deleteRepositoryGroupAction" )
+@Scope( "prototype" )
+public class DeleteRepositoryGroupAction
+    extends AbstractRepositoriesAdminAction
+    implements Preparable
+{
+    private RepositoryGroup repositoryGroup;
+
+    @Inject
+    private RepositoryGroupAdmin repositoryGroupAdmin;
+
+    private String repoGroupId;
+
+    public void prepare()
+        throws RepositoryAdminException
+    {
+
+        if ( StringUtils.isNotBlank( repoGroupId ) )
+        {
+            this.repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( repoGroupId );
+        }
+    }
+
+    public String confirmDelete()
+    {
+        if ( StringUtils.isBlank( repoGroupId ) )
+        {
+            addActionError( "Unable to delete repository group: repository id was blank." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String delete()
+    {
+
+        try
+        {
+            RepositoryGroup group = repositoryGroupAdmin.getRepositoryGroup( repoGroupId );
+            if ( group == null )
+            {
+                addActionError( "A repository group with that id does not exist." );
+                return ERROR;
+            }
+
+            repositoryGroupAdmin.deleteRepositoryGroup( repoGroupId, getAuditInformation() );
+            return SUCCESS;
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "error occured " + e.getMessage() );
+            return ERROR;
+        }
+    }
+
+    public RepositoryGroup getRepositoryGroup()
+    {
+        return repositoryGroup;
+    }
+
+    public void setRepositoryGroup( RepositoryGroup repositoryGroup )
+    {
+        this.repositoryGroup = repositoryGroup;
+    }
+
+    public String getRepoGroupId()
+    {
+        return repoGroupId;
+    }
+
+    public void setRepoGroupId( String repoGroupId )
+    {
+        this.repoGroupId = repoGroupId;
+    }
+
+    public RepositoryGroupAdmin getRepositoryGroupAdmin()
+    {
+        return repositoryGroupAdmin;
+    }
+
+    public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
+    {
+        this.repositoryGroupAdmin = repositoryGroupAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java
new file mode 100644 (file)
index 0000000..e4a9dbf
--- /dev/null
@@ -0,0 +1,213 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.redback.components.scheduler.CronExpressionValidator;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import java.io.File;
+
+/**
+ * AddManagedRepositoryAction
+ *
+ * @version $Id$
+ */
+@Controller( "editManagedRepositoryAction" )
+@Scope( "prototype" )
+public class EditManagedRepositoryAction
+    extends AbstractManagedRepositoriesAction
+    implements Preparable, Validateable
+{
+
+    private ManagedRepository repository;
+
+    private ManagedRepository stagingRepository;
+
+    private String repoid;
+
+    private final String action = "editRepository";
+
+    private boolean stageNeeded;
+
+
+    // FIXME better error message
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        if ( StringUtils.isNotBlank( repoid ) )
+        {
+            repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
+            stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
+        }
+        else if ( repository != null )
+        {
+            repository.setReleases( false );
+            repository.setScanned( false );
+        }
+    }
+
+    public String input()
+    {
+        if ( repository == null )
+        {
+            addActionError( "Edit failure, unable to edit a repository with a blank repository id." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String confirmUpdate()
+    {
+        // location was changed
+        return save( true );
+    }
+
+    public String commit()
+        throws RepositoryAdminException
+    {
+        ManagedRepository existingConfig = getManagedRepositoryAdmin().getManagedRepository( repository.getId() );
+        boolean resetStats = false;
+
+        // check if the location was changed
+        repository.setLocation( getRepositoryCommonValidator().removeExpressions( repository.getLocation() ) );
+
+        if ( !StringUtils.equalsIgnoreCase( existingConfig.getLocation().trim(), repository.getLocation().trim() ) )
+        {
+            resetStats = true;
+
+            File dir = new File( repository.getLocation() );
+            if ( dir.exists() )
+            {
+                return CONFIRM;
+            }
+        }
+
+        return save( resetStats );
+    }
+
+    private String save( boolean resetStats )
+    {
+
+        String result = SUCCESS;
+        try
+        {
+            getManagedRepositoryAdmin().updateManagedRepository( repository, stageNeeded, getAuditInformation(),
+                                                                 resetStats );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "Repository Administration Exception: " + e.getMessage() );
+            result = ERROR;
+        }
+
+        return result;
+    }
+
+
+    @Override
+    public void validate()
+    {
+        CronExpressionValidator validator = new CronExpressionValidator();
+
+        if ( !validator.validate( repository.getCronExpression() ) )
+        {
+            addFieldError( "repository.refreshCronExpression", "Invalid cron expression." );
+        }
+
+        trimAllRequestParameterValues();
+    }
+
+    private void trimAllRequestParameterValues()
+    {
+        if ( StringUtils.isNotEmpty( repository.getId() ) )
+        {
+            repository.setId( repository.getId().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( repository.getName() ) )
+        {
+            repository.setName( repository.getName().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( repository.getLocation() ) )
+        {
+            repository.setLocation( repository.getLocation().trim() );
+        }
+
+        if ( StringUtils.isNotEmpty( repository.getIndexDirectory() ) )
+        {
+            repository.setIndexDirectory( repository.getIndexDirectory().trim() );
+        }
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+
+
+    public boolean isStageNeeded()
+    {
+        return stageNeeded;
+    }
+
+    public void setStageNeeded( boolean stageNeeded )
+    {
+
+        this.stageNeeded = stageNeeded;
+    }
+
+    public String getAction()
+    {
+        return action;
+    }
+
+    public ManagedRepository getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( ManagedRepository repository )
+    {
+        this.repository = repository;
+    }
+
+    public ManagedRepository getStagingRepository()
+    {
+        return stagingRepository;
+    }
+
+    public void setStagingRepository( ManagedRepository stagingRepository )
+    {
+        this.stagingRepository = stagingRepository;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryAction.java
new file mode 100644 (file)
index 0000000..2a8e574
--- /dev/null
@@ -0,0 +1,105 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+/**
+ * EditRemoteRepositoryAction
+ *
+ * @version $Id$
+ */
+@Controller( "editRemoteRepositoryAction" )
+@Scope( "prototype" )
+public class EditRemoteRepositoryAction
+    extends AbstractRemoteRepositoriesAction
+    implements Preparable
+{
+    /**
+     * The model for this action.
+     */
+    private RemoteRepository repository;
+
+    /**
+     * The repository id to edit.
+     */
+    private String repoid;
+
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        if ( StringUtils.isNotBlank( repoid ) )
+        {
+            this.repository = getRemoteRepositoryAdmin().getRemoteRepository( repoid );
+        }
+    }
+
+    public String input()
+    {
+        if ( StringUtils.isBlank( repoid ) )
+        {
+            addActionError( "Edit failure, unable to edit a repository with a blank repository id." );
+            return ERROR;
+        }
+
+        return INPUT;
+    }
+
+    public String commit()
+    {
+        String result = SUCCESS;
+        try
+        {
+            getRemoteRepositoryAdmin().updateRemoteRepository( getRepository(), getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "RepositoryAdminException: " + e.getMessage() );
+            result = INPUT;
+        }
+
+        return result;
+    }
+
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+    }
+
+    public String getRepoid()
+    {
+        return repoid;
+    }
+
+    public void setRepoid( String repoid )
+    {
+        this.repoid = repoid;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/RepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/RepositoriesAction.java
new file mode 100644 (file)
index 0000000..bbe1396
--- /dev/null
@@ -0,0 +1,222 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.repository.utils.RepositoryComparator;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepositoryException;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.archiva.web.util.ContextUtils;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.apache.struts2.interceptor.ServletRequestAware;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Shows the Repositories Tab for the administrator.
+ *
+ * @version $Id$
+ */
+@Controller( "repositoriesAction" )
+@Scope( "prototype" )
+public class RepositoriesAction
+    extends AbstractActionSupport
+    implements SecureAction, ServletRequestAware, Preparable
+{
+
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    @Inject
+    private RemoteRepositoryAdmin remoteRepositoryAdmin;
+
+    @Inject
+    private RepositoryGroupAdmin repositoryGroupAdmin;
+
+    private List<ManagedRepository> managedRepositories;
+
+    private List<RemoteRepository> remoteRepositories;
+
+    private Map<String, RepositoryStatistics> repositoryStatistics;
+
+    private Map<String, List<String>> repositoryToGroupMap;
+
+    /**
+     * Used to construct the repository WebDAV URL in the repository action.
+     */
+    private String baseUrl;
+
+
+    @Inject
+    private RepositoryStatisticsManager repositoryStatisticsManager;
+
+    public void setServletRequest( HttpServletRequest request )
+    {
+        // TODO: is there a better way to do this?
+        this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        remoteRepositories = new ArrayList<RemoteRepository>( getRemoteRepositoryAdmin().getRemoteRepositories() );
+        managedRepositories = new ArrayList<ManagedRepository>( getManagedRepositoryAdmin().getManagedRepositories() );
+        repositoryToGroupMap = getRepositoryGroupAdmin().getRepositoryToGroupMap();
+
+        Collections.sort( managedRepositories, new RepositoryComparator() );
+        Collections.sort( remoteRepositories, new RepositoryComparator() );
+
+        repositoryStatistics = new HashMap<String, RepositoryStatistics>();
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            for ( ManagedRepository repo : managedRepositories )
+            {
+                RepositoryStatistics stats = null;
+                try
+                {
+                    stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, repo.getId() );
+                }
+                catch ( MetadataRepositoryException e )
+                {
+                    addActionError(
+                        "Error retrieving statistics for repository " + repo.getId() + " - consult application logs" );
+                    log.warn( "Error retrieving repository statistics: " + e.getMessage(), e );
+                }
+                if ( stats != null )
+                {
+                    repositoryStatistics.put( repo.getId(), stats );
+                }
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+    }
+
+    public List<ManagedRepository> getManagedRepositories()
+    {
+        List<ManagedRepository> managedRepositoriesList = new ArrayList<ManagedRepository>();
+        for ( ManagedRepository repoConfig : managedRepositories )
+        {
+            if ( !repoConfig.getId().endsWith( "-stage" ) )
+            {
+                managedRepositoriesList.add( repoConfig );
+            }
+        }
+        return managedRepositoriesList;
+    }
+
+    public List<RemoteRepository> getRemoteRepositories()
+    {
+        return remoteRepositories;
+    }
+
+    public Map<String, RepositoryStatistics> getRepositoryStatistics()
+    {
+        return repositoryStatistics;
+    }
+
+    public String getBaseUrl()
+    {
+        return baseUrl;
+    }
+
+    public Map<String, List<String>> getRepositoryToGroupMap()
+    {
+        return repositoryToGroupMap;
+    }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+
+    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
+    {
+        return remoteRepositoryAdmin;
+    }
+
+    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
+    {
+        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
+    }
+
+    public RepositoryGroupAdmin getRepositoryGroupAdmin()
+    {
+        return repositoryGroupAdmin;
+    }
+
+    public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
+    {
+        this.repositoryGroupAdmin = repositoryGroupAdmin;
+    }
+
+    public RepositoryStatisticsManager getRepositoryStatisticsManager()
+    {
+        return repositoryStatisticsManager;
+    }
+
+    public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
+    {
+        this.repositoryStatisticsManager = repositoryStatisticsManager;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/RepositoryGroupsAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/RepositoryGroupsAction.java
new file mode 100644 (file)
index 0000000..7c5d9f8
--- /dev/null
@@ -0,0 +1,193 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.beans.RepositoryGroup;
+import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
+import org.apache.archiva.web.util.ContextUtils;
+import org.apache.struts2.interceptor.ServletRequestAware;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/**
+ * RepositoryGroupsAction
+ */
+@Controller( "repositoryGroupsAction" )
+@Scope( "prototype" )
+public class RepositoryGroupsAction
+    extends AbstractRepositoriesAdminAction
+    implements ServletRequestAware, Preparable
+{
+
+    @Inject
+    private RepositoryGroupAdmin repositoryGroupAdmin;
+
+    private RepositoryGroup repositoryGroup;
+
+    private Map<String, RepositoryGroup> repositoryGroups;
+
+    private Map<String, ManagedRepository> managedRepositories;
+
+    private Map<String, List<String>> groupToRepositoryMap;
+
+    private String repoGroupId;
+
+    private String repoId;
+
+    /**
+     * Used to construct the repository WebDAV URL in the repository action.
+     */
+    private String baseUrl;
+
+    private static final Pattern REPO_GROUP_ID_PATTERN = Pattern.compile( "[A-Za-z0-9\\._\\-]+" );
+
+    public void setServletRequest( HttpServletRequest request )
+    {
+        this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
+    }
+
+    public void prepare()
+        throws RepositoryAdminException
+    {
+
+        repositoryGroup = new RepositoryGroup();
+        repositoryGroups = getRepositoryGroupAdmin().getRepositoryGroupsAsMap();
+        managedRepositories = getManagedRepositoryAdmin().getManagedRepositoriesAsMap();
+        groupToRepositoryMap = getRepositoryGroupAdmin().getGroupToRepositoryMap();
+    }
+
+    public String addRepositoryGroup()
+    {
+        try
+        {
+            getRepositoryGroupAdmin().addRepositoryGroup( repositoryGroup, getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+
+        return SUCCESS;
+    }
+
+    public String addRepositoryToGroup()
+    {
+        try
+        {
+            getRepositoryGroupAdmin().addRepositoryToGroup( repoGroupId, repoId, getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+        return SUCCESS;
+    }
+
+    public String removeRepositoryFromGroup()
+    {
+        try
+        {
+            getRepositoryGroupAdmin().deleteRepositoryFromGroup( repoGroupId, repoId, getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( e.getMessage() );
+            return ERROR;
+        }
+        return SUCCESS;
+    }
+
+
+    public RepositoryGroup getRepositoryGroup()
+    {
+        return repositoryGroup;
+    }
+
+    public void setRepositoryGroup( RepositoryGroup repositoryGroup )
+    {
+        this.repositoryGroup = repositoryGroup;
+    }
+
+    public Map<String, RepositoryGroup> getRepositoryGroups()
+    {
+        return repositoryGroups;
+    }
+
+    public void setRepositoryGroups( Map<String, RepositoryGroup> repositoryGroups )
+    {
+        this.repositoryGroups = repositoryGroups;
+    }
+
+    public Map<String, ManagedRepository> getManagedRepositories()
+    {
+        return managedRepositories;
+    }
+
+    public Map<String, List<String>> getGroupToRepositoryMap()
+    {
+        return this.groupToRepositoryMap;
+    }
+
+    public String getRepoGroupId()
+    {
+        return repoGroupId;
+    }
+
+    public void setRepoGroupId( String repoGroupId )
+    {
+        this.repoGroupId = repoGroupId;
+    }
+
+    public String getRepoId()
+    {
+        return repoId;
+    }
+
+    public void setRepoId( String repoId )
+    {
+        this.repoId = repoId;
+    }
+
+    public String getBaseUrl()
+    {
+        return baseUrl;
+    }
+
+    public RepositoryGroupAdmin getRepositoryGroupAdmin()
+    {
+        return repositoryGroupAdmin;
+    }
+
+    public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
+    {
+        this.repositoryGroupAdmin = repositoryGroupAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/SortRepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/repositories/SortRepositoriesAction.java
new file mode 100644 (file)
index 0000000..307a748
--- /dev/null
@@ -0,0 +1,171 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.codehaus.plexus.registry.RegistryException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import java.util.List;
+
+/**
+ * SortRepositoriesAction
+ * FIXME remove access to archivaconfiguration
+ */
+@Controller( "sortRepositoriesAction" )
+@Scope( "prototype" )
+public class SortRepositoriesAction
+    extends AbstractRepositoriesAdminAction
+{
+
+    private String repoGroupId;
+
+    private String targetRepo;
+
+    @Inject
+    protected ArchivaConfiguration archivaConfiguration;
+
+    public String sortDown()
+    {
+        Configuration config = archivaConfiguration.getConfiguration();
+
+        List<String> repositories = getRepositoriesFromGroup();
+
+        int idx = findTargetRepository( repositories, targetRepo );
+
+        if ( idx >= 0 && validIndex( repositories, idx + 1 ) )
+        {
+            repositories.remove( idx );
+            repositories.add( idx + 1, targetRepo );
+        }
+
+        return saveConfiguration( config );
+    }
+
+    public String sortUp()
+    {
+        Configuration config = archivaConfiguration.getConfiguration();
+
+        List<String> repositories = getRepositoriesFromGroup();
+
+        int idx = findTargetRepository( repositories, targetRepo );
+
+        if ( idx >= 0 && validIndex( repositories, idx - 1 ) )
+        {
+            repositories.remove( idx );
+            repositories.add( idx - 1, targetRepo );
+        }
+
+        return saveConfiguration( config );
+    }
+
+/**
+     * Save the configuration.
+     *
+     * @param configuration the configuration to save.
+     * @return the webwork result code to issue.
+     * @throws java.io.IOException                   thrown if unable to save file to disk.
+     * @throws org.apache.archiva.configuration.InvalidConfigurationException thrown if configuration is invalid.
+     * @throws org.codehaus.plexus.registry.RegistryException             thrown if configuration subsystem has a problem saving the configuration to disk.
+     */
+    protected String saveConfiguration( Configuration configuration )
+    {
+        try
+        {
+            archivaConfiguration.save( configuration );
+            addActionMessage( "Successfully saved configuration" );
+        }
+        catch ( IndeterminateConfigurationException e )
+        {
+            addActionError( e.getMessage() );
+            return INPUT;
+        }
+        catch ( RegistryException e )
+        {
+            addActionError( "Configuration Registry Exception: " + e.getMessage() );
+            return INPUT;
+        }
+
+        return SUCCESS;
+    }
+
+    public String getRepoGroupId()
+    {
+        return repoGroupId;
+    }
+
+    public void setRepoGroupId( String repoGroupId )
+    {
+        this.repoGroupId = repoGroupId;
+    }
+
+    public String getTargetRepo()
+    {
+        return targetRepo;
+    }
+
+    public void setTargetRepo( String targetRepo )
+    {
+        this.targetRepo = targetRepo;
+    }
+
+    private int findTargetRepository( List<String> repositories, String targetRepository )
+    {
+        int idx = ( -1 );
+
+        for ( int i = 0; i < repositories.size(); i++ )
+        {
+            if ( StringUtils.equals( targetRepository, repositories.get( i ) ) )
+            {
+                idx = i;
+                break;
+            }
+        }
+        return idx;
+    }
+
+    private List<String> getRepositoriesFromGroup()
+    {
+        Configuration config = archivaConfiguration.getConfiguration();
+        RepositoryGroupConfiguration repoGroup = config.findRepositoryGroupById( repoGroupId );
+        return repoGroup.getRepositories();
+    }
+
+    private boolean validIndex( List<String> repositories, int idx )
+    {
+        return ( idx >= 0 ) && ( idx < repositories.size() );
+    }
+
+    public ArchivaConfiguration getArchivaConfiguration()
+    {
+        return archivaConfiguration;
+    }
+
+    public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+    {
+        this.archivaConfiguration = archivaConfiguration;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AddAdminRepoConsumerClosure.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AddAdminRepoConsumerClosure.java
new file mode 100644 (file)
index 0000000..34f9c77
--- /dev/null
@@ -0,0 +1,65 @@
+package org.apache.archiva.web.action.admin.scanning;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Closure;
+import org.apache.archiva.consumers.RepositoryContentConsumer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AddAdminRepoConsumerClosure 
+ *
+ * @version $Id$
+ */
+public class AddAdminRepoConsumerClosure
+    implements Closure
+{
+    private List<AdminRepositoryConsumer> list = new ArrayList<AdminRepositoryConsumer>();
+
+    private List<String> selectedIds;
+
+    public AddAdminRepoConsumerClosure( List<String> selectedIds )
+    {
+        this.selectedIds = selectedIds;
+    }
+
+    public void execute( Object input )
+    {
+        if ( input instanceof RepositoryContentConsumer )
+        {
+            RepositoryContentConsumer consumer = (RepositoryContentConsumer) input;
+
+            boolean enabled = this.selectedIds.contains( consumer.getId() );
+            AdminRepositoryConsumer adminconsumer = new AdminRepositoryConsumer();
+            adminconsumer.setEnabled( enabled );
+            adminconsumer.setId( consumer.getId() );
+            adminconsumer.setDescription( consumer.getDescription() );
+
+            list.add( adminconsumer );
+        }
+    }
+
+    public List<AdminRepositoryConsumer> getList()
+    {
+        return list;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java
new file mode 100644 (file)
index 0000000..5d71413
--- /dev/null
@@ -0,0 +1,62 @@
+package org.apache.archiva.web.action.admin.scanning;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * AdminRepositoryConsumer 
+ *
+ * @version $Id$
+ */
+public class AdminRepositoryConsumer
+{
+    private boolean enabled = false;
+    private String id;
+    private String description;
+    
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public boolean isEnabled()
+    {
+        return enabled;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public void setEnabled( boolean enabled )
+    {
+        this.enabled = enabled;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumerComparator.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumerComparator.java
new file mode 100644 (file)
index 0000000..44dc677
--- /dev/null
@@ -0,0 +1,60 @@
+package org.apache.archiva.web.action.admin.scanning;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Comparator;
+
+/**
+ * AdminRepositoryConsumerComparator 
+ *
+ * @version $Id$
+ */
+public class AdminRepositoryConsumerComparator
+    implements Comparator<AdminRepositoryConsumer>
+{
+    private static AdminRepositoryConsumerComparator INSTANCE = new AdminRepositoryConsumerComparator();
+
+    public static AdminRepositoryConsumerComparator getInstance()
+    {
+        return INSTANCE;
+    }
+
+    public int compare( AdminRepositoryConsumer o1, AdminRepositoryConsumer o2 )
+    {
+        if ( o1 == null && o2 == null )
+        {
+            return 0;
+        }
+
+        if ( o1 == null && o2 != null )
+        {
+            return 1;
+        }
+
+        if ( o1 != null && o2 == null )
+        {
+            return -1;
+        }
+
+        String id1 = o1.getId();
+        String id2 = o2.getId();
+        return id1.compareToIgnoreCase( id2 );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java
new file mode 100644 (file)
index 0000000..fffcf60
--- /dev/null
@@ -0,0 +1,359 @@
+package org.apache.archiva.web.action.admin.scanning;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.beans.FileType;
+import org.apache.archiva.admin.repository.admin.FiletypeToMapClosure;
+import org.apache.archiva.audit.Auditable;
+import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * RepositoryScanningAction
+ *
+ * @version $Id$
+ */
+@Controller( "repositoryScanningAction" )
+@Scope( "prototype" )
+public class RepositoryScanningAction
+    extends AbstractActionSupport
+    implements Preparable, Validateable, SecureAction, Auditable
+{
+
+    @Inject
+    private RepositoryContentConsumers repoconsumerUtil;
+
+    @Inject
+    private ArchivaAdministration archivaAdministration;
+
+    private Map<String, FileType> fileTypeMap;
+
+    private List<String> fileTypeIds;
+
+    /**
+     * List of {@link AdminRepositoryConsumer} objects for consumers of known content.
+     */
+    private List<AdminRepositoryConsumer> knownContentConsumers;
+
+    /**
+     * List of enabled {@link AdminRepositoryConsumer} objects for consumers of known content.
+     */
+    private List<String> enabledKnownContentConsumers;
+
+    /**
+     * List of {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content.
+     */
+    private List<AdminRepositoryConsumer> invalidContentConsumers;
+
+    /**
+     * List of enabled {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content.
+     */
+    private List<String> enabledInvalidContentConsumers;
+
+    private String pattern;
+
+    private String fileTypeId;
+
+    public void addActionError( String anErrorMessage )
+    {
+        super.addActionError( anErrorMessage );
+        log.warn( "[ActionError] {}", anErrorMessage );
+    }
+
+    public void addActionMessage( String aMessage )
+    {
+        super.addActionMessage( aMessage );
+        log.info( "[ActionMessage] {}", aMessage );
+    }
+
+    public String addFiletypePattern()
+    {
+        log.info( "Add New File Type Pattern [{}:{}]", getFileTypeId(), getPattern() );
+
+        if ( !isValidFiletypeCommand() )
+        {
+            return INPUT;
+        }
+
+        try
+        {
+            getArchivaAdministration().addFileTypePattern( getFileTypeId(), getPattern(), getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "error adding file type pattern " + e.getMessage() );
+            return INPUT;
+        }
+        return SUCCESS;
+    }
+
+    public String removeFiletypePattern()
+        throws RepositoryAdminException
+    {
+        log.info( "Remove File Type Pattern [{}:{}]", getFileTypeId(), getPattern() );
+
+        if ( !isValidFiletypeCommand() )
+        {
+            return INPUT;
+        }
+
+        try
+        {
+            getArchivaAdministration().removeFileTypePattern( getFileTypeId(), getPattern(), getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "error adding file type pattern " + e.getMessage() );
+            return INPUT;
+        }
+
+        return SUCCESS;
+    }
+
+    public String getFileTypeId()
+    {
+        return fileTypeId;
+    }
+
+    public List<String> getFileTypeIds()
+    {
+        return fileTypeIds;
+    }
+
+    public Map<String, FileType> getFileTypeMap()
+    {
+        return fileTypeMap;
+    }
+
+    public List<AdminRepositoryConsumer> getInvalidContentConsumers()
+    {
+        return invalidContentConsumers;
+    }
+
+    public List<AdminRepositoryConsumer> getKnownContentConsumers()
+    {
+        return knownContentConsumers;
+    }
+
+    public String getPattern()
+    {
+        return pattern;
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public void prepare()
+        throws Exception
+    {
+
+
+        FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
+
+        CollectionUtils.forAllDo( archivaAdministration.getFileTypes(), filetypeToMapClosure );
+        fileTypeMap = filetypeToMapClosure.getMap();
+
+        AddAdminRepoConsumerClosure addAdminRepoConsumer =
+            new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
+        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
+        this.knownContentConsumers = addAdminRepoConsumer.getList();
+        Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
+
+        addAdminRepoConsumer = new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
+        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
+        this.invalidContentConsumers = addAdminRepoConsumer.getList();
+        Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
+
+        fileTypeIds = new ArrayList<String>();
+        fileTypeIds.addAll( fileTypeMap.keySet() );
+        Collections.sort( fileTypeIds );
+    }
+
+    public void setFileTypeId( String fileTypeId )
+    {
+        this.fileTypeId = fileTypeId;
+    }
+
+    public void setPattern( String pattern )
+    {
+        this.pattern = pattern;
+    }
+
+    public String updateInvalidConsumers()
+    {
+
+        try
+        {
+            List<String> oldConsumers = getArchivaAdministration().getInvalidContentConsumers();
+
+            if ( enabledInvalidContentConsumers != null )
+            {
+                for ( String oldConsumer : oldConsumers )
+                {
+                    if ( !enabledInvalidContentConsumers.contains( oldConsumer ) )
+                    {
+                        getArchivaAdministration().removeInvalidContentConsumer( oldConsumer, getAuditInformation() );
+                    }
+                }
+                for ( String enabledKnowContentConsumer : enabledInvalidContentConsumers )
+                {
+                    getArchivaAdministration().addInvalidContentConsumer( enabledKnowContentConsumer,
+                                                                          getAuditInformation() );
+                }
+            }
+            else
+            {
+                for ( String oldConsumer : oldConsumers )
+                {
+                    getArchivaAdministration().removeInvalidContentConsumer( oldConsumer, getAuditInformation() );
+                }
+            }
+        }
+        catch ( RepositoryAdminException e )
+        {
+            log.error( e.getMessage(), e );
+            addActionError( "Error update invalidContentConsumers " + e.getMessage() );
+            return INPUT;
+        }
+        addActionMessage( "Update Invalid Consumers" );
+
+        return SUCCESS;
+    }
+
+    public String updateKnownConsumers()
+    {
+
+        try
+        {
+            List<String> oldConsumers = getArchivaAdministration().getKnownContentConsumers();
+
+            if ( enabledKnownContentConsumers != null )
+            {
+                for ( String oldConsumer : oldConsumers )
+                {
+                    if ( !enabledKnownContentConsumers.contains( oldConsumer ) )
+                    {
+                        getArchivaAdministration().removeKnownContentConsumer( oldConsumer, getAuditInformation() );
+                    }
+                }
+                for ( String enabledKnowContentConsumer : enabledKnownContentConsumers )
+                {
+                    getArchivaAdministration().addKnownContentConsumer( enabledKnowContentConsumer,
+                                                                        getAuditInformation() );
+                }
+            }
+            else
+            {
+                for ( String oldConsumer : oldConsumers )
+                {
+                    getArchivaAdministration().removeKnownContentConsumer( oldConsumer, getAuditInformation() );
+                }
+            }
+        }
+        catch ( RepositoryAdminException e )
+        {
+            log.error( e.getMessage(), e );
+            addActionError( "Error update knowContentConsumers " + e.getMessage() );
+            return INPUT;
+        }
+        addActionMessage( "Update Known Consumers" );
+
+        return SUCCESS;
+    }
+
+    private FileType findFileType( String id )
+        throws RepositoryAdminException
+    {
+        return getArchivaAdministration().getFileType( id );
+    }
+
+    private boolean isValidFiletypeCommand()
+    {
+        if ( StringUtils.isBlank( getFileTypeId() ) )
+        {
+            addActionError( "Unable to process blank filetype id." );
+        }
+
+        if ( StringUtils.isBlank( getPattern() ) )
+        {
+            addActionError( "Unable to process blank pattern." );
+        }
+
+        return !hasActionErrors();
+    }
+
+
+    public List<String> getEnabledInvalidContentConsumers()
+    {
+        return enabledInvalidContentConsumers;
+    }
+
+    public void setEnabledInvalidContentConsumers( List<String> enabledInvalidContentConsumers )
+    {
+        this.enabledInvalidContentConsumers = enabledInvalidContentConsumers;
+    }
+
+    public List<String> getEnabledKnownContentConsumers()
+    {
+        return enabledKnownContentConsumers;
+    }
+
+    public void setEnabledKnownContentConsumers( List<String> enabledKnownContentConsumers )
+    {
+        this.enabledKnownContentConsumers = enabledKnownContentConsumers;
+    }
+
+    public ArchivaAdministration getArchivaAdministration()
+    {
+        return archivaAdministration;
+    }
+
+    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
+    {
+        this.archivaAdministration = archivaAdministration;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/reports/GenerateReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/reports/GenerateReportAction.java
new file mode 100644 (file)
index 0000000..77b623f
--- /dev/null
@@ -0,0 +1,774 @@
+package org.apache.archiva.web.action.reports;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepositoryException;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.reports.RepositoryProblemFacet;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.archiva.web.action.AbstractRepositoryBasedAction;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ *
+ */
+@Controller( "generateReport" )
+@Scope( "prototype" )
+public class GenerateReportAction
+    extends AbstractRepositoryBasedAction
+    implements SecureAction, Preparable
+{
+    public static final String ALL_REPOSITORIES = "All Repositories";
+
+    public static final String BLANK = "blank";
+
+    private static final String[] datePatterns =
+        new String[]{ "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
+            "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy" };
+
+    public static final String SEND_FILE = "send-file";
+
+    private Logger log = LoggerFactory.getLogger( GenerateReportAction.class );
+
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    @Inject
+    private RepositoryStatisticsManager repositoryStatisticsManager;
+
+    private String groupId;
+
+    private String repositoryId;
+
+    private int page = 1;
+
+    private int rowCount = 100;
+
+    private List<String> selectedRepositories = new ArrayList<String>();
+
+    private String startDate;
+
+    private String endDate;
+
+    private int numPages;
+
+    private List<String> repositoryIds;
+
+    private Map<String, List<RepositoryProblemFacet>> repositoriesMap =
+        new TreeMap<String, List<RepositoryProblemFacet>>();
+
+    private List<String> availableRepositories;
+
+    private List<RepositoryStatistics> repositoryStatistics = new ArrayList<RepositoryStatistics>();
+
+    private InputStream inputStream;
+
+    private boolean lastPage;
+
+    @SuppressWarnings( "unchecked" )
+    public void prepare()
+        throws RepositoryAdminException
+    {
+        repositoryIds = new ArrayList<String>();
+        repositoryIds.add( ALL_REPOSITORIES ); // comes first to be first in the list
+        repositoryIds.addAll( getObservableRepos() );
+
+        availableRepositories = new ArrayList<String>();
+
+        // remove selected repositories in the option for the statistics report
+        availableRepositories.addAll( managedRepositoryAdmin.getManagedRepositoriesAsMap().keySet() );
+        for ( String repo : selectedRepositories )
+        {
+            if ( availableRepositories.contains( repo ) )
+            {
+                availableRepositories.remove( repo );
+            }
+        }
+    }
+
+    /**
+     * Generate the statistics report.
+     * <p/>
+     * check whether single repo report or comparison report
+     * 1. if it is a single repository, get all the statistics for the repository on the specified date
+     * - if no date is specified, get only the latest
+     * (total page = 1 --> no pagination since only the most recent stats will be displayed)
+     * - otherwise, get everything within the date range (total pages = repo stats / rows per page)
+     * - required params: repository, startDate, endDate
+     * <p/>
+     * 2. if multiple repositories, get the latest statistics on each repository on the specified date
+     * - if no date is specified, use the current date endDate
+     * - required params: repositories, endDate
+     * - total pages = repositories / rows per page
+     *
+     * @return action result
+     */
+    public String generateStatistics()
+    {
+        if ( rowCount < 10 )
+        {
+            // TODO: move to validation framework
+            addFieldError( "rowCount", "Row count must be larger than 10." );
+            return INPUT;
+        }
+        Date startDateInDF;
+        Date endDateInDF;
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            if ( selectedRepositories.size() > 1 )
+            {
+                numPages = 1;
+
+                try
+                {
+                    startDateInDF = getStartDateInDateFormat();
+                    endDateInDF = getEndDateInDateFormat();
+                }
+                catch ( ParseException e )
+                {
+                    addActionError( "Error parsing date(s)." );
+                    return ERROR;
+                }
+
+                if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
+                {
+                    addFieldError( "startDate", "Start Date must be earlier than the End Date" );
+                    return INPUT;
+                }
+
+                // multiple repos
+                for ( String repo : selectedRepositories )
+                {
+                    List<RepositoryStatistics> stats = null;
+                    try
+                    {
+                        stats =
+                            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo, startDateInDF,
+                                                                              endDateInDF );
+                    }
+                    catch ( MetadataRepositoryException e )
+                    {
+                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
+                    }
+                    if ( stats == null || stats.isEmpty() )
+                    {
+                        log.info( "No statistics available for repository '" + repo + "'." );
+                        // TODO set repo's stats to 0
+                        continue;
+                    }
+
+                    repositoryStatistics.add( stats.get( 0 ) );
+                }
+            }
+            else if ( selectedRepositories.size() == 1 )
+            {
+                repositoryId = selectedRepositories.get( 0 );
+                try
+                {
+                    startDateInDF = getStartDateInDateFormat();
+                    endDateInDF = getEndDateInDateFormat();
+
+                    if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
+                    {
+                        addFieldError( "startDate", "Start Date must be earlier than the End Date" );
+                        return INPUT;
+                    }
+
+                    List<RepositoryStatistics> stats = null;
+                    try
+                    {
+                        stats = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repositoryId,
+                                                                                  startDateInDF, endDateInDF );
+                    }
+                    catch ( MetadataRepositoryException e )
+                    {
+                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
+                    }
+                    if ( stats == null || stats.isEmpty() )
+                    {
+                        addActionError(
+                            "No statistics available for repository. Repository might not have been scanned." );
+                        return ERROR;
+                    }
+
+                    int rowCount = getRowCount();
+                    int extraPage = ( stats.size() % rowCount ) != 0 ? 1 : 0;
+                    int totalPages = ( stats.size() / rowCount ) + extraPage;
+                    numPages = totalPages;
+
+                    int currentPage = getPage();
+                    if ( currentPage > totalPages )
+                    {
+                        addActionError(
+                            "Error encountered while generating report :: The requested page exceeds the total number of pages." );
+                        return ERROR;
+                    }
+
+                    int start = rowCount * ( currentPage - 1 );
+                    int end = ( start + rowCount ) - 1;
+
+                    if ( end >= stats.size() )
+                    {
+                        end = stats.size() - 1;
+                    }
+
+                    repositoryStatistics = stats.subList( start, end + 1 );
+                }
+                catch ( ParseException pe )
+                {
+                    addActionError( pe.getMessage() );
+                    return ERROR;
+                }
+            }
+            else
+            {
+                addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
+                return INPUT;
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        if ( repositoryStatistics.isEmpty() )
+        {
+            return BLANK;
+        }
+
+        return SUCCESS;
+    }
+
+    /**
+     * Export report to CSV.
+     *
+     * @return action result
+     */
+    public String downloadStatisticsReport()
+    {
+        Date startDateInDF;
+        Date endDateInDF;
+
+        selectedRepositories = parseSelectedRepositories();
+        List<RepositoryStatistics> repositoryStatistics = new ArrayList<RepositoryStatistics>();
+
+        StringBuilder input;
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            if ( selectedRepositories.size() > 1 )
+            {
+                try
+                {
+                    startDateInDF = getStartDateInDateFormat();
+                    endDateInDF = getEndDateInDateFormat();
+                }
+                catch ( ParseException e )
+                {
+                    addActionError( "Error parsing date(s)." );
+                    return ERROR;
+                }
+
+                if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
+                {
+                    addFieldError( "startDate", "Start Date must be earlier than the End Date" );
+                    return INPUT;
+                }
+
+                input = new StringBuilder(
+                    "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,"
+                        + "Jars,Wars\n" );
+
+                // multiple repos
+                for ( String repo : selectedRepositories )
+                {
+                    List<RepositoryStatistics> stats = null;
+                    try
+                    {
+                        stats =
+                            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo, startDateInDF,
+                                                                              endDateInDF );
+                    }
+                    catch ( MetadataRepositoryException e )
+                    {
+                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
+                    }
+                    if ( stats == null || stats.isEmpty() )
+                    {
+                        log.info( "No statistics available for repository '" + repo + "'." );
+                        // TODO set repo's stats to 0
+                        continue;
+                    }
+
+                    // only the first one
+                    RepositoryStatistics repositoryStats = stats.get( 0 );
+                    repositoryStatistics.add( repositoryStats );
+
+                    input.append( repo ).append( "," );
+                    input.append( repositoryStats.getTotalFileCount() ).append( "," );
+                    input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
+                    input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
+                    input.append( repositoryStats.getTotalGroupCount() ).append( "," );
+                    input.append( repositoryStats.getTotalProjectCount() ).append( "," );
+                    input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
+                    input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
+                    input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
+                    input.append( repositoryStats.getTotalCountForType( "war" ) );
+                    input.append( "\n" );
+                }
+            }
+            else if ( selectedRepositories.size() == 1 )
+            {
+                repositoryId = selectedRepositories.get( 0 );
+                try
+                {
+                    startDateInDF = getStartDateInDateFormat();
+                    endDateInDF = getEndDateInDateFormat();
+
+                    if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
+                    {
+                        addFieldError( "startDate", "Start Date must be earlier than the End Date" );
+                        return INPUT;
+                    }
+
+                    List<RepositoryStatistics> stats = null;
+                    try
+                    {
+                        stats = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repositoryId,
+                                                                                  startDateInDF, endDateInDF );
+                    }
+                    catch ( MetadataRepositoryException e )
+                    {
+                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
+                    }
+                    if ( stats == null || stats.isEmpty() )
+                    {
+                        addActionError(
+                            "No statistics available for repository. Repository might not have been scanned." );
+                        return ERROR;
+                    }
+
+                    input = new StringBuilder(
+                        "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,"
+                            + "Archetypes,Jars,Wars\n" );
+
+                    for ( RepositoryStatistics repositoryStats : stats )
+                    {
+                        input.append( repositoryStats.getScanStartTime() ).append( "," );
+                        input.append( repositoryStats.getTotalFileCount() ).append( "," );
+                        input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
+                        input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
+                        input.append( repositoryStats.getTotalGroupCount() ).append( "," );
+                        input.append( repositoryStats.getTotalProjectCount() ).append( "," );
+                        input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
+                        input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
+                        input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
+                        input.append( repositoryStats.getTotalCountForType( "war" ) );
+                        input.append( "\n" );
+                    }
+
+                    repositoryStatistics = stats;
+                }
+                catch ( ParseException pe )
+                {
+                    addActionError( pe.getMessage() );
+                    return ERROR;
+                }
+            }
+            else
+            {
+                addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
+                return INPUT;
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        if ( repositoryStatistics.isEmpty() )
+        {
+            return BLANK;
+        }
+
+        // write output stream depending on single or comparison report
+        StringReader reader = new StringReader( input.toString() );
+
+        try
+        {
+            inputStream = new ByteArrayInputStream( IOUtils.toByteArray( reader ) );
+        }
+        catch ( IOException i )
+        {
+            addActionError( "Error occurred while generating CSV file." );
+            return ERROR;
+        }
+
+        return SEND_FILE;
+    }
+
+    // hack for parsing the struts list passed as param in <s:url ../>
+
+    private List<String> parseSelectedRepositories()
+    {
+        List<String> parsedSelectedRepos = new ArrayList<String>();
+
+        for ( String repo : selectedRepositories )
+        {
+            String[] tokens = StringUtils.split( repo, ',' );
+            if ( tokens.length > 1 )
+            {
+                for ( String token : tokens )
+                {
+                    parsedSelectedRepos.add( StringUtils.remove( StringUtils.remove( token, '[' ), ']' ).trim() );
+                }
+            }
+            else
+            {
+                parsedSelectedRepos.add( StringUtils.remove( StringUtils.remove( repo, '[' ), ']' ).trim() );
+            }
+        }
+        return parsedSelectedRepos;
+    }
+
+    private Date getStartDateInDateFormat()
+        throws ParseException
+    {
+        Date startDateInDF;
+        if ( startDate == null || "".equals( startDate ) )
+        {
+            startDateInDF = null;
+        }
+        else
+        {
+            startDateInDF = DateUtils.parseDate( startDate, datePatterns );
+        }
+        return startDateInDF;
+    }
+
+    private Date getEndDateInDateFormat()
+        throws ParseException
+    {
+        Date endDateInDF;
+        if ( endDate == null || "".equals( endDate ) )
+        {
+            endDateInDF = null;
+        }
+        else
+        {
+            endDateInDF = DateUtils.parseDate( endDate, datePatterns );
+
+            // add a day, since we don't inclue time and want the date to be inclusive
+            Calendar cal = Calendar.getInstance();
+            cal.setTime( endDateInDF );
+            cal.add( Calendar.DAY_OF_MONTH, 1 );
+            endDateInDF = cal.getTime();
+        }
+
+        return endDateInDF;
+    }
+
+    public String execute()
+        throws Exception
+    {
+        if ( repositoryId == null )
+        {
+            addFieldError( "repositoryId", "You must provide a repository id." );
+            return INPUT;
+        }
+
+        if ( rowCount < 10 )
+        {
+            addFieldError( "rowCount", "Row count must be larger than 10." );
+            return INPUT;
+        }
+
+        List<String> observableRepos = getObservableRepos();
+        Collection<String> repoIds;
+        if ( StringUtils.isEmpty( repositoryId ) || ALL_REPOSITORIES.equals( repositoryId ) )
+        {
+            repoIds = observableRepos;
+        }
+        else if ( observableRepos.contains( repositoryId ) )
+        {
+            repoIds = Collections.singletonList( repositoryId );
+        }
+        else
+        {
+            repoIds = Collections.emptyList();
+        }
+
+        List<RepositoryProblemFacet> problemArtifacts = new ArrayList<RepositoryProblemFacet>();
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+            for ( String repoId : repoIds )
+            {
+                // TODO: improve performance by navigating into a group subtree. Currently group is property, not part of name of item
+                for ( String name : metadataRepository.getMetadataFacets( repoId, RepositoryProblemFacet.FACET_ID ) )
+                {
+                    RepositoryProblemFacet metadataFacet =
+                        (RepositoryProblemFacet) metadataRepository.getMetadataFacet( repoId,
+                                                                                      RepositoryProblemFacet.FACET_ID,
+                                                                                      name );
+
+                    if ( StringUtils.isEmpty( groupId ) || groupId.equals( metadataFacet.getNamespace() ) )
+                    {
+                        problemArtifacts.add( metadataFacet );
+                    }
+                }
+            }
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        // TODO: getting range only after reading is not efficient for a large number of artifacts
+        int lowerBound = ( page - 1 ) * rowCount;
+        int upperBound = ( page * rowCount ) + 1; // Add 1 to check if it's the last page or not.
+        if ( upperBound <= problemArtifacts.size() )
+        {
+            problemArtifacts = problemArtifacts.subList( lowerBound, upperBound );
+        }
+        else
+        {
+            problemArtifacts = problemArtifacts.subList( lowerBound, problemArtifacts.size() );
+        }
+
+        for ( RepositoryProblemFacet problem : problemArtifacts )
+        {
+            List<RepositoryProblemFacet> problemsList;
+            if ( repositoriesMap.containsKey( problem.getRepositoryId() ) )
+            {
+                problemsList = repositoriesMap.get( problem.getRepositoryId() );
+            }
+            else
+            {
+                problemsList = new ArrayList<RepositoryProblemFacet>();
+                repositoriesMap.put( problem.getRepositoryId(), problemsList );
+            }
+
+            problemsList.add( problem );
+        }
+
+        // TODO: handling should be improved
+        if ( problemArtifacts.size() <= rowCount )
+        {
+            lastPage = true;
+        }
+
+        if ( problemArtifacts.isEmpty() && page == 1 )
+        {
+            return BLANK;
+        }
+        else
+        {
+            return SUCCESS;
+        }
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_ACCESS_REPORT, Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public List<String> getRepositoryIds()
+    {
+        return repositoryIds;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public int getPage()
+    {
+        return page;
+    }
+
+    public void setPage( int page )
+    {
+        this.page = page;
+    }
+
+    public int getRowCount()
+    {
+        return rowCount;
+    }
+
+    public void setRowCount( int rowCount )
+    {
+        this.rowCount = rowCount;
+    }
+
+    public void setRepositoriesMap( Map<String, List<RepositoryProblemFacet>> repositoriesMap )
+    {
+        this.repositoriesMap = repositoriesMap;
+    }
+
+    public Map<String, List<RepositoryProblemFacet>> getRepositoriesMap()
+    {
+        return repositoriesMap;
+    }
+
+    public List<String> getSelectedRepositories()
+    {
+        return selectedRepositories;
+    }
+
+    public void setSelectedRepositories( List<String> selectedRepositories )
+    {
+        this.selectedRepositories = selectedRepositories;
+    }
+
+    public List<String> getAvailableRepositories()
+    {
+        return availableRepositories;
+    }
+
+    public void setAvailableRepositories( List<String> availableRepositories )
+    {
+        this.availableRepositories = availableRepositories;
+    }
+
+    public String getStartDate()
+    {
+        return startDate;
+    }
+
+    public void setStartDate( String startDate )
+    {
+        this.startDate = startDate;
+    }
+
+    public String getEndDate()
+    {
+        return endDate;
+    }
+
+    public void setEndDate( String endDate )
+    {
+        this.endDate = endDate;
+    }
+
+    public List<RepositoryStatistics> getRepositoryStatistics()
+    {
+        return repositoryStatistics;
+    }
+
+    public void setRepositoryStatistics( List<RepositoryStatistics> repositoryStatistics )
+    {
+        this.repositoryStatistics = repositoryStatistics;
+    }
+
+    public boolean isLastPage()
+    {
+        return lastPage;
+    }
+
+    public void setLastPage( boolean lastPage )
+    {
+        this.lastPage = lastPage;
+    }
+
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+
+    public int getNumPages()
+    {
+        return numPages;
+    }
+
+    public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
+    {
+        this.repositoryStatisticsManager = repositoryStatisticsManager;
+    }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/reports/ViewAuditLogReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/reports/ViewAuditLogReportAction.java
new file mode 100644 (file)
index 0000000..e598a69
--- /dev/null
@@ -0,0 +1,408 @@
+package org.apache.archiva.web.action.reports;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditManager;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.archiva.security.AccessDeniedException;
+import org.apache.archiva.security.ArchivaSecurityException;
+import org.apache.archiva.security.PrincipalNotFoundException;
+import org.apache.archiva.security.UserRepositories;
+import org.apache.archiva.web.action.AbstractActionSupport;
+import org.apache.struts2.interceptor.ServletRequestAware;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Controller;
+
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ *
+ */
+@Controller( "viewAuditLogReport" )
+@Scope( "prototype" )
+public class ViewAuditLogReportAction
+    extends AbstractActionSupport
+    implements SecureAction, ServletRequestAware, Preparable
+{
+    protected HttpServletRequest request;
+
+    @Inject
+    private UserRepositories userRepositories;
+
+    @Inject
+    private AuditManager auditManager;
+
+    private String repository;
+
+    private List<String> repositories;
+
+    private String groupId;
+
+    private String artifactId;
+
+    private String startDate;
+
+    private String endDate;
+
+    private int rowCount = 30;
+
+    private int page = 1;
+
+    protected boolean isLastPage = true;
+
+    private List<AuditEvent> auditLogs;
+
+    private static final String ALL_REPOSITORIES = "all";
+
+    private String initial = "true";
+
+    private String headerName;
+
+    private static final String HEADER_LATEST_EVENTS = "Latest Events";
+
+    private static final String HEADER_RESULTS = "Results";
+
+    private String[] datePatterns =
+    new String[]{ "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
+    "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy" };
+
+
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+
+        // TODO: should require this, but for now we trust in the list of repositories
+//        bundle.setRequiresAuthentication( true );
+//        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_VIEW_AUDIT_LOG );
+
+        return bundle;
+    }
+
+    public void setServletRequest( HttpServletRequest request )
+    {
+        this.request = request;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void prepare()
+        throws Exception
+    {
+        repositories = new ArrayList<String>();
+        repositories.add( ALL_REPOSITORIES );
+        List<String> repos = getManagableRepositories();
+        repositories.addAll( repos );
+
+        auditLogs = null;
+        groupId = "";
+        artifactId = "";
+        repository = "";
+
+        if ( Boolean.parseBoolean( initial ) )
+        {
+            headerName = HEADER_LATEST_EVENTS;
+        }
+        else
+        {
+            headerName = HEADER_RESULTS;
+        }
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            auditLogs = auditManager.getMostRecentAuditEvents( repositorySession.getRepository(), repos );
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+    }
+
+    public String execute()
+        throws Exception
+    {
+        Date startDateInDF = null;
+        Date endDateInDF = null;
+        if ( !StringUtils.isEmpty( startDate ) )
+        {
+            startDateInDF = DateUtils.parseDate( startDate, datePatterns );
+        }
+
+        if ( !StringUtils.isEmpty( endDate ) )
+        {
+            endDateInDF = DateUtils.parseDate( endDate, datePatterns );
+            Calendar cal = Calendar.getInstance();
+            cal.setTime( endDateInDF );
+            cal.set( Calendar.HOUR, 23 );
+            cal.set( Calendar.MINUTE, 59 );
+            cal.set( Calendar.SECOND, 59 );
+
+            endDateInDF = cal.getTime();
+        }
+
+        Collection<String> repos = getManagableRepositories();
+        if ( !repository.equals( ALL_REPOSITORIES ) )
+        {
+            if ( repos.contains( repository ) )
+            {
+                repos = Collections.singletonList( repository );
+            }
+            else
+            {
+                repos = Collections.emptyList();
+            }
+        }
+
+        if ( StringUtils.isEmpty( groupId ) && !StringUtils.isEmpty( artifactId ) )
+        {
+            // Until we store the full artifact metadata in the audit event, we can't query by these individually
+            addActionError( "If you specify an artifact ID, you must specify a group ID" );
+            auditLogs = null;
+            return INPUT;
+        }
+
+        String resource = null;
+        if ( !StringUtils.isEmpty( groupId ) )
+        {
+            String groupIdAsPath = groupId.replace( '.', '/' );
+            if ( StringUtils.isEmpty( artifactId ) )
+            {
+                resource = groupIdAsPath;
+            }
+            else
+            {
+                resource = groupIdAsPath + "/" + artifactId;
+            }
+        }
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+        try
+        {
+            auditLogs =
+                auditManager.getAuditEventsInRange( repositorySession.getRepository(), repos, resource, startDateInDF,
+                                                    endDateInDF );
+        }
+        finally
+        {
+            repositorySession.close();
+        }
+
+        headerName = HEADER_RESULTS;
+
+        if ( auditLogs.isEmpty() )
+        {
+            addActionError( "No audit logs found." );
+            initial = "true";
+            return SUCCESS;
+        }
+        else
+        {
+            initial = "false";
+            return paginate();
+        }
+    }
+
+    private String paginate()
+    {
+        int rowCount = getRowCount();
+        int extraPage = ( auditLogs.size() % rowCount ) != 0 ? 1 : 0;
+        int totalPages = ( auditLogs.size() / rowCount ) + extraPage;
+
+        int currentPage = getPage();
+        if ( currentPage > totalPages )
+        {
+            addActionError(
+                "Error encountered while generating report :: The requested page exceeds the total number of pages." );
+            return ERROR;
+        }
+
+        if ( currentPage == totalPages )
+        {
+            isLastPage = true;
+        }
+        else
+        {
+            isLastPage = false;
+        }
+
+        int start = rowCount * ( currentPage - 1 );
+        int end = ( start + rowCount ) - 1;
+
+        if ( end >= auditLogs.size() )
+        {
+            end = auditLogs.size() - 1;
+        }
+
+        auditLogs = auditLogs.subList( start, end + 1 );
+
+        return SUCCESS;
+    }
+
+    private List<String> getManagableRepositories()
+    {
+        try
+        {
+            return userRepositories.getManagableRepositoryIds( getPrincipal() );
+        }
+        catch ( PrincipalNotFoundException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( AccessDeniedException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( ArchivaSecurityException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        return Collections.emptyList();
+    }
+
+    public String getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( String repository )
+    {
+        this.repository = repository;
+    }
+
+    public List<String> getRepositories()
+    {
+        return repositories;
+    }
+
+    public void setRepositories( List<String> repositories )
+    {
+        this.repositories = repositories;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public List<AuditEvent> getAuditLogs()
+    {
+        return auditLogs;
+    }
+
+    public int getRowCount()
+    {
+        return rowCount;
+    }
+
+    public void setRowCount( int rowCount )
+    {
+        this.rowCount = rowCount;
+    }
+
+    public String getStartDate()
+    {
+        return startDate;
+    }
+
+    public void setStartDate( String startDate )
+    {
+        this.startDate = startDate;
+    }
+
+    public String getEndDate()
+    {
+        return endDate;
+    }
+
+    public void setEndDate( String endDate )
+    {
+        this.endDate = endDate;
+    }
+
+    public int getPage()
+    {
+        return page;
+    }
+
+    public void setPage( int page )
+    {
+        this.page = page;
+    }
+
+    public boolean getIsLastPage()
+    {
+        return isLastPage;
+    }
+
+    public void setIsLastPage( boolean isLastPage )
+    {
+        this.isLastPage = isLastPage;
+    }
+
+    public String getInitial()
+    {
+        return initial;
+    }
+
+    public void setInitial( String initial )
+    {
+        this.initial = initial;
+    }
+
+    public String getHeaderName()
+    {
+        return headerName;
+    }
+
+    public void setHeaderName( String headerName )
+    {
+        this.headerName = headerName;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java
deleted file mode 100644 (file)
index 001b67b..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-package org.apache.maven.archiva.web.action;\r
-\r
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements.  See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership.  The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * "License"); you may not use this file except in compliance\r
- * with the License.  You may obtain a copy of the License at\r
- *\r
- *  http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied.  See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-import com.opensymphony.xwork2.ActionContext;\r
-import com.opensymphony.xwork2.ActionSupport;\r
-import org.apache.archiva.admin.model.AuditInformation;\r
-import org.apache.archiva.audit.AuditEvent;\r
-import org.apache.archiva.audit.AuditListener;\r
-import org.apache.archiva.audit.Auditable;\r
-import org.apache.archiva.metadata.repository.RepositorySessionFactory;\r
-import org.apache.archiva.security.ArchivaXworkUser;\r
-import org.apache.commons.lang.StringUtils;\r
-import org.apache.struts2.ServletActionContext;\r
-import org.apache.struts2.interceptor.SessionAware;\r
-import org.codehaus.plexus.redback.users.User;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.springframework.context.ApplicationContext;\r
-\r
-import javax.annotation.PostConstruct;\r
-import javax.inject.Inject;\r
-import javax.inject.Named;\r
-import javax.servlet.http.HttpServletRequest;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-/**\r
- * LogEnabled and SessionAware ActionSupport\r
- */\r
-public abstract class AbstractActionSupport\r
-    extends ActionSupport\r
-    implements SessionAware, Auditable\r
-{\r
-    protected Map<?, ?> session;\r
-\r
-    protected Logger log = LoggerFactory.getLogger( getClass() );\r
-\r
-    @Inject\r
-    private List<AuditListener> auditListeners = new ArrayList<AuditListener>();\r
-\r
-\r
-    @Inject\r
-    @Named( value = "repositorySessionFactory" )\r
-    protected RepositorySessionFactory repositorySessionFactory;\r
-\r
-    @Inject\r
-    protected ApplicationContext applicationContext;\r
-\r
-    private String principal;\r
-\r
-    @PostConstruct\r
-    public void initialize()\r
-    {\r
-        // no op\r
-    }\r
-\r
-    @SuppressWarnings( "unchecked" )\r
-    public void setSession( Map map )\r
-    {\r
-        this.session = map;\r
-    }\r
-\r
-    public void addAuditListener( AuditListener listener )\r
-    {\r
-        this.auditListeners.add( listener );\r
-    }\r
-\r
-    public void clearAuditListeners()\r
-    {\r
-        this.auditListeners.clear();\r
-    }\r
-\r
-    public void removeAuditListener( AuditListener listener )\r
-    {\r
-        this.auditListeners.remove( listener );\r
-    }\r
-\r
-    protected void triggerAuditEvent( String repositoryId, String resource, String action )\r
-    {\r
-        AuditEvent event = new AuditEvent( repositoryId, getPrincipal(), resource, action );\r
-        event.setRemoteIP( getRemoteAddr() );\r
-\r
-        for ( AuditListener listener : auditListeners )\r
-        {\r
-            listener.auditEvent( event );\r
-        }\r
-    }\r
-\r
-    protected void triggerAuditEvent( String resource, String action )\r
-    {\r
-        AuditEvent event = new AuditEvent( null, getPrincipal(), resource, action );\r
-        event.setRemoteIP( getRemoteAddr() );\r
-\r
-        for ( AuditListener listener : auditListeners )\r
-        {\r
-            listener.auditEvent( event );\r
-        }\r
-    }\r
-\r
-    protected void triggerAuditEvent( String action )\r
-    {\r
-        AuditEvent event = new AuditEvent( null, getPrincipal(), null, action );\r
-        event.setRemoteIP( getRemoteAddr() );\r
-\r
-        for ( AuditListener listener : auditListeners )\r
-        {\r
-            listener.auditEvent( event );\r
-        }\r
-    }\r
-\r
-    private String getRemoteAddr()\r
-    {\r
-        HttpServletRequest request = ServletActionContext.getRequest();\r
-        return request != null ? request.getRemoteAddr() : null;\r
-    }\r
-\r
-    @SuppressWarnings( "unchecked" )\r
-    protected String getPrincipal()\r
-    {\r
-        if ( principal != null )\r
-        {\r
-            return principal;\r
-        }\r
-        return ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );\r
-    }\r
-\r
-    void setPrincipal( String principal )\r
-    {\r
-        this.principal = principal;\r
-    }\r
-\r
-    public void setAuditListeners( List<AuditListener> auditListeners )\r
-    {\r
-        this.auditListeners = auditListeners;\r
-    }\r
-\r
-    public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )\r
-    {\r
-        this.repositorySessionFactory = repositorySessionFactory;\r
-    }\r
-\r
-    protected <T> Map<String, T> getBeansOfType( Class<T> clazz )\r
-    {\r
-        //TODO do some caching here !!!\r
-        // olamy : with plexus we get only roleHint\r
-        // as per convention we named spring bean role#hint remove role# if exists\r
-        Map<String, T> springBeans = applicationContext.getBeansOfType( clazz );\r
-\r
-        Map<String, T> beans = new HashMap<String, T>( springBeans.size() );\r
-\r
-        for ( Map.Entry<String, T> entry : springBeans.entrySet() )\r
-        {\r
-            String key = StringUtils.substringAfterLast( entry.getKey(), "#" );\r
-            beans.put( key, entry.getValue() );\r
-        }\r
-        return beans;\r
-    }\r
-\r
-\r
-    protected AuditInformation getAuditInformation()\r
-    {\r
-        AuditInformation auditInformation = new AuditInformation( new SimpleUser( getPrincipal() ), getRemoteAddr() );\r
-\r
-        return auditInformation;\r
-    }\r
-\r
-    /**\r
-     * dummy information for audit events\r
-     * @since 1.4\r
-     */\r
-    private static class SimpleUser\r
-        implements User\r
-    {\r
-\r
-        private String principal;\r
-\r
-        protected SimpleUser( String principal )\r
-        {\r
-            this.principal = principal;\r
-        }\r
-\r
-        public Object getPrincipal()\r
-        {\r
-            return this.principal;\r
-        }\r
-\r
-        public String getUsername()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setUsername( String name )\r
-        {\r
-\r
-        }\r
-\r
-        public String getFullName()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setFullName( String name )\r
-        {\r
-\r
-        }\r
-\r
-        public String getEmail()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setEmail( String address )\r
-        {\r
-\r
-        }\r
-\r
-        public String getPassword()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setPassword( String rawPassword )\r
-        {\r
-\r
-        }\r
-\r
-        public String getEncodedPassword()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setEncodedPassword( String encodedPassword )\r
-        {\r
-\r
-        }\r
-\r
-        public Date getLastPasswordChange()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setLastPasswordChange( Date passwordChangeDate )\r
-        {\r
-\r
-        }\r
-\r
-        public List<String> getPreviousEncodedPasswords()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setPreviousEncodedPasswords( List<String> encodedPasswordList )\r
-        {\r
-\r
-        }\r
-\r
-        public void addPreviousEncodedPassword( String encodedPassword )\r
-        {\r
-\r
-        }\r
-\r
-        public boolean isPermanent()\r
-        {\r
-            return false;\r
-        }\r
-\r
-        public void setPermanent( boolean permanent )\r
-        {\r
-\r
-        }\r
-\r
-        public boolean isLocked()\r
-        {\r
-            return false;\r
-        }\r
-\r
-        public void setLocked( boolean locked )\r
-        {\r
-\r
-        }\r
-\r
-        public boolean isPasswordChangeRequired()\r
-        {\r
-            return false;\r
-        }\r
-\r
-        public void setPasswordChangeRequired( boolean changeRequired )\r
-        {\r
-\r
-        }\r
-\r
-        public boolean isValidated()\r
-        {\r
-            return false;\r
-        }\r
-\r
-        public void setValidated( boolean valid )\r
-        {\r
-\r
-        }\r
-\r
-        public int getCountFailedLoginAttempts()\r
-        {\r
-            return 0;\r
-        }\r
-\r
-        public void setCountFailedLoginAttempts( int count )\r
-        {\r
-\r
-        }\r
-\r
-        public Date getAccountCreationDate()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setAccountCreationDate( Date date )\r
-        {\r
-\r
-        }\r
-\r
-        public Date getLastLoginDate()\r
-        {\r
-            return null;\r
-        }\r
-\r
-        public void setLastLoginDate( Date date )\r
-        {\r
-\r
-        }\r
-    }\r
-\r
-\r
-}\r
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractRepositoryBasedAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractRepositoryBasedAction.java
deleted file mode 100644 (file)
index 8232d6c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.security.AccessDeniedException;
-import org.apache.archiva.security.ArchivaSecurityException;
-import org.apache.archiva.security.PrincipalNotFoundException;
-import org.apache.archiva.security.UserRepositories;
-
-import javax.inject.Inject;
-import java.util.Collections;
-import java.util.List;
-
-public class AbstractRepositoryBasedAction
-    extends AbstractActionSupport
-{
-
-    @Inject
-    private UserRepositories userRepositories;
-
-    protected List<String> getObservableRepos()
-    {
-        try
-        {
-            List<String> ids = userRepositories.getObservableRepositoryIds( getPrincipal() );
-            return ids == null ? Collections.<String>emptyList() : ids;
-        }
-        catch ( PrincipalNotFoundException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        catch ( AccessDeniedException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        catch ( ArchivaSecurityException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        return Collections.emptyList();
-    }
-
-    public void setUserRepositories( UserRepositories userRepositories )
-    {
-        this.userRepositories = userRepositories;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java
deleted file mode 100644 (file)
index 678ae55..0000000
+++ /dev/null
@@ -1,395 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.module.sitemesh.Factory;
-import com.opensymphony.sitemesh.webapp.SiteMeshFilter;
-import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.repository.MetadataResolutionException;
-import org.apache.archiva.metadata.repository.MetadataResolver;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Browse the repository.
- *
- * @todo implement repository selectors (all or specific repository)
- */
-@Controller( "browseAction" )
-@Scope( "prototype" )
-public class BrowseAction
-    extends AbstractRepositoryBasedAction
-{
-    private String groupId;
-
-    private String artifactId;
-
-    private String repositoryId;
-
-    private ProjectVersionMetadata sharedModel;
-
-    private Collection<String> namespaces;
-
-    private Collection<String> projectIds;
-
-    private Collection<String> projectVersions;
-
-    public String browse()
-        throws MetadataResolutionException
-    {
-        List<String> selectedRepos = getObservableRepos();
-        if ( CollectionUtils.isEmpty( selectedRepos ) )
-        {
-            return GlobalResults.ACCESS_TO_NO_REPOS;
-        }
-
-        Set<String> namespaces = new LinkedHashSet<String>();
-
-        // TODO: this logic should be optional, particularly remembering we want to keep this code simple
-        //       it is located here to avoid the content repository implementation needing to do too much for what
-        //       is essentially presentation code
-        Set<String> namespacesToCollapse;
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataResolver metadataResolver = repositorySession.getResolver();
-            namespacesToCollapse = new LinkedHashSet<String>();
-            for ( String repoId : selectedRepos )
-            {
-                namespacesToCollapse.addAll( metadataResolver.resolveRootNamespaces( repositorySession, repoId ) );
-            }
-
-            for ( String n : namespacesToCollapse )
-            {
-                // TODO: check performance of this
-                namespaces.add( collapseNamespaces( repositorySession, metadataResolver, selectedRepos, n ) );
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        this.namespaces = getSortedList( namespaces );
-        return SUCCESS;
-    }
-
-    private String collapseNamespaces( RepositorySession repositorySession, MetadataResolver metadataResolver,
-                                       Collection<String> repoIds, String n )
-        throws MetadataResolutionException
-    {
-        Set<String> subNamespaces = new LinkedHashSet<String>();
-        for ( String repoId : repoIds )
-        {
-            subNamespaces.addAll( metadataResolver.resolveNamespaces( repositorySession, repoId, n ) );
-        }
-        if ( subNamespaces.size() != 1 )
-        {
-            log.debug( "{} is not collapsible as it has sub-namespaces: {}", n, subNamespaces );
-            return n;
-        }
-        else
-        {
-            for ( String repoId : repoIds )
-            {
-                Collection<String> projects = metadataResolver.resolveProjects( repositorySession, repoId, n );
-                if ( projects != null && !projects.isEmpty() )
-                {
-                    log.debug( "{} is not collapsible as it has projects", n );
-                    return n;
-                }
-            }
-            return collapseNamespaces( repositorySession, metadataResolver, repoIds,
-                                       n + "." + subNamespaces.iterator().next() );
-        }
-    }
-
-    public String browseGroup()
-        throws MetadataResolutionException
-    {
-        if ( StringUtils.isEmpty( groupId ) )
-        {
-            // TODO: i18n
-            addActionError( "You must specify a group ID to browse" );
-            return ERROR;
-        }
-
-        List<String> selectedRepos = getObservableRepos();
-        if ( CollectionUtils.isEmpty( selectedRepos ) )
-        {
-            return GlobalResults.ACCESS_TO_NO_REPOS;
-        }
-
-        Set<String> projects = new LinkedHashSet<String>();
-
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        Set<String> namespaces;
-        try
-        {
-            MetadataResolver metadataResolver = repositorySession.getResolver();
-
-            Set<String> namespacesToCollapse = new LinkedHashSet<String>();
-            for ( String repoId : selectedRepos )
-            {
-                namespacesToCollapse.addAll( metadataResolver.resolveNamespaces( repositorySession, repoId, groupId ) );
-
-                projects.addAll( metadataResolver.resolveProjects( repositorySession, repoId, groupId ) );
-            }
-
-            // TODO: this logic should be optional, particularly remembering we want to keep this code simple
-            //       it is located here to avoid the content repository implementation needing to do too much for what
-            //       is essentially presentation code
-            namespaces = new LinkedHashSet<String>();
-            for ( String n : namespacesToCollapse )
-            {
-                // TODO: check performance of this
-                namespaces.add(
-                    collapseNamespaces( repositorySession, metadataResolver, selectedRepos, groupId + "." + n ) );
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        this.namespaces = getSortedList( namespaces );
-        this.projectIds = getSortedList( projects );
-        return SUCCESS;
-    }
-
-    private ArrayList<String> getSortedList( Set<String> set )
-    {
-        ArrayList<String> list = new ArrayList<String>( set );
-        Collections.sort( list );
-        return list;
-    }
-
-    public String browseArtifact()
-        throws MetadataResolutionException
-    {
-        if ( StringUtils.isEmpty( groupId ) )
-        {
-            // TODO: i18n
-            addActionError( "You must specify a group ID to browse" );
-            return ERROR;
-        }
-
-        if ( StringUtils.isEmpty( artifactId ) )
-        {
-            // TODO: i18n
-            addActionError( "You must specify a artifact ID to browse" );
-            return ERROR;
-        }
-
-        List<String> selectedRepos = getObservableRepos();
-        if ( CollectionUtils.isEmpty( selectedRepos ) )
-        {
-            return GlobalResults.ACCESS_TO_NO_REPOS;
-        }
-
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataResolver metadataResolver = repositorySession.getResolver();
-
-            Set<String> versions = new LinkedHashSet<String>();
-            for ( String repoId : selectedRepos )
-            {
-                versions.addAll(
-                    metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId, artifactId ) );
-            }
-
-            // TODO: sort by known version ordering method
-            this.projectVersions = new ArrayList<String>( versions );
-
-            populateSharedModel( repositorySession, metadataResolver, selectedRepos, versions );
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        return SUCCESS;
-    }
-
-    private void populateSharedModel( RepositorySession repositorySession, MetadataResolver metadataResolver,
-                                      Collection<String> selectedRepos, Collection<String> projectVersions )
-    {
-        sharedModel = new ProjectVersionMetadata();
-
-        MavenProjectFacet mavenFacet = new MavenProjectFacet();
-        mavenFacet.setGroupId( groupId );
-        mavenFacet.setArtifactId( artifactId );
-        sharedModel.addFacet( mavenFacet );
-
-        boolean isFirstVersion = true;
-
-        for ( String version : projectVersions )
-        {
-            ProjectVersionMetadata versionMetadata = null;
-            for ( String repoId : selectedRepos )
-            {
-                if ( versionMetadata == null )
-                {
-                    try
-                    {
-                        versionMetadata =
-                            metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId, artifactId,
-                                                                    version );
-                    }
-                    catch ( MetadataResolutionException e )
-                    {
-                        log.error(
-                            "Skipping invalid metadata while compiling shared model for " + groupId + ":" + artifactId
-                                + " in repo " + repoId + ": " + e.getMessage() );
-                    }
-                }
-            }
-
-            if ( versionMetadata == null )
-            {
-                continue;
-            }
-
-            if ( isFirstVersion )
-            {
-                sharedModel = versionMetadata;
-                sharedModel.setId( null );
-            }
-            else
-            {
-                MavenProjectFacet versionMetadataMavenFacet =
-                    (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
-                if ( versionMetadataMavenFacet != null )
-                {
-                    if ( mavenFacet.getPackaging() != null && !StringUtils.equalsIgnoreCase( mavenFacet.getPackaging(),
-                                                                                             versionMetadataMavenFacet.getPackaging() ) )
-                    {
-                        mavenFacet.setPackaging( null );
-                    }
-                }
-
-                if ( sharedModel.getName() != null && !StringUtils.equalsIgnoreCase( sharedModel.getName(),
-                                                                                     versionMetadata.getName() ) )
-                {
-                    sharedModel.setName( "" );
-                }
-
-                if ( sharedModel.getDescription() != null && !StringUtils.equalsIgnoreCase(
-                    sharedModel.getDescription(), versionMetadata.getDescription() ) )
-                {
-                    sharedModel.setDescription( null );
-                }
-
-                if ( sharedModel.getIssueManagement() != null && versionMetadata.getIssueManagement() != null
-                    && !StringUtils.equalsIgnoreCase( sharedModel.getIssueManagement().getUrl(),
-                                                      versionMetadata.getIssueManagement().getUrl() ) )
-                {
-                    sharedModel.setIssueManagement( null );
-                }
-
-                if ( sharedModel.getCiManagement() != null && versionMetadata.getCiManagement() != null
-                    && !StringUtils.equalsIgnoreCase( sharedModel.getCiManagement().getUrl(),
-                                                      versionMetadata.getCiManagement().getUrl() ) )
-                {
-                    sharedModel.setCiManagement( null );
-                }
-
-                if ( sharedModel.getOrganization() != null && versionMetadata.getOrganization() != null
-                    && !StringUtils.equalsIgnoreCase( sharedModel.getOrganization().getName(),
-                                                      versionMetadata.getOrganization().getName() ) )
-                {
-                    sharedModel.setOrganization( null );
-                }
-
-                if ( sharedModel.getUrl() != null && !StringUtils.equalsIgnoreCase( sharedModel.getUrl(),
-                                                                                    versionMetadata.getUrl() ) )
-                {
-                    sharedModel.setUrl( null );
-                }
-            }
-
-            isFirstVersion = false;
-        }
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = artifactId;
-    }
-
-    public Collection<String> getNamespaces()
-    {
-        return namespaces;
-    }
-
-    public String getRepositoryId()
-    {
-
-        return repositoryId;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-
-        this.repositoryId = repositoryId;
-    }
-
-    public ProjectVersionMetadata getSharedModel()
-    {
-        return sharedModel;
-    }
-
-    public Collection<String> getProjectIds()
-    {
-        return projectIds;
-    }
-
-    public Collection<String> getProjectVersions()
-    {
-        return projectVersions;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java
deleted file mode 100644 (file)
index 56570c4..0000000
+++ /dev/null
@@ -1,470 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.Auditable;
-import org.apache.archiva.checksum.ChecksumAlgorithm;
-import org.apache.archiva.checksum.ChecksummedFile;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataRepositoryException;
-import org.apache.archiva.metadata.repository.MetadataResolutionException;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.repository.events.RepositoryListener;
-import org.apache.archiva.security.AccessDeniedException;
-import org.apache.archiva.security.ArchivaSecurityException;
-import org.apache.archiva.security.PrincipalNotFoundException;
-import org.apache.archiva.security.UserRepositories;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.common.utils.VersionComparator;
-import org.apache.archiva.common.utils.VersionUtil;
-import org.apache.archiva.model.ArchivaRepositoryMetadata;
-import org.apache.archiva.model.VersionedReference;
-import org.apache.archiva.repository.ContentNotFoundException;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.RepositoryContentFactory;
-import org.apache.archiva.repository.RepositoryException;
-import org.apache.archiva.repository.RepositoryNotFoundException;
-import org.apache.archiva.repository.metadata.MetadataTools;
-import org.apache.archiva.repository.metadata.RepositoryMetadataException;
-import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
-import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- * Delete an artifact. Metadata will be updated if one exists, otherwise it would be created.
- */
-@Controller( "deleteArtifactAction" )
-@Scope( "prototype" )
-public class DeleteArtifactAction
-    extends AbstractActionSupport
-    implements Validateable, Preparable, Auditable
-{
-    /**
-     * The groupId of the artifact to be deleted.
-     */
-    private String groupId;
-
-    /**
-     * The artifactId of the artifact to be deleted.
-     */
-    private String artifactId;
-
-    /**
-     * The version of the artifact to be deleted.
-     */
-    private String version;
-
-    /**
-     * The repository where the artifact is to be deleted.
-     */
-    private String repositoryId;
-
-    /**
-     * List of managed repositories to delete from.
-     */
-    private List<String> managedRepos;
-
-    @Inject
-    private UserRepositories userRepositories;
-
-    @Inject
-    private RepositoryContentFactory repositoryFactory;
-
-    @Inject
-    private List<RepositoryListener> listeners;
-
-    @Inject
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
-
-    @PostConstruct
-    public void initialize()
-    {
-        super.initialize();
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = artifactId;
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public void setVersion( String version )
-    {
-        this.version = version;
-    }
-
-    public String getRepositoryId()
-    {
-        return repositoryId;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-        this.repositoryId = repositoryId;
-    }
-
-    public List<String> getManagedRepos()
-    {
-        return managedRepos;
-    }
-
-    public void setManagedRepos( List<String> managedRepos )
-    {
-        this.managedRepos = managedRepos;
-    }
-
-    public void prepare()
-    {
-        managedRepos = getManagableRepos();
-    }
-
-    public String input()
-    {
-        return INPUT;
-    }
-
-    private void reset()
-    {
-        // reset the fields so the form is clear when 
-        // the action returns to the jsp page
-        groupId = "";
-        artifactId = "";
-        version = "";
-        repositoryId = "";
-    }
-
-    public String doDelete()
-    {
-
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
-
-            TimeZone timezone = TimeZone.getTimeZone( "UTC" );
-            DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
-            fmt.setTimeZone( timezone );
-            ManagedRepository repoConfig = getManagedRepositoryAdmin().getManagedRepository( repositoryId );
-
-            VersionedReference ref = new VersionedReference();
-            ref.setArtifactId( artifactId );
-            ref.setGroupId( groupId );
-            ref.setVersion( version );
-            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
-
-            String path = repository.toMetadataPath( ref );
-            int index = path.lastIndexOf( '/' );
-            path = path.substring( 0, index );
-            File targetPath = new File( repoConfig.getLocation(), path );
-
-            if ( !targetPath.exists() )
-            {
-                throw new ContentNotFoundException( groupId + ":" + artifactId + ":" + version );
-            }
-
-            // TODO: this should be in the storage mechanism so that it is all tied together
-            // delete from file system
-            repository.deleteVersion( ref );
-
-            File metadataFile = getMetadata( targetPath.getAbsolutePath() );
-            ArchivaRepositoryMetadata metadata = getMetadata( metadataFile );
-
-            updateMetadata( metadata, metadataFile, lastUpdatedTimestamp );
-
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            Collection<ArtifactMetadata> artifacts =
-                metadataRepository.getArtifacts( repositoryId, groupId, artifactId, version );
-
-            for ( ArtifactMetadata artifact : artifacts )
-            {
-                // TODO: mismatch between artifact (snapshot) version and project (base) version here
-                if ( artifact.getVersion().equals( version ) )
-                {
-                    metadataRepository.removeArtifact( artifact.getRepositoryId(), artifact.getNamespace(),
-                                                       artifact.getProject(), artifact.getVersion(), artifact.getId() );
-
-                    // TODO: move into the metadata repository proper - need to differentiate attachment of
-                    //       repository metadata to an artifact
-                    for ( RepositoryListener listener : listeners )
-                    {
-                        listener.deleteArtifact( metadataRepository, repository.getId(), artifact.getNamespace(),
-                                                 artifact.getProject(), artifact.getVersion(), artifact.getId() );
-                    }
-
-                    triggerAuditEvent( repositoryId, path, AuditEvent.REMOVE_FILE );
-                }
-            }
-            repositorySession.save();
-        }
-        catch ( ContentNotFoundException e )
-        {
-            addActionError( "Artifact does not exist: " + e.getMessage() );
-            return ERROR;
-        }
-        catch ( RepositoryNotFoundException e )
-        {
-            addActionError( "Target repository cannot be found: " + e.getMessage() );
-            return ERROR;
-        }
-        catch ( RepositoryException e )
-        {
-            addActionError( "Repository exception: " + e.getMessage() );
-            return ERROR;
-        }
-        catch ( MetadataResolutionException e )
-        {
-            addActionError( "Repository exception: " + e.getMessage() );
-            return ERROR;
-        }
-        catch ( MetadataRepositoryException e )
-        {
-            addActionError( "Repository exception: " + e.getMessage() );
-            return ERROR;
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "RepositoryAdmin exception: " + e.getMessage() );
-            return ERROR;
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version
-            + "\' was successfully deleted from repository \'" + repositoryId + "\'";
-
-        addActionMessage( msg );
-
-        reset();
-        return SUCCESS;
-    }
-
-    private File getMetadata( String targetPath )
-    {
-        String artifactPath = targetPath.substring( 0, targetPath.lastIndexOf( File.separatorChar ) );
-
-        return new File( artifactPath, MetadataTools.MAVEN_METADATA );
-    }
-
-    private ArchivaRepositoryMetadata getMetadata( File metadataFile )
-        throws RepositoryMetadataException
-    {
-        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
-        if ( metadataFile.exists() )
-        {
-            metadata = RepositoryMetadataReader.read( metadataFile );
-        }
-        return metadata;
-    }
-
-    /**
-     * Update artifact level metadata. Creates one if metadata does not exist after artifact deletion.
-     *
-     * @param metadata
-     */
-    private void updateMetadata( ArchivaRepositoryMetadata metadata, File metadataFile, Date lastUpdatedTimestamp )
-        throws RepositoryMetadataException
-    {
-        List<String> availableVersions = new ArrayList<String>();
-        String latestVersion = "";
-
-        if ( metadataFile.exists() )
-        {
-            if ( metadata.getAvailableVersions() != null )
-            {
-                availableVersions = metadata.getAvailableVersions();
-
-                if ( availableVersions.size() > 0 )
-                {
-                    Collections.sort( availableVersions, VersionComparator.getInstance() );
-
-                    if ( availableVersions.contains( version ) )
-                    {
-                        availableVersions.remove( availableVersions.indexOf( version ) );
-                    }
-                    if ( availableVersions.size() > 0 )
-                    {
-                        latestVersion = availableVersions.get( availableVersions.size() - 1 );
-                    }
-                }
-            }
-        }
-
-        if ( metadata.getGroupId() == null )
-        {
-            metadata.setGroupId( groupId );
-        }
-        if ( metadata.getArtifactId() == null )
-        {
-            metadata.setArtifactId( artifactId );
-        }
-
-        if ( !VersionUtil.isSnapshot( version ) )
-        {
-            if ( metadata.getReleasedVersion() != null && metadata.getReleasedVersion().equals( version ) )
-            {
-                metadata.setReleasedVersion( latestVersion );
-            }
-        }
-
-        metadata.setLatestVersion( latestVersion );
-        metadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
-        metadata.setAvailableVersions( availableVersions );
-
-        RepositoryMetadataWriter.write( metadata, metadataFile );
-        ChecksummedFile checksum = new ChecksummedFile( metadataFile );
-        checksum.fixChecksums( algorithms );
-    }
-
-    public void validate()
-    {
-        try
-        {
-            if ( !userRepositories.isAuthorizedToDeleteArtifacts( getPrincipal(), repositoryId ) )
-            {
-                addActionError( "User is not authorized to delete artifacts in repository '" + repositoryId + "'." );
-            }
-
-            if ( ( version.length() > 0 ) && ( !VersionUtil.isVersion( version ) ) )
-            {
-                addActionError( "Invalid version." );
-            }
-        }
-        catch ( AccessDeniedException e )
-        {
-            addActionError( e.getMessage() );
-        }
-        catch ( ArchivaSecurityException e )
-        {
-            addActionError( e.getMessage() );
-        }
-
-        // trims all request parameter values, since the trailing/leading white-spaces are ignored during validation.
-        trimAllRequestParameterValues();
-    }
-
-    private List<String> getManagableRepos()
-    {
-        try
-        {
-            return userRepositories.getManagableRepositoryIds( getPrincipal() );
-        }
-        catch ( PrincipalNotFoundException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        catch ( AccessDeniedException e )
-        {
-            log.warn( e.getMessage(), e );
-            // TODO: pass this onto the screen.
-        }
-        catch ( ArchivaSecurityException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        return Collections.emptyList();
-    }
-
-    private void trimAllRequestParameterValues()
-    {
-        if ( StringUtils.isNotEmpty( groupId ) )
-        {
-            groupId = groupId.trim();
-        }
-
-        if ( StringUtils.isNotEmpty( artifactId ) )
-        {
-            artifactId = artifactId.trim();
-        }
-
-        if ( StringUtils.isNotEmpty( version ) )
-        {
-            version = version.trim();
-        }
-
-        if ( StringUtils.isNotEmpty( repositoryId ) )
-        {
-            repositoryId = repositoryId.trim();
-        }
-    }
-
-    public List<RepositoryListener> getListeners()
-    {
-        return listeners;
-    }
-
-    public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
-    {
-        this.repositoryFactory = repositoryFactory;
-    }
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/GlobalResults.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/GlobalResults.java
deleted file mode 100644 (file)
index ea91b24..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * GlobalResults - constants for global result definitions. 
- *
- * @version $Id$
- */
-public class GlobalResults
-{
-    public static final String ACCESS_TO_NO_REPOS = "access_to_no_repos";
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java
deleted file mode 100644 (file)
index 87e86bf..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.Auditable;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.filter.Filter;
-import org.apache.archiva.metadata.repository.filter.IncludesFilter;
-import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
-import org.apache.archiva.scheduler.repository.RepositoryTask;
-import org.apache.archiva.stagerepository.merge.Maven2RepositoryMerger;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- *
- */
-@Controller( "mergeAction" )
-@Scope( "prototype" )
-public class MergeAction
-    extends AbstractActionSupport
-    implements Validateable, Preparable, Auditable
-{
-
-    @Inject
-    @Named( value = "repositoryMerger#maven2" )
-    private Maven2RepositoryMerger repositoryMerger;
-
-    @Inject
-    protected ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    @Inject
-    @Named( value = "archivaTaskScheduler#repository" )
-    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
-
-    private ManagedRepository repository;
-
-    private String repoid;
-
-    private String sourceRepoId;
-
-    private final String action = "merge";
-
-    private final String hasConflicts = "CONFLICTS";
-
-    private List<ArtifactMetadata> conflictSourceArtifacts;
-
-    private List<ArtifactMetadata> conflictSourceArtifactsToBeDisplayed;
-
-    public String getConflicts()
-    {
-        try
-        {
-            sourceRepoId = repoid + "-stage";
-            ManagedRepository targetRepoConfig = managedRepositoryAdmin.getManagedRepository( sourceRepoId );
-
-            if ( targetRepoConfig != null )
-            {
-                return hasConflicts;
-            }
-            else
-            {
-                return ERROR;
-            }
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "RepositoryAdminException " + e.getMessage() );
-            return ERROR;
-        }
-    }
-
-    public String doMerge()
-    {
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
-
-            if ( repository.isReleases() && !repository.isSnapshots() )
-            {
-                mergeWithOutSnapshots( metadataRepository, sourceArtifacts, sourceRepoId, repoid );
-            }
-            else
-            {
-                repositoryMerger.merge( metadataRepository, sourceRepoId, repoid );
-
-                for ( ArtifactMetadata metadata : sourceArtifacts )
-                {
-                    triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
-                }
-            }
-
-            scanRepository();
-
-            addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
-
-            return SUCCESS;
-        }
-        catch ( Exception e )
-        {
-            log.error( e.getMessage(), e );
-            addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
-            return ERROR;
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-    }
-
-    public String mergeBySkippingConflicts()
-    {
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
-            sourceArtifacts.removeAll( conflictSourceArtifacts );
-
-            if ( repository.isReleases() && !repository.isSnapshots() )
-            {
-                mergeWithOutSnapshots( metadataRepository, sourceArtifacts, sourceRepoId, repoid );
-            }
-            else
-            {
-
-                Filter<ArtifactMetadata> artifactsWithOutConflicts =
-                    new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
-                repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactsWithOutConflicts );
-                for ( ArtifactMetadata metadata : sourceArtifacts )
-                {
-                    triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
-                }
-            }
-
-            scanRepository();
-
-            addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
-
-            return SUCCESS;
-        }
-        catch ( Exception e )
-        {
-            log.error( e.getMessage(), e );
-            addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
-            return ERROR;
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-    }
-
-    public String mergeWithOutConlficts()
-    {
-        sourceRepoId = repoid + "-stage";
-
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            conflictSourceArtifacts =
-                repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
-        }
-        catch ( Exception e )
-        {
-            addActionError( "Error occurred while merging the repositories." );
-            return ERROR;
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
-
-        return SUCCESS;
-    }
-
-    public ManagedRepository getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( ManagedRepository repository )
-    {
-        this.repository = repository;
-    }
-
-    public void prepare()
-        throws Exception
-    {
-        sourceRepoId = repoid + "-stage";
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            conflictSourceArtifacts =
-                repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        this.repository = managedRepositoryAdmin.getManagedRepository( repoid );
-        setConflictSourceArtifactsToBeDisplayed( conflictSourceArtifacts );
-    }
-
-    public String getSourceRepoId()
-    {
-        return sourceRepoId;
-    }
-
-    public void setSourceRepoId( String sourceRepoId )
-    {
-        this.sourceRepoId = sourceRepoId;
-    }
-
-    public String getRepoid()
-    {
-        return repoid;
-    }
-
-    public void setRepoid( String repoid )
-    {
-        this.repoid = repoid;
-    }
-
-    public List<ArtifactMetadata> getConflictSourceArtifacts()
-    {
-        return conflictSourceArtifacts;
-    }
-
-    public void setConflictSourceArtifacts( List<ArtifactMetadata> conflictSourceArtifacts )
-    {
-        this.conflictSourceArtifacts = conflictSourceArtifacts;
-    }
-
-    public List<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed()
-    {
-        return conflictSourceArtifactsToBeDisplayed;
-    }
-
-    public void setConflictSourceArtifactsToBeDisplayed( List<ArtifactMetadata> conflictSourceArtifacts )
-        throws Exception
-    {
-        this.conflictSourceArtifactsToBeDisplayed = new ArrayList<ArtifactMetadata>();
-        HashMap<String, ArtifactMetadata> map = new HashMap<String, ArtifactMetadata>();
-        for ( ArtifactMetadata metadata : conflictSourceArtifacts )
-        {
-            String metadataId =
-                metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion();
-            map.put( metadataId, metadata );
-        }
-        conflictSourceArtifactsToBeDisplayed.addAll( map.values() );
-    }
-
-    private void mergeWithOutSnapshots( MetadataRepository metadataRepository, List<ArtifactMetadata> sourceArtifacts,
-                                        String sourceRepoId, String repoid )
-        throws Exception
-    {
-        List<ArtifactMetadata> artifactsWithOutSnapshots = new ArrayList<ArtifactMetadata>();
-        for ( ArtifactMetadata metadata : sourceArtifacts )
-        {
-
-            if ( metadata.getProjectVersion().contains( "SNAPSHOT" ) )
-            {
-                artifactsWithOutSnapshots.add( metadata );
-            }
-            else
-            {
-                triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
-            }
-
-        }
-        sourceArtifacts.removeAll( artifactsWithOutSnapshots );
-
-        Filter<ArtifactMetadata> artifactListWithOutSnapShots = new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
-        repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots );
-    }
-
-    private void scanRepository()
-    {
-        RepositoryTask task = new RepositoryTask();
-        task.setRepositoryId( repoid );
-        task.setScanAll( true );
-
-        if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoid ) )
-        {
-            log.info( "Repository [" + repoid + "] task was already queued." );
-        }
-        else
-        {
-            try
-            {
-                log.info( "Your request to have repository [" + repoid + "] be indexed has been queued." );
-                repositoryTaskScheduler.queueTask( task );
-            }
-            catch ( TaskQueueException e )
-            {
-                log.warn(
-                    "Unable to queue your request to have repository [" + repoid + "] be indexed: " + e.getMessage() );
-            }
-        }
-    }
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
deleted file mode 100644 (file)
index e9089bf..0000000
+++ /dev/null
@@ -1,587 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.indexer.search.RepositorySearch;
-import org.apache.archiva.indexer.search.RepositorySearchException;
-import org.apache.archiva.indexer.search.SearchFields;
-import org.apache.archiva.indexer.search.SearchResultHit;
-import org.apache.archiva.indexer.search.SearchResultLimits;
-import org.apache.archiva.indexer.search.SearchResults;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.struts2.ServletActionContext;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-
-import javax.inject.Inject;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Search all indexed fields by the given criteria.
- */
-@Controller( "searchAction" )
-@Scope( "prototype" )
-public class SearchAction
-    extends AbstractRepositoryBasedAction
-    implements Preparable
-{
-
-    @Inject
-    protected ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    /**
-     * Query string.
-     */
-    private String q;
-
-    /**
-     * The Search Results.
-     */
-    private SearchResults results;
-
-    private static final String RESULTS = "results";
-
-    private static final String ARTIFACT = "artifact";
-
-    private List<ArtifactMetadata> databaseResults;
-
-    private int currentPage = 0;
-
-    private int totalPages;
-
-    private boolean searchResultsOnly;
-
-    private String completeQueryString;
-
-    private static final String COMPLETE_QUERY_STRING_SEPARATOR = ";";
-
-    private List<String> managedRepositoryList = new ArrayList<String>();
-
-    private String groupId;
-
-    private String artifactId;
-
-    private String version;
-
-    private String className;
-
-    private int rowCount = 30;
-
-    private String repositoryId;
-
-    private boolean fromFilterSearch;
-
-    private boolean filterSearch = false;
-
-    private boolean fromResultsPage;
-
-    @Inject
-    private RepositorySearch nexusSearch;
-
-    private Map<String, String> searchFields;
-
-    private String infoMessage;
-
-    public boolean isFromResultsPage()
-    {
-        return fromResultsPage;
-    }
-
-    public void setFromResultsPage( boolean fromResultsPage )
-    {
-        this.fromResultsPage = fromResultsPage;
-    }
-
-    public boolean isFromFilterSearch()
-    {
-        return fromFilterSearch;
-    }
-
-    public void setFromFilterSearch( boolean fromFilterSearch )
-    {
-        this.fromFilterSearch = fromFilterSearch;
-    }
-
-    public void prepare()
-    {
-        managedRepositoryList = getObservableRepos();
-
-        if ( managedRepositoryList.size() > 0 )
-        {
-            managedRepositoryList.add( "all" );
-        }
-
-        searchFields = new LinkedHashMap<String, String>();
-        searchFields.put( "groupId", "Group ID" );
-        searchFields.put( "artifactId", "Artifact ID" );
-        searchFields.put( "version", "Version" );
-        searchFields.put( "className", "Class/Package Name" );
-        searchFields.put( "rowCount", "Row Count" );
-
-        super.clearErrorsAndMessages();
-        clearSearchFields();
-    }
-
-    private void clearSearchFields()
-    {
-        repositoryId = "";
-        artifactId = "";
-        groupId = "";
-        version = "";
-        className = "";
-        rowCount = 30;
-        currentPage = 0;
-    }
-
-    // advanced search MRM-90 -- filtered search
-    public String filteredSearch()
-        throws MalformedURLException
-    {
-        if ( ( groupId == null || "".equals( groupId ) ) && ( artifactId == null || "".equals( artifactId ) )
-            && ( className == null || "".equals( className ) ) && ( version == null || "".equals( version ) ) )
-        {
-            addActionError( "Advanced Search - At least one search criteria must be provided." );
-            return INPUT;
-        }
-
-        fromFilterSearch = true;
-
-        if ( CollectionUtils.isEmpty( managedRepositoryList ) )
-        {
-            return GlobalResults.ACCESS_TO_NO_REPOS;
-        }
-
-        SearchResultLimits limits = new SearchResultLimits( currentPage );
-        limits.setPageSize( rowCount );
-        List<String> selectedRepos = new ArrayList<String>();
-
-        if ( repositoryId == null || StringUtils.isBlank( repositoryId ) || "all".equals(
-            StringUtils.stripToEmpty( repositoryId ) ) )
-        {
-            selectedRepos = getObservableRepos();
-        }
-        else
-        {
-            selectedRepos.add( repositoryId );
-        }
-
-        if ( CollectionUtils.isEmpty( selectedRepos ) )
-        {
-            return GlobalResults.ACCESS_TO_NO_REPOS;
-        }
-
-        SearchFields searchFields = new SearchFields( groupId, artifactId, version, null, className, selectedRepos );
-
-        log.debug( "filteredSearch with searchFields {}", searchFields );
-
-        // TODO: add packaging in the list of fields for advanced search (UI)?
-        try
-        {
-            results = getNexusSearch().search( getPrincipal(), searchFields, limits );
-        }
-        catch ( RepositorySearchException e )
-        {
-            addActionError( e.getMessage() );
-            return ERROR;
-        }
-
-        if ( results.isEmpty() )
-        {
-            addActionError( "No results found" );
-            return INPUT;
-        }
-
-        totalPages = results.getTotalHits() / limits.getPageSize();
-
-        if ( ( results.getTotalHits() % limits.getPageSize() ) != 0 )
-        {
-            totalPages = totalPages + 1;
-        }
-
-        for ( SearchResultHit hit : results.getHits() )
-        {
-            // fix version ?
-            //hit.setVersion( VersionUtil.getBaseVersion( version ) );
-
-        }
-
-        return SUCCESS;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public String quickSearch()
-        throws MalformedURLException
-    {
-        /* TODO: give action message if indexing is in progress.
-         * This should be based off a count of 'unprocessed' artifacts.
-         * This (yet to be written) routine could tell the user that X (unprocessed) artifacts are not yet
-         * present in the full text search.
-         */
-
-        assert q != null && q.length() != 0;
-
-        fromFilterSearch = false;
-
-        SearchResultLimits limits = new SearchResultLimits( currentPage );
-
-        List<String> selectedRepos = getObservableRepos();
-        if ( CollectionUtils.isEmpty( selectedRepos ) )
-        {
-            return GlobalResults.ACCESS_TO_NO_REPOS;
-        }
-
-        log.debug( "quickSearch with selectedRepos {} query {}", selectedRepos, q );
-
-        try
-        {
-            if ( searchResultsOnly && !completeQueryString.equals( "" ) )
-            {
-                results =
-                    getNexusSearch().search( getPrincipal(), selectedRepos, q, limits, parseCompleteQueryString() );
-            }
-            else
-            {
-                completeQueryString = "";
-                results = getNexusSearch().search( getPrincipal(), selectedRepos, q, limits, null );
-            }
-        }
-        catch ( RepositorySearchException e )
-        {
-            addActionError( e.getMessage() );
-            return ERROR;
-        }
-
-        if ( results.isEmpty() )
-        {
-            addActionError( "No results found" );
-            return INPUT;
-        }
-
-        totalPages = results.getTotalHits() / limits.getPageSize();
-
-        if ( ( results.getTotalHits() % limits.getPageSize() ) != 0 )
-        {
-            totalPages = totalPages + 1;
-        }
-
-        if ( !isEqualToPreviousSearchTerm( q ) )
-        {
-            buildCompleteQueryString( q );
-        }
-
-        return SUCCESS;
-    }
-
-    public String findArtifact()
-        throws Exception
-    {
-        // TODO: give action message if indexing is in progress
-
-        if ( StringUtils.isBlank( q ) )
-        {
-            addActionError( "Unable to search for a blank checksum" );
-            return INPUT;
-        }
-
-        databaseResults = new ArrayList<ArtifactMetadata>();
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            for ( String repoId : getObservableRepos() )
-            {
-                databaseResults.addAll( metadataRepository.getArtifactsByChecksum( repoId, q ) );
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        if ( databaseResults.isEmpty() )
-        {
-            addActionError( "No results found" );
-            return INPUT;
-        }
-
-        if ( databaseResults.size() == 1 )
-        {
-            // 1 hit? return it's information directly!
-            return ARTIFACT;
-        }
-
-        return RESULTS;
-    }
-
-    public String doInput()
-    {
-        return INPUT;
-    }
-
-    private void buildCompleteQueryString( String searchTerm )
-    {
-        if ( searchTerm.indexOf( COMPLETE_QUERY_STRING_SEPARATOR ) != -1 )
-        {
-            searchTerm = StringUtils.remove( searchTerm, COMPLETE_QUERY_STRING_SEPARATOR );
-        }
-
-        if ( completeQueryString == null || "".equals( completeQueryString ) )
-        {
-            completeQueryString = searchTerm;
-        }
-        else
-        {
-            completeQueryString = completeQueryString + COMPLETE_QUERY_STRING_SEPARATOR + searchTerm;
-        }
-    }
-
-    private List<String> parseCompleteQueryString()
-    {
-        List<String> parsedCompleteQueryString = new ArrayList<String>();
-        String[] parsed = StringUtils.split( completeQueryString, COMPLETE_QUERY_STRING_SEPARATOR );
-        CollectionUtils.addAll( parsedCompleteQueryString, parsed );
-
-        return parsedCompleteQueryString;
-    }
-
-    private boolean isEqualToPreviousSearchTerm( String searchTerm )
-    {
-        if ( !"".equals( completeQueryString ) )
-        {
-            String[] parsed = StringUtils.split( completeQueryString, COMPLETE_QUERY_STRING_SEPARATOR );
-            if ( StringUtils.equalsIgnoreCase( searchTerm, parsed[parsed.length - 1] ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    public String getQ()
-    {
-        return q;
-    }
-
-    public void setQ( String q )
-    {
-        this.q = q;
-    }
-
-    public SearchResults getResults()
-    {
-        return results;
-    }
-
-    public List<ArtifactMetadata> getDatabaseResults()
-    {
-        return databaseResults;
-    }
-
-    public void setCurrentPage( int page )
-    {
-        this.currentPage = page;
-    }
-
-    public int getCurrentPage()
-    {
-        return currentPage;
-    }
-
-    public int getTotalPages()
-    {
-        return totalPages;
-    }
-
-    public void setTotalPages( int totalPages )
-    {
-        this.totalPages = totalPages;
-    }
-
-    public boolean isSearchResultsOnly()
-    {
-        return searchResultsOnly;
-    }
-
-    public void setSearchResultsOnly( boolean searchResultsOnly )
-    {
-        this.searchResultsOnly = searchResultsOnly;
-    }
-
-    public String getCompleteQueryString()
-    {
-        return completeQueryString;
-    }
-
-    public void setCompleteQueryString( String completeQueryString )
-    {
-        this.completeQueryString = completeQueryString;
-    }
-
-    public Map<String, ManagedRepository> getManagedRepositories() throws RepositoryAdminException
-    {
-        return managedRepositoryAdmin.getManagedRepositoriesAsMap();
-    }
-
-    // wtf : does nothing ??
-    public void setManagedRepositories( Map<String, ManagedRepository> managedRepositories )
-    {
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = artifactId;
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public void setVersion( String version )
-    {
-        this.version = version;
-    }
-
-    public int getRowCount()
-    {
-        return rowCount;
-    }
-
-    public void setRowCount( int rowCount )
-    {
-        this.rowCount = rowCount;
-    }
-
-    public boolean isFilterSearch()
-    {
-        return filterSearch;
-    }
-
-    public void setFilterSearch( boolean filterSearch )
-    {
-        this.filterSearch = filterSearch;
-    }
-
-    public String getRepositoryId()
-    {
-        return repositoryId;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-        this.repositoryId = repositoryId;
-    }
-
-    public List<String> getManagedRepositoryList()
-    {
-        return managedRepositoryList;
-    }
-
-    public void setManagedRepositoryList( List<String> managedRepositoryList )
-    {
-        this.managedRepositoryList = managedRepositoryList;
-    }
-
-    public String getClassName()
-    {
-        return className;
-    }
-
-    public void setClassName( String className )
-    {
-        this.className = className;
-    }
-
-    public RepositorySearch getNexusSearch()
-    {
-        if ( nexusSearch == null )
-        {
-            WebApplicationContext wac =
-                WebApplicationContextUtils.getRequiredWebApplicationContext( ServletActionContext.getServletContext() );
-            nexusSearch = wac.getBean( "nexusSearch", RepositorySearch.class );
-        }
-        return nexusSearch;
-    }
-
-    public void setNexusSearch( RepositorySearch nexusSearch )
-    {
-        this.nexusSearch = nexusSearch;
-    }
-
-    public Map<String, String> getSearchFields()
-    {
-        return searchFields;
-    }
-
-    public void setSearchFields( Map<String, String> searchFields )
-    {
-        this.searchFields = searchFields;
-    }
-
-    public String getInfoMessage()
-    {
-        return infoMessage;
-    }
-
-    public void setInfoMessage( String infoMessage )
-    {
-        this.infoMessage = infoMessage;
-    }
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
deleted file mode 100644 (file)
index 17f7585..0000000
+++ /dev/null
@@ -1,739 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.metadata.generic.GenericMetadataFacet;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.model.Dependency;
-import org.apache.archiva.metadata.model.MailingList;
-import org.apache.archiva.metadata.model.MetadataFacet;
-import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.model.ProjectVersionReference;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataRepositoryException;
-import org.apache.archiva.metadata.repository.MetadataResolutionException;
-import org.apache.archiva.metadata.repository.MetadataResolver;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
-import org.apache.archiva.reports.RepositoryProblemFacet;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.RepositoryContentFactory;
-import org.apache.archiva.repository.RepositoryException;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import javax.inject.Inject;
-
-/**
- * Browse the repository.
- *
- * TODO change name to ShowVersionedAction to conform to terminology.
- *
- */
-@SuppressWarnings( "serial" )
-@Controller( "showArtifactAction" )
-@Scope( "prototype" )
-public class ShowArtifactAction
-    extends AbstractRepositoryBasedAction
-    implements Validateable
-{
-    /* .\ Not Exposed \._____________________________________________ */
-
-    @Inject
-    private RepositoryContentFactory repositoryFactory;
-
-    /* .\ Exposed Output Objects \.__________________________________ */
-
-    private String groupId;
-
-    private String artifactId;
-
-    private String version;
-
-    private String repositoryId;
-
-    /**
-     * The model of this versioned project.
-     */
-    private ProjectVersionMetadata model;
-
-    /**
-     * The list of artifacts that depend on this versioned project.
-     */
-    private List<ProjectVersionReference> dependees;
-
-    private List<MailingList> mailingLists;
-
-    private List<Dependency> dependencies;
-
-    private Map<String, List<ArtifactDownloadInfo>> artifacts;
-
-    private boolean dependencyTree = false;
-
-    private String deleteItem;
-
-    private Map<String, String> genericMetadata;
-
-    private String propertyName;
-
-    private String propertyValue;
-
-    /**
-     * Show the versioned project information tab. TODO: Change name to 'project' - we are showing project versions
-     * here, not specific artifact information (though that is rendered in the download box).
-     */
-    public String artifact()
-    {
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            return handleArtifact( repositorySession );
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-    }
-
-    private String handleArtifact( RepositorySession session )
-    {
-        // In the future, this should be replaced by the repository grouping mechanism, so that we are only making
-        // simple resource requests here and letting the resolver take care of it
-        ProjectVersionMetadata versionMetadata = getProjectVersionMetadata( session );
-
-        if ( versionMetadata == null )
-        {
-            addActionError( "Artifact not found" );
-            return ERROR;
-        }
-
-        if ( versionMetadata.isIncomplete() )
-        {
-            addIncompleteModelWarning( "Artifact metadata is incomplete." );
-        }
-
-        model = versionMetadata;
-
-        return SUCCESS;
-    }
-
-    private ProjectVersionMetadata getProjectVersionMetadata( RepositorySession session )
-    {
-        ProjectVersionMetadata versionMetadata = null;
-        artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();
-
-        List<String> repos = getObservableRepos();
-        
-        MetadataResolver metadataResolver = session.getResolver();
-        for ( String repoId : repos )
-        {
-            if ( versionMetadata == null )
-            {
-                // we don't want the implementation being that intelligent - so another resolver to do the
-                // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
-                try
-                {
-                    versionMetadata = metadataResolver.resolveProjectVersion( session, repoId, groupId, artifactId,
-                                                                              version );
-                    if ( versionMetadata != null )
-                    {
-                        MetadataFacet repoProbFacet;
-                        if ( (repoProbFacet = versionMetadata.getFacet( RepositoryProblemFacet.FACET_ID ) ) != null )
-                        {
-                            addIncompleteModelWarning( "Artifact metadata is incomplete: " + ( ( RepositoryProblemFacet) repoProbFacet ).getProblem() );
-                            //set metadata to complete so that no additional 'Artifact metadata is incomplete' warning is logged
-                            versionMetadata.setIncomplete( false );
-                        }
-                    }
-                    
-                }
-                catch ( MetadataResolutionException e )
-                {
-                    addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );
-                    
-                    // TODO: need a consistent way to construct this - same in ArchivaMetadataCreationConsumer
-                    versionMetadata = new ProjectVersionMetadata();
-                    versionMetadata.setId( version );
-                }
-                if ( versionMetadata != null )
-                {
-                    repositoryId = repoId;
-
-                    List<ArtifactMetadata> artifacts;
-                    try
-                    {
-                        artifacts = new ArrayList<ArtifactMetadata>( metadataResolver.resolveArtifacts( session, repoId,
-                                                                                                        groupId,
-                                                                                                        artifactId,
-                                                                                                        version ) );
-                    }
-                    catch ( MetadataResolutionException e )
-                    {
-                        addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );
-                        artifacts = Collections.emptyList();
-                    }
-                    Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
-                    {
-                        public int compare( ArtifactMetadata o1, ArtifactMetadata o2 )
-                        {
-                            // sort by version (reverse), then ID
-                            // TODO: move version sorting into repository handling (maven2 specific), and perhaps add a
-                            // way to get latest instead
-                            int result = new DefaultArtifactVersion( o2.getVersion() ).compareTo(
-                                new DefaultArtifactVersion( o1.getVersion() ) );
-                            return result != 0 ? result : o1.getId().compareTo( o2.getId() );
-                        }
-                    } );
-
-                    for ( ArtifactMetadata artifact : artifacts )
-                    {
-                        List<ArtifactDownloadInfo> l = this.artifacts.get( artifact.getVersion() );
-                        if ( l == null )
-                        {
-                            l = new ArrayList<ArtifactDownloadInfo>();
-                            this.artifacts.put( artifact.getVersion(), l );
-                        }
-                        l.add( new ArtifactDownloadInfo( artifact ) );
-                    }
-                }
-            }
-        }
-
-        return versionMetadata;
-    }
-    
-    private void addIncompleteModelWarning( String warningMessage )
-    {
-        addActionError( warningMessage );
-        //"The model may be incomplete due to a previous error in resolving information. Refer to the repository problem reports for more information." );
-    }
-
-    /**
-     * Show the artifact information tab.
-     */
-    public String dependencies()
-    {
-        String result = artifact();
-
-        this.dependencies = model.getDependencies();
-
-        return result;
-    }
-
-    /**
-     * Show the mailing lists information tab.
-     */
-    public String mailingLists()
-    {
-        String result = artifact();
-
-        this.mailingLists = model.getMailingLists();
-
-        return result;
-    }
-
-    /**
-     * Show the reports tab.
-     */
-    public String reports()
-    {
-        // TODO: hook up reports on project
-
-        return SUCCESS;
-    }
-
-    /**
-     * Show the dependees (other artifacts that depend on this project) tab.
-     */
-    public String dependees()
-        throws MetadataResolutionException
-    {
-        List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>();
-        // TODO: what if we get duplicates across repositories?
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataResolver metadataResolver = repositorySession.getResolver();
-            for ( String repoId : getObservableRepos() )
-            {
-                // TODO: what about if we want to see this irrespective of version?
-                references.addAll( metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId,
-                                                                              artifactId, version ) );
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        this.dependees = references;
-
-        // TODO: may need to note on the page that references will be incomplete if the other artifacts are not yet
-        // stored in the content repository
-        // (especially in the case of pre-population import)
-
-        return artifact();
-    }
-
-    /**
-     * Show the dependencies of this versioned project tab.
-     */
-    public String dependencyTree()
-    {
-        // temporarily use this as we only need the model for the tag to perform, but we should be resolving the
-        // graph here instead
-
-        // TODO: may need to note on the page that tree will be incomplete if the other artifacts are not yet stored in
-        // the content repository
-        // (especially in the case of pre-population import)
-
-        // TODO: a bit ugly, should really be mapping all these results differently now
-        this.dependencyTree = true;
-
-        return artifact();
-    }
-
-    public String projectMetadata()
-    {
-        String result = artifact();
-
-        if ( model.getFacet( GenericMetadataFacet.FACET_ID ) != null )
-        {
-            genericMetadata = model.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
-        }
-
-        if ( genericMetadata == null )
-        {
-            genericMetadata = new HashMap<String, String>();
-        }
-
-        return result;
-    }
-
-    public String addMetadataProperty()
-    {
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        ProjectVersionMetadata projectMetadata;
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            projectMetadata = getProjectVersionMetadata( repositorySession );
-            if ( projectMetadata == null )
-            {
-                addActionError( "Artifact not found" );
-                return ERROR;
-            }
-
-            if ( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) == null )
-            {
-                genericMetadata = new HashMap<String, String>();
-            }
-            else
-            {
-                genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
-            }
-
-            if ( propertyName == null || "".equals( propertyName.trim() ) || propertyValue == null || "".equals(
-                propertyValue.trim() ) )
-            {
-                model = projectMetadata;
-                addActionError( "Property Name and Property Value are required." );
-                return INPUT;
-            }
-
-            genericMetadata.put( propertyName, propertyValue );
-
-            try
-            {
-                updateProjectMetadata( projectMetadata, metadataRepository );
-                repositorySession.save();
-            }
-            catch ( MetadataRepositoryException e )
-            {
-                log.warn( "Unable to persist modified project metadata after adding entry: " + e.getMessage(), e );
-                addActionError(
-                    "Unable to add metadata item to underlying content storage - consult application logs." );
-                return ERROR;
-            }
-
-            // TODO: why re-retrieve?
-            projectMetadata = getProjectVersionMetadata( repositorySession );
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
-
-        model = projectMetadata;
-
-        propertyName = "";
-        propertyValue = "";
-
-        return SUCCESS;
-    }
-
-    public String deleteMetadataEntry()
-    {
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            ProjectVersionMetadata projectMetadata = getProjectVersionMetadata( repositorySession );
-
-            if ( projectMetadata == null )
-            {
-                addActionError( "Artifact not found" );
-                return ERROR;
-            }
-
-            if ( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) != null )
-            {
-                genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
-
-                if ( !StringUtils.isEmpty( deleteItem ) )
-                {
-                    genericMetadata.remove( deleteItem );
-
-                    try
-                    {
-                        updateProjectMetadata( projectMetadata, metadataRepository );
-                        repositorySession.save();
-                    }
-                    catch ( MetadataRepositoryException e )
-                    {
-                        log.warn( "Unable to persist modified project metadata after removing entry: " + e.getMessage(),
-                                  e );
-                        addActionError(
-                            "Unable to remove metadata item to underlying content storage - consult application logs." );
-                        return ERROR;
-                    }
-
-                    // TODO: why re-retrieve?
-                    projectMetadata = getProjectVersionMetadata( repositorySession );
-
-                    genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
-
-                    model = projectMetadata;
-
-                    addActionMessage( "Property successfully deleted." );
-                }
-
-                deleteItem = "";
-            }
-            else
-            {
-                addActionError( "No generic metadata facet for this artifact." );
-                return ERROR;
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        return SUCCESS;
-    }
-
-    private void updateProjectMetadata( ProjectVersionMetadata projectMetadata, MetadataRepository metadataRepository )
-        throws MetadataRepositoryException
-    {
-        GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
-        genericMetadataFacet.fromProperties( genericMetadata );
-
-        projectMetadata.addFacet( genericMetadataFacet );
-
-        metadataRepository.updateProjectVersion( repositoryId, groupId, artifactId, projectMetadata );
-    }
-
-    @Override
-    public void validate()
-    {
-        if ( StringUtils.isBlank( groupId ) )
-        {
-            addActionError( "You must specify a group ID to browse" );
-        }
-
-        if ( StringUtils.isBlank( artifactId ) )
-        {
-            addActionError( "You must specify a artifact ID to browse" );
-        }
-
-        if ( StringUtils.isBlank( version ) )
-        {
-            addActionError( "You must specify a version to browse" );
-        }
-    }
-
-    public ProjectVersionMetadata getModel()
-    {
-        return model;
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = artifactId;
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public void setVersion( String version )
-    {
-        this.version = version;
-    }
-
-    public List<MailingList> getMailingLists()
-    {
-        return mailingLists;
-    }
-
-    public List<Dependency> getDependencies()
-    {
-        return dependencies;
-    }
-
-    public List<ProjectVersionReference> getDependees()
-    {
-        return dependees;
-    }
-
-    public String getRepositoryId()
-    {
-        return repositoryId;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-        this.repositoryId = repositoryId;
-    }
-
-    public Map<String, List<ArtifactDownloadInfo>> getArtifacts()
-    {
-        return artifacts;
-    }
-
-    public Collection<String> getSnapshotVersions()
-    {
-        return artifacts.keySet();
-    }
-
-    public boolean isDependencyTree()
-    {
-        return dependencyTree;
-    }
-
-    public void setDeleteItem( String deleteItem )
-    {
-        this.deleteItem = deleteItem;
-    }
-
-    public Map<String, String> getGenericMetadata()
-    {
-        return genericMetadata;
-    }
-
-    public void setGenericMetadata( Map<String, String> genericMetadata )
-    {
-        this.genericMetadata = genericMetadata;
-    }
-
-    public String getPropertyName()
-    {
-        return propertyName;
-    }
-
-    public void setPropertyName( String propertyName )
-    {
-        this.propertyName = propertyName;
-    }
-
-    public String getPropertyValue()
-    {
-        return propertyValue;
-    }
-
-    public void setPropertyValue( String propertyValue )
-    {
-        this.propertyValue = propertyValue;
-    }
-
-    public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
-    {
-        this.repositoryFactory = repositoryFactory;
-    }
-
-    // TODO: move this into the artifact metadata itself via facets where necessary
-
-    public class ArtifactDownloadInfo
-    {
-        private String type;
-
-        private String namespace;
-
-        private String project;
-
-        private String size;
-
-        private String id;
-
-        private String repositoryId;
-
-        private String version;
-
-        private String path;
-
-        public ArtifactDownloadInfo( ArtifactMetadata artifact )
-        {
-            repositoryId = artifact.getRepositoryId();
-
-            // TODO: use metadata resolver capability instead - maybe the storage path could be stored in the metadata
-            // though keep in mind the request may not necessarily need to reflect the storage
-            ManagedRepositoryContent repo;
-            try
-            {
-                repo = repositoryFactory.getManagedRepositoryContent( repositoryId );
-            }
-            catch ( RepositoryException e )
-            {
-                throw new RuntimeException( e );
-            }
-
-            ArtifactReference ref = new ArtifactReference();
-            ref.setArtifactId( artifact.getProject() );
-            ref.setGroupId( artifact.getNamespace() );
-            ref.setVersion( artifact.getVersion() );
-            path = repo.toPath( ref );
-            path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifact.getId();
-
-            // TODO: need to accommodate Maven 1 layout too. Non-maven repository formats will need to generate this
-            // facet (perhaps on the fly) if wanting to display the Maven 2 elements on the Archiva pages
-            String type = null;
-            MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID );
-            if ( facet != null )
-            {
-                type = facet.getType();
-            }
-            this.type = type;
-
-            namespace = artifact.getNamespace();
-            project = artifact.getProject();
-
-            // TODO: find a reusable formatter for this
-            double s = artifact.getSize();
-            String symbol = "b";
-            if ( s > 1024 )
-            {
-                symbol = "K";
-                s /= 1024;
-
-                if ( s > 1024 )
-                {
-                    symbol = "M";
-                    s /= 1024;
-
-                    if ( s > 1024 )
-                    {
-                        symbol = "G";
-                        s /= 1024;
-                    }
-                }
-            }
-
-            DecimalFormat df = new DecimalFormat( "#,###.##", new DecimalFormatSymbols( Locale.US) );
-            size = df.format( s ) + " " + symbol;
-            id = artifact.getId();
-            version = artifact.getVersion();
-        }
-
-        public String getNamespace()
-        {
-            return namespace;
-        }
-
-        public String getType()
-        {
-            return type;
-        }
-
-        public String getProject()
-        {
-            return project;
-        }
-
-        public String getSize()
-        {
-            return size;
-        }
-
-        public String getId()
-        {
-            return id;
-        }
-
-        public String getVersion()
-        {
-            return version;
-        }
-
-        public String getRepositoryId()
-        {
-            return repositoryId;
-        }
-
-        public String getPath()
-        {
-            return path;
-        }
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
deleted file mode 100644 (file)
index a4b8d06..0000000
+++ /dev/null
@@ -1,713 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.admin.ArchivaAdministration;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.Auditable;
-import org.apache.archiva.checksum.ChecksumAlgorithm;
-import org.apache.archiva.checksum.ChecksummedFile;
-import org.apache.archiva.scheduler.ArchivaTaskScheduler;
-import org.apache.archiva.scheduler.repository.RepositoryTask;
-import org.apache.archiva.security.AccessDeniedException;
-import org.apache.archiva.security.ArchivaSecurityException;
-import org.apache.archiva.security.PrincipalNotFoundException;
-import org.apache.archiva.security.UserRepositories;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.common.utils.VersionComparator;
-import org.apache.archiva.common.utils.VersionUtil;
-import org.apache.archiva.model.ArchivaRepositoryMetadata;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.model.SnapshotVersion;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.RepositoryContentFactory;
-import org.apache.archiva.repository.RepositoryException;
-import org.apache.archiva.repository.RepositoryNotFoundException;
-import org.apache.archiva.repository.metadata.MetadataTools;
-import org.apache.archiva.repository.metadata.RepositoryMetadataException;
-import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
-import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.util.IOUtil;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- * Upload an artifact using Jakarta file upload in webwork. If set by the user a pom will also be generated. Metadata
- * will also be updated if one exists, otherwise it would be created.
- */
-@SuppressWarnings( "serial" )
-@Controller( "uploadAction" )
-@Scope( "prototype" )
-public class UploadAction
-    extends AbstractActionSupport
-    implements Validateable, Preparable, Auditable
-{
-    /**
-     * The groupId of the artifact to be deployed.
-     */
-    private String groupId;
-
-    /**
-     * The artifactId of the artifact to be deployed.
-     */
-    private String artifactId;
-
-    /**
-     * The version of the artifact to be deployed.
-     */
-    private String version;
-
-    /**
-     * The packaging of the artifact to be deployed.
-     */
-    private String packaging;
-
-    /**
-     * The classifier of the artifact to be deployed.
-     */
-    private String classifier;
-
-    /**
-     * The temporary file representing the artifact to be deployed.
-     */
-    private File artifactFile;
-
-    /**
-     * The temporary file representing the pom to be deployed alongside the artifact.
-     */
-    private File pomFile;
-
-    /**
-     * The repository where the artifact is to be deployed.
-     */
-    private String repositoryId;
-
-    /**
-     * Flag whether to generate a pom for the artifact or not.
-     */
-    private boolean generatePom;
-
-    /**
-     * List of managed repositories to deploy to.
-     */
-    private List<String> managedRepoIdList;
-
-    @Inject
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    @Inject
-    private UserRepositories userRepositories;
-
-    @Inject
-    private ArchivaAdministration archivaAdministration;
-
-    @Inject
-    private RepositoryContentFactory repositoryFactory;
-
-    @Inject
-    @Named( value = "archivaTaskScheduler#repository" )
-    private ArchivaTaskScheduler scheduler;
-
-    private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
-
-    public void setArtifact( File file )
-    {
-        this.artifactFile = file;
-    }
-
-    public void setArtifactContentType( String contentType )
-    {
-        StringUtils.trim( contentType );
-    }
-
-    public void setArtifactFileName( String filename )
-    {
-        StringUtils.trim( filename );
-    }
-
-    public void setPom( File file )
-    {
-        this.pomFile = file;
-    }
-
-    public void setPomContentType( String contentType )
-    {
-        StringUtils.trim( contentType );
-    }
-
-    public void setPomFileName( String filename )
-    {
-        StringUtils.trim( filename );
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = StringUtils.trim( groupId );
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = StringUtils.trim( artifactId );
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public void setVersion( String version )
-    {
-        this.version = StringUtils.trim( version );
-    }
-
-    public String getPackaging()
-    {
-        return packaging;
-    }
-
-    public void setPackaging( String packaging )
-    {
-        this.packaging = StringUtils.trim( packaging );
-    }
-
-    public String getClassifier()
-    {
-        return classifier;
-    }
-
-    public void setClassifier( String classifier )
-    {
-        this.classifier = StringUtils.trim( classifier );
-    }
-
-    public String getRepositoryId()
-    {
-        return repositoryId;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-        this.repositoryId = repositoryId;
-    }
-
-    public boolean isGeneratePom()
-    {
-        return generatePom;
-    }
-
-    public void setGeneratePom( boolean generatePom )
-    {
-        this.generatePom = generatePom;
-    }
-
-    public List<String> getManagedRepoIdList()
-    {
-        return managedRepoIdList;
-    }
-
-    public void setManagedRepoIdList( List<String> managedRepoIdList )
-    {
-        this.managedRepoIdList = managedRepoIdList;
-    }
-
-    public void prepare()
-    {
-        managedRepoIdList = getManagableRepos();
-    }
-
-    public String input()
-    {
-        return INPUT;
-    }
-
-    private void reset()
-    {
-        // reset the fields so the form is clear when 
-        // the action returns to the jsp page
-        groupId = "";
-        artifactId = "";
-        version = "";
-        packaging = "";
-        classifier = "";
-        artifactFile = null;
-        pomFile = null;
-        repositoryId = "";
-        generatePom = false;
-    }
-
-    public String doUpload()
-    {
-        try
-        {
-            ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repositoryId );
-
-            ArtifactReference artifactReference = new ArtifactReference();
-            artifactReference.setArtifactId( artifactId );
-            artifactReference.setGroupId( groupId );
-            artifactReference.setVersion( version );
-            artifactReference.setClassifier( classifier );
-            artifactReference.setType( packaging );
-
-            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
-
-            String artifactPath = repository.toPath( artifactReference );
-
-            int lastIndex = artifactPath.lastIndexOf( '/' );
-
-            String path = artifactPath.substring( 0, lastIndex );
-            File targetPath = new File( repoConfig.getLocation(), path );
-
-            Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
-            int newBuildNumber = -1;
-            String timestamp = null;
-
-            File versionMetadataFile = new File( targetPath, MetadataTools.MAVEN_METADATA );
-            ArchivaRepositoryMetadata versionMetadata = getMetadata( versionMetadataFile );
-
-            if ( VersionUtil.isSnapshot( version ) )
-            {
-                TimeZone timezone = TimeZone.getTimeZone( "UTC" );
-                DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
-                fmt.setTimeZone( timezone );
-                timestamp = fmt.format( lastUpdatedTimestamp );
-                if ( versionMetadata.getSnapshotVersion() != null )
-                {
-                    newBuildNumber = versionMetadata.getSnapshotVersion().getBuildNumber() + 1;
-                }
-                else
-                {
-                    newBuildNumber = 1;
-                }
-            }
-
-            if ( !targetPath.exists() )
-            {
-                targetPath.mkdirs();
-            }
-
-            String filename = artifactPath.substring( lastIndex + 1 );
-            if ( VersionUtil.isSnapshot( version ) )
-            {
-                filename = filename.replaceAll( "SNAPSHOT", timestamp + "-" + newBuildNumber );
-            }
-
-            boolean fixChecksums =
-                !( archivaAdministration.getKnownContentConsumers().contains( "create-missing-checksums" ) );
-
-            try
-            {
-                File targetFile = new File( targetPath, filename );
-                if ( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() )
-                {
-                    addActionError(
-                        "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed." );
-                    return ERROR;
-                }
-                else
-                {
-                    copyFile( artifactFile, targetPath, filename, fixChecksums );
-                    triggerAuditEvent( repository.getId(), path + "/" + filename, AuditEvent.UPLOAD_FILE );
-                    queueRepositoryTask( repository.getId(), targetFile );
-                }
-            }
-            catch ( IOException ie )
-            {
-                addActionError( "Error encountered while uploading file: " + ie.getMessage() );
-                return ERROR;
-            }
-
-            String pomFilename = filename;
-            if ( classifier != null && !"".equals( classifier ) )
-            {
-                pomFilename = StringUtils.remove( pomFilename, "-" + classifier );
-            }
-            pomFilename = FilenameUtils.removeExtension( pomFilename ) + ".pom";
-
-            if ( generatePom )
-            {
-                try
-                {
-                    File generatedPomFile = createPom( targetPath, pomFilename );
-                    triggerAuditEvent( repoConfig.getId(), path + "/" + pomFilename, AuditEvent.UPLOAD_FILE );
-                    if ( fixChecksums )
-                    {
-                        fixChecksums( generatedPomFile );
-                    }
-                    queueRepositoryTask( repoConfig.getId(), generatedPomFile );
-                }
-                catch ( IOException ie )
-                {
-                    addActionError( "Error encountered while writing pom file: " + ie.getMessage() );
-                    return ERROR;
-                }
-            }
-
-            if ( pomFile != null && pomFile.length() > 0 )
-            {
-                try
-                {
-                    copyFile( pomFile, targetPath, pomFilename, fixChecksums );
-                    triggerAuditEvent( repoConfig.getId(), path + "/" + pomFilename, AuditEvent.UPLOAD_FILE );
-                    queueRepositoryTask( repoConfig.getId(), new File( targetPath, pomFilename ) );
-                }
-                catch ( IOException ie )
-                {
-                    addActionError( "Error encountered while uploading pom file: " + ie.getMessage() );
-                    return ERROR;
-                }
-
-            }
-
-            // explicitly update only if metadata-updater consumer is not enabled!
-            if ( !archivaAdministration.getKnownContentConsumers().contains( "metadata-updater" ) )
-            {
-                updateProjectMetadata( targetPath.getAbsolutePath(), lastUpdatedTimestamp, timestamp, newBuildNumber,
-                                       fixChecksums );
-
-                if ( VersionUtil.isSnapshot( version ) )
-                {
-                    updateVersionMetadata( versionMetadata, versionMetadataFile, lastUpdatedTimestamp, timestamp,
-                                           newBuildNumber, fixChecksums );
-                }
-            }
-
-            String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version
-                + "\' was successfully deployed to repository \'" + repositoryId + "\'";
-
-            addActionMessage( msg );
-
-            reset();
-            return SUCCESS;
-        }
-        catch ( RepositoryNotFoundException re )
-        {
-            addActionError( "Target repository cannot be found: " + re.getMessage() );
-            return ERROR;
-        }
-        catch ( RepositoryException rep )
-        {
-            addActionError( "Repository exception: " + rep.getMessage() );
-            return ERROR;
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "RepositoryAdmin exception: " + e.getMessage() );
-            return ERROR;
-        }
-    }
-
-    private void fixChecksums( File file )
-    {
-        ChecksummedFile checksum = new ChecksummedFile( file );
-        checksum.fixChecksums( algorithms );
-    }
-
-    private void copyFile( File sourceFile, File targetPath, String targetFilename, boolean fixChecksums )
-        throws IOException
-    {
-        FileOutputStream out = new FileOutputStream( new File( targetPath, targetFilename ) );
-        FileInputStream input = new FileInputStream( sourceFile );
-
-        try
-        {
-            IOUtils.copy( input, out );
-        }
-        finally
-        {
-            out.close();
-            input.close();
-        }
-
-        if ( fixChecksums )
-        {
-            fixChecksums( new File( targetPath, targetFilename ) );
-        }
-    }
-
-    private File createPom( File targetPath, String filename )
-        throws IOException
-    {
-        Model projectModel = new Model();
-        projectModel.setModelVersion( "4.0.0" );
-        projectModel.setGroupId( groupId );
-        projectModel.setArtifactId( artifactId );
-        projectModel.setVersion( version );
-        projectModel.setPackaging( packaging );
-
-        File pomFile = new File( targetPath, filename );
-        MavenXpp3Writer writer = new MavenXpp3Writer();
-        FileWriter w = new FileWriter( pomFile );
-        try
-        {
-            writer.write( w, projectModel );
-        }
-        finally
-        {
-            IOUtil.close( w );
-        }
-
-        return pomFile;
-    }
-
-    private ArchivaRepositoryMetadata getMetadata( File metadataFile )
-        throws RepositoryMetadataException
-    {
-        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
-        if ( metadataFile.exists() )
-        {
-            metadata = RepositoryMetadataReader.read( metadataFile );
-        }
-        return metadata;
-    }
-
-
-    /**
-     * Update version level metadata for snapshot artifacts. If it does not exist, create the metadata and fix checksums
-     * if necessary.
-     */
-    private void updateVersionMetadata( ArchivaRepositoryMetadata metadata, File metadataFile,
-                                        Date lastUpdatedTimestamp, String timestamp, int buildNumber,
-                                        boolean fixChecksums )
-        throws RepositoryMetadataException
-    {
-        if ( !metadataFile.exists() )
-        {
-            metadata.setGroupId( groupId );
-            metadata.setArtifactId( artifactId );
-            metadata.setVersion( version );
-        }
-
-        if ( metadata.getSnapshotVersion() == null )
-        {
-            metadata.setSnapshotVersion( new SnapshotVersion() );
-        }
-
-        metadata.getSnapshotVersion().setBuildNumber( buildNumber );
-        metadata.getSnapshotVersion().setTimestamp( timestamp );
-        metadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
-
-        RepositoryMetadataWriter.write( metadata, metadataFile );
-
-        if ( fixChecksums )
-        {
-            fixChecksums( metadataFile );
-        }
-    }
-
-    /**
-     * Update artifact level metadata. If it does not exist, create the metadata and fix checksums if necessary.
-     */
-    private void updateProjectMetadata( String targetPath, Date lastUpdatedTimestamp, String timestamp, int buildNumber,
-                                        boolean fixChecksums )
-        throws RepositoryMetadataException
-    {
-        List<String> availableVersions = new ArrayList<String>();
-        String latestVersion = version;
-
-        File projectDir = new File( targetPath ).getParentFile();
-        File projectMetadataFile = new File( projectDir, MetadataTools.MAVEN_METADATA );
-
-        ArchivaRepositoryMetadata projectMetadata = getMetadata( projectMetadataFile );
-
-        if ( projectMetadataFile.exists() )
-        {
-            availableVersions = projectMetadata.getAvailableVersions();
-
-            Collections.sort( availableVersions, VersionComparator.getInstance() );
-
-            if ( !availableVersions.contains( version ) )
-            {
-                availableVersions.add( version );
-            }
-
-            latestVersion = availableVersions.get( availableVersions.size() - 1 );
-        }
-        else
-        {
-            availableVersions.add( version );
-
-            projectMetadata.setGroupId( groupId );
-            projectMetadata.setArtifactId( artifactId );
-        }
-
-        if ( projectMetadata.getGroupId() == null )
-        {
-            projectMetadata.setGroupId( groupId );
-        }
-
-        if ( projectMetadata.getArtifactId() == null )
-        {
-            projectMetadata.setArtifactId( artifactId );
-        }
-
-        projectMetadata.setLatestVersion( latestVersion );
-        projectMetadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
-        projectMetadata.setAvailableVersions( availableVersions );
-
-        if ( !VersionUtil.isSnapshot( version ) )
-        {
-            projectMetadata.setReleasedVersion( latestVersion );
-        }
-
-        RepositoryMetadataWriter.write( projectMetadata, projectMetadataFile );
-
-        if ( fixChecksums )
-        {
-            fixChecksums( projectMetadataFile );
-        }
-    }
-
-    public void validate()
-    {
-        try
-        {
-            // is this enough check for the repository permission?
-            if ( !userRepositories.isAuthorizedToUploadArtifacts( getPrincipal(), repositoryId ) )
-            {
-                addActionError( "User is not authorized to upload in repository " + repositoryId );
-            }
-
-            if ( artifactFile == null || artifactFile.length() == 0 )
-            {
-                addActionError( "Please add a file to upload." );
-            }
-
-            if ( version == null || !VersionUtil.isVersion( version ) )
-            {
-                addActionError( "Invalid version." );
-            }
-        }
-        catch ( PrincipalNotFoundException pe )
-        {
-            addActionError( pe.getMessage() );
-        }
-        catch ( ArchivaSecurityException ae )
-        {
-            addActionError( ae.getMessage() );
-        }
-    }
-
-    private List<String> getManagableRepos()
-    {
-        try
-        {
-            return userRepositories.getManagableRepositoryIds( getPrincipal() );
-        }
-        catch ( PrincipalNotFoundException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        catch ( AccessDeniedException e )
-        {
-            log.warn( e.getMessage(), e );
-            // TODO: pass this onto the screen.
-        }
-        catch ( ArchivaSecurityException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        return Collections.emptyList();
-    }
-
-    private void queueRepositoryTask( String repositoryId, File localFile )
-    {
-        RepositoryTask task = new RepositoryTask();
-        task.setRepositoryId( repositoryId );
-        task.setResourceFile( localFile );
-        task.setUpdateRelatedArtifacts( true );
-        task.setScanAll( true );
-
-        try
-        {
-            scheduler.queueTask( task );
-        }
-        catch ( TaskQueueException e )
-        {
-            log.error( "Unable to queue repository task to execute consumers on resource file ['" + localFile.getName()
-                           + "']." );
-        }
-    }
-
-    public void setScheduler( ArchivaTaskScheduler scheduler )
-    {
-        this.scheduler = scheduler;
-    }
-
-    public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
-    {
-        this.repositoryFactory = repositoryFactory;
-    }
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-
-    public ArchivaAdministration getArchivaAdministration()
-    {
-        return archivaAdministration;
-    }
-
-    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
-    {
-        this.archivaAdministration = archivaAdministration;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java
deleted file mode 100644 (file)
index 24430dc..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
-import org.apache.archiva.scheduler.repository.RepositoryTask;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-/**
- * Configures the application.
- */
-@Controller( "schedulerAction" )
-@Scope( "prototype" )
-public class SchedulerAction
-    extends AbstractActionSupport
-    implements SecureAction
-{
-
-    @Inject
-    @Named( value = "archivaTaskScheduler#repository" )
-    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
-
-    private String repoid;
-
-    private boolean scanAll;
-
-    public String scanRepository()
-    {
-        if ( StringUtils.isBlank( repoid ) )
-        {
-            addActionError( "Cannot run indexer on blank repository id." );
-            return SUCCESS;
-        }
-
-        RepositoryTask task = new RepositoryTask();
-        task.setRepositoryId( repoid );
-        task.setScanAll( scanAll );
-
-        if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoid ) )
-        {
-            addActionError( "Repository [" + repoid + "] task was already queued." );
-        }
-        else
-        {
-            try
-            {
-                addActionMessage( "Your request to have repository [" + repoid + "] be indexed has been queued." );
-                repositoryTaskScheduler.queueTask( task );
-            }
-            catch ( TaskQueueException e )
-            {
-                addActionError(
-                    "Unable to queue your request to have repository [" + repoid + "] be indexed: " + e.getMessage() );
-            }
-        }
-
-        // Return to the repositories screen.
-        return SUCCESS;
-    }
-
-    @Override
-    public void addActionMessage( String aMessage )
-    {
-        super.addActionMessage( aMessage );
-        log.info( "[ActionMessage] " + aMessage );
-    }
-
-    @Override
-    public void addActionError( String anErrorMessage )
-    {
-        super.addActionError( anErrorMessage );
-        log.warn( "[ActionError] " + anErrorMessage );
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_RUN_INDEXER, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-    public String getRepoid()
-    {
-        return repoid;
-    }
-
-    public void setRepoid( String repoid )
-    {
-        this.repoid = repoid;
-    }
-
-    public boolean getScanAll()
-    {
-        return scanAll;
-    }
-
-    public void setScanAll( boolean scanAll )
-    {
-        this.scanAll = scanAll;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java
deleted file mode 100644 (file)
index 80b46b4..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.apache.maven.archiva.web.action.admin;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.repository.scanner.RepositoryScanner;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.codehaus.plexus.cache.Cache;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.plexus.taskqueue.TaskQueue;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import java.util.Map;
-
-/**
- * Shows system status information for the administrator.
- *
- * @version $Id$
- */
-@Controller( "systemStatus" )
-@Scope( "prototype" )
-public class SystemStatusAction
-    extends AbstractActionSupport
-    implements SecureAction
-{
-
-    private Map<String, TaskQueue> queues;
-
-    private Map<String, Cache> caches;
-
-    @Inject
-    private RepositoryScanner scanner;
-
-    private String memoryStatus;
-
-    private String cacheKey;
-
-    @PostConstruct
-    public void initialize()
-    {
-        super.initialize();
-        queues = getBeansOfType( TaskQueue.class );
-        caches = getBeansOfType( Cache.class );
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-    public String execute()
-    {
-        Runtime runtime = Runtime.getRuntime();
-        runtime.gc();
-        long total = runtime.totalMemory();
-        long used = total - runtime.freeMemory();
-        long max = runtime.maxMemory();
-        memoryStatus = formatMemory( used ) + "/" + formatMemory( total ) + " (Max: " + formatMemory( max ) + ")";
-
-        return SUCCESS;
-    }
-    
-    public String flush()
-    {
-        if( !StringUtils.isEmpty( cacheKey ) )
-        {
-            Cache cache = caches.get( cacheKey );
-            cache.clear();
-        }
-
-        return SUCCESS;
-    }
-
-    private static String formatMemory( long l )
-    {
-        return l / ( 1024 * 1024 ) + "M";
-    }
-
-    public String getMemoryStatus()
-    {
-        return memoryStatus;
-    }
-
-    public RepositoryScanner getScanner()
-    {
-        return scanner;
-    }
-
-    public Map<String, Cache> getCaches()
-    {
-        return caches;
-    }
-
-    public Map<String, TaskQueue> getQueues()
-    {
-        return queues;
-    }
-
-    public String getCacheKey()
-    {
-        return cacheKey;
-    }
-
-    public void setCacheKey( String cacheKey )
-    {
-        this.cacheKey = cacheKey;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java
deleted file mode 100644 (file)
index 565a344..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.appearance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.admin.ArchivaAdministration;
-import org.apache.archiva.admin.model.beans.OrganisationInformation;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-
-import javax.inject.Inject;
-
-/**
- * AbstractAppearanceAction
- *
- * @version $Id$
- */
-public abstract class AbstractAppearanceAction
-    extends AbstractActionSupport
-    implements Preparable
-{
-
-    @Inject
-    protected ArchivaAdministration archivaAdministration;
-
-    private String organisationLogo;
-
-    private String organisationUrl;
-
-    private String organisationName;
-
-    public String getOrganisationLogo()
-    {
-        return organisationLogo;
-    }
-
-    public String getOrganisationName()
-    {
-        return organisationName;
-    }
-
-    public String getOrganisationUrl()
-    {
-        return organisationUrl;
-    }
-
-    public void setOrganisationLogo( String organisationLogo )
-    {
-        this.organisationLogo = organisationLogo;
-    }
-
-    public void setOrganisationName( String organisationName )
-    {
-        this.organisationName = organisationName;
-    }
-
-    public void setOrganisationUrl( String organisationUrl )
-    {
-        this.organisationUrl = organisationUrl;
-    }
-
-    public void prepare()
-        throws Exception
-    {
-
-        OrganisationInformation orgInfo = archivaAdministration.getOrganisationInformation();
-        if ( orgInfo != null )
-        {
-            setOrganisationLogo( orgInfo.getLogoLocation() );
-            setOrganisationName( orgInfo.getName() );
-            setOrganisationUrl( orgInfo.getUrl() );
-        }
-
-    }
-
-    public ArchivaAdministration getArchivaAdministration()
-    {
-        return archivaAdministration;
-    }
-
-    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
-    {
-        this.archivaAdministration = archivaAdministration;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java
deleted file mode 100644 (file)
index 7195277..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.appearance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.OrganisationInformation;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * @version $Id: ConfigurationAction.java 480950 2006-11-30 14:58:35Z evenisse $
- */
-@Controller( "editOrganisationInfo" )
-@Scope( "prototype" )
-public class EditOrganisationInfoAction
-    extends AbstractAppearanceAction
-    implements SecureAction, Validateable
-{
-    @Override
-    public String execute()
-        throws RepositoryAdminException
-    {
-
-        OrganisationInformation orgInfo = archivaAdministration.getOrganisationInformation();
-
-        orgInfo.setLogoLocation( getOrganisationLogo() );
-        orgInfo.setName( getOrganisationName() );
-        orgInfo.setUrl( getOrganisationUrl() );
-
-        archivaAdministration.setOrganisationInformation( orgInfo );
-        return SUCCESS;
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-        return bundle;
-    }
-
-    public void validate()
-    {
-        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
-        trimAllRequestParameterValues();
-    }
-
-    private void trimAllRequestParameterValues()
-    {
-        if ( StringUtils.isNotEmpty( super.getOrganisationName() ) )
-        {
-            super.setOrganisationName( super.getOrganisationName().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( super.getOrganisationUrl() ) )
-        {
-            super.setOrganisationUrl( super.getOrganisationUrl().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( super.getOrganisationLogo() ) )
-        {
-            super.setOrganisationLogo( super.getOrganisationLogo().trim() );
-        }
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/OrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/OrganisationInfoAction.java
deleted file mode 100644 (file)
index 7921336..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.appearance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * Stores the organisation information for displaying on the page.
- */
-@Controller( "organisationInfo" )
-@Scope( "prototype" )
-public class OrganisationInfoAction
-    extends AbstractAppearanceAction
-{
-    // no op
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java
deleted file mode 100644 (file)
index e31c82a..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
-import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-
-import javax.inject.Inject;
-import java.util.List;
-import java.util.Map;
-
-/**
- * AbstractProxyConnectorAction
- *
- * @version $Id$
- */
-public abstract class AbstractProxyConnectorAction
-    extends AbstractActionSupport
-    implements SecureAction
-{
-    public static final String DIRECT_CONNECTION = "(direct connection)";
-
-    @Inject
-    private ProxyConnectorAdmin proxyConnectorAdmin;
-
-    @Inject
-    private RemoteRepositoryAdmin remoteRepositoryAdmin;
-
-    @Inject
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-
-    protected void addProxyConnector( ProxyConnector proxyConnector )
-        throws RepositoryAdminException
-    {
-        getProxyConnectorAdmin().addProxyConnector( proxyConnector, getAuditInformation() );
-    }
-
-    protected ProxyConnector findProxyConnector( String sourceId, String targetId )
-        throws RepositoryAdminException
-    {
-        if ( StringUtils.isBlank( sourceId ) )
-        {
-            return null;
-        }
-
-        if ( StringUtils.isBlank( targetId ) )
-        {
-            return null;
-        }
-
-        return getProxyConnectorAdmin().getProxyConnector( sourceId, targetId );
-    }
-
-    protected Map<String, List<ProxyConnector>> createProxyConnectorMap()
-        throws RepositoryAdminException
-    {
-        return getProxyConnectorAdmin().getProxyConnectorAsMap();
-    }
-
-    protected void removeConnector( String sourceId, String targetId )
-        throws RepositoryAdminException
-    {
-        ProxyConnector proxyConnector = findProxyConnector( sourceId, targetId );
-        if ( proxyConnector != null )
-        {
-            getProxyConnectorAdmin().deleteProxyConnector( proxyConnector, getAuditInformation() );
-        }
-    }
-
-    protected void removeProxyConnector( ProxyConnector connector )
-        throws RepositoryAdminException
-    {
-        getProxyConnectorAdmin().deleteProxyConnector( connector, getAuditInformation() );
-    }
-
-
-    public ProxyConnectorAdmin getProxyConnectorAdmin()
-    {
-        return proxyConnectorAdmin;
-    }
-
-    public void setProxyConnectorAdmin( ProxyConnectorAdmin proxyConnectorAdmin )
-    {
-        this.proxyConnectorAdmin = proxyConnectorAdmin;
-    }
-
-    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
-    {
-        return remoteRepositoryAdmin;
-    }
-
-    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
-    {
-        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
-    }
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
deleted file mode 100644 (file)
index f392b6f..0000000
+++ /dev/null
@@ -1,518 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.NetworkProxy;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.policies.DownloadErrorPolicy;
-import org.apache.archiva.policies.Policy;
-import org.apache.archiva.policies.PostDownloadPolicy;
-import org.apache.archiva.policies.PreDownloadPolicy;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * AbstractProxyConnectorFormAction - generic fields and methods for either add or edit actions related with the
- * Proxy Connector.
- *
- * @version $Id$
- */
-public abstract class AbstractProxyConnectorFormAction
-    extends AbstractProxyConnectorAction
-    implements Preparable
-{
-
-
-    private Map<String, PreDownloadPolicy> preDownloadPolicyMap;
-
-    private Map<String, PostDownloadPolicy> postDownloadPolicyMap;
-
-    private Map<String, DownloadErrorPolicy> downloadErrorPolicyMap;
-
-    private List<String> proxyIdOptions;
-
-    private List<String> managedRepoIdList;
-
-    private List<String> remoteRepoIdList;
-
-    /**
-     * The map of policies that are available to be set.
-     */
-    private Map<String, Policy> policyMap;
-
-    /**
-     * The property key to add or remove.
-     */
-    private String propertyKey;
-
-    /**
-     * The property value to add.
-     */
-    private String propertyValue;
-
-    /**
-     * The blacklist pattern to add.
-     */
-    private String blackListPattern;
-
-    /**
-     * The whitelist pattern to add.
-     */
-    private String whiteListPattern;
-
-    /**
-     * The pattern to add or remove (black or white).
-     */
-    private String pattern;
-
-    /**
-     * The model for this action.
-     */
-    protected ProxyConnector connector;
-
-    @Inject
-    private NetworkProxyAdmin networkProxyAdmin;
-
-    @PostConstruct
-    public void initialize()
-    {
-        super.initialize();
-        this.preDownloadPolicyMap = getBeansOfType( PreDownloadPolicy.class );
-        this.postDownloadPolicyMap = getBeansOfType( PostDownloadPolicy.class );
-        this.downloadErrorPolicyMap = getBeansOfType( DownloadErrorPolicy.class );
-    }
-
-    protected List<String> escapePatterns( List<String> patterns )
-    {
-        List<String> escapedPatterns = new ArrayList<String>();
-        if ( patterns != null )
-        {
-            for ( String pattern : patterns )
-            {
-                escapedPatterns.add( StringUtils.replace( pattern, "\\", "\\\\" ) );
-            }
-        }
-
-        return escapedPatterns;
-    }
-
-    protected List<String> unescapePatterns( List<String> patterns )
-    {
-        List<String> rawPatterns = new ArrayList<String>();
-        if ( patterns != null )
-        {
-            for ( String pattern : patterns )
-            {
-                rawPatterns.add( StringUtils.replace( pattern, "\\\\", "\\" ) );
-            }
-        }
-
-        return rawPatterns;
-    }
-
-    private String escapePattern( String pattern )
-    {
-        return StringUtils.replace( pattern, "\\", "\\\\" );
-    }
-
-    public String addBlackListPattern()
-    {
-        String pattern = getBlackListPattern();
-
-        if ( StringUtils.isBlank( pattern ) )
-        {
-            addActionError( "Cannot add a blank black list pattern." );
-        }
-
-        if ( !hasActionErrors() )
-        {
-            getConnector().getBlackListPatterns().add( escapePattern( pattern ) );
-            setBlackListPattern( null );
-        }
-
-        return INPUT;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public String addProperty()
-    {
-        String key = getPropertyKey();
-        String value = getPropertyValue();
-
-        if ( StringUtils.isBlank( key ) )
-        {
-            addActionError( "Unable to add property with blank key." );
-        }
-
-        if ( StringUtils.isBlank( value ) )
-        {
-            addActionError( "Unable to add property with blank value." );
-        }
-
-        if ( !hasActionErrors() )
-        {
-            getConnector().getProperties().put( key, value );
-            setPropertyKey( null );
-            setPropertyValue( null );
-        }
-
-        return INPUT;
-    }
-
-    public String addWhiteListPattern()
-    {
-        String pattern = getWhiteListPattern();
-
-        if ( StringUtils.isBlank( pattern ) )
-        {
-            addActionError( "Cannot add a blank white list pattern." );
-        }
-
-        if ( !hasActionErrors() )
-        {
-            getConnector().getWhiteListPatterns().add( escapePattern( pattern ) );
-            setWhiteListPattern( null );
-        }
-
-        return INPUT;
-    }
-
-    public String getBlackListPattern()
-    {
-        return blackListPattern;
-    }
-
-    public ProxyConnector getConnector()
-    {
-        return connector;
-    }
-
-    public List<String> getManagedRepoIdList()
-    {
-        return managedRepoIdList;
-    }
-
-    public String getPattern()
-    {
-        return pattern;
-    }
-
-    public Map<String, Policy> getPolicyMap()
-    {
-        return policyMap;
-    }
-
-    public String getPropertyKey()
-    {
-        return propertyKey;
-    }
-
-    public String getPropertyValue()
-    {
-        return propertyValue;
-    }
-
-    public List<String> getProxyIdOptions()
-    {
-        return proxyIdOptions;
-    }
-
-    public List<String> getRemoteRepoIdList()
-    {
-        return remoteRepoIdList;
-    }
-
-    public String getWhiteListPattern()
-    {
-        return whiteListPattern;
-    }
-
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        proxyIdOptions = createNetworkProxyOptions();
-        managedRepoIdList = createManagedRepoOptions();
-        remoteRepoIdList = createRemoteRepoOptions();
-        policyMap = createPolicyMap();
-    }
-
-    public String removeBlackListPattern()
-    {
-        String pattern = getPattern();
-
-        if ( StringUtils.isBlank( pattern ) )
-        {
-            addActionError( "Cannot remove a blank black list pattern." );
-        }
-
-        if ( !getConnector().getBlackListPatterns().contains( pattern )
-            && !getConnector().getBlackListPatterns().contains( StringUtils.replace( pattern, "\\", "\\\\" ) ) )
-        {
-            addActionError( "Non-existant black list pattern [" + pattern + "], no black list pattern removed." );
-        }
-
-        if ( !hasActionErrors() )
-        {
-            getConnector().getBlackListPatterns().remove( escapePattern( pattern ) );
-        }
-
-        setBlackListPattern( null );
-        setPattern( null );
-
-        return INPUT;
-    }
-
-    public String removeProperty()
-    {
-        String key = getPropertyKey();
-
-        if ( StringUtils.isBlank( key ) )
-        {
-            addActionError( "Unable to remove property with blank key." );
-        }
-
-        if ( !getConnector().getProperties().containsKey( key ) )
-        {
-            addActionError( "Non-existant property key [" + pattern + "], no property was removed." );
-        }
-
-        if ( !hasActionErrors() )
-        {
-            getConnector().getProperties().remove( key );
-        }
-
-        setPropertyKey( null );
-        setPropertyValue( null );
-
-        return INPUT;
-    }
-
-    public String removeWhiteListPattern()
-    {
-        String pattern = getPattern();
-
-        if ( StringUtils.isBlank( pattern ) )
-        {
-            addActionError( "Cannot remove a blank white list pattern." );
-        }
-
-        if ( !getConnector().getWhiteListPatterns().contains( pattern )
-            && !getConnector().getWhiteListPatterns().contains( StringUtils.replace( pattern, "\\", "\\\\" ) ) )
-        {
-            addActionError( "Non-existant white list pattern [" + pattern + "], no white list pattern removed." );
-        }
-
-        if ( !hasActionErrors() )
-        {
-            getConnector().getWhiteListPatterns().remove( escapePattern( pattern ) );
-        }
-
-        setWhiteListPattern( null );
-        setPattern( null );
-
-        return INPUT;
-    }
-
-    public void setBlackListPattern( String blackListPattern )
-    {
-        this.blackListPattern = blackListPattern;
-    }
-
-    public void setConnector( ProxyConnector connector )
-    {
-        this.connector = connector;
-    }
-
-    public void setManagedRepoIdList( List<String> managedRepoIdList )
-    {
-        this.managedRepoIdList = managedRepoIdList;
-    }
-
-    public void setPattern( String pattern )
-    {
-        this.pattern = pattern;
-    }
-
-    public void setPolicyMap( Map<String, Policy> policyMap )
-    {
-        this.policyMap = policyMap;
-    }
-
-    public void setPropertyKey( String propertyKey )
-    {
-        this.propertyKey = propertyKey;
-    }
-
-    public void setPropertyValue( String propertyValue )
-    {
-        this.propertyValue = propertyValue;
-    }
-
-    public void setProxyIdOptions( List<String> proxyIdOptions )
-    {
-        this.proxyIdOptions = proxyIdOptions;
-    }
-
-    public void setRemoteRepoIdList( List<String> remoteRepoIdList )
-    {
-        this.remoteRepoIdList = remoteRepoIdList;
-    }
-
-    public void setWhiteListPattern( String whiteListPattern )
-    {
-        this.whiteListPattern = whiteListPattern;
-    }
-
-    protected List<String> createManagedRepoOptions()
-        throws RepositoryAdminException
-    {
-        return new ArrayList<String>( getManagedRepositoryAdmin().getManagedRepositoriesAsMap().keySet() );
-    }
-
-    protected List<String> createNetworkProxyOptions()
-        throws RepositoryAdminException
-    {
-        List<String> options = new ArrayList<String>();
-
-        options.add( DIRECT_CONNECTION );
-        options.addAll( getNetworkProxiesKeys() );
-
-        return options;
-    }
-
-    private Collection<String> getNetworkProxiesKeys()
-        throws RepositoryAdminException
-    {
-        List<NetworkProxy> networkProxies = networkProxyAdmin.getNetworkProxies();
-        if ( networkProxies == null || networkProxies.isEmpty() )
-        {
-            return Collections.emptyList();
-        }
-        List<String> keys = new ArrayList<String>( networkProxies.size() );
-        for ( NetworkProxy networkProxy : networkProxies )
-        {
-            keys.add( networkProxy.getId() );
-        }
-        return keys;
-
-    }
-
-    protected Map<String, Policy> createPolicyMap()
-    {
-        Map<String, Policy> policyMap = new HashMap<String, Policy>();
-
-        policyMap.putAll( preDownloadPolicyMap );
-        policyMap.putAll( postDownloadPolicyMap );
-        policyMap.putAll( downloadErrorPolicyMap );
-
-        return policyMap;
-    }
-
-    protected List<String> createRemoteRepoOptions()
-        throws RepositoryAdminException
-    {
-        return new ArrayList<String>( getRemoteRepositoryAdmin().getRemoteRepositoriesAsMap().keySet() );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    protected void validateConnector()
-    {
-        if ( connector.getPolicies() == null )
-        {
-            addActionError( "Policies must be set." );
-        }
-        else
-        {
-            // Validate / Fix policy settings arriving from browser.
-            for ( Map.Entry<String, Policy> entry : getPolicyMap().entrySet() )
-            {
-                String policyId = entry.getKey();
-                Policy policy = entry.getValue();
-                List<String> options = policy.getOptions();
-
-                if ( !connector.getPolicies().containsKey( policyId ) )
-                {
-                    addActionError( "Policy [" + policyId + "] must be set (missing id)." );
-                    continue;
-                }
-
-                Map<String, String> properties = connector.getProperties();
-                for ( Map.Entry<String, String> entry2 : properties.entrySet() )
-                {
-                    Object value = entry2.getValue();
-                    if ( value.getClass().isArray() )
-                    {
-                        String[] arr = (String[]) value;
-                        properties.put( entry2.getKey(), arr[0] );
-                    }
-                }
-
-                // Ugly hack to compensate for ugly browsers.
-                Object o = connector.getPolicies().get( policyId );
-                String value;
-                if ( o.getClass().isArray() )
-                {
-                    String arr[] = (String[]) o;
-                    value = arr[0];
-                }
-                else
-                {
-                    value = (String) o;
-                }
-
-                connector.getPolicies().put( policyId, value );
-
-                if ( StringUtils.isBlank( value ) )
-                {
-                    addActionError( "Policy [" + policyId + "] must be set (missing value)." );
-                    continue;
-                }
-
-                if ( !options.contains( value ) )
-                {
-                    addActionError(
-                        "Value of [" + value + "] is invalid for policy [" + policyId + "], valid values: " + options );
-                    continue;
-                }
-            }
-        }
-    }
-
-    public NetworkProxyAdmin getNetworkProxyAdmin()
-    {
-        return networkProxyAdmin;
-    }
-
-    public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
-    {
-        this.networkProxyAdmin = networkProxyAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorAction.java
deleted file mode 100644 (file)
index 97d5cfc..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * AddProxyConnectorAction
- *
- * @version $Id$
- */
-@Controller( "addProxyConnectorAction" )
-@Scope( "prototype" )
-public class AddProxyConnectorAction
-    extends AbstractProxyConnectorFormAction
-{
-    @Override
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        super.prepare();
-        connector = new ProxyConnector();
-    }
-
-    @Override
-    public String input()
-    {
-        if ( connector != null )
-        {
-            // MRM-1135
-            connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
-            connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
-        }
-
-        return INPUT;
-    }
-
-    public String commit()
-        throws RepositoryAdminException
-    {
-        /* Too complex for webwork's ${Action}-validation.xml techniques.
-         * Not appropriate for use with webwork's implements Validatable, as that validates regardless of
-         * the request method, such as .addProperty() or .addWhiteList().
-         * 
-         * This validation is ultimately only useful on this one request method.
-         */
-        String sourceId = connector.getSourceRepoId();
-        String targetId = connector.getTargetRepoId();
-
-        ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
-        if ( otherConnector != null )
-        {
-            addActionError(
-                "Unable to add proxy connector, as one already exists with source repository id [" + sourceId
-                    + "] and target repository id [" + targetId + "]." );
-        }
-
-        validateConnector();
-
-        if ( hasActionErrors() )
-        {
-            return INPUT;
-        }
-
-        if ( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
-        {
-            connector.setProxyId( null );
-        }
-
-        // MRM-1135
-        connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
-        connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
-
-        addProxyConnector( connector );
-        return SUCCESS;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java
deleted file mode 100644 (file)
index 210fc0a..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * DeleteProxyConnectorAction
- *
- * @version $Id$
- */
-@Controller( "deleteProxyConnectorAction" )
-@Scope( "prototype" )
-public class DeleteProxyConnectorAction
-    extends AbstractProxyConnectorAction
-{
-    private String source;
-
-    private String target;
-
-    private ProxyConnector proxyConfig;
-
-    public String confirmDelete()
-        throws RepositoryAdminException
-    {
-        this.proxyConfig = findProxyConnector( source, target );
-
-        // Not set? Then there is nothing to delete.
-        if ( this.proxyConfig == null )
-        {
-            addActionError(
-                "Unable to delete proxy configuration, configuration with source [" + source + "], and target ["
-                    + target + "] does not exist." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String delete()
-        throws RepositoryAdminException
-    {
-        this.proxyConfig = findProxyConnector( source, target );
-
-        // Not set? Then there is nothing to delete.
-        if ( this.proxyConfig == null )
-        {
-            addActionError(
-                "Unable to delete proxy configuration, configuration with source [" + source + "], and target ["
-                    + target + "] does not exist." );
-            return ERROR;
-        }
-
-        if ( hasActionErrors() )
-        {
-            return ERROR;
-        }
-
-        getProxyConnectorAdmin().deleteProxyConnector( proxyConfig, getAuditInformation() );
-        addActionMessage( "Successfully removed proxy connector [" + source + " , " + target + " ]" );
-
-        setSource( null );
-        setTarget( null );
-
-        return SUCCESS;
-    }
-
-    public String getSource()
-    {
-        return source;
-    }
-
-    public void setSource( String id )
-    {
-        this.source = id;
-    }
-
-    public String getTarget()
-    {
-        return target;
-    }
-
-    public void setTarget( String id )
-    {
-        this.target = id;
-    }
-
-    public ProxyConnector getProxyConfig()
-    {
-        return proxyConfig;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java
deleted file mode 100644 (file)
index 14744a2..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * DisableProxyConnectorAction
- */
-@Controller( "disableProxyConnectorAction" )
-@Scope( "prototype" )
-public class DisableProxyConnectorAction
-    extends AbstractProxyConnectorAction
-{
-    private String source;
-
-    private String target;
-
-    private ProxyConnector proxyConfig;
-
-    public String confirmDisable()
-        throws RepositoryAdminException
-    {
-        this.proxyConfig = findProxyConnector( source, target );
-
-        // Not set? Then there is nothing to delete.
-        if ( this.proxyConfig == null )
-        {
-            addActionError(
-                "Unable to disable proxy configuration, configuration with source [" + source + "], and target ["
-                    + target + "] does not exist." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String disable()
-        throws RepositoryAdminException
-    {
-        this.proxyConfig = findProxyConnector( source, target );
-
-        // Not set? Then there is nothing to delete.
-        if ( this.proxyConfig == null )
-        {
-            addActionError(
-                "Unable to disable proxy configuration, configuration with source [" + source + "], and target ["
-                    + target + "] does not exist." );
-            return ERROR;
-        }
-
-        if ( hasActionErrors() )
-        {
-            return ERROR;
-        }
-
-        proxyConfig.setDisabled( true );
-
-        addActionMessage( "Successfully disabled proxy connector [" + source + " , " + target + " ]" );
-
-        setSource( null );
-        setTarget( null );
-
-        getProxyConnectorAdmin().updateProxyConnector( proxyConfig, getAuditInformation() );
-        return SUCCESS;
-    }
-
-    public String getSource()
-    {
-        return source;
-    }
-
-    public void setSource( String source )
-    {
-        this.source = source;
-    }
-
-    public String getTarget()
-    {
-        return target;
-    }
-
-    public void setTarget( String target )
-    {
-        this.target = target;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java
deleted file mode 100644 (file)
index 22a1458..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * EditProxyConnectorAction
- *
- * @version $Id$
- */
-@Controller( "editProxyConnectorAction" )
-@Scope( "prototype" )
-public class EditProxyConnectorAction
-    extends AbstractProxyConnectorFormAction
-{
-    /**
-     * The proxy connector source id to edit. (used with {@link #target})
-     */
-    private String source;
-
-    /**
-     * The proxy connector target id to edit. (used with {@link #source})
-     */
-    private String target;
-
-    @Override
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        super.prepare();
-
-        connector = findProxyConnector( source, target );
-    }
-
-    public String input()
-    {
-        if ( connector == null )
-        {
-            addActionError(
-                "Unable to edit non existant proxy connector with source [" + source + "] and target [" + target
-                    + "]" );
-            return ERROR;
-        }
-
-        if ( connector != null )
-        {
-            // MRM-1135
-            connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
-            connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
-        }
-
-        return INPUT;
-    }
-
-    public String commit()
-        throws RepositoryAdminException
-    {
-        validateConnector();
-
-        if ( hasActionErrors() )
-        {
-            return INPUT;
-        }
-
-        String sourceId = connector.getSourceRepoId();
-        String targetId = connector.getTargetRepoId();
-
-        ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
-        if ( otherConnector != null )
-        {
-            // Remove the previous connector.
-            removeProxyConnector( otherConnector );
-        }
-
-        if ( hasActionErrors() )
-        {
-            return INPUT;
-        }
-
-        addProxyConnector( connector );
-        return SUCCESS;
-    }
-
-    public String getSource()
-    {
-        return source;
-    }
-
-    public void setSource( String source )
-    {
-        this.source = source;
-    }
-
-    public String getTarget()
-    {
-        return target;
-    }
-
-    public void setTarget( String target )
-    {
-        this.target = target;
-    }
-
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java
deleted file mode 100644 (file)
index 50f50ab..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * EnableProxyConnectorAction
- */
-@Controller( "enableProxyConnectorAction" )
-@Scope( "prototype" )
-public class EnableProxyConnectorAction
-    extends AbstractProxyConnectorAction
-{
-    private String source;
-
-    private String target;
-
-    private ProxyConnector proxyConfig;
-
-    public String confirmEnable()
-        throws RepositoryAdminException
-    {
-        this.proxyConfig = findProxyConnector( source, target );
-
-        // Not set? Then there is nothing to delete.
-        if ( this.proxyConfig == null )
-        {
-            addActionError(
-                "Unable to enable proxy configuration, configuration with source [" + source + "], and target ["
-                    + target + "] does not exist." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String enable() throws RepositoryAdminException
-    {
-        this.proxyConfig = findProxyConnector( source, target );
-
-        // Not set? Then there is nothing to delete.
-        if ( this.proxyConfig == null )
-        {
-            addActionError(
-                "Unable to enabled proxy configuration, configuration with source [" + source + "], and target ["
-                    + target + "] does not exist." );
-            return ERROR;
-        }
-
-        if ( hasActionErrors() )
-        {
-            return ERROR;
-        }
-
-        proxyConfig.setDisabled( false );
-
-        getProxyConnectorAdmin().updateProxyConnector( proxyConfig, getAuditInformation() );
-
-        addActionMessage( "Successfully enabled proxy connector [" + source + " , " + target + " ]" );
-
-        setSource( null );
-        setTarget( null );
-
-        return SUCCESS;
-    }
-
-    public String getSource()
-    {
-        return source;
-    }
-
-    public void setSource( String source )
-    {
-        this.source = source;
-    }
-
-    public String getTarget()
-    {
-        return target;
-    }
-
-    public void setTarget( String target )
-    {
-        this.target = target;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java
deleted file mode 100644 (file)
index 9fa7a98..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.AbstractRepository;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * ProxyConnectorsAction
- *
- * @version $Id$
- */
-@Controller( "proxyConnectorsAction" )
-@Scope( "prototype" )
-public class ProxyConnectorsAction
-    extends AbstractProxyConnectorAction
-    implements Preparable
-{
-    private Map<String, AbstractRepository> repoMap;
-
-    /**
-     * boolean to indicate that remote repo is present. Used for Add Link
-     */
-    private boolean remoteRepoExists = false;
-
-    /**
-     * Map of Proxy Connectors.
-     */
-    private Map<String, List<ProxyConnector>> proxyConnectorMap;
-
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        repoMap = new HashMap<String, AbstractRepository>();
-        repoMap.putAll( getRemoteRepositoryAdmin().getRemoteRepositoriesAsMap() );
-        // FIXME olamy : are we sure we want Managed too ???
-        repoMap.putAll( getManagedRepositoryAdmin().getManagedRepositoriesAsMap() );
-
-        proxyConnectorMap = createProxyConnectorMap();
-
-        remoteRepoExists = getRemoteRepositoryAdmin().getRemoteRepositories().size() > 0;
-    }
-
-    public Map<String, AbstractRepository> getRepoMap()
-    {
-        return repoMap;
-    }
-
-    public Map<String, List<ProxyConnector>> getProxyConnectorMap()
-    {
-        return proxyConnectorMap;
-    }
-
-    // FIXME olamy should be is !
-    public boolean getRemoteRepoExists()
-    {
-        return remoteRepoExists;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java
deleted file mode 100644 (file)
index ac58ff1..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import java.util.List;
-
-/**
- * SortProxyConnectorsAction -
- *
- * @version $Id$
- */
-@Controller( "sortProxyConnectorsAction" )
-@Scope( "prototype" )
-public class SortProxyConnectorsAction
-    extends AbstractProxyConnectorAction
-{
-    private String source;
-
-    private String target;
-
-    public String getSource()
-    {
-        return source;
-    }
-
-    public String getTarget()
-    {
-        return target;
-    }
-
-    public void setSource( String id )
-    {
-        this.source = id;
-    }
-
-    public void setTarget( String id )
-    {
-        this.target = id;
-    }
-
-    public String sortDown()
-        throws RepositoryAdminException
-    {
-        List<ProxyConnector> connectors = createProxyConnectorMap().get( source );
-
-        int idx = findTargetConnector( connectors, target );
-
-        if ( idx >= 0 )
-        {
-            incrementConnectorOrder( connectors, idx );
-            decrementConnectorOrder( connectors, idx + 1 );
-        }
-
-        for ( ProxyConnector proxyConnector : connectors )
-        {
-            getProxyConnectorAdmin().updateProxyConnector( proxyConnector, getAuditInformation() );
-        }
-        return SUCCESS;
-    }
-
-    public String sortUp()
-        throws RepositoryAdminException
-    {
-        List<ProxyConnector> connectors = createProxyConnectorMap().get( source );
-
-        int idx = findTargetConnector( connectors, target );
-
-        if ( idx >= 0 )
-        {
-            decrementConnectorOrder( connectors, idx );
-            incrementConnectorOrder( connectors, idx - 1 );
-        }
-
-        for ( ProxyConnector proxyConnector : connectors )
-        {
-            getProxyConnectorAdmin().updateProxyConnector( proxyConnector, getAuditInformation() );
-        }
-        return SUCCESS;
-    }
-
-    private void decrementConnectorOrder( List<ProxyConnector> connectors, int idx )
-    {
-        if ( !validIndex( connectors, idx ) )
-        {
-            // Do nothing.
-            return;
-        }
-
-        int order = connectors.get( idx ).getOrder();
-        connectors.get( idx ).setOrder( Math.max( 1, order - 1 ) );
-    }
-
-    private int findTargetConnector( List<ProxyConnector> connectors, String targetRepoId )
-    {
-        int idx = ( -1 );
-
-        for ( int i = 0; i < connectors.size(); i++ )
-        {
-            if ( StringUtils.equals( targetRepoId, connectors.get( i ).getTargetRepoId() ) )
-            {
-                idx = i;
-                break;
-            }
-        }
-
-        return idx;
-    }
-
-    private void incrementConnectorOrder( List<ProxyConnector> connectors, int idx )
-    {
-        if ( !validIndex( connectors, idx ) )
-        {
-            // Do nothing.
-            return;
-        }
-
-        int order = connectors.get( idx ).getOrder();
-        connectors.get( idx ).setOrder( order + 1 );
-    }
-
-    private boolean validIndex( List<ProxyConnector> connectors, int idx )
-    {
-        return ( idx >= 0 ) && ( idx < connectors.size() );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction.java
deleted file mode 100644 (file)
index e08708f..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.legacy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.admin.ArchivaAdministration;
-import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-/**
- * Add a LegacyArtifactPath to archiva configuration
- *
- * @since 1.1
- */
-@Controller( "addLegacyArtifactPathAction" )
-@Scope( "prototype" )
-public class AddLegacyArtifactPathAction
-    extends AbstractActionSupport
-    implements Preparable, Validateable
-{
-
-    @Inject
-    private ArchivaAdministration archivaAdministration;
-
-    @Inject
-    @Named( value = "managedRepositoryContent#legacy" )
-    private ManagedRepositoryContent repositoryContent;
-
-
-    private LegacyArtifactPath legacyArtifactPath;
-
-    private String groupId;
-
-    private String artifactId;
-
-    private String version;
-
-    private String classifier;
-
-    private String type;
-
-
-    public void prepare()
-    {
-        this.legacyArtifactPath = new LegacyArtifactPath();
-    }
-
-    public String input()
-    {
-        return INPUT;
-    }
-
-    public String commit()
-    {
-        this.legacyArtifactPath.setArtifact(
-            this.groupId + ":" + this.artifactId + ":" + this.version + ":" + this.classifier + ":" + this.type );
-
-        // Check the proposed Artifact macthes the path
-        ArtifactReference artifact = new ArtifactReference();
-
-        artifact.setGroupId( this.groupId );
-        artifact.setArtifactId( this.artifactId );
-        artifact.setClassifier( this.classifier );
-        artifact.setVersion( this.version );
-        artifact.setType( this.type );
-
-        String path = repositoryContent.toPath( artifact );
-        if ( !path.equals( this.legacyArtifactPath.getPath() ) )
-        {
-            addActionError( "artifact reference does not match the initial path : " + path );
-            return ERROR;
-        }
-
-        try
-        {
-            getArchivaAdministration().addLegacyArtifactPath( legacyArtifactPath, getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            log.error( e.getMessage(), e );
-            addActionError( "Error occured " + e.getMessage() );
-            return INPUT;
-        }
-        return SUCCESS;
-    }
-
-    public LegacyArtifactPath getLegacyArtifactPath()
-    {
-        return legacyArtifactPath;
-    }
-
-    public void setLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
-    {
-        this.legacyArtifactPath = legacyArtifactPath;
-    }
-
-    public void validate()
-    {
-        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
-        trimAllRequestParameterValues();
-    }
-
-    private void trimAllRequestParameterValues()
-    {
-        if ( StringUtils.isNotEmpty( legacyArtifactPath.getPath() ) )
-        {
-            legacyArtifactPath.setPath( legacyArtifactPath.getPath().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( groupId ) )
-        {
-            groupId = groupId.trim();
-        }
-
-        if ( StringUtils.isNotEmpty( artifactId ) )
-        {
-            artifactId = artifactId.trim();
-        }
-
-        if ( StringUtils.isNotEmpty( version ) )
-        {
-            version = version.trim();
-        }
-
-        if ( StringUtils.isNotEmpty( classifier ) )
-        {
-            classifier = classifier.trim();
-        }
-
-        if ( StringUtils.isNotEmpty( type ) )
-        {
-            type = type.trim();
-        }
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = artifactId;
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public void setVersion( String version )
-    {
-        this.version = version;
-    }
-
-    public String getClassifier()
-    {
-        return classifier;
-    }
-
-    public void setClassifier( String classifier )
-    {
-        this.classifier = classifier;
-    }
-
-    public String getType()
-    {
-        return type;
-    }
-
-    public void setType( String type )
-    {
-        this.type = type;
-    }
-
-    public ArchivaAdministration getArchivaAdministration()
-    {
-        return archivaAdministration;
-    }
-
-    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
-    {
-        this.archivaAdministration = archivaAdministration;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/DeleteLegacyArtifactPathAction.java
deleted file mode 100644 (file)
index 79f4abc..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.legacy;\r
-\r
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements.  See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership.  The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * "License"); you may not use this file except in compliance\r
- * with the License.  You may obtain a copy of the License at\r
- *\r
- *  http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied.  See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-import org.apache.archiva.admin.model.RepositoryAdminException;\r
-import org.apache.archiva.admin.model.admin.ArchivaAdministration;\r
-import org.apache.maven.archiva.web.action.AbstractActionSupport;\r
-import org.springframework.context.annotation.Scope;\r
-import org.springframework.stereotype.Controller;\r
-\r
-import javax.inject.Inject;\r
-\r
-/**\r
- * Delete a LegacyArtifactPath to archiva configuration\r
- *\r
- * @since 1.1\r
- */\r
-@Controller( "deleteLegacyArtifactPathAction" )\r
-@Scope( "prototype" )\r
-public class DeleteLegacyArtifactPathAction\r
-    extends AbstractActionSupport\r
-{\r
-\r
-    @Inject\r
-    private ArchivaAdministration archivaAdministration;\r
-\r
-    private String path;\r
-\r
-    public String delete()\r
-    {\r
-        log.info( "remove [" + path + "] from legacy artifact path resolution" );\r
-        try\r
-        {\r
-            getArchivaAdministration().deleteLegacyArtifactPath( path, getAuditInformation() );\r
-        }\r
-        catch ( RepositoryAdminException e )\r
-        {\r
-            log.error( e.getMessage(), e );\r
-            addActionError( "Exception during delete " + e.getMessage() );\r
-        }\r
-        return SUCCESS;\r
-    }\r
-\r
-    public String getPath()\r
-    {\r
-        return path;\r
-    }\r
-\r
-    public void setPath( String path )\r
-    {\r
-        this.path = path;\r
-    }\r
-\r
-    public ArchivaAdministration getArchivaAdministration()\r
-    {\r
-        return archivaAdministration;\r
-    }\r
-\r
-    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )\r
-    {\r
-        this.archivaAdministration = archivaAdministration;\r
-    }\r
-}\r
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java
deleted file mode 100644 (file)
index ffc743e..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.legacy;\r
-\r
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements.  See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership.  The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * "License"); you may not use this file except in compliance\r
- * with the License.  You may obtain a copy of the License at\r
- *\r
- *  http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied.  See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-import com.opensymphony.xwork2.Preparable;\r
-import org.apache.archiva.admin.model.RepositoryAdminException;\r
-import org.apache.archiva.admin.model.admin.ArchivaAdministration;\r
-import org.apache.archiva.admin.model.beans.LegacyArtifactPath;\r
-import org.apache.archiva.security.common.ArchivaRoleConstants;\r
-import org.apache.archiva.web.util.ContextUtils;\r
-import org.apache.maven.archiva.web.action.AbstractActionSupport;\r
-import org.apache.struts2.interceptor.ServletRequestAware;\r
-import org.codehaus.plexus.redback.rbac.Resource;\r
-import org.codehaus.redback.integration.interceptor.SecureAction;\r
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;\r
-import org.codehaus.redback.integration.interceptor.SecureActionException;\r
-import org.springframework.context.annotation.Scope;\r
-import org.springframework.stereotype.Controller;\r
-\r
-import javax.inject.Inject;\r
-import javax.servlet.http.HttpServletRequest;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-/**\r
- * Shows the LegacyArtifactPath Tab for the administrator.\r
- *\r
- * @since 1.1\r
- */\r
-@Controller( "legacyArtifactPathAction" )\r
-@Scope( "prototype" )\r
-public class LegacyArtifactPathAction\r
-    extends AbstractActionSupport\r
-    implements SecureAction, ServletRequestAware, Preparable\r
-{\r
-\r
-    @Inject\r
-    private ArchivaAdministration archivaAdministration;\r
-\r
-    private List<LegacyArtifactPath> legacyArtifactPaths;\r
-\r
-    /**\r
-     * Used to construct the repository WebDAV URL in the repository action.\r
-     */\r
-    private String baseUrl;\r
-\r
-    public void setServletRequest( HttpServletRequest request )\r
-    {\r
-        // TODO: is there a better way to do this?\r
-        this.baseUrl = ContextUtils.getBaseURL( request, "repository" );\r
-    }\r
-\r
-    public SecureActionBundle getSecureActionBundle()\r
-        throws SecureActionException\r
-    {\r
-        SecureActionBundle bundle = new SecureActionBundle();\r
-\r
-        bundle.setRequiresAuthentication( true );\r
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );\r
-\r
-        return bundle;\r
-    }\r
-\r
-    public void prepare()\r
-        throws RepositoryAdminException\r
-    {\r
-        legacyArtifactPaths = new ArrayList<LegacyArtifactPath>( getArchivaAdministration().getLegacyArtifactPaths() );\r
-    }\r
-\r
-    public List<LegacyArtifactPath> getLegacyArtifactPaths()\r
-    {\r
-        return legacyArtifactPaths;\r
-    }\r
-\r
-    public String getBaseUrl()\r
-    {\r
-        return baseUrl;\r
-    }\r
-\r
-    public ArchivaAdministration getArchivaAdministration()\r
-    {\r
-        return archivaAdministration;\r
-    }\r
-\r
-    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )\r
-    {\r
-        this.archivaAdministration = archivaAdministration;\r
-    }\r
-}\r
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java
deleted file mode 100644 (file)
index 1d1d132..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.networkproxies;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.NetworkProxy;
-import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-
-/**
- * ConfigureNetworkProxyAction
- *
- * @version $Id$
- */
-@Controller( "configureNetworkProxyAction" )
-@Scope( "prototype" )
-public class ConfigureNetworkProxyAction
-    extends AbstractActionSupport
-    implements SecureAction, Preparable, Validateable
-{
-
-    @Inject
-    private NetworkProxyAdmin networkProxyAdmin;
-
-    private String mode;
-
-    private String proxyid;
-
-    private NetworkProxy proxy;
-
-    public String add()
-    {
-        this.mode = "add";
-        return INPUT;
-    }
-
-    public String confirm()
-    {
-        return INPUT;
-    }
-
-    public String delete()
-        throws RepositoryAdminException
-    {
-
-        String id = getProxyid();
-        if ( StringUtils.isBlank( id ) )
-        {
-            addActionError( "Unable to delete network proxy with blank id." );
-            return SUCCESS;
-        }
-
-        NetworkProxy networkProxy = getNetworkProxyAdmin().getNetworkProxy( id );
-        if ( networkProxy == null )
-        {
-            addActionError( "Unable to remove network proxy, proxy with id [" + id + "] not found." );
-            return SUCCESS;
-        }
-
-        getNetworkProxyAdmin().deleteNetworkProxy( id, getAuditInformation() );
-        addActionMessage( "Successfully removed network proxy [" + id + "]" );
-        return SUCCESS;
-    }
-
-    public String edit()
-    {
-        this.mode = "edit";
-        return INPUT;
-    }
-
-    public String getMode()
-    {
-        return mode;
-    }
-
-    public NetworkProxy getProxy()
-    {
-        return proxy;
-    }
-
-    public String getProxyid()
-    {
-        return proxyid;
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-    public String input()
-    {
-        return INPUT;
-    }
-
-    public void prepare()
-        throws Exception
-    {
-        String id = getProxyid();
-
-        if ( StringUtils.isNotBlank( id ) )
-        {
-            proxy = findNetworkProxy( id );
-        }
-
-        if ( proxy == null )
-        {
-            proxy = new NetworkProxy();
-        }
-    }
-
-    public String save()
-        throws RepositoryAdminException
-    {
-        String mode = getMode();
-
-        String id = getProxy().getId();
-
-        if ( StringUtils.equalsIgnoreCase( "edit", mode ) )
-        {
-            getNetworkProxyAdmin().updateNetworkProxy( proxy, getAuditInformation() );
-        }
-        else
-        {
-            getNetworkProxyAdmin().addNetworkProxy( proxy, getAuditInformation() );
-        }
-
-        return SUCCESS;
-    }
-
-    public void validate()
-    {
-        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
-        trimAllRequestParameterValues();
-    }
-
-    public void setMode( String mode )
-    {
-        this.mode = mode;
-    }
-
-    public void setProxy( NetworkProxy proxy )
-    {
-        this.proxy = proxy;
-    }
-
-    public void setProxyid( String proxyid )
-    {
-        this.proxyid = proxyid;
-    }
-
-
-    private NetworkProxy findNetworkProxy( String id )
-        throws RepositoryAdminException
-    {
-        return getNetworkProxyAdmin().getNetworkProxy( id );
-    }
-
-    private void removeNetworkProxy( String id )
-        throws RepositoryAdminException
-    {
-        getNetworkProxyAdmin().deleteNetworkProxy( id, getAuditInformation() );
-    }
-
-
-    private void trimAllRequestParameterValues()
-    {
-        if ( StringUtils.isNotEmpty( proxy.getId() ) )
-        {
-            proxy.setId( proxy.getId().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( proxy.getHost() ) )
-        {
-            proxy.setHost( proxy.getHost().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( proxy.getPassword() ) )
-        {
-            proxy.setPassword( proxy.getPassword().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( proxy.getProtocol() ) )
-        {
-            proxy.setProtocol( proxy.getProtocol().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( proxy.getUsername() ) )
-        {
-            proxy.setUsername( proxy.getUsername().trim() );
-        }
-    }
-
-    public NetworkProxyAdmin getNetworkProxyAdmin()
-    {
-        return networkProxyAdmin;
-    }
-
-    public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
-    {
-        this.networkProxyAdmin = networkProxyAdmin;
-    }
-}
-
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java
deleted file mode 100644 (file)
index 65a0bc7..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.networkproxies;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.beans.NetworkProxy;
-import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import java.util.List;
-
-/**
- * NetworkProxiesAction
- *
- * @version $Id$
- */
-@Controller( "networkProxiesAction" )
-@Scope( "prototype" )
-public class NetworkProxiesAction
-    extends AbstractActionSupport
-    implements Preparable, SecureAction
-{
-
-    @Inject
-    private NetworkProxyAdmin networkProxyAdmin;
-
-    private List<NetworkProxy> networkProxies;
-
-    public void prepare()
-        throws Exception
-    {
-        networkProxies = getNetworkProxyAdmin().getNetworkProxies();
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-    public List<NetworkProxy> getNetworkProxies()
-    {
-        return networkProxies;
-    }
-
-    public void setNetworkProxies( List<NetworkProxy> networkProxies )
-    {
-        this.networkProxies = networkProxies;
-    }
-
-    public NetworkProxyAdmin getNetworkProxyAdmin()
-    {
-        return networkProxyAdmin;
-    }
-
-    public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
-    {
-        this.networkProxyAdmin = networkProxyAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesAction.java
deleted file mode 100644 (file)
index 9e315b5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Abstract ManagedRepositories Action.
- * <p/>
- * Place for all generic methods used in Managed Repository Administration.
- *
- * @version $Id$
- */
-public abstract class AbstractManagedRepositoriesAction
-    extends AbstractRepositoriesAdminAction
-{
-    public static final String CONFIRM = "confirm";
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRemoteRepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRemoteRepositoriesAction.java
deleted file mode 100644 (file)
index 197beae..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
-
-import javax.inject.Inject;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * AbstractRemoteRepositoriesAction
- *
- * @version $Id$
- */
-public class AbstractRemoteRepositoriesAction
-    extends AbstractRepositoriesAdminAction
-{
-    @Inject
-    private RemoteRepositoryAdmin remoteRepositoryAdmin;
-
-    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
-    {
-        return remoteRepositoryAdmin;
-    }
-
-    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
-    {
-        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java
deleted file mode 100644 (file)
index 615cf1c..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.RepositoryCommonValidator;
-import org.apache.archiva.audit.Auditable;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-
-import javax.inject.Inject;
-
-/**
- * Abstract AdminRepositories Action base.
- * <p/>
- * Base class for all repository administrative functions.
- * This should be neutral to the type of action (add/edit/delete) and type of repo (managed/remote)
- *
- * @version $Id$
- */
-public abstract class AbstractRepositoriesAdminAction
-    extends AbstractActionSupport
-    implements SecureAction, Auditable
-{
-
-    @Inject
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    @Inject
-    private RepositoryCommonValidator repositoryCommonValidator;
-
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-
-    public RepositoryCommonValidator getRepositoryCommonValidator()
-    {
-        return repositoryCommonValidator;
-    }
-
-    public void setRepositoryCommonValidator( RepositoryCommonValidator repositoryCommonValidator )
-    {
-        this.repositoryCommonValidator = repositoryCommonValidator;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java
deleted file mode 100644 (file)
index cefb6d2..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import java.io.File;
-
-/**
- * AddManagedRepositoryAction
- *
- * @version $Id$
- */
-@Controller( "addManagedRepositoryAction" )
-@Scope( "prototype" )
-public class AddManagedRepositoryAction
-    extends AbstractManagedRepositoriesAction
-    implements Preparable, Validateable
-{
-
-    private ManagedRepository repository;
-
-    private boolean stageNeeded;
-
-    private String action = "addRepository";
-
-    public void prepare()
-    {
-        this.repository = new ManagedRepository();
-        this.repository.setReleases( false );
-        this.repository.setScanned( false );
-        this.repository.setBlockRedeployments( false );
-    }
-
-    public String input()
-    {
-        this.repository.setReleases( true );
-        this.repository.setScanned( true );
-        this.repository.setBlockRedeployments( true );
-
-        return INPUT;
-    }
-
-    public String confirmAdd()
-    {
-        return save();
-    }
-
-    public String commit()
-    {
-        repository.setLocation( getRepositoryCommonValidator().removeExpressions( repository.getLocation() ) );
-
-        File location = new File( repository.getLocation() );
-        if ( location.exists() )
-        {
-            return CONFIRM;
-        }
-
-        return save();
-    }
-
-    private String save()
-    {
-        String result = SUCCESS;
-        try
-        {
-            getManagedRepositoryAdmin().addManagedRepository( repository, stageNeeded, getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            log.error( e.getMessage(), e );
-            addActionError( "Check your server logs, Repository Administration Exception: " + e.getMessage() );
-            result = INPUT;
-        }
-
-        return result;
-    }
-
-    @Override
-    public void validate()
-    {
-        // trim all unecessary trailing/leading white-spaces; always put this statement before the closing braces(after all validation).
-        trimAllRequestParameterValues();
-    }
-
-    private void trimAllRequestParameterValues()
-    {
-        if ( StringUtils.isNotEmpty( repository.getId() ) )
-        {
-            repository.setId( repository.getId().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( repository.getName() ) )
-        {
-            repository.setName( repository.getName().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( repository.getLocation() ) )
-        {
-            repository.setLocation( repository.getLocation().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( repository.getIndexDirectory() ) )
-        {
-            repository.setIndexDirectory( repository.getIndexDirectory().trim() );
-        }
-    }
-
-    public ManagedRepository getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( ManagedRepository repository )
-    {
-        this.repository = repository;
-    }
-
-
-    public void setStageNeeded( boolean stageNeeded )
-    {
-        this.stageNeeded = stageNeeded;
-    }
-
-    public String getAction()
-    {
-        return action;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java
deleted file mode 100644 (file)
index 02bb469..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * AddRemoteRepositoryAction
- *
- * @version $Id$
- */
-@Controller( "addRemoteRepositoryAction" )
-@Scope( "prototype" )
-public class AddRemoteRepositoryAction
-    extends AbstractRemoteRepositoriesAction
-    implements Preparable, Validateable
-{
-    /**
-     * The model for this action.
-     */
-    private RemoteRepository repository;
-
-    public void prepare()
-    {
-        this.repository = new RemoteRepository();
-    }
-
-    public String input()
-    {
-        return INPUT;
-    }
-
-    public String commit()
-    {
-
-        String result = SUCCESS;
-        try
-        {
-            getRemoteRepositoryAdmin().addRemoteRepository( repository, getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "RepositoryAdminException: " + e.getMessage() );
-            result = INPUT;
-        }
-
-        return result;
-    }
-
-
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java
deleted file mode 100644 (file)
index 5e523d4..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * DeleteManagedRepositoryAction
- *
- * @version $Id$
- */
-@Controller( "deleteManagedRepositoryAction" )
-@Scope( "prototype" )
-public class DeleteManagedRepositoryAction
-    extends AbstractManagedRepositoriesAction
-    implements Preparable
-{
-
-
-    private ManagedRepository repository;
-
-    private ManagedRepository stagingRepository;
-
-    private String repoid;
-
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        if ( StringUtils.isNotBlank( repoid ) )
-        {
-            this.repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
-            this.stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
-        }
-    }
-
-    public String confirmDelete()
-    {
-        if ( StringUtils.isBlank( repoid ) )
-        {
-            addActionError( "Unable to delete managed repository: repository id was blank." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String deleteEntry()
-    {
-        return deleteRepository( false );
-    }
-
-    public String deleteContents()
-    {
-        return deleteRepository( true );
-    }
-
-    private String deleteRepository( boolean deleteContents )
-    {
-        ManagedRepository existingRepository = repository;
-        if ( existingRepository == null )
-        {
-            addActionError( "A repository with that id does not exist" );
-            return ERROR;
-        }
-
-        String result = SUCCESS;
-
-        try
-        {
-            getManagedRepositoryAdmin().deleteManagedRepository( existingRepository.getId(), getAuditInformation(),
-                                                                 deleteContents );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError(
-                "Unable to delete repository, content may already be partially removed: " + e.getMessage() );
-            log.error( e.getMessage(), e );
-            result = ERROR;
-        }
-        return result;
-    }
-
-    public ManagedRepository getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( ManagedRepository repository )
-    {
-        this.repository = repository;
-    }
-
-    public String getRepoid()
-    {
-        return repoid;
-    }
-
-    public void setRepoid( String repoid )
-    {
-        this.repoid = repoid;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryAction.java
deleted file mode 100644 (file)
index 8061244..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * DeleteRemoteRepositoryAction
- *
- * @version $Id$
- */
-@Controller( "deleteRemoteRepositoryAction" )
-@Scope( "prototype" )
-public class DeleteRemoteRepositoryAction
-    extends AbstractRemoteRepositoriesAction
-    implements Preparable
-{
-    private RemoteRepository repository;
-
-    private String repoid;
-
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        if ( StringUtils.isNotBlank( repoid ) )
-        {
-            this.repository = getRemoteRepositoryAdmin().getRemoteRepository( repoid );
-        }
-    }
-
-    public String confirmDelete()
-    {
-        if ( StringUtils.isBlank( repoid ) )
-        {
-            addActionError( "Unable to delete remote repository: repository id was blank." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String delete()
-    {
-        String result = SUCCESS;
-        RemoteRepository existingRepository = repository;
-        if ( existingRepository == null )
-        {
-            addActionError( "A repository with that id does not exist" );
-            return ERROR;
-        }
-
-        try
-        {
-            getRemoteRepositoryAdmin().deleteRemoteRepository( existingRepository.getId(), getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "RepositoryAdminException: " + e.getMessage() );
-            result = ERROR;
-        }
-        return result;
-    }
-
-
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-    }
-
-    public String getRepoid()
-    {
-        return repoid;
-    }
-
-    public void setRepoid( String repoid )
-    {
-        this.repoid = repoid;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java
deleted file mode 100644 (file)
index 3b468cc..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RepositoryGroup;
-import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-
-/**
- * DeleteRepositoryGroupAction
- */
-@Controller( "deleteRepositoryGroupAction" )
-@Scope( "prototype" )
-public class DeleteRepositoryGroupAction
-    extends AbstractRepositoriesAdminAction
-    implements Preparable
-{
-    private RepositoryGroup repositoryGroup;
-
-    @Inject
-    private RepositoryGroupAdmin repositoryGroupAdmin;
-
-    private String repoGroupId;
-
-    public void prepare()
-        throws RepositoryAdminException
-    {
-
-        if ( StringUtils.isNotBlank( repoGroupId ) )
-        {
-            this.repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( repoGroupId );
-        }
-    }
-
-    public String confirmDelete()
-    {
-        if ( StringUtils.isBlank( repoGroupId ) )
-        {
-            addActionError( "Unable to delete repository group: repository id was blank." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String delete()
-    {
-
-        try
-        {
-            RepositoryGroup group = repositoryGroupAdmin.getRepositoryGroup( repoGroupId );
-            if ( group == null )
-            {
-                addActionError( "A repository group with that id does not exist." );
-                return ERROR;
-            }
-
-            repositoryGroupAdmin.deleteRepositoryGroup( repoGroupId, getAuditInformation() );
-            return SUCCESS;
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "error occured " + e.getMessage() );
-            return ERROR;
-        }
-    }
-
-    public RepositoryGroup getRepositoryGroup()
-    {
-        return repositoryGroup;
-    }
-
-    public void setRepositoryGroup( RepositoryGroup repositoryGroup )
-    {
-        this.repositoryGroup = repositoryGroup;
-    }
-
-    public String getRepoGroupId()
-    {
-        return repoGroupId;
-    }
-
-    public void setRepoGroupId( String repoGroupId )
-    {
-        this.repoGroupId = repoGroupId;
-    }
-
-    public RepositoryGroupAdmin getRepositoryGroupAdmin()
-    {
-        return repositoryGroupAdmin;
-    }
-
-    public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
-    {
-        this.repositoryGroupAdmin = repositoryGroupAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java
deleted file mode 100644 (file)
index 9d2a3cc..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.redback.components.scheduler.CronExpressionValidator;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import java.io.File;
-
-/**
- * AddManagedRepositoryAction
- *
- * @version $Id$
- */
-@Controller( "editManagedRepositoryAction" )
-@Scope( "prototype" )
-public class EditManagedRepositoryAction
-    extends AbstractManagedRepositoriesAction
-    implements Preparable, Validateable
-{
-
-    private ManagedRepository repository;
-
-    private ManagedRepository stagingRepository;
-
-    private String repoid;
-
-    private final String action = "editRepository";
-
-    private boolean stageNeeded;
-
-
-    // FIXME better error message
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        if ( StringUtils.isNotBlank( repoid ) )
-        {
-            repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
-            stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
-        }
-        else if ( repository != null )
-        {
-            repository.setReleases( false );
-            repository.setScanned( false );
-        }
-    }
-
-    public String input()
-    {
-        if ( repository == null )
-        {
-            addActionError( "Edit failure, unable to edit a repository with a blank repository id." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String confirmUpdate()
-    {
-        // location was changed
-        return save( true );
-    }
-
-    public String commit()
-        throws RepositoryAdminException
-    {
-        ManagedRepository existingConfig = getManagedRepositoryAdmin().getManagedRepository( repository.getId() );
-        boolean resetStats = false;
-
-        // check if the location was changed
-        repository.setLocation( getRepositoryCommonValidator().removeExpressions( repository.getLocation() ) );
-
-        if ( !StringUtils.equalsIgnoreCase( existingConfig.getLocation().trim(), repository.getLocation().trim() ) )
-        {
-            resetStats = true;
-
-            File dir = new File( repository.getLocation() );
-            if ( dir.exists() )
-            {
-                return CONFIRM;
-            }
-        }
-
-        return save( resetStats );
-    }
-
-    private String save( boolean resetStats )
-    {
-
-        String result = SUCCESS;
-        try
-        {
-            getManagedRepositoryAdmin().updateManagedRepository( repository, stageNeeded, getAuditInformation(),
-                                                                 resetStats );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "Repository Administration Exception: " + e.getMessage() );
-            result = ERROR;
-        }
-
-        return result;
-    }
-
-
-    @Override
-    public void validate()
-    {
-        CronExpressionValidator validator = new CronExpressionValidator();
-
-        if ( !validator.validate( repository.getCronExpression() ) )
-        {
-            addFieldError( "repository.refreshCronExpression", "Invalid cron expression." );
-        }
-
-        trimAllRequestParameterValues();
-    }
-
-    private void trimAllRequestParameterValues()
-    {
-        if ( StringUtils.isNotEmpty( repository.getId() ) )
-        {
-            repository.setId( repository.getId().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( repository.getName() ) )
-        {
-            repository.setName( repository.getName().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( repository.getLocation() ) )
-        {
-            repository.setLocation( repository.getLocation().trim() );
-        }
-
-        if ( StringUtils.isNotEmpty( repository.getIndexDirectory() ) )
-        {
-            repository.setIndexDirectory( repository.getIndexDirectory().trim() );
-        }
-    }
-
-    public String getRepoid()
-    {
-        return repoid;
-    }
-
-    public void setRepoid( String repoid )
-    {
-        this.repoid = repoid;
-    }
-
-
-    public boolean isStageNeeded()
-    {
-        return stageNeeded;
-    }
-
-    public void setStageNeeded( boolean stageNeeded )
-    {
-
-        this.stageNeeded = stageNeeded;
-    }
-
-    public String getAction()
-    {
-        return action;
-    }
-
-    public ManagedRepository getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( ManagedRepository repository )
-    {
-        this.repository = repository;
-    }
-
-    public ManagedRepository getStagingRepository()
-    {
-        return stagingRepository;
-    }
-
-    public void setStagingRepository( ManagedRepository stagingRepository )
-    {
-        this.stagingRepository = stagingRepository;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryAction.java
deleted file mode 100644 (file)
index 3c03256..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-/**
- * EditRemoteRepositoryAction
- *
- * @version $Id$
- */
-@Controller( "editRemoteRepositoryAction" )
-@Scope( "prototype" )
-public class EditRemoteRepositoryAction
-    extends AbstractRemoteRepositoriesAction
-    implements Preparable
-{
-    /**
-     * The model for this action.
-     */
-    private RemoteRepository repository;
-
-    /**
-     * The repository id to edit.
-     */
-    private String repoid;
-
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        if ( StringUtils.isNotBlank( repoid ) )
-        {
-            this.repository = getRemoteRepositoryAdmin().getRemoteRepository( repoid );
-        }
-    }
-
-    public String input()
-    {
-        if ( StringUtils.isBlank( repoid ) )
-        {
-            addActionError( "Edit failure, unable to edit a repository with a blank repository id." );
-            return ERROR;
-        }
-
-        return INPUT;
-    }
-
-    public String commit()
-    {
-        String result = SUCCESS;
-        try
-        {
-            getRemoteRepositoryAdmin().updateRemoteRepository( getRepository(), getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "RepositoryAdminException: " + e.getMessage() );
-            result = INPUT;
-        }
-
-        return result;
-    }
-
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-    }
-
-    public String getRepoid()
-    {
-        return repoid;
-    }
-
-    public void setRepoid( String repoid )
-    {
-        this.repoid = repoid;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java
deleted file mode 100644 (file)
index 935ba38..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
-import org.apache.archiva.admin.repository.utils.RepositoryComparator;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataRepositoryException;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.archiva.web.util.ContextUtils;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.apache.struts2.interceptor.ServletRequestAware;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Shows the Repositories Tab for the administrator.
- *
- * @version $Id$
- */
-@Controller( "repositoriesAction" )
-@Scope( "prototype" )
-public class RepositoriesAction
-    extends AbstractActionSupport
-    implements SecureAction, ServletRequestAware, Preparable
-{
-
-    @Inject
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    @Inject
-    private RemoteRepositoryAdmin remoteRepositoryAdmin;
-
-    @Inject
-    private RepositoryGroupAdmin repositoryGroupAdmin;
-
-    private List<ManagedRepository> managedRepositories;
-
-    private List<RemoteRepository> remoteRepositories;
-
-    private Map<String, RepositoryStatistics> repositoryStatistics;
-
-    private Map<String, List<String>> repositoryToGroupMap;
-
-    /**
-     * Used to construct the repository WebDAV URL in the repository action.
-     */
-    private String baseUrl;
-
-
-    @Inject
-    private RepositoryStatisticsManager repositoryStatisticsManager;
-
-    public void setServletRequest( HttpServletRequest request )
-    {
-        // TODO: is there a better way to do this?
-        this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        remoteRepositories = new ArrayList<RemoteRepository>( getRemoteRepositoryAdmin().getRemoteRepositories() );
-        managedRepositories = new ArrayList<ManagedRepository>( getManagedRepositoryAdmin().getManagedRepositories() );
-        repositoryToGroupMap = getRepositoryGroupAdmin().getRepositoryToGroupMap();
-
-        Collections.sort( managedRepositories, new RepositoryComparator() );
-        Collections.sort( remoteRepositories, new RepositoryComparator() );
-
-        repositoryStatistics = new HashMap<String, RepositoryStatistics>();
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            for ( ManagedRepository repo : managedRepositories )
-            {
-                RepositoryStatistics stats = null;
-                try
-                {
-                    stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, repo.getId() );
-                }
-                catch ( MetadataRepositoryException e )
-                {
-                    addActionError(
-                        "Error retrieving statistics for repository " + repo.getId() + " - consult application logs" );
-                    log.warn( "Error retrieving repository statistics: " + e.getMessage(), e );
-                }
-                if ( stats != null )
-                {
-                    repositoryStatistics.put( repo.getId(), stats );
-                }
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-    }
-
-    public List<ManagedRepository> getManagedRepositories()
-    {
-        List<ManagedRepository> managedRepositoriesList = new ArrayList<ManagedRepository>();
-        for ( ManagedRepository repoConfig : managedRepositories )
-        {
-            if ( !repoConfig.getId().endsWith( "-stage" ) )
-            {
-                managedRepositoriesList.add( repoConfig );
-            }
-        }
-        return managedRepositoriesList;
-    }
-
-    public List<RemoteRepository> getRemoteRepositories()
-    {
-        return remoteRepositories;
-    }
-
-    public Map<String, RepositoryStatistics> getRepositoryStatistics()
-    {
-        return repositoryStatistics;
-    }
-
-    public String getBaseUrl()
-    {
-        return baseUrl;
-    }
-
-    public Map<String, List<String>> getRepositoryToGroupMap()
-    {
-        return repositoryToGroupMap;
-    }
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-
-    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
-    {
-        return remoteRepositoryAdmin;
-    }
-
-    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
-    {
-        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
-    }
-
-    public RepositoryGroupAdmin getRepositoryGroupAdmin()
-    {
-        return repositoryGroupAdmin;
-    }
-
-    public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
-    {
-        this.repositoryGroupAdmin = repositoryGroupAdmin;
-    }
-
-    public RepositoryStatisticsManager getRepositoryStatisticsManager()
-    {
-        return repositoryStatisticsManager;
-    }
-
-    public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
-    {
-        this.repositoryStatisticsManager = repositoryStatisticsManager;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java
deleted file mode 100644 (file)
index ddd2123..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.beans.RepositoryGroup;
-import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
-import org.apache.archiva.web.util.ContextUtils;
-import org.apache.struts2.interceptor.ServletRequestAware;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-/**
- * RepositoryGroupsAction
- */
-@Controller( "repositoryGroupsAction" )
-@Scope( "prototype" )
-public class RepositoryGroupsAction
-    extends AbstractRepositoriesAdminAction
-    implements ServletRequestAware, Preparable
-{
-
-    @Inject
-    private RepositoryGroupAdmin repositoryGroupAdmin;
-
-    private RepositoryGroup repositoryGroup;
-
-    private Map<String, RepositoryGroup> repositoryGroups;
-
-    private Map<String, ManagedRepository> managedRepositories;
-
-    private Map<String, List<String>> groupToRepositoryMap;
-
-    private String repoGroupId;
-
-    private String repoId;
-
-    /**
-     * Used to construct the repository WebDAV URL in the repository action.
-     */
-    private String baseUrl;
-
-    private static final Pattern REPO_GROUP_ID_PATTERN = Pattern.compile( "[A-Za-z0-9\\._\\-]+" );
-
-    public void setServletRequest( HttpServletRequest request )
-    {
-        this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
-    }
-
-    public void prepare()
-        throws RepositoryAdminException
-    {
-
-        repositoryGroup = new RepositoryGroup();
-        repositoryGroups = getRepositoryGroupAdmin().getRepositoryGroupsAsMap();
-        managedRepositories = getManagedRepositoryAdmin().getManagedRepositoriesAsMap();
-        groupToRepositoryMap = getRepositoryGroupAdmin().getGroupToRepositoryMap();
-    }
-
-    public String addRepositoryGroup()
-    {
-        try
-        {
-            getRepositoryGroupAdmin().addRepositoryGroup( repositoryGroup, getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( e.getMessage() );
-            return ERROR;
-        }
-
-        return SUCCESS;
-    }
-
-    public String addRepositoryToGroup()
-    {
-        try
-        {
-            getRepositoryGroupAdmin().addRepositoryToGroup( repoGroupId, repoId, getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( e.getMessage() );
-            return ERROR;
-        }
-        return SUCCESS;
-    }
-
-    public String removeRepositoryFromGroup()
-    {
-        try
-        {
-            getRepositoryGroupAdmin().deleteRepositoryFromGroup( repoGroupId, repoId, getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( e.getMessage() );
-            return ERROR;
-        }
-        return SUCCESS;
-    }
-
-
-    public RepositoryGroup getRepositoryGroup()
-    {
-        return repositoryGroup;
-    }
-
-    public void setRepositoryGroup( RepositoryGroup repositoryGroup )
-    {
-        this.repositoryGroup = repositoryGroup;
-    }
-
-    public Map<String, RepositoryGroup> getRepositoryGroups()
-    {
-        return repositoryGroups;
-    }
-
-    public void setRepositoryGroups( Map<String, RepositoryGroup> repositoryGroups )
-    {
-        this.repositoryGroups = repositoryGroups;
-    }
-
-    public Map<String, ManagedRepository> getManagedRepositories()
-    {
-        return managedRepositories;
-    }
-
-    public Map<String, List<String>> getGroupToRepositoryMap()
-    {
-        return this.groupToRepositoryMap;
-    }
-
-    public String getRepoGroupId()
-    {
-        return repoGroupId;
-    }
-
-    public void setRepoGroupId( String repoGroupId )
-    {
-        this.repoGroupId = repoGroupId;
-    }
-
-    public String getRepoId()
-    {
-        return repoId;
-    }
-
-    public void setRepoId( String repoId )
-    {
-        this.repoId = repoId;
-    }
-
-    public String getBaseUrl()
-    {
-        return baseUrl;
-    }
-
-    public RepositoryGroupAdmin getRepositoryGroupAdmin()
-    {
-        return repositoryGroupAdmin;
-    }
-
-    public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
-    {
-        this.repositoryGroupAdmin = repositoryGroupAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesAction.java
deleted file mode 100644 (file)
index 5114527..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
-import org.codehaus.plexus.registry.RegistryException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import java.util.List;
-
-/**
- * SortRepositoriesAction
- * FIXME remove access to archivaconfiguration
- */
-@Controller( "sortRepositoriesAction" )
-@Scope( "prototype" )
-public class SortRepositoriesAction
-    extends AbstractRepositoriesAdminAction
-{
-
-    private String repoGroupId;
-
-    private String targetRepo;
-
-    @Inject
-    protected ArchivaConfiguration archivaConfiguration;
-
-    public String sortDown()
-    {
-        Configuration config = archivaConfiguration.getConfiguration();
-
-        List<String> repositories = getRepositoriesFromGroup();
-
-        int idx = findTargetRepository( repositories, targetRepo );
-
-        if ( idx >= 0 && validIndex( repositories, idx + 1 ) )
-        {
-            repositories.remove( idx );
-            repositories.add( idx + 1, targetRepo );
-        }
-
-        return saveConfiguration( config );
-    }
-
-    public String sortUp()
-    {
-        Configuration config = archivaConfiguration.getConfiguration();
-
-        List<String> repositories = getRepositoriesFromGroup();
-
-        int idx = findTargetRepository( repositories, targetRepo );
-
-        if ( idx >= 0 && validIndex( repositories, idx - 1 ) )
-        {
-            repositories.remove( idx );
-            repositories.add( idx - 1, targetRepo );
-        }
-
-        return saveConfiguration( config );
-    }
-
-/**
-     * Save the configuration.
-     *
-     * @param configuration the configuration to save.
-     * @return the webwork result code to issue.
-     * @throws java.io.IOException                   thrown if unable to save file to disk.
-     * @throws org.apache.archiva.configuration.InvalidConfigurationException thrown if configuration is invalid.
-     * @throws org.codehaus.plexus.registry.RegistryException             thrown if configuration subsystem has a problem saving the configuration to disk.
-     */
-    protected String saveConfiguration( Configuration configuration )
-    {
-        try
-        {
-            archivaConfiguration.save( configuration );
-            addActionMessage( "Successfully saved configuration" );
-        }
-        catch ( IndeterminateConfigurationException e )
-        {
-            addActionError( e.getMessage() );
-            return INPUT;
-        }
-        catch ( RegistryException e )
-        {
-            addActionError( "Configuration Registry Exception: " + e.getMessage() );
-            return INPUT;
-        }
-
-        return SUCCESS;
-    }
-
-    public String getRepoGroupId()
-    {
-        return repoGroupId;
-    }
-
-    public void setRepoGroupId( String repoGroupId )
-    {
-        this.repoGroupId = repoGroupId;
-    }
-
-    public String getTargetRepo()
-    {
-        return targetRepo;
-    }
-
-    public void setTargetRepo( String targetRepo )
-    {
-        this.targetRepo = targetRepo;
-    }
-
-    private int findTargetRepository( List<String> repositories, String targetRepository )
-    {
-        int idx = ( -1 );
-
-        for ( int i = 0; i < repositories.size(); i++ )
-        {
-            if ( StringUtils.equals( targetRepository, repositories.get( i ) ) )
-            {
-                idx = i;
-                break;
-            }
-        }
-        return idx;
-    }
-
-    private List<String> getRepositoriesFromGroup()
-    {
-        Configuration config = archivaConfiguration.getConfiguration();
-        RepositoryGroupConfiguration repoGroup = config.findRepositoryGroupById( repoGroupId );
-        return repoGroup.getRepositories();
-    }
-
-    private boolean validIndex( List<String> repositories, int idx )
-    {
-        return ( idx >= 0 ) && ( idx < repositories.size() );
-    }
-
-    public ArchivaConfiguration getArchivaConfiguration()
-    {
-        return archivaConfiguration;
-    }
-
-    public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
-    {
-        this.archivaConfiguration = archivaConfiguration;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AddAdminRepoConsumerClosure.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AddAdminRepoConsumerClosure.java
deleted file mode 100644 (file)
index 4085cdb..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.scanning;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.collections.Closure;
-import org.apache.archiva.consumers.RepositoryContentConsumer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * AddAdminRepoConsumerClosure 
- *
- * @version $Id$
- */
-public class AddAdminRepoConsumerClosure
-    implements Closure
-{
-    private List<AdminRepositoryConsumer> list = new ArrayList<AdminRepositoryConsumer>();
-
-    private List<String> selectedIds;
-
-    public AddAdminRepoConsumerClosure( List<String> selectedIds )
-    {
-        this.selectedIds = selectedIds;
-    }
-
-    public void execute( Object input )
-    {
-        if ( input instanceof RepositoryContentConsumer )
-        {
-            RepositoryContentConsumer consumer = (RepositoryContentConsumer) input;
-
-            boolean enabled = this.selectedIds.contains( consumer.getId() );
-            AdminRepositoryConsumer adminconsumer = new AdminRepositoryConsumer();
-            adminconsumer.setEnabled( enabled );
-            adminconsumer.setId( consumer.getId() );
-            adminconsumer.setDescription( consumer.getDescription() );
-
-            list.add( adminconsumer );
-        }
-    }
-
-    public List<AdminRepositoryConsumer> getList()
-    {
-        return list;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java
deleted file mode 100644 (file)
index 3c27a2d..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.scanning;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * AdminRepositoryConsumer 
- *
- * @version $Id$
- */
-public class AdminRepositoryConsumer
-{
-    private boolean enabled = false;
-    private String id;
-    private String description;
-    
-    public String getDescription()
-    {
-        return description;
-    }
-
-    public String getId()
-    {
-        return id;
-    }
-
-    public boolean isEnabled()
-    {
-        return enabled;
-    }
-
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
-
-    public void setEnabled( boolean enabled )
-    {
-        this.enabled = enabled;
-    }
-
-    public void setId( String id )
-    {
-        this.id = id;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AdminRepositoryConsumerComparator.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/AdminRepositoryConsumerComparator.java
deleted file mode 100644 (file)
index 583e6d2..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.scanning;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Comparator;
-
-/**
- * AdminRepositoryConsumerComparator 
- *
- * @version $Id$
- */
-public class AdminRepositoryConsumerComparator
-    implements Comparator<AdminRepositoryConsumer>
-{
-    private static AdminRepositoryConsumerComparator INSTANCE = new AdminRepositoryConsumerComparator();
-
-    public static AdminRepositoryConsumerComparator getInstance()
-    {
-        return INSTANCE;
-    }
-
-    public int compare( AdminRepositoryConsumer o1, AdminRepositoryConsumer o2 )
-    {
-        if ( o1 == null && o2 == null )
-        {
-            return 0;
-        }
-
-        if ( o1 == null && o2 != null )
-        {
-            return 1;
-        }
-
-        if ( o1 != null && o2 == null )
-        {
-            return -1;
-        }
-
-        String id1 = o1.getId();
-        String id2 = o2.getId();
-        return id1.compareToIgnoreCase( id2 );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java
deleted file mode 100644 (file)
index 14ca5be..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.scanning;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.admin.ArchivaAdministration;
-import org.apache.archiva.admin.model.beans.FileType;
-import org.apache.archiva.admin.repository.admin.FiletypeToMapClosure;
-import org.apache.archiva.audit.Auditable;
-import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * RepositoryScanningAction
- *
- * @version $Id$
- */
-@Controller( "repositoryScanningAction" )
-@Scope( "prototype" )
-public class RepositoryScanningAction
-    extends AbstractActionSupport
-    implements Preparable, Validateable, SecureAction, Auditable
-{
-
-    @Inject
-    private RepositoryContentConsumers repoconsumerUtil;
-
-    @Inject
-    private ArchivaAdministration archivaAdministration;
-
-    private Map<String, FileType> fileTypeMap;
-
-    private List<String> fileTypeIds;
-
-    /**
-     * List of {@link AdminRepositoryConsumer} objects for consumers of known content.
-     */
-    private List<AdminRepositoryConsumer> knownContentConsumers;
-
-    /**
-     * List of enabled {@link AdminRepositoryConsumer} objects for consumers of known content.
-     */
-    private List<String> enabledKnownContentConsumers;
-
-    /**
-     * List of {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content.
-     */
-    private List<AdminRepositoryConsumer> invalidContentConsumers;
-
-    /**
-     * List of enabled {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content.
-     */
-    private List<String> enabledInvalidContentConsumers;
-
-    private String pattern;
-
-    private String fileTypeId;
-
-    public void addActionError( String anErrorMessage )
-    {
-        super.addActionError( anErrorMessage );
-        log.warn( "[ActionError] {}", anErrorMessage );
-    }
-
-    public void addActionMessage( String aMessage )
-    {
-        super.addActionMessage( aMessage );
-        log.info( "[ActionMessage] {}", aMessage );
-    }
-
-    public String addFiletypePattern()
-    {
-        log.info( "Add New File Type Pattern [{}:{}]", getFileTypeId(), getPattern() );
-
-        if ( !isValidFiletypeCommand() )
-        {
-            return INPUT;
-        }
-
-        try
-        {
-            getArchivaAdministration().addFileTypePattern( getFileTypeId(), getPattern(), getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "error adding file type pattern " + e.getMessage() );
-            return INPUT;
-        }
-        return SUCCESS;
-    }
-
-    public String removeFiletypePattern()
-        throws RepositoryAdminException
-    {
-        log.info( "Remove File Type Pattern [{}:{}]", getFileTypeId(), getPattern() );
-
-        if ( !isValidFiletypeCommand() )
-        {
-            return INPUT;
-        }
-
-        try
-        {
-            getArchivaAdministration().removeFileTypePattern( getFileTypeId(), getPattern(), getAuditInformation() );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            addActionError( "error adding file type pattern " + e.getMessage() );
-            return INPUT;
-        }
-
-        return SUCCESS;
-    }
-
-    public String getFileTypeId()
-    {
-        return fileTypeId;
-    }
-
-    public List<String> getFileTypeIds()
-    {
-        return fileTypeIds;
-    }
-
-    public Map<String, FileType> getFileTypeMap()
-    {
-        return fileTypeMap;
-    }
-
-    public List<AdminRepositoryConsumer> getInvalidContentConsumers()
-    {
-        return invalidContentConsumers;
-    }
-
-    public List<AdminRepositoryConsumer> getKnownContentConsumers()
-    {
-        return knownContentConsumers;
-    }
-
-    public String getPattern()
-    {
-        return pattern;
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-    public void prepare()
-        throws Exception
-    {
-
-
-        FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
-
-        CollectionUtils.forAllDo( archivaAdministration.getFileTypes(), filetypeToMapClosure );
-        fileTypeMap = filetypeToMapClosure.getMap();
-
-        AddAdminRepoConsumerClosure addAdminRepoConsumer =
-            new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
-        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
-        this.knownContentConsumers = addAdminRepoConsumer.getList();
-        Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
-
-        addAdminRepoConsumer = new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
-        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
-        this.invalidContentConsumers = addAdminRepoConsumer.getList();
-        Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
-
-        fileTypeIds = new ArrayList<String>();
-        fileTypeIds.addAll( fileTypeMap.keySet() );
-        Collections.sort( fileTypeIds );
-    }
-
-    public void setFileTypeId( String fileTypeId )
-    {
-        this.fileTypeId = fileTypeId;
-    }
-
-    public void setPattern( String pattern )
-    {
-        this.pattern = pattern;
-    }
-
-    public String updateInvalidConsumers()
-    {
-
-        try
-        {
-            List<String> oldConsumers = getArchivaAdministration().getInvalidContentConsumers();
-
-            if ( enabledInvalidContentConsumers != null )
-            {
-                for ( String oldConsumer : oldConsumers )
-                {
-                    if ( !enabledInvalidContentConsumers.contains( oldConsumer ) )
-                    {
-                        getArchivaAdministration().removeInvalidContentConsumer( oldConsumer, getAuditInformation() );
-                    }
-                }
-                for ( String enabledKnowContentConsumer : enabledInvalidContentConsumers )
-                {
-                    getArchivaAdministration().addInvalidContentConsumer( enabledKnowContentConsumer,
-                                                                          getAuditInformation() );
-                }
-            }
-            else
-            {
-                for ( String oldConsumer : oldConsumers )
-                {
-                    getArchivaAdministration().removeInvalidContentConsumer( oldConsumer, getAuditInformation() );
-                }
-            }
-        }
-        catch ( RepositoryAdminException e )
-        {
-            log.error( e.getMessage(), e );
-            addActionError( "Error update invalidContentConsumers " + e.getMessage() );
-            return INPUT;
-        }
-        addActionMessage( "Update Invalid Consumers" );
-
-        return SUCCESS;
-    }
-
-    public String updateKnownConsumers()
-    {
-
-        try
-        {
-            List<String> oldConsumers = getArchivaAdministration().getKnownContentConsumers();
-
-            if ( enabledKnownContentConsumers != null )
-            {
-                for ( String oldConsumer : oldConsumers )
-                {
-                    if ( !enabledKnownContentConsumers.contains( oldConsumer ) )
-                    {
-                        getArchivaAdministration().removeKnownContentConsumer( oldConsumer, getAuditInformation() );
-                    }
-                }
-                for ( String enabledKnowContentConsumer : enabledKnownContentConsumers )
-                {
-                    getArchivaAdministration().addKnownContentConsumer( enabledKnowContentConsumer,
-                                                                        getAuditInformation() );
-                }
-            }
-            else
-            {
-                for ( String oldConsumer : oldConsumers )
-                {
-                    getArchivaAdministration().removeKnownContentConsumer( oldConsumer, getAuditInformation() );
-                }
-            }
-        }
-        catch ( RepositoryAdminException e )
-        {
-            log.error( e.getMessage(), e );
-            addActionError( "Error update knowContentConsumers " + e.getMessage() );
-            return INPUT;
-        }
-        addActionMessage( "Update Known Consumers" );
-
-        return SUCCESS;
-    }
-
-    private FileType findFileType( String id )
-        throws RepositoryAdminException
-    {
-        return getArchivaAdministration().getFileType( id );
-    }
-
-    private boolean isValidFiletypeCommand()
-    {
-        if ( StringUtils.isBlank( getFileTypeId() ) )
-        {
-            addActionError( "Unable to process blank filetype id." );
-        }
-
-        if ( StringUtils.isBlank( getPattern() ) )
-        {
-            addActionError( "Unable to process blank pattern." );
-        }
-
-        return !hasActionErrors();
-    }
-
-
-    public List<String> getEnabledInvalidContentConsumers()
-    {
-        return enabledInvalidContentConsumers;
-    }
-
-    public void setEnabledInvalidContentConsumers( List<String> enabledInvalidContentConsumers )
-    {
-        this.enabledInvalidContentConsumers = enabledInvalidContentConsumers;
-    }
-
-    public List<String> getEnabledKnownContentConsumers()
-    {
-        return enabledKnownContentConsumers;
-    }
-
-    public void setEnabledKnownContentConsumers( List<String> enabledKnownContentConsumers )
-    {
-        this.enabledKnownContentConsumers = enabledKnownContentConsumers;
-    }
-
-    public ArchivaAdministration getArchivaAdministration()
-    {
-        return archivaAdministration;
-    }
-
-    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
-    {
-        this.archivaAdministration = archivaAdministration;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java
deleted file mode 100644 (file)
index 5478584..0000000
+++ /dev/null
@@ -1,774 +0,0 @@
-package org.apache.maven.archiva.web.action.reports;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataRepositoryException;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
-import org.apache.archiva.reports.RepositoryProblemFacet;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.maven.archiva.web.action.AbstractRepositoryBasedAction;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- *
- */
-@Controller( "generateReport" )
-@Scope( "prototype" )
-public class GenerateReportAction
-    extends AbstractRepositoryBasedAction
-    implements SecureAction, Preparable
-{
-    public static final String ALL_REPOSITORIES = "All Repositories";
-
-    public static final String BLANK = "blank";
-
-    private static final String[] datePatterns =
-        new String[]{ "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
-            "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy" };
-
-    public static final String SEND_FILE = "send-file";
-
-    private Logger log = LoggerFactory.getLogger( GenerateReportAction.class );
-
-    @Inject
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    @Inject
-    private RepositoryStatisticsManager repositoryStatisticsManager;
-
-    private String groupId;
-
-    private String repositoryId;
-
-    private int page = 1;
-
-    private int rowCount = 100;
-
-    private List<String> selectedRepositories = new ArrayList<String>();
-
-    private String startDate;
-
-    private String endDate;
-
-    private int numPages;
-
-    private List<String> repositoryIds;
-
-    private Map<String, List<RepositoryProblemFacet>> repositoriesMap =
-        new TreeMap<String, List<RepositoryProblemFacet>>();
-
-    private List<String> availableRepositories;
-
-    private List<RepositoryStatistics> repositoryStatistics = new ArrayList<RepositoryStatistics>();
-
-    private InputStream inputStream;
-
-    private boolean lastPage;
-
-    @SuppressWarnings( "unchecked" )
-    public void prepare()
-        throws RepositoryAdminException
-    {
-        repositoryIds = new ArrayList<String>();
-        repositoryIds.add( ALL_REPOSITORIES ); // comes first to be first in the list
-        repositoryIds.addAll( getObservableRepos() );
-
-        availableRepositories = new ArrayList<String>();
-
-        // remove selected repositories in the option for the statistics report
-        availableRepositories.addAll( managedRepositoryAdmin.getManagedRepositoriesAsMap().keySet() );
-        for ( String repo : selectedRepositories )
-        {
-            if ( availableRepositories.contains( repo ) )
-            {
-                availableRepositories.remove( repo );
-            }
-        }
-    }
-
-    /**
-     * Generate the statistics report.
-     * <p/>
-     * check whether single repo report or comparison report
-     * 1. if it is a single repository, get all the statistics for the repository on the specified date
-     * - if no date is specified, get only the latest
-     * (total page = 1 --> no pagination since only the most recent stats will be displayed)
-     * - otherwise, get everything within the date range (total pages = repo stats / rows per page)
-     * - required params: repository, startDate, endDate
-     * <p/>
-     * 2. if multiple repositories, get the latest statistics on each repository on the specified date
-     * - if no date is specified, use the current date endDate
-     * - required params: repositories, endDate
-     * - total pages = repositories / rows per page
-     *
-     * @return action result
-     */
-    public String generateStatistics()
-    {
-        if ( rowCount < 10 )
-        {
-            // TODO: move to validation framework
-            addFieldError( "rowCount", "Row count must be larger than 10." );
-            return INPUT;
-        }
-        Date startDateInDF;
-        Date endDateInDF;
-
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            if ( selectedRepositories.size() > 1 )
-            {
-                numPages = 1;
-
-                try
-                {
-                    startDateInDF = getStartDateInDateFormat();
-                    endDateInDF = getEndDateInDateFormat();
-                }
-                catch ( ParseException e )
-                {
-                    addActionError( "Error parsing date(s)." );
-                    return ERROR;
-                }
-
-                if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
-                {
-                    addFieldError( "startDate", "Start Date must be earlier than the End Date" );
-                    return INPUT;
-                }
-
-                // multiple repos
-                for ( String repo : selectedRepositories )
-                {
-                    List<RepositoryStatistics> stats = null;
-                    try
-                    {
-                        stats =
-                            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo, startDateInDF,
-                                                                              endDateInDF );
-                    }
-                    catch ( MetadataRepositoryException e )
-                    {
-                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
-                    }
-                    if ( stats == null || stats.isEmpty() )
-                    {
-                        log.info( "No statistics available for repository '" + repo + "'." );
-                        // TODO set repo's stats to 0
-                        continue;
-                    }
-
-                    repositoryStatistics.add( stats.get( 0 ) );
-                }
-            }
-            else if ( selectedRepositories.size() == 1 )
-            {
-                repositoryId = selectedRepositories.get( 0 );
-                try
-                {
-                    startDateInDF = getStartDateInDateFormat();
-                    endDateInDF = getEndDateInDateFormat();
-
-                    if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
-                    {
-                        addFieldError( "startDate", "Start Date must be earlier than the End Date" );
-                        return INPUT;
-                    }
-
-                    List<RepositoryStatistics> stats = null;
-                    try
-                    {
-                        stats = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repositoryId,
-                                                                                  startDateInDF, endDateInDF );
-                    }
-                    catch ( MetadataRepositoryException e )
-                    {
-                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
-                    }
-                    if ( stats == null || stats.isEmpty() )
-                    {
-                        addActionError(
-                            "No statistics available for repository. Repository might not have been scanned." );
-                        return ERROR;
-                    }
-
-                    int rowCount = getRowCount();
-                    int extraPage = ( stats.size() % rowCount ) != 0 ? 1 : 0;
-                    int totalPages = ( stats.size() / rowCount ) + extraPage;
-                    numPages = totalPages;
-
-                    int currentPage = getPage();
-                    if ( currentPage > totalPages )
-                    {
-                        addActionError(
-                            "Error encountered while generating report :: The requested page exceeds the total number of pages." );
-                        return ERROR;
-                    }
-
-                    int start = rowCount * ( currentPage - 1 );
-                    int end = ( start + rowCount ) - 1;
-
-                    if ( end >= stats.size() )
-                    {
-                        end = stats.size() - 1;
-                    }
-
-                    repositoryStatistics = stats.subList( start, end + 1 );
-                }
-                catch ( ParseException pe )
-                {
-                    addActionError( pe.getMessage() );
-                    return ERROR;
-                }
-            }
-            else
-            {
-                addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
-                return INPUT;
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        if ( repositoryStatistics.isEmpty() )
-        {
-            return BLANK;
-        }
-
-        return SUCCESS;
-    }
-
-    /**
-     * Export report to CSV.
-     *
-     * @return action result
-     */
-    public String downloadStatisticsReport()
-    {
-        Date startDateInDF;
-        Date endDateInDF;
-
-        selectedRepositories = parseSelectedRepositories();
-        List<RepositoryStatistics> repositoryStatistics = new ArrayList<RepositoryStatistics>();
-
-        StringBuilder input;
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            if ( selectedRepositories.size() > 1 )
-            {
-                try
-                {
-                    startDateInDF = getStartDateInDateFormat();
-                    endDateInDF = getEndDateInDateFormat();
-                }
-                catch ( ParseException e )
-                {
-                    addActionError( "Error parsing date(s)." );
-                    return ERROR;
-                }
-
-                if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
-                {
-                    addFieldError( "startDate", "Start Date must be earlier than the End Date" );
-                    return INPUT;
-                }
-
-                input = new StringBuilder(
-                    "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,"
-                        + "Jars,Wars\n" );
-
-                // multiple repos
-                for ( String repo : selectedRepositories )
-                {
-                    List<RepositoryStatistics> stats = null;
-                    try
-                    {
-                        stats =
-                            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repo, startDateInDF,
-                                                                              endDateInDF );
-                    }
-                    catch ( MetadataRepositoryException e )
-                    {
-                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
-                    }
-                    if ( stats == null || stats.isEmpty() )
-                    {
-                        log.info( "No statistics available for repository '" + repo + "'." );
-                        // TODO set repo's stats to 0
-                        continue;
-                    }
-
-                    // only the first one
-                    RepositoryStatistics repositoryStats = stats.get( 0 );
-                    repositoryStatistics.add( repositoryStats );
-
-                    input.append( repo ).append( "," );
-                    input.append( repositoryStats.getTotalFileCount() ).append( "," );
-                    input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
-                    input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
-                    input.append( repositoryStats.getTotalGroupCount() ).append( "," );
-                    input.append( repositoryStats.getTotalProjectCount() ).append( "," );
-                    input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
-                    input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
-                    input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
-                    input.append( repositoryStats.getTotalCountForType( "war" ) );
-                    input.append( "\n" );
-                }
-            }
-            else if ( selectedRepositories.size() == 1 )
-            {
-                repositoryId = selectedRepositories.get( 0 );
-                try
-                {
-                    startDateInDF = getStartDateInDateFormat();
-                    endDateInDF = getEndDateInDateFormat();
-
-                    if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) )
-                    {
-                        addFieldError( "startDate", "Start Date must be earlier than the End Date" );
-                        return INPUT;
-                    }
-
-                    List<RepositoryStatistics> stats = null;
-                    try
-                    {
-                        stats = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, repositoryId,
-                                                                                  startDateInDF, endDateInDF );
-                    }
-                    catch ( MetadataRepositoryException e )
-                    {
-                        log.warn( "Unable to retrieve stats, assuming is empty: " + e.getMessage(), e );
-                    }
-                    if ( stats == null || stats.isEmpty() )
-                    {
-                        addActionError(
-                            "No statistics available for repository. Repository might not have been scanned." );
-                        return ERROR;
-                    }
-
-                    input = new StringBuilder(
-                        "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,"
-                            + "Archetypes,Jars,Wars\n" );
-
-                    for ( RepositoryStatistics repositoryStats : stats )
-                    {
-                        input.append( repositoryStats.getScanStartTime() ).append( "," );
-                        input.append( repositoryStats.getTotalFileCount() ).append( "," );
-                        input.append( repositoryStats.getTotalArtifactFileSize() ).append( "," );
-                        input.append( repositoryStats.getTotalArtifactCount() ).append( "," );
-                        input.append( repositoryStats.getTotalGroupCount() ).append( "," );
-                        input.append( repositoryStats.getTotalProjectCount() ).append( "," );
-                        input.append( repositoryStats.getTotalCountForType( "maven-plugin" ) ).append( "," );
-                        input.append( repositoryStats.getTotalCountForType( "maven-archetype" ) ).append( "," );
-                        input.append( repositoryStats.getTotalCountForType( "jar" ) ).append( "," );
-                        input.append( repositoryStats.getTotalCountForType( "war" ) );
-                        input.append( "\n" );
-                    }
-
-                    repositoryStatistics = stats;
-                }
-                catch ( ParseException pe )
-                {
-                    addActionError( pe.getMessage() );
-                    return ERROR;
-                }
-            }
-            else
-            {
-                addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
-                return INPUT;
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        if ( repositoryStatistics.isEmpty() )
-        {
-            return BLANK;
-        }
-
-        // write output stream depending on single or comparison report
-        StringReader reader = new StringReader( input.toString() );
-
-        try
-        {
-            inputStream = new ByteArrayInputStream( IOUtils.toByteArray( reader ) );
-        }
-        catch ( IOException i )
-        {
-            addActionError( "Error occurred while generating CSV file." );
-            return ERROR;
-        }
-
-        return SEND_FILE;
-    }
-
-    // hack for parsing the struts list passed as param in <s:url ../>
-
-    private List<String> parseSelectedRepositories()
-    {
-        List<String> parsedSelectedRepos = new ArrayList<String>();
-
-        for ( String repo : selectedRepositories )
-        {
-            String[] tokens = StringUtils.split( repo, ',' );
-            if ( tokens.length > 1 )
-            {
-                for ( String token : tokens )
-                {
-                    parsedSelectedRepos.add( StringUtils.remove( StringUtils.remove( token, '[' ), ']' ).trim() );
-                }
-            }
-            else
-            {
-                parsedSelectedRepos.add( StringUtils.remove( StringUtils.remove( repo, '[' ), ']' ).trim() );
-            }
-        }
-        return parsedSelectedRepos;
-    }
-
-    private Date getStartDateInDateFormat()
-        throws ParseException
-    {
-        Date startDateInDF;
-        if ( startDate == null || "".equals( startDate ) )
-        {
-            startDateInDF = null;
-        }
-        else
-        {
-            startDateInDF = DateUtils.parseDate( startDate, datePatterns );
-        }
-        return startDateInDF;
-    }
-
-    private Date getEndDateInDateFormat()
-        throws ParseException
-    {
-        Date endDateInDF;
-        if ( endDate == null || "".equals( endDate ) )
-        {
-            endDateInDF = null;
-        }
-        else
-        {
-            endDateInDF = DateUtils.parseDate( endDate, datePatterns );
-
-            // add a day, since we don't inclue time and want the date to be inclusive
-            Calendar cal = Calendar.getInstance();
-            cal.setTime( endDateInDF );
-            cal.add( Calendar.DAY_OF_MONTH, 1 );
-            endDateInDF = cal.getTime();
-        }
-
-        return endDateInDF;
-    }
-
-    public String execute()
-        throws Exception
-    {
-        if ( repositoryId == null )
-        {
-            addFieldError( "repositoryId", "You must provide a repository id." );
-            return INPUT;
-        }
-
-        if ( rowCount < 10 )
-        {
-            addFieldError( "rowCount", "Row count must be larger than 10." );
-            return INPUT;
-        }
-
-        List<String> observableRepos = getObservableRepos();
-        Collection<String> repoIds;
-        if ( StringUtils.isEmpty( repositoryId ) || ALL_REPOSITORIES.equals( repositoryId ) )
-        {
-            repoIds = observableRepos;
-        }
-        else if ( observableRepos.contains( repositoryId ) )
-        {
-            repoIds = Collections.singletonList( repositoryId );
-        }
-        else
-        {
-            repoIds = Collections.emptyList();
-        }
-
-        List<RepositoryProblemFacet> problemArtifacts = new ArrayList<RepositoryProblemFacet>();
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            MetadataRepository metadataRepository = repositorySession.getRepository();
-            for ( String repoId : repoIds )
-            {
-                // TODO: improve performance by navigating into a group subtree. Currently group is property, not part of name of item
-                for ( String name : metadataRepository.getMetadataFacets( repoId, RepositoryProblemFacet.FACET_ID ) )
-                {
-                    RepositoryProblemFacet metadataFacet =
-                        (RepositoryProblemFacet) metadataRepository.getMetadataFacet( repoId,
-                                                                                      RepositoryProblemFacet.FACET_ID,
-                                                                                      name );
-
-                    if ( StringUtils.isEmpty( groupId ) || groupId.equals( metadataFacet.getNamespace() ) )
-                    {
-                        problemArtifacts.add( metadataFacet );
-                    }
-                }
-            }
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        // TODO: getting range only after reading is not efficient for a large number of artifacts
-        int lowerBound = ( page - 1 ) * rowCount;
-        int upperBound = ( page * rowCount ) + 1; // Add 1 to check if it's the last page or not.
-        if ( upperBound <= problemArtifacts.size() )
-        {
-            problemArtifacts = problemArtifacts.subList( lowerBound, upperBound );
-        }
-        else
-        {
-            problemArtifacts = problemArtifacts.subList( lowerBound, problemArtifacts.size() );
-        }
-
-        for ( RepositoryProblemFacet problem : problemArtifacts )
-        {
-            List<RepositoryProblemFacet> problemsList;
-            if ( repositoriesMap.containsKey( problem.getRepositoryId() ) )
-            {
-                problemsList = repositoriesMap.get( problem.getRepositoryId() );
-            }
-            else
-            {
-                problemsList = new ArrayList<RepositoryProblemFacet>();
-                repositoriesMap.put( problem.getRepositoryId(), problemsList );
-            }
-
-            problemsList.add( problem );
-        }
-
-        // TODO: handling should be improved
-        if ( problemArtifacts.size() <= rowCount )
-        {
-            lastPage = true;
-        }
-
-        if ( problemArtifacts.isEmpty() && page == 1 )
-        {
-            return BLANK;
-        }
-        else
-        {
-            return SUCCESS;
-        }
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_ACCESS_REPORT, Resource.GLOBAL );
-
-        return bundle;
-    }
-
-    public List<String> getRepositoryIds()
-    {
-        return repositoryIds;
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public String getRepositoryId()
-    {
-        return repositoryId;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-        this.repositoryId = repositoryId;
-    }
-
-    public int getPage()
-    {
-        return page;
-    }
-
-    public void setPage( int page )
-    {
-        this.page = page;
-    }
-
-    public int getRowCount()
-    {
-        return rowCount;
-    }
-
-    public void setRowCount( int rowCount )
-    {
-        this.rowCount = rowCount;
-    }
-
-    public void setRepositoriesMap( Map<String, List<RepositoryProblemFacet>> repositoriesMap )
-    {
-        this.repositoriesMap = repositoriesMap;
-    }
-
-    public Map<String, List<RepositoryProblemFacet>> getRepositoriesMap()
-    {
-        return repositoriesMap;
-    }
-
-    public List<String> getSelectedRepositories()
-    {
-        return selectedRepositories;
-    }
-
-    public void setSelectedRepositories( List<String> selectedRepositories )
-    {
-        this.selectedRepositories = selectedRepositories;
-    }
-
-    public List<String> getAvailableRepositories()
-    {
-        return availableRepositories;
-    }
-
-    public void setAvailableRepositories( List<String> availableRepositories )
-    {
-        this.availableRepositories = availableRepositories;
-    }
-
-    public String getStartDate()
-    {
-        return startDate;
-    }
-
-    public void setStartDate( String startDate )
-    {
-        this.startDate = startDate;
-    }
-
-    public String getEndDate()
-    {
-        return endDate;
-    }
-
-    public void setEndDate( String endDate )
-    {
-        this.endDate = endDate;
-    }
-
-    public List<RepositoryStatistics> getRepositoryStatistics()
-    {
-        return repositoryStatistics;
-    }
-
-    public void setRepositoryStatistics( List<RepositoryStatistics> repositoryStatistics )
-    {
-        this.repositoryStatistics = repositoryStatistics;
-    }
-
-    public boolean isLastPage()
-    {
-        return lastPage;
-    }
-
-    public void setLastPage( boolean lastPage )
-    {
-        this.lastPage = lastPage;
-    }
-
-    public InputStream getInputStream()
-    {
-        return inputStream;
-    }
-
-    public int getNumPages()
-    {
-        return numPages;
-    }
-
-    public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
-    {
-        this.repositoryStatisticsManager = repositoryStatisticsManager;
-    }
-
-    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return managedRepositoryAdmin;
-    }
-
-    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
-    {
-        this.managedRepositoryAdmin = managedRepositoryAdmin;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
deleted file mode 100644 (file)
index 9d2f4f0..0000000
+++ /dev/null
@@ -1,408 +0,0 @@
-package org.apache.maven.archiva.web.action.reports;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Preparable;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.AuditManager;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.archiva.security.AccessDeniedException;
-import org.apache.archiva.security.ArchivaSecurityException;
-import org.apache.archiva.security.PrincipalNotFoundException;
-import org.apache.archiva.security.UserRepositories;
-import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.apache.struts2.interceptor.ServletRequestAware;
-import org.codehaus.redback.integration.interceptor.SecureAction;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Controller;
-
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-/**
- *
- */
-@Controller( "viewAuditLogReport" )
-@Scope( "prototype" )
-public class ViewAuditLogReportAction
-    extends AbstractActionSupport
-    implements SecureAction, ServletRequestAware, Preparable
-{
-    protected HttpServletRequest request;
-
-    @Inject
-    private UserRepositories userRepositories;
-
-    @Inject
-    private AuditManager auditManager;
-
-    private String repository;
-
-    private List<String> repositories;
-
-    private String groupId;
-
-    private String artifactId;
-
-    private String startDate;
-
-    private String endDate;
-
-    private int rowCount = 30;
-
-    private int page = 1;
-
-    protected boolean isLastPage = true;
-
-    private List<AuditEvent> auditLogs;
-
-    private static final String ALL_REPOSITORIES = "all";
-
-    private String initial = "true";
-
-    private String headerName;
-
-    private static final String HEADER_LATEST_EVENTS = "Latest Events";
-
-    private static final String HEADER_RESULTS = "Results";
-
-    private String[] datePatterns =
-    new String[]{ "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
-    "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy" };
-
-
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-
-        // TODO: should require this, but for now we trust in the list of repositories
-//        bundle.setRequiresAuthentication( true );
-//        bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_VIEW_AUDIT_LOG );
-
-        return bundle;
-    }
-
-    public void setServletRequest( HttpServletRequest request )
-    {
-        this.request = request;
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public void prepare()
-        throws Exception
-    {
-        repositories = new ArrayList<String>();
-        repositories.add( ALL_REPOSITORIES );
-        List<String> repos = getManagableRepositories();
-        repositories.addAll( repos );
-
-        auditLogs = null;
-        groupId = "";
-        artifactId = "";
-        repository = "";
-
-        if ( Boolean.parseBoolean( initial ) )
-        {
-            headerName = HEADER_LATEST_EVENTS;
-        }
-        else
-        {
-            headerName = HEADER_RESULTS;
-        }
-
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            auditLogs = auditManager.getMostRecentAuditEvents( repositorySession.getRepository(), repos );
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-    }
-
-    public String execute()
-        throws Exception
-    {
-        Date startDateInDF = null;
-        Date endDateInDF = null;
-        if ( !StringUtils.isEmpty( startDate ) )
-        {
-            startDateInDF = DateUtils.parseDate( startDate, datePatterns );
-        }
-
-        if ( !StringUtils.isEmpty( endDate ) )
-        {
-            endDateInDF = DateUtils.parseDate( endDate, datePatterns );
-            Calendar cal = Calendar.getInstance();
-            cal.setTime( endDateInDF );
-            cal.set( Calendar.HOUR, 23 );
-            cal.set( Calendar.MINUTE, 59 );
-            cal.set( Calendar.SECOND, 59 );
-
-            endDateInDF = cal.getTime();
-        }
-
-        Collection<String> repos = getManagableRepositories();
-        if ( !repository.equals( ALL_REPOSITORIES ) )
-        {
-            if ( repos.contains( repository ) )
-            {
-                repos = Collections.singletonList( repository );
-            }
-            else
-            {
-                repos = Collections.emptyList();
-            }
-        }
-
-        if ( StringUtils.isEmpty( groupId ) && !StringUtils.isEmpty( artifactId ) )
-        {
-            // Until we store the full artifact metadata in the audit event, we can't query by these individually
-            addActionError( "If you specify an artifact ID, you must specify a group ID" );
-            auditLogs = null;
-            return INPUT;
-        }
-
-        String resource = null;
-        if ( !StringUtils.isEmpty( groupId ) )
-        {
-            String groupIdAsPath = groupId.replace( '.', '/' );
-            if ( StringUtils.isEmpty( artifactId ) )
-            {
-                resource = groupIdAsPath;
-            }
-            else
-            {
-                resource = groupIdAsPath + "/" + artifactId;
-            }
-        }
-
-        RepositorySession repositorySession = repositorySessionFactory.createSession();
-        try
-        {
-            auditLogs =
-                auditManager.getAuditEventsInRange( repositorySession.getRepository(), repos, resource, startDateInDF,
-                                                    endDateInDF );
-        }
-        finally
-        {
-            repositorySession.close();
-        }
-
-        headerName = HEADER_RESULTS;
-
-        if ( auditLogs.isEmpty() )
-        {
-            addActionError( "No audit logs found." );
-            initial = "true";
-            return SUCCESS;
-        }
-        else
-        {
-            initial = "false";
-            return paginate();
-        }
-    }
-
-    private String paginate()
-    {
-        int rowCount = getRowCount();
-        int extraPage = ( auditLogs.size() % rowCount ) != 0 ? 1 : 0;
-        int totalPages = ( auditLogs.size() / rowCount ) + extraPage;
-
-        int currentPage = getPage();
-        if ( currentPage > totalPages )
-        {
-            addActionError(
-                "Error encountered while generating report :: The requested page exceeds the total number of pages." );
-            return ERROR;
-        }
-
-        if ( currentPage == totalPages )
-        {
-            isLastPage = true;
-        }
-        else
-        {
-            isLastPage = false;
-        }
-
-        int start = rowCount * ( currentPage - 1 );
-        int end = ( start + rowCount ) - 1;
-
-        if ( end >= auditLogs.size() )
-        {
-            end = auditLogs.size() - 1;
-        }
-
-        auditLogs = auditLogs.subList( start, end + 1 );
-
-        return SUCCESS;
-    }
-
-    private List<String> getManagableRepositories()
-    {
-        try
-        {
-            return userRepositories.getManagableRepositoryIds( getPrincipal() );
-        }
-        catch ( PrincipalNotFoundException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        catch ( AccessDeniedException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        catch ( ArchivaSecurityException e )
-        {
-            log.warn( e.getMessage(), e );
-        }
-        return Collections.emptyList();
-    }
-
-    public String getRepository()
-    {
-        return repository;
-    }
-
-    public void setRepository( String repository )
-    {
-        this.repository = repository;
-    }
-
-    public List<String> getRepositories()
-    {
-        return repositories;
-    }
-
-    public void setRepositories( List<String> repositories )
-    {
-        this.repositories = repositories;
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = artifactId;
-    }
-
-    public List<AuditEvent> getAuditLogs()
-    {
-        return auditLogs;
-    }
-
-    public int getRowCount()
-    {
-        return rowCount;
-    }
-
-    public void setRowCount( int rowCount )
-    {
-        this.rowCount = rowCount;
-    }
-
-    public String getStartDate()
-    {
-        return startDate;
-    }
-
-    public void setStartDate( String startDate )
-    {
-        this.startDate = startDate;
-    }
-
-    public String getEndDate()
-    {
-        return endDate;
-    }
-
-    public void setEndDate( String endDate )
-    {
-        this.endDate = endDate;
-    }
-
-    public int getPage()
-    {
-        return page;
-    }
-
-    public void setPage( int page )
-    {
-        this.page = page;
-    }
-
-    public boolean getIsLastPage()
-    {
-        return isLastPage;
-    }
-
-    public void setIsLastPage( boolean isLastPage )
-    {
-        this.isLastPage = isLastPage;
-    }
-
-    public String getInitial()
-    {
-        return initial;
-    }
-
-    public void setInitial( String initial )
-    {
-        this.initial = initial;
-    }
-
-    public String getHeaderName()
-    {
-        return headerName;
-    }
-
-    public void setHeaderName( String headerName )
-    {
-        this.headerName = headerName;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/DeleteArtifactAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/DeleteArtifactAction-validation.xml
new file mode 100644 (file)
index 0000000..bfe08fa
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<!-- validate temporarily-trimmed inputs, actual values are then carried over to the action class to be trimmed once more. -->
+<validators>
+  <field name="groupId">
+    <field-validator type="requiredstring">
+      <message>You must enter a groupId.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="artifactId">
+    <field-validator type="requiredstring">
+      <message>You must enter an artifactId.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <!-- version's validation is inside the validate() method of the action class -->
+  <field name="version">
+    <field-validator type="requiredstring">
+      <message>You must enter a version.</message>
+    </field-validator>
+  </field>
+  <field name="repositoryId">
+    <!-- no requiredstring validation, because there was none before(being consistent). -->
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]*$</param>
+        <message>Repository id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-checksumSearch-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-checksumSearch-validation.xml
new file mode 100644 (file)
index 0000000..712e291
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="q">
+    <field-validator type="requiredstring">
+      <message>
+        You must select a file, or enter the checksum. If the file was given and you receive this message,
+        there may have been an error generating the checksum.
+      </message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-filteredSearch-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-filteredSearch-validation.xml
new file mode 100644 (file)
index 0000000..5f9c897
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="rowCount">
+    <field-validator type="int">
+      <message>Invalid entry</message>
+    </field-validator>
+    <field-validator type="int">
+    <param name="min">1</param>
+      <message>Row count must be larger than ${min}.</message>
+    </field-validator>
+  </field>
+</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-quickSearch-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/SearchAction-quickSearch-validation.xml
new file mode 100644 (file)
index 0000000..705f0be
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="q">
+    <field-validator type="requiredstring">
+      <message>You must enter some search terms.</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/UploadAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/UploadAction-validation.xml
new file mode 100644 (file)
index 0000000..b56cf37
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="groupId">
+    <field-validator type="requiredstring">
+      <message>You must enter a groupId.</message>
+    </field-validator>
+  </field>
+  <field name="artifactId">
+    <field-validator type="requiredstring">
+      <message>You must enter an artifactId.</message>
+    </field-validator>
+  </field>
+  <field name="version">
+    <field-validator type="requiredstring">
+      <message>You must enter a version.</message>
+    </field-validator>
+  </field>   
+  <field name="packaging">
+    <field-validator type="requiredstring">
+      <message>You must enter a packaging.</message>
+    </field-validator>
+  </field>   
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAction-validation.xml
new file mode 100644 (file)
index 0000000..3253d2e
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="indexPath">
+    <field-validator type="requiredstring">
+      <message>You must enter the index directory.</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance-validation.xml
new file mode 100644 (file)
index 0000000..64c011f
--- /dev/null
@@ -0,0 +1,35 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC
+    "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="organisationUrl">
+    <field-validator type="url">
+      <message key="appearance.organisation.url"/>
+    </field-validator>
+  </field>
+  <field name="organisationLogo">
+    <field-validator type="url">
+      <message key="appearance.organisation.logourl"/>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance.properties b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance.properties
new file mode 100644 (file)
index 0000000..2084ccd
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+appearance.organisation.url = You must define an organisation url."
+appearance.organisation.logourl = You must define an organisation logo url."
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance_en.properties b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureAppearance_en.properties
new file mode 100644 (file)
index 0000000..661b0cb
--- /dev/null
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml
new file mode 100644 (file)
index 0000000..74f61f4
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="id">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository identifier.</message>
+    </field-validator>
+    <!--field-validator type="regex">
+      <param name="expression"><![CDATA[([A-Z][a-z][0-9])]]></param>
+      <message>Id must not have special characters.</message>
+    </field-validator-->
+  </field>
+  <field name="name">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository name.</message>
+    </field-validator>
+  </field>
+
+  <field name="url">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository URL.</message>
+    </field-validator>
+  </field>
+  <field name="snapshotsInterval">
+    <field-validator type="regex">
+      <param name="expression"><![CDATA[([0-9])]]></param>
+      <message>The value must be numeric</message>
+    </field-validator>
+  </field>
+  <field name="releasesInterval">
+    <field-validator type="regex">
+      <param name="expression"><![CDATA[([0-9])]]></param>
+      <message>The value must be numeric</message>
+    </field-validator>
+  </field>
+
+  <!-- TODO: is the validation correct? -->
+  <validator type="interval">
+    <message/>
+  </validator>
+
+  <field name="layout">
+    <field-validator type="required">
+      <message>Repository type is required.</message>
+    </field-validator>
+    <field-validator type="fieldexpression">
+      <param name="expression">layout in {"legacy", "default"}</param>
+      <message>Invalid repository type.</message>
+    </field-validator>
+  </field>
+  <field name="snapshotsPolicy">
+    <field-validator type="fieldexpression">
+      <param name="expression">snapshotsPolicy in { "disabled", "daily", "hourly", "never", "interval" }</param>
+      <message>Invalid snapshot policy.</message>
+    </field-validator>
+  </field>
+  <field name="releasesPolicy">
+    <field-validator type="fieldexpression">
+      <param name="expression">releasesPolicy in { "disabled", "daily", "hourly", "never", "interval" }</param>
+      <message>Invalid releases policy.</message>
+    </field-validator>
+  </field>
+
+  <field name="managedRepository">
+    <field-validator type="requiredstring">
+      <message>A managed repository must be selected.</message>
+    </field-validator>
+  </field>
+
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureRepositoryAction-validation.xml
new file mode 100644 (file)
index 0000000..7d38693
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="id">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository identifier.</message>
+    </field-validator>
+  </field>
+  <field name="urlName">
+    <field-validator type="requiredstring">
+      <message>You must enter the url name.</message>
+    </field-validator>
+  </field>
+  <field name="name">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository name.</message>
+    </field-validator>
+  </field>
+  <field name="directory">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository directory.</message>
+    </field-validator>
+  </field>
+  <field name="layout">
+    <field-validator type="fieldexpression">
+      <param name="expression">layout in {"legacy", "default"}</param>
+      <message>Invalid repository type.</message>
+    </field-validator>
+  </field>
+</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureSyncedRepositoryAction-addSelectedSyncedRepository-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureSyncedRepositoryAction-addSelectedSyncedRepository-validation.xml
new file mode 100644 (file)
index 0000000..d31c27c
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="id">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository identifier.</message>
+    </field-validator>
+  </field>
+  <field name="name">
+    <field-validator type="requiredstring">
+      <message>You must enter the repository name.</message>
+    </field-validator>
+  </field>
+  <field name="layout">
+    <field-validator type="requiredstring">
+      <message>Select repository type.</message>
+    </field-validator>
+    <field-validator type="fieldexpression">
+      <param name="expression">layout in {"legacy", "default"}</param>
+      <message>Invalid repository type.</message>
+    </field-validator>
+  </field>
+  <field name="managedRepository">
+    <field-validator type="requiredstring">
+      <message>A managed repository must be selected.</message>
+    </field-validator>
+  </field>
+
+  <validator type="syncedrepo">
+    <message/>
+  </validator>
+
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureSyncedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/ConfigureSyncedRepositoryAction-validation.xml
new file mode 100644 (file)
index 0000000..483ebdd
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="method">
+    <field-validator type="requiredstring">
+      <message>You must enter the synchronization method.</message>
+    </field-validator>
+    <field-validator type="fieldexpression">
+      <param name="expression">method in { "rsync", "cvs", "svn", "file" }</param>
+      <message>Invalid method.</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml
new file mode 100644 (file)
index 0000000..bc3d556
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+    <field name="organisationName">
+        <field-validator type="requiredstring">
+            <message>You must enter a name</message>
+        </field-validator>
+        <field-validator type="regex">
+            <param name="trim">true</param>
+            <param name="expression">^([-a-zA-Z0-9._/~:?!&amp;=\\]|\s)+$</param>
+            <message>Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
+        </field-validator>
+    </field>
+    <field name="organisationUrl">
+        <field-validator type="url">
+            <message>You must enter a URL.</message>
+        </field-validator>
+    </field>
+    <field name="organisationLogo">
+        <field-validator type="url">
+            <message>You must enter a URL for your logo.</message>
+        </field-validator>
+    </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml
new file mode 100644 (file)
index 0000000..5c6e25c
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="connector.sourceRepoId">
+    <field-validator type="requiredstring">
+      <param name="trim">true</param>
+      <message>You must select a source repository Id.</message>
+    </field-validator>
+  </field>
+  <field name="connector.targetRepoId">
+    <field-validator type="requiredstring">
+      <param name="trim">true</param>
+      <message>You must select a target repository Id.</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml
new file mode 100644 (file)
index 0000000..bbf09dd
--- /dev/null
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<!-- validate temporarily-trimmed inputs, actual values are then carried over to the action class to be trimmed once more. -->
+<validators>
+  <field name="legacyArtifactPath.path">
+    <field-validator type="requiredstring">
+      <message>You must enter a legacy path.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9._/\\]+$</param>
+        <message>Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\), underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="groupId">
+    <field-validator type="requiredstring">
+      <message>You must enter a groupId.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="artifactId">
+    <field-validator type="requiredstring">
+      <message>You must enter an artifactId.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="version">
+    <field-validator type="requiredstring">
+      <message>You must enter a version.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="classifier">
+    <!-- no requiredstring validation, because there was none before(being consistent). -->
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]*$</param>
+        <message>Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="type">
+    <field-validator type="requiredstring">
+      <message>You must enter a type.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml
new file mode 100644 (file)
index 0000000..669b3b1
--- /dev/null
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+
+
+<validators>
+  <field name="proxy.id">
+    <field-validator type="requiredstring">
+      <param name="trim">true</param>
+      <message>You must enter an identifier.</message>
+    </field-validator>
+    <field-validator type="stringlength">
+      <param name="minLength">4</param>
+      <param name="maxLength">45</param>
+      <param name="trim">true</param>
+      <message>You must enter an identifier of 4 or more than 4 characters.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="proxy.protocol">
+    <field-validator type="requiredstring">
+      <param name="trim">true</param>
+      <message>You must enter a protocol.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9./:\\]+$</param>
+        <message>Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\), dots(.), colons(:), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="proxy.host">
+    <field-validator type="requiredstring">
+      <param name="trim">true</param>
+      <message>You must enter a host.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]+$</param>
+        <message>Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="proxy.port">
+    <field-validator type="required">
+      <message>You must enter an port.</message>
+    </field-validator>
+    <field-validator type="int">
+      <param name="min">1</param>
+<!-- Webwork bug renders this as 65.535
+      <param name="max">65535</param>
+      <message>Port needs to be between ${min} and ${max}</message>
+-->
+      <message>Port needs to be larger than ${min}</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[0-9]+$</param>
+        <message>Port must only contain numeric characters.</message>
+    </field-validator>
+  </field>
+  <field name="proxy.username">
+    <!-- no requiredstring validation, because there was none before(being consistent). -->
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9.@/_\\]*$</param>
+        <message>Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\), underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryAction-validation.xml
new file mode 100644 (file)
index 0000000..8c951cb
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="repository.id">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository identifier.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="repository.location">
+    <field-validator type="requiredstring">
+      <message>You must enter a directory.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]+$</param>
+        <message>Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="repository.indexDirectory">
+    <!-- no requiredstring validation, because there was none before(being consistent). -->
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]*$</param>
+        <message>Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="repository.name">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository name.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^([a-zA-Z0-9.)/_(-]|\s)+$</param>
+        <message>Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>   
+  <field name="repository.retentionCount">
+    <field-validator type="int">
+      <param name="min">1</param>
+      <param name="max">100</param>
+      <message>Repository Purge By Retention Count needs to be between ${min} and ${max}.</message>
+    </field-validator>    
+  </field>
+  <field name="repository.daysOlder">
+    <field-validator type="int">
+      <param name="min">0</param>
+      <message>Repository Purge By Days Older Than needs to be larger than ${min}.</message>
+    </field-validator>    
+  </field>
+</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryAction-validation.xml
new file mode 100644 (file)
index 0000000..7902bc5
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="repository.id">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository identifier.</message>
+    </field-validator>
+  </field>
+  <field name="repository.url">
+    <field-validator type="requiredstring">
+      <message>You must enter a url.</message>
+    </field-validator>
+  </field>
+  <field name="repository.name">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository name.</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryAction-validation.xml
new file mode 100644 (file)
index 0000000..abc9e55
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="repository.id">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository identifier.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[a-zA-Z0-9._-]+$</param>
+        <message>Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="repository.location">
+    <field-validator type="requiredstring">
+      <message>You must enter a directory.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]+$</param>
+        <message>Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="repository.indexDirectory">
+    <!-- no requiredstring validation, because there was none before(being consistent). -->
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]*$</param>
+        <message>Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="repository.name">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository name.</message>
+    </field-validator>
+    <field-validator type="regex">
+        <param name="trim">true</param>
+        <param name="expression">^([a-zA-Z0-9.)/_(-]|\s)+$</param>
+        <message>Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-).</message>
+    </field-validator>
+  </field>
+  <field name="repository.retentionCount">
+    <field-validator type="int">
+      <param name="min">1</param>
+      <param name="max">100</param>
+      <message>Repository Purge By Retention Count needs to be between ${min} and ${max}.</message>
+    </field-validator>
+  </field>
+  <field name="repository.daysOlder">
+    <field-validator type="int">
+      <param name="min">0</param>
+      <message>Repository Purge By Days Older Than needs to be larger than ${min}.</message>
+    </field-validator>
+  </field>
+</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryAction-validation.xml
new file mode 100644 (file)
index 0000000..7902bc5
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+  <field name="repository.id">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository identifier.</message>
+    </field-validator>
+  </field>
+  <field name="repository.url">
+    <field-validator type="requiredstring">
+      <message>You must enter a url.</message>
+    </field-validator>
+  </field>
+  <field name="repository.name">
+    <field-validator type="requiredstring">
+      <message>You must enter a repository name.</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/DeleteArtifactAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/DeleteArtifactAction-validation.xml
deleted file mode 100644 (file)
index bfe08fa..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<!-- validate temporarily-trimmed inputs, actual values are then carried over to the action class to be trimmed once more. -->
-<validators>
-  <field name="groupId">
-    <field-validator type="requiredstring">
-      <message>You must enter a groupId.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="artifactId">
-    <field-validator type="requiredstring">
-      <message>You must enter an artifactId.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <!-- version's validation is inside the validate() method of the action class -->
-  <field name="version">
-    <field-validator type="requiredstring">
-      <message>You must enter a version.</message>
-    </field-validator>
-  </field>
-  <field name="repositoryId">
-    <!-- no requiredstring validation, because there was none before(being consistent). -->
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]*$</param>
-        <message>Repository id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-checksumSearch-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-checksumSearch-validation.xml
deleted file mode 100644 (file)
index 712e291..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="q">
-    <field-validator type="requiredstring">
-      <message>
-        You must select a file, or enter the checksum. If the file was given and you receive this message,
-        there may have been an error generating the checksum.
-      </message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-filteredSearch-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-filteredSearch-validation.xml
deleted file mode 100644 (file)
index 5f9c897..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="rowCount">
-    <field-validator type="int">
-      <message>Invalid entry</message>
-    </field-validator>
-    <field-validator type="int">
-    <param name="min">1</param>
-      <message>Row count must be larger than ${min}.</message>
-    </field-validator>
-  </field>
-</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-quickSearch-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/SearchAction-quickSearch-validation.xml
deleted file mode 100644 (file)
index 705f0be..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="q">
-    <field-validator type="requiredstring">
-      <message>You must enter some search terms.</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/UploadAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/UploadAction-validation.xml
deleted file mode 100644 (file)
index b56cf37..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="groupId">
-    <field-validator type="requiredstring">
-      <message>You must enter a groupId.</message>
-    </field-validator>
-  </field>
-  <field name="artifactId">
-    <field-validator type="requiredstring">
-      <message>You must enter an artifactId.</message>
-    </field-validator>
-  </field>
-  <field name="version">
-    <field-validator type="requiredstring">
-      <message>You must enter a version.</message>
-    </field-validator>
-  </field>   
-  <field name="packaging">
-    <field-validator type="requiredstring">
-      <message>You must enter a packaging.</message>
-    </field-validator>
-  </field>   
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAction-validation.xml
deleted file mode 100644 (file)
index 3253d2e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="indexPath">
-    <field-validator type="requiredstring">
-      <message>You must enter the index directory.</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance-validation.xml
deleted file mode 100644 (file)
index 64c011f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC
-    "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="organisationUrl">
-    <field-validator type="url">
-      <message key="appearance.organisation.url"/>
-    </field-validator>
-  </field>
-  <field name="organisationLogo">
-    <field-validator type="url">
-      <message key="appearance.organisation.logourl"/>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance.properties b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance.properties
deleted file mode 100644 (file)
index 2084ccd..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-appearance.organisation.url = You must define an organisation url."
-appearance.organisation.logourl = You must define an organisation logo url."
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance_en.properties b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureAppearance_en.properties
deleted file mode 100644 (file)
index 661b0cb..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml
deleted file mode 100644 (file)
index 74f61f4..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="id">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository identifier.</message>
-    </field-validator>
-    <!--field-validator type="regex">
-      <param name="expression"><![CDATA[([A-Z][a-z][0-9])]]></param>
-      <message>Id must not have special characters.</message>
-    </field-validator-->
-  </field>
-  <field name="name">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository name.</message>
-    </field-validator>
-  </field>
-
-  <field name="url">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository URL.</message>
-    </field-validator>
-  </field>
-  <field name="snapshotsInterval">
-    <field-validator type="regex">
-      <param name="expression"><![CDATA[([0-9])]]></param>
-      <message>The value must be numeric</message>
-    </field-validator>
-  </field>
-  <field name="releasesInterval">
-    <field-validator type="regex">
-      <param name="expression"><![CDATA[([0-9])]]></param>
-      <message>The value must be numeric</message>
-    </field-validator>
-  </field>
-
-  <!-- TODO: is the validation correct? -->
-  <validator type="interval">
-    <message/>
-  </validator>
-
-  <field name="layout">
-    <field-validator type="required">
-      <message>Repository type is required.</message>
-    </field-validator>
-    <field-validator type="fieldexpression">
-      <param name="expression">layout in {"legacy", "default"}</param>
-      <message>Invalid repository type.</message>
-    </field-validator>
-  </field>
-  <field name="snapshotsPolicy">
-    <field-validator type="fieldexpression">
-      <param name="expression">snapshotsPolicy in { "disabled", "daily", "hourly", "never", "interval" }</param>
-      <message>Invalid snapshot policy.</message>
-    </field-validator>
-  </field>
-  <field name="releasesPolicy">
-    <field-validator type="fieldexpression">
-      <param name="expression">releasesPolicy in { "disabled", "daily", "hourly", "never", "interval" }</param>
-      <message>Invalid releases policy.</message>
-    </field-validator>
-  </field>
-
-  <field name="managedRepository">
-    <field-validator type="requiredstring">
-      <message>A managed repository must be selected.</message>
-    </field-validator>
-  </field>
-
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction-validation.xml
deleted file mode 100644 (file)
index 7d38693..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="id">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository identifier.</message>
-    </field-validator>
-  </field>
-  <field name="urlName">
-    <field-validator type="requiredstring">
-      <message>You must enter the url name.</message>
-    </field-validator>
-  </field>
-  <field name="name">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository name.</message>
-    </field-validator>
-  </field>
-  <field name="directory">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository directory.</message>
-    </field-validator>
-  </field>
-  <field name="layout">
-    <field-validator type="fieldexpression">
-      <param name="expression">layout in {"legacy", "default"}</param>
-      <message>Invalid repository type.</message>
-    </field-validator>
-  </field>
-</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction-addSelectedSyncedRepository-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction-addSelectedSyncedRepository-validation.xml
deleted file mode 100644 (file)
index d31c27c..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="id">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository identifier.</message>
-    </field-validator>
-  </field>
-  <field name="name">
-    <field-validator type="requiredstring">
-      <message>You must enter the repository name.</message>
-    </field-validator>
-  </field>
-  <field name="layout">
-    <field-validator type="requiredstring">
-      <message>Select repository type.</message>
-    </field-validator>
-    <field-validator type="fieldexpression">
-      <param name="expression">layout in {"legacy", "default"}</param>
-      <message>Invalid repository type.</message>
-    </field-validator>
-  </field>
-  <field name="managedRepository">
-    <field-validator type="requiredstring">
-      <message>A managed repository must be selected.</message>
-    </field-validator>
-  </field>
-
-  <validator type="syncedrepo">
-    <message/>
-  </validator>
-
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/ConfigureSyncedRepositoryAction-validation.xml
deleted file mode 100644 (file)
index 483ebdd..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="method">
-    <field-validator type="requiredstring">
-      <message>You must enter the synchronization method.</message>
-    </field-validator>
-    <field-validator type="fieldexpression">
-      <param name="expression">method in { "rsync", "cvs", "svn", "file" }</param>
-      <message>Invalid method.</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction-validation.xml
deleted file mode 100644 (file)
index bc3d556..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-    <field name="organisationName">
-        <field-validator type="requiredstring">
-            <message>You must enter a name</message>
-        </field-validator>
-        <field-validator type="regex">
-            <param name="trim">true</param>
-            <param name="expression">^([-a-zA-Z0-9._/~:?!&amp;=\\]|\s)+$</param>
-            <message>Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
-        </field-validator>
-    </field>
-    <field name="organisationUrl">
-        <field-validator type="url">
-            <message>You must enter a URL.</message>
-        </field-validator>
-    </field>
-    <field name="organisationLogo">
-        <field-validator type="url">
-            <message>You must enter a URL for your logo.</message>
-        </field-validator>
-    </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml
deleted file mode 100644 (file)
index 5c6e25c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="connector.sourceRepoId">
-    <field-validator type="requiredstring">
-      <param name="trim">true</param>
-      <message>You must select a source repository Id.</message>
-    </field-validator>
-  </field>
-  <field name="connector.targetRepoId">
-    <field-validator type="requiredstring">
-      <param name="trim">true</param>
-      <message>You must select a target repository Id.</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathAction-validation.xml
deleted file mode 100644 (file)
index bbf09dd..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<!-- validate temporarily-trimmed inputs, actual values are then carried over to the action class to be trimmed once more. -->
-<validators>
-  <field name="legacyArtifactPath.path">
-    <field-validator type="requiredstring">
-      <message>You must enter a legacy path.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9._/\\]+$</param>
-        <message>Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\), underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="groupId">
-    <field-validator type="requiredstring">
-      <message>You must enter a groupId.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="artifactId">
-    <field-validator type="requiredstring">
-      <message>You must enter an artifactId.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="version">
-    <field-validator type="requiredstring">
-      <message>You must enter a version.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="classifier">
-    <!-- no requiredstring validation, because there was none before(being consistent). -->
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]*$</param>
-        <message>Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="type">
-    <field-validator type="requiredstring">
-      <message>You must enter a type.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml
deleted file mode 100644 (file)
index 669b3b1..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-
-
-<validators>
-  <field name="proxy.id">
-    <field-validator type="requiredstring">
-      <param name="trim">true</param>
-      <message>You must enter an identifier.</message>
-    </field-validator>
-    <field-validator type="stringlength">
-      <param name="minLength">4</param>
-      <param name="maxLength">45</param>
-      <param name="trim">true</param>
-      <message>You must enter an identifier of 4 or more than 4 characters.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="proxy.protocol">
-    <field-validator type="requiredstring">
-      <param name="trim">true</param>
-      <message>You must enter a protocol.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9./:\\]+$</param>
-        <message>Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\), dots(.), colons(:), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="proxy.host">
-    <field-validator type="requiredstring">
-      <param name="trim">true</param>
-      <message>You must enter a host.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]+$</param>
-        <message>Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="proxy.port">
-    <field-validator type="required">
-      <message>You must enter an port.</message>
-    </field-validator>
-    <field-validator type="int">
-      <param name="min">1</param>
-<!-- Webwork bug renders this as 65.535
-      <param name="max">65535</param>
-      <message>Port needs to be between ${min} and ${max}</message>
--->
-      <message>Port needs to be larger than ${min}</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[0-9]+$</param>
-        <message>Port must only contain numeric characters.</message>
-    </field-validator>
-  </field>
-  <field name="proxy.username">
-    <!-- no requiredstring validation, because there was none before(being consistent). -->
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9.@/_\\]*$</param>
-        <message>Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\), underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction-validation.xml
deleted file mode 100644 (file)
index 8c951cb..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="repository.id">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository identifier.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="repository.location">
-    <field-validator type="requiredstring">
-      <message>You must enter a directory.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]+$</param>
-        <message>Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="repository.indexDirectory">
-    <!-- no requiredstring validation, because there was none before(being consistent). -->
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]*$</param>
-        <message>Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="repository.name">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository name.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^([a-zA-Z0-9.)/_(-]|\s)+$</param>
-        <message>Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>   
-  <field name="repository.retentionCount">
-    <field-validator type="int">
-      <param name="min">1</param>
-      <param name="max">100</param>
-      <message>Repository Purge By Retention Count needs to be between ${min} and ${max}.</message>
-    </field-validator>    
-  </field>
-  <field name="repository.daysOlder">
-    <field-validator type="int">
-      <param name="min">0</param>
-      <message>Repository Purge By Days Older Than needs to be larger than ${min}.</message>
-    </field-validator>    
-  </field>
-</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction-validation.xml
deleted file mode 100644 (file)
index 7902bc5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="repository.id">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository identifier.</message>
-    </field-validator>
-  </field>
-  <field name="repository.url">
-    <field-validator type="requiredstring">
-      <message>You must enter a url.</message>
-    </field-validator>
-  </field>
-  <field name="repository.name">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository name.</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction-validation.xml
deleted file mode 100644 (file)
index abc9e55..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="repository.id">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository identifier.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[a-zA-Z0-9._-]+$</param>
-        <message>Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="repository.location">
-    <field-validator type="requiredstring">
-      <message>You must enter a directory.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]+$</param>
-        <message>Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="repository.indexDirectory">
-    <!-- no requiredstring validation, because there was none before(being consistent). -->
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^[-a-zA-Z0-9._/~:?!&amp;=\\]*$</param>
-        <message>Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&amp;), forward-slashes(/), back-slashes(\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="repository.name">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository name.</message>
-    </field-validator>
-    <field-validator type="regex">
-        <param name="trim">true</param>
-        <param name="expression">^([a-zA-Z0-9.)/_(-]|\s)+$</param>
-        <message>Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-).</message>
-    </field-validator>
-  </field>
-  <field name="repository.retentionCount">
-    <field-validator type="int">
-      <param name="min">1</param>
-      <param name="max">100</param>
-      <message>Repository Purge By Retention Count needs to be between ${min} and ${max}.</message>
-    </field-validator>
-  </field>
-  <field name="repository.daysOlder">
-    <field-validator type="int">
-      <param name="min">0</param>
-      <message>Repository Purge By Days Older Than needs to be larger than ${min}.</message>
-    </field-validator>
-  </field>
-</validators>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryAction-validation.xml
deleted file mode 100644 (file)
index 7902bc5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-
-<validators>
-  <field name="repository.id">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository identifier.</message>
-    </field-validator>
-  </field>
-  <field name="repository.url">
-    <field-validator type="requiredstring">
-      <message>You must enter a url.</message>
-    </field-validator>
-  </field>
-  <field name="repository.name">
-    <field-validator type="requiredstring">
-      <message>You must enter a repository name.</message>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractActionTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractActionTestCase.java
new file mode 100644 (file)
index 0000000..3c5193d
--- /dev/null
@@ -0,0 +1,223 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import org.apache.archiva.metadata.generic.GenericMetadataFacet;
+import org.apache.archiva.metadata.model.CiManagement;
+import org.apache.archiva.metadata.model.IssueManagement;
+import org.apache.archiva.metadata.model.License;
+import org.apache.archiva.metadata.model.Organization;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.Scm;
+import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectParent;
+import org.apache.archiva.security.UserRepositoriesStub;
+import org.apache.struts2.StrutsSpringTestCase;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractActionTestCase
+    extends StrutsSpringTestCase
+{
+    protected static final String TEST_REPO = "test-repo";
+
+    protected TestMetadataResolver metadataResolver;
+
+    protected static final String TEST_GROUP_ID = "groupId";
+
+    protected static final String TEST_ARTIFACT_ID = "artifactId";
+
+    protected static final String TEST_PACKAGING = "packaging";
+
+    protected static final String TEST_ISSUE_URL = "http://jira.codehaus.org/browse/MRM";
+
+    protected static final String TEST_ISSUE_SYSTEM = "jira";
+
+    protected static final String TEST_CI_SYSTEM = "continuum";
+
+    protected static final String TEST_CI_URL = "http://vmbuild.apache.org/";
+
+    protected static final String TEST_URL = "url";
+
+    protected static final String TEST_NAME = "name";
+
+    protected static final String TEST_DESCRIPTION = "description";
+
+    protected static final String TEST_PARENT_GROUP_ID = "parentGroupId";
+
+    protected static final String TEST_PARENT_ARTIFACT_ID = "parentArtifactId";
+
+    protected static final String TEST_PARENT_VERSION = "parentVersion";
+
+    protected static final String TEST_ORGANIZATION_NAME = "organizationName";
+
+    protected static final String TEST_ORGANIZATION_URL = "organizationUrl";
+
+    protected static final String TEST_LICENSE_URL = "licenseUrl";
+
+    protected static final String TEST_LICENSE_NAME = "licenseName";
+
+    protected static final String TEST_LICENSE_URL_2 = "licenseUrl_2";
+
+    protected static final String TEST_LICENSE_NAME_2 = "licenseName_2";
+
+    protected static final String TEST_SCM_CONNECTION = "scmConnection";
+
+    protected static final String TEST_SCM_DEV_CONNECTION = "scmDevConnection";
+
+    protected static final String TEST_SCM_URL = "scmUrl";
+
+    protected static final String TEST_GENERIC_METADATA_PROPERTY_NAME = "rating";
+
+    protected static final String TEST_GENERIC_METADATA_PROPERTY_VALUE = "5 stars";
+
+    @Override
+    protected String[] getContextLocations()
+    {
+        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
+    }
+
+    protected void setObservableRepos( List<String> repoIds )
+    {
+        UserRepositoriesStub repos = applicationContext.getBean( "userRepositories", UserRepositoriesStub.class );
+        repos.setObservableRepositoryIds( repoIds );
+    }
+
+    protected void assertDefaultModel( ProjectVersionMetadata model, String version )
+    {
+        assertDefaultModel( model, TEST_GROUP_ID, TEST_ARTIFACT_ID, version );
+    }
+
+    protected void assertDefaultModel( ProjectVersionMetadata model, String groupId, String artifactId, String version )
+    {
+        assertEquals( version, model.getVersion() );
+        assertEquals( TEST_URL, model.getUrl() );
+        assertEquals( TEST_NAME, model.getName() );
+        assertEquals( TEST_DESCRIPTION, model.getDescription() );
+        assertEquals( TEST_ORGANIZATION_NAME, model.getOrganization().getName() );
+        assertEquals( TEST_ORGANIZATION_URL, model.getOrganization().getUrl() );
+        assertEquals( 2, model.getLicenses().size() );
+        License l = model.getLicenses().get( 0 );
+        assertEquals( TEST_LICENSE_NAME, l.getName() );
+        assertEquals( TEST_LICENSE_URL, l.getUrl() );
+        l = model.getLicenses().get( 1 );
+        assertEquals( TEST_LICENSE_NAME_2, l.getName() );
+        assertEquals( TEST_LICENSE_URL_2, l.getUrl() );
+        assertEquals( TEST_ISSUE_SYSTEM, model.getIssueManagement().getSystem() );
+        assertEquals( TEST_ISSUE_URL, model.getIssueManagement().getUrl() );
+        assertEquals( TEST_CI_SYSTEM, model.getCiManagement().getSystem() );
+        assertEquals( TEST_CI_URL, model.getCiManagement().getUrl() );
+        assertEquals( TEST_SCM_CONNECTION, model.getScm().getConnection() );
+        assertEquals( TEST_SCM_DEV_CONNECTION, model.getScm().getDeveloperConnection() );
+        assertEquals( TEST_SCM_URL, model.getScm().getUrl() );
+
+        MavenProjectFacet mavenFacet = (MavenProjectFacet) model.getFacet( MavenProjectFacet.FACET_ID );
+        assertEquals( groupId, mavenFacet.getGroupId() );
+        assertEquals( artifactId, mavenFacet.getArtifactId() );
+        assertEquals( TEST_PACKAGING, mavenFacet.getPackaging() );
+        assertEquals( TEST_PARENT_GROUP_ID, mavenFacet.getParent().getGroupId() );
+        assertEquals( TEST_PARENT_ARTIFACT_ID, mavenFacet.getParent().getArtifactId() );
+        assertEquals( TEST_PARENT_VERSION, mavenFacet.getParent().getVersion() );
+    }
+
+    protected ProjectVersionMetadata createProjectModel( String version )
+    {
+        return createProjectModel( TEST_GROUP_ID, TEST_ARTIFACT_ID, version );
+    }
+
+    protected ProjectVersionMetadata createProjectModel( String groupId, String artifactId, String version )
+    {
+        ProjectVersionMetadata model = new ProjectVersionMetadata();
+        model.setId( version );
+        model.setUrl( TEST_URL );
+        model.setName( TEST_NAME );
+        model.setDescription( TEST_DESCRIPTION );
+        CiManagement ci = new CiManagement();
+        ci.setSystem( TEST_CI_SYSTEM );
+        ci.setUrl( TEST_CI_URL );
+        model.setCiManagement( ci );
+        IssueManagement issue = new IssueManagement();
+        issue.setSystem( TEST_ISSUE_SYSTEM );
+        issue.setUrl( TEST_ISSUE_URL );
+        model.setIssueManagement( issue );
+        Organization organization = new Organization();
+        organization.setName( TEST_ORGANIZATION_NAME );
+        organization.setUrl( TEST_ORGANIZATION_URL );
+        model.setOrganization( organization );
+        License l = new License();
+        l.setName( TEST_LICENSE_NAME );
+        l.setUrl( TEST_LICENSE_URL );
+        model.addLicense( l );
+        l = new License();
+        l.setName( TEST_LICENSE_NAME_2 );
+        l.setUrl( TEST_LICENSE_URL_2 );
+        model.addLicense( l );
+        Scm scm = new Scm();
+        scm.setConnection( TEST_SCM_CONNECTION );
+        scm.setDeveloperConnection( TEST_SCM_DEV_CONNECTION );
+        scm.setUrl( TEST_SCM_URL );
+        model.setScm( scm );
+
+        MavenProjectFacet mavenProjectFacet = new MavenProjectFacet();
+        mavenProjectFacet.setGroupId( groupId );
+        mavenProjectFacet.setArtifactId( artifactId );
+        mavenProjectFacet.setPackaging( TEST_PACKAGING );
+        MavenProjectParent parent = new MavenProjectParent();
+        parent.setGroupId( TEST_PARENT_GROUP_ID );
+        parent.setArtifactId( TEST_PARENT_ARTIFACT_ID );
+        parent.setVersion( TEST_PARENT_VERSION );
+        mavenProjectFacet.setParent( parent );
+        model.addFacet( mavenProjectFacet );
+
+        GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
+        Map<String, String> props = new HashMap<String, String>();
+        props.put( TEST_GENERIC_METADATA_PROPERTY_NAME, TEST_GENERIC_METADATA_PROPERTY_VALUE );
+        genericMetadataFacet.setAdditionalProperties( props );
+        model.addFacet( genericMetadataFacet );
+
+        return model;
+    }
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        ConfigurationManager configurationManager = new ConfigurationManager();
+        configurationManager.addContainerProvider( new XWorkConfigurationProvider() );
+        Configuration config = configurationManager.getConfiguration();
+        Container container = config.getContainer();
+
+        ValueStack stack = container.getInstance( ValueStackFactory.class ).createValueStack();
+        stack.getContext().put( ActionContext.CONTAINER, container );
+        ActionContext.setContext( new ActionContext( stack.getContext() ) );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractWebworkTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AbstractWebworkTestCase.java
new file mode 100644 (file)
index 0000000..fd6b6a3
--- /dev/null
@@ -0,0 +1,136 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.StrutsSpringTestCase;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * AbstractWebworkTestCase 
+ *
+ * @version $Id$
+ */
+public abstract class AbstractWebworkTestCase
+    extends StrutsSpringTestCase
+{
+
+
+    @Override
+    protected String[] getContextLocations()
+    {
+        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
+    }
+
+    /**
+     * This is a conveinence method for mimicking how the webwork interceptors
+     * operate on an action, before the request is processed.
+     * 
+     * Call this before each major request to the action to be sure you mimic the webwork process correctly. 
+     */
+    protected void preRequest( ActionSupport action )
+    {
+        action.clearErrorsAndMessages();
+    }
+
+    /**
+     * Tests the action to ensure that it has errors.
+     * 
+     * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
+     */
+    protected void assertHasErrors( ActionSupport action )
+    {
+        assertNotNull( action.getActionErrors() );
+        assertTrue( "Expected an error to occur.", action.getActionErrors().size() > 0 );
+    }
+    
+    /**
+     * Tests the action to ensure that it has messages.
+     * 
+     * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
+     */
+    protected void assertHasMessages( ActionSupport action )
+    {
+        assertNotNull( action.getActionMessages() );
+        assertTrue( "Expected an message to be set.", action.getActionMessages().size() > 0 );
+    }
+
+    /**
+     * Tests the action to ensure that it has NO errors.
+     * 
+     * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
+     */
+    @SuppressWarnings("unchecked")
+    protected void assertNoErrors( ActionSupport action )
+    {
+        List<String> errors = (List<String>) action.getActionErrors();
+    
+        assertNotNull( errors );
+        if ( errors.size() > 0 )
+        {
+            StringBuffer msg = new StringBuffer();
+            msg.append( "Should have had no errors. but found the following errors." );
+    
+            for ( String error : errors )
+            {
+                msg.append( "\n " ).append( error );
+            }
+            fail( msg.toString() );
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void assertRequestStatus( ActionSupport action, String expectedStatus, String methodName )
+        throws Exception
+    {
+        action.clearErrorsAndMessages();
+    
+        Method method = action.getClass().getDeclaredMethod( methodName, (Class[]) null );
+        Object actualStatus = method.invoke( action, (Object[]) null );
+        assertTrue( "return should be of type String", actualStatus instanceof String );
+    
+        if ( !StringUtils.equals( expectedStatus, (String) actualStatus ) )
+        {
+            StringBuffer msg = new StringBuffer();
+            msg.append( "Unexpected status returned from method <" );
+            msg.append( methodName ).append( "> on action <" );
+            String clazzname = action.getClass().getName();
+            msg.append( clazzname.substring( clazzname.lastIndexOf( '.' ) ) );
+            msg.append( ">: expected:<" ).append( expectedStatus ).append( "> but was:<" );
+            msg.append( (String) actualStatus ).append( ">. (see attached action messages and errors below)" );
+    
+            for ( String message : (Collection<String>) action.getActionMessages() )
+            {
+                msg.append( "\n  [MESSAGE]: " ).append( message );
+            }
+    
+            for ( String error : (Collection<String>) action.getActionErrors() )
+            {
+                msg.append( "\n  [ERROR]: " ).append( error );
+            }
+    
+            fail( msg.toString() );
+        }
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AuditEventArgumentsMatcher.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/AuditEventArgumentsMatcher.java
new file mode 100644 (file)
index 0000000..54396b2
--- /dev/null
@@ -0,0 +1,49 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.audit.AuditEvent;
+import org.easymock.ArgumentsMatcher;
+
+import java.util.Arrays;
+
+public class AuditEventArgumentsMatcher
+    implements ArgumentsMatcher
+{
+    public boolean matches( Object[] objects, Object[] objects1 )
+    {
+        if ( objects.length != 1 || objects1.length != 1 )
+        {
+            return false;
+        }
+        else
+        {
+            AuditEvent o1 = (AuditEvent) objects[0];
+            AuditEvent o2 = (AuditEvent) objects1[0];
+            o2.setTimestamp( o1.getTimestamp() ); // effectively ignore the timestamp
+            return o1.equals( o2 );
+        }
+    }
+
+    public String toString( Object[] objects )
+    {
+        return Arrays.asList( objects ).toString();
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/BrowseActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/BrowseActionTest.java
new file mode 100644 (file)
index 0000000..ea9a976
--- /dev/null
@@ -0,0 +1,411 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.google.common.collect.Lists;
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class BrowseActionTest
+    extends AbstractActionTestCase
+{
+    private static final String ACTION_HINT = "browseAction";
+
+    private BrowseAction action;
+
+    private static final List<String> GROUPS =
+        Arrays.asList( "org.apache.archiva", "commons-lang", "org.apache.maven", "com.sun", "com.oracle",
+                       "repeat.repeat" );
+
+    private static final String OTHER_TEST_REPO = "other-repo";
+
+    public void testInstantiation()
+    {
+        assertFalse( action == (BrowseAction) getActionProxy( "/browse.action" ).getAction() );
+    }
+
+    public void testBrowse()
+        throws Exception
+    {
+        metadataResolver.setNamespaces( TEST_REPO, GROUPS );
+
+        String result = action.browse();
+        assertSuccessResult( result );
+
+        assertEquals( Arrays.asList( "com", "commons-lang", "org.apache", "repeat.repeat" ), action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+
+        assertNull( action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseNoObservableRepos()
+        throws Exception
+    {
+        setObservableRepos( Collections.<String>emptyList() );
+
+        String result = action.browse();
+        assertNoAccessResult( result );
+
+        assertNoOutputVariables();
+    }
+
+    public void testBrowseGroupNoObservableRepos()
+        throws Exception
+    {
+        setObservableRepos( Collections.<String>emptyList() );
+        String selectedGroupId = "org";
+
+        action.setGroupId( selectedGroupId );
+        String result = action.browseGroup();
+        assertNoAccessResult( result );
+
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertNull( action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseArtifactNoObservableRepos()
+        throws Exception
+    {
+        setObservableRepos( Collections.<String>emptyList() );
+        String selectedGroupId = "org.apache";
+        String selectedArtifactId = "apache";
+
+        action.setGroupId( selectedGroupId );
+        action.setArtifactId( selectedArtifactId );
+        String result = action.browseArtifact();
+        assertNoAccessResult( result );
+
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertEquals( selectedArtifactId, action.getArtifactId() );
+        assertNull( action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseGroupNoGroupId()
+        throws Exception
+    {
+        String result = action.browseGroup();
+        assertErrorResult( result );
+        assertNoOutputVariables();
+    }
+
+    public void testBrowseGroupNoArtifacts()
+        throws Exception
+    {
+        String selectedGroupId = "org";
+        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache.maven" );
+
+        metadataResolver.setNamespaces( TEST_REPO, groups );
+        action.setGroupId( selectedGroupId );
+        String result = action.browseGroup();
+        assertSuccessResult( result );
+
+        assertEquals( Collections.singletonList( "org.apache" ), action.getNamespaces() );
+        assertEquals( Collections.<String>emptyList(), action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseGroupWithArtifacts()
+        throws Exception
+    {
+        String artifacts = "apache";
+        String selectedGroupId = "org.apache";
+        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache.maven" );
+
+        metadataResolver.setNamespaces( TEST_REPO, groups );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, artifacts, new ProjectVersionMetadata() );
+        action.setGroupId( selectedGroupId );
+        String result = action.browseGroup();
+        assertSuccessResult( result );
+
+        assertEquals( groups, action.getNamespaces() );
+        assertEquals( Collections.singletonList( artifacts ), action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseWithCollapsedGroupsAndArtifacts()
+        throws Exception
+    {
+        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache" );
+
+        metadataResolver.setNamespaces( TEST_REPO, groups );
+        // add an artifact in the tree to make sure "single" is not collapsed
+        metadataResolver.setProjectVersion( TEST_REPO, "org.apache", "apache", new ProjectVersionMetadata() );
+
+        String result = action.browse();
+        assertSuccessResult( result );
+
+        assertEquals( Collections.singletonList( "org.apache" ), action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+
+        assertNull( action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseWithCollapsedGroupsAndArtifactsAcrossRepositories()
+        throws Exception
+    {
+        setObservableRepos( Arrays.asList( TEST_REPO, OTHER_TEST_REPO ) );
+
+        metadataResolver.setNamespaces( TEST_REPO, Arrays.asList( "org.apache.archiva", "org.apache" ) );
+        metadataResolver.setNamespaces( OTHER_TEST_REPO, Arrays.asList( "org.codehaus.plexus", "org.codehaus" ) );
+
+        // add an artifact in the tree to make sure "single" is not collapsed
+        metadataResolver.setProjectVersion( TEST_REPO, "org.apache", "apache", new ProjectVersionMetadata() );
+
+        String result = action.browse();
+        assertSuccessResult( result );
+
+        assertEquals( Collections.singletonList( "org" ), action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+
+        assertNull( action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseGroupWithCollapsedGroupsAndArtifacts()
+        throws Exception
+    {
+        String artifacts = "apache";
+        String selectedGroupId = "org.apache";
+        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache" );
+
+        metadataResolver.setNamespaces( TEST_REPO, groups );
+        // add an artifact in the tree to make sure "single" is not collapsed
+        metadataResolver.setProjectVersion( TEST_REPO, "org.apache", "apache", new ProjectVersionMetadata() );
+
+        action.setGroupId( selectedGroupId );
+        String result = action.browseGroup();
+        assertSuccessResult( result );
+
+        assertEquals( Collections.singletonList( "org.apache.archiva" ), action.getNamespaces() );
+        assertEquals( Collections.singletonList( artifacts ), action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseArtifactNoGroupId()
+        throws Exception
+    {
+        String selectedArtifactId = "apache";
+
+        action.setArtifactId( selectedArtifactId );
+        String result = action.browseArtifact();
+        assertErrorResult( result );
+
+        assertNull( action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+        assertNull( action.getGroupId() );
+        assertEquals( selectedArtifactId, action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseArtifactNoArtifactId()
+        throws Exception
+    {
+        String selectedGroupId = "org.apache";
+
+        action.setGroupId( selectedGroupId );
+        String result = action.browseArtifact();
+        assertErrorResult( result );
+
+        assertNull( action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    public void testBrowseArtifact()
+        throws Exception
+
+    {
+        String selectedGroupId = "org.apache";
+        String selectedArtifactId = "apache";
+
+        List<String> versions = Arrays.asList( "1", "2", "3", "4" );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "1" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "2" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "3" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "4" ) );
+
+        action.setGroupId( selectedGroupId );
+        action.setArtifactId( selectedArtifactId );
+        String result = action.browseArtifact();
+        assertSuccessResult( result );
+
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertEquals( selectedArtifactId, action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+
+        assertNull( action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertEquals( versions, action.getProjectVersions() );
+
+        ProjectVersionMetadata model = action.getSharedModel();
+        assertDefaultModel( model, selectedGroupId, selectedArtifactId, null );
+    }
+
+    public void testBrowseArtifactWithSnapshots()
+        throws Exception
+
+    {
+        String selectedGroupId = "org.apache";
+        String selectedArtifactId = "apache";
+
+        List<String> versions = Arrays.asList( "1", "2", "3", "4-SNAPSHOT", "4", "5-SNAPSHOT" );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "1" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "2" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "3" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "4-SNAPSHOT" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "4" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "5-SNAPSHOT" ) );
+
+        action.setGroupId( selectedGroupId );
+        action.setArtifactId( selectedArtifactId );
+        String result = action.browseArtifact();
+        assertSuccessResult( result );
+
+        assertEquals( selectedGroupId, action.getGroupId() );
+        assertEquals( selectedArtifactId, action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+
+        assertNull( action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertEquals( versions, action.getProjectVersions() );
+
+        ProjectVersionMetadata model = action.getSharedModel();
+        assertDefaultModel( model, selectedGroupId, selectedArtifactId, null );
+    }
+
+    // TODO: test with restricted observable repos
+    // TODO: current behaviour is to ignore values that differ between models - instead, pick the latest and use that.
+    //       Need to update the tests to verify this as models are currently the same
+
+    private void assertNoAccessResult( String result )
+    {
+        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
+        assertEquals( 0, action.getActionErrors().size() );
+        assertEquals( 0, action.getActionMessages().size() );
+    }
+
+    private void assertSuccessResult( String result )
+    {
+        assertEquals( Action.SUCCESS, result );
+        assertEquals( 0, action.getActionErrors().size() );
+        assertEquals( 0, action.getActionMessages().size() );
+    }
+
+    private void assertErrorResult( String result )
+    {
+        assertEquals( Action.ERROR, result );
+        assertEquals( 1, action.getActionErrors().size() );
+        assertEquals( 0, action.getActionMessages().size() );
+    }
+
+    private void assertNoOutputVariables()
+    {
+        assertNull( action.getNamespaces() );
+        assertNull( action.getProjectIds() );
+        assertNull( action.getProjectVersions() );
+        assertNull( action.getGroupId() );
+        assertNull( action.getArtifactId() );
+        assertNull( action.getRepositoryId() );
+        assertNull( action.getSharedModel() );
+    }
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setObservableRepos( Lists.<String>newArrayList( "test-repo" ) );
+        //action = (BrowseAction) lookup( Action.class, ACTION_HINT );
+        action = (BrowseAction) getActionProxy( "/browse.action" ).getAction();
+        metadataResolver = new TestMetadataResolver();
+        RepositorySession repositorySession = mock( RepositorySession.class );
+        when( repositorySession.getResolver() ).thenReturn( metadataResolver );
+        TestRepositorySessionFactory factory =
+            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
+        factory.setRepositorySession( repositorySession );
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        setObservableRepos( Lists.<String>newArrayList( "test-repo" ) );
+    }
+}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/DeleteArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/DeleteArtifactActionTest.java
new file mode 100644 (file)
index 0000000..1dc6ae8
--- /dev/null
@@ -0,0 +1,180 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
+import org.apache.struts2.StrutsSpringTestCase;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class DeleteArtifactActionTest
+    extends StrutsSpringTestCase
+{
+    private DeleteArtifactAction action;
+
+    private ArchivaConfiguration configuration;
+
+    private MockControl configurationControl;
+
+    private RepositoryContentFactory repositoryFactory;
+
+    private MockControl repositoryFactoryControl;
+
+    private MetadataRepository metadataRepository;
+
+    private MockControl metadataRepositoryControl;
+
+    private static final String REPOSITORY_ID = "test-repo";
+
+    private static final String GROUP_ID = "org.apache.archiva";
+
+    private static final String ARTIFACT_ID = "npe-metadata";
+
+    private static final String VERSION = "1.0";
+
+    private static final String REPO_LOCATION = "target/test-classes/test-repo";
+
+    @Override
+    protected String[] getContextLocations()
+    {
+        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
+    }
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        //action = (DeleteArtifactAction) lookup( Action.class.getName(), "deleteArtifactAction" );
+        action = (DeleteArtifactAction) getActionProxy( "/deleteArtifact.action" ).getAction();
+        assertNotNull( action );
+
+        configurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        configuration = (ArchivaConfiguration) configurationControl.getMock();
+
+        repositoryFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
+        repositoryFactory = (RepositoryContentFactory) repositoryFactoryControl.getMock();
+
+        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
+        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+
+        RepositorySession repositorySession = mock( RepositorySession.class );
+        when( repositorySession.getRepository() ).thenReturn( metadataRepository );
+
+        TestRepositorySessionFactory repositorySessionFactory =
+            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
+
+        repositorySessionFactory.setRepositorySession( repositorySession );
+
+        (( DefaultManagedRepositoryAdmin)action.getManagedRepositoryAdmin()).setArchivaConfiguration( configuration );
+        action.setRepositoryFactory( repositoryFactory );
+    }
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        action = null;
+
+        super.tearDown();
+    }
+
+    public void testGetListeners()
+        throws Exception
+    {
+        assertNotNull( action.getListeners() );
+        assertFalse( action.getListeners().isEmpty() );
+    }
+
+    public void testNPEInDeleteArtifact()
+        throws Exception
+    {
+        action.setGroupId( GROUP_ID );
+        action.setArtifactId( ARTIFACT_ID );
+        action.setVersion( VERSION );
+        action.setRepositoryId( REPOSITORY_ID );
+
+        Configuration config = createConfiguration();
+
+        ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
+        repoContent.setRepository(
+            new BeanReplicator().replicateBean( config.findManagedRepositoryById( REPOSITORY_ID ),
+                                                ManagedRepository.class ) );
+
+        configurationControl.expectAndReturn( configuration.getConfiguration(), config );
+        repositoryFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( REPOSITORY_ID ),
+                                                  repoContent );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getArtifacts( REPOSITORY_ID, GROUP_ID, ARTIFACT_ID, VERSION ),
+            new ArrayList<ArtifactMetadata>() );
+
+        configurationControl.replay();
+        repositoryFactoryControl.replay();
+        metadataRepositoryControl.replay();
+
+        action.doDelete();
+
+        String artifactPath = REPO_LOCATION + "/" + StringUtils.replace( GROUP_ID, ".", "/" ) + "/"
+            + StringUtils.replace( ARTIFACT_ID, ".", "/" ) + "/" + VERSION + "/" + ARTIFACT_ID + "-" + VERSION;
+
+        assertFalse( new File( artifactPath + ".jar" ).exists() );
+        assertFalse( new File( artifactPath + ".jar.sha1" ).exists() );
+        assertFalse( new File( artifactPath + ".jar.md5" ).exists() );
+
+        assertFalse( new File( artifactPath + ".pom" ).exists() );
+        assertFalse( new File( artifactPath + ".pom.sha1" ).exists() );
+        assertFalse( new File( artifactPath + ".pom.md5" ).exists() );
+    }
+
+    private Configuration createConfiguration()
+    {
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( REPOSITORY_ID );
+        managedRepo.setName( "Test Repository" );
+
+        managedRepo.setLocation( REPO_LOCATION );
+        managedRepo.setReleases( true );
+
+        Configuration config = new Configuration();
+        config.addManagedRepository( managedRepo );
+
+        return config;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/SearchActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/SearchActionTest.java
new file mode 100644 (file)
index 0000000..3065f52
--- /dev/null
@@ -0,0 +1,528 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.indexer.search.RepositorySearch;
+import org.apache.archiva.indexer.search.SearchFields;
+import org.apache.archiva.indexer.search.SearchResultHit;
+import org.apache.archiva.indexer.search.SearchResultLimits;
+import org.apache.archiva.indexer.search.SearchResults;
+import org.apache.archiva.indexer.util.SearchUtil;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+import org.apache.archiva.security.UserRepositories;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.easymock.MockControl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ *
+ */
+public class SearchActionTest
+    extends AbstractActionTestCase
+{
+    private SearchAction action;
+
+    private MockControl userReposControl;
+
+    private UserRepositories userRepos;
+
+    private MockControl searchControl;
+
+    private MockControl repoAdminControl;
+
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    private RepositorySearch search;
+
+    private static final String TEST_CHECKSUM = "afbcdeaadbcffceabbba1";
+
+    private static final String TEST_REPO = "test-repo";
+
+    private static final String GUEST = "guest";
+
+    private RepositorySession session;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = new SearchAction();
+
+        session = mock( RepositorySession.class );
+        //TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class );
+        TestRepositorySessionFactory factory = new TestRepositorySessionFactory();
+        factory.setRepositorySession( session );
+        action.setRepositorySessionFactory( factory );
+
+        MockControl archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
+        ArchivaConfiguration archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
+
+        userReposControl = MockControl.createControl( UserRepositories.class );
+        userRepos = (UserRepositories) userReposControl.getMock();
+
+        searchControl = MockControl.createControl( RepositorySearch.class );
+        searchControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        search = (RepositorySearch) searchControl.getMock();
+
+        repoAdminControl = MockControl.createControl( ManagedRepositoryAdmin.class );
+        managedRepositoryAdmin = (ManagedRepositoryAdmin) repoAdminControl.getMock();
+
+        //( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfig );
+
+        action.setManagedRepositoryAdmin( managedRepositoryAdmin );
+        action.setUserRepositories( userRepos );
+        action.setNexusSearch( search );
+    }
+
+    // quick search...
+
+    public void testQuickSearch()
+        throws Exception
+    {
+        action.setQ( "archiva" );
+        action.setCurrentPage( 0 );
+        action.setSearchResultsOnly( false );
+        action.setCompleteQueryString( "" );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( "internal" );
+        selectedRepos.add( "snapshots" );
+
+        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
+        limits.setPageSize( 30 );
+
+        SearchResultHit hit = new SearchResultHit();
+        hit.setGroupId( "org.apache.archiva" );
+        hit.setArtifactId( "archiva-configuration" );
+        hit.setUrl( "url" );
+        hit.addVersion( "1.0" );
+        hit.addVersion( "1.1" );
+
+        SearchResults results = new SearchResults();
+        results.setLimits( limits );
+        results.setTotalHits( 1 );
+        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+
+        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
+
+        userReposControl.replay();
+        searchControl.replay();
+
+        action.setPrincipal( "user" );
+        String result = action.quickSearch();
+
+        assertEquals( Action.SUCCESS, result );
+        assertEquals( 1, action.getTotalPages() );
+        assertEquals( 1, action.getResults().getTotalHits() );
+
+        userReposControl.verify();
+        searchControl.verify();
+    }
+
+    public void testSearchWithinSearchResults()
+        throws Exception
+    {
+        action.setQ( "archiva" );
+        action.setCurrentPage( 0 );
+        action.setSearchResultsOnly( true );
+        action.setCompleteQueryString( "org;apache" );
+
+        List<String> parsed = new ArrayList<String>();
+        parsed.add( "org" );
+        parsed.add( "apache" );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( "internal" );
+        selectedRepos.add( "snapshots" );
+
+        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
+        limits.setPageSize( 30 );
+
+        SearchResultHit hit = new SearchResultHit();
+        hit.setGroupId( "org.apache.archiva" );
+        hit.setArtifactId( "archiva-configuration" );
+        hit.setUrl( "url" );
+        hit.addVersion( "1.0" );
+        hit.addVersion( "1.1" );
+
+        SearchResults results = new SearchResults();
+        results.setLimits( limits );
+        results.setTotalHits( 1 );
+        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+
+        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, parsed ), results );
+
+        userReposControl.replay();
+        searchControl.replay();
+
+        action.setPrincipal( "user" );
+        String result = action.quickSearch();
+
+        assertEquals( Action.SUCCESS, result );
+        assertEquals( "org;apache;archiva", action.getCompleteQueryString() );
+        assertEquals( 1, action.getTotalPages() );
+        assertEquals( 1, action.getResults().getTotalHits() );
+
+        userReposControl.verify();
+        searchControl.verify();
+    }
+
+    public void testQuickSearchUserHasNoAccessToAnyRepository()
+        throws Exception
+    {
+        action.setQ( "archiva" );
+        action.setCurrentPage( 0 );
+
+        List<String> selectedRepos = new ArrayList<String>();
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+
+        userReposControl.replay();
+
+        action.setPrincipal( "user" );
+        String result = action.quickSearch();
+
+        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
+
+        userReposControl.verify();
+    }
+
+    public void testQuickSearchNoSearchHits()
+        throws Exception
+    {
+        action.setQ( "archiva" );
+        action.setCurrentPage( 0 );
+        action.setSearchResultsOnly( false );
+        action.setCompleteQueryString( "" );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( "internal" );
+        selectedRepos.add( "snapshots" );
+
+        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
+        limits.setPageSize( 30 );
+
+        SearchResults results = new SearchResults();
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+
+        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
+
+        userReposControl.replay();
+        searchControl.replay();
+
+        action.setPrincipal( "user" );
+        String result = action.quickSearch();
+
+        assertEquals( Action.INPUT, result );
+
+        userReposControl.verify();
+        searchControl.verify();
+    }
+
+    // advanced/filtered search...
+
+    public void testAdvancedSearchOneRepository()
+        throws Exception
+    {
+        List<String> managedRepos = new ArrayList<String>();
+        managedRepos.add( "internal" );
+        managedRepos.add( "snapshots" );
+
+        action.setRepositoryId( "internal" );
+        action.setManagedRepositoryList( managedRepos );
+        action.setCurrentPage( 0 );
+        action.setRowCount( 30 );
+        action.setGroupId( "org" );
+
+        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
+        limits.setPageSize( 30 );
+
+        SearchResultHit hit = new SearchResultHit();
+        hit.setGroupId( "org.apache.archiva" );
+        hit.setArtifactId( "archiva-configuration" );
+        hit.setUrl( "url" );
+        hit.addVersion( "1.0" );
+        hit.addVersion( "1.1" );
+
+        SearchResults results = new SearchResults();
+        results.setLimits( limits );
+        results.setTotalHits( 1 );
+        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( "internal" );
+        selectedRepos.add( "snapshots" );
+
+        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
+
+        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
+
+        searchControl.replay();
+
+        String result = action.filteredSearch();
+
+        assertEquals( Action.SUCCESS, result );
+        assertEquals( 1, action.getTotalPages() );
+        assertEquals( 1, action.getResults().getTotalHits() );
+
+        searchControl.verify();
+    }
+
+    public void testAdvancedSearchAllRepositories()
+        throws Exception
+    {
+        List<String> managedRepos = new ArrayList<String>();
+        managedRepos.add( "internal" );
+        managedRepos.add( "snapshots" );
+
+        action.setRepositoryId( "all" );
+        action.setManagedRepositoryList( managedRepos );
+        action.setCurrentPage( 0 );
+        action.setRowCount( 30 );
+        action.setGroupId( "org" );
+
+        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
+        limits.setPageSize( 30 );
+
+        SearchResultHit hit = new SearchResultHit();
+        hit.setGroupId( "org.apache.archiva" );
+        hit.setArtifactId( "archiva-configuration" );
+        hit.setUrl( "url" );
+        hit.addVersion( "1.0" );
+        hit.addVersion( "1.1" );
+
+        SearchResults results = new SearchResults();
+        results.setLimits( limits );
+        results.setTotalHits( 1 );
+        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( "internal" );
+
+        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
+
+        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
+
+        searchControl.replay();
+        userReposControl.replay();
+
+        action.setPrincipal( "user" );
+        String result = action.filteredSearch();
+
+        assertEquals( Action.SUCCESS, result );
+        assertEquals( 1, action.getTotalPages() );
+        assertEquals( 1, action.getResults().getTotalHits() );
+
+        searchControl.verify();
+        userReposControl.verify();
+    }
+
+    public void testAdvancedSearchNoSearchHits()
+        throws Exception
+    {
+        List<String> managedRepos = new ArrayList<String>();
+        managedRepos.add( "internal" );
+        managedRepos.add( "snapshots" );
+
+        action.setRepositoryId( "internal" );
+        action.setManagedRepositoryList( managedRepos );
+        action.setCurrentPage( 0 );
+        action.setRowCount( 30 );
+        action.setGroupId( "org" );
+
+        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
+        limits.setPageSize( 30 );
+
+        SearchResults results = new SearchResults();
+
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.add( "internal" );
+        selectedRepos.add( "snapshots" );
+
+        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
+
+        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
+
+        searchControl.replay();
+
+        String result = action.filteredSearch();
+
+        assertEquals( Action.INPUT, result );
+        assertFalse( action.getActionErrors().isEmpty() );
+        assertEquals( "No results found", (String) action.getActionErrors().iterator().next() );
+
+        searchControl.verify();
+    }
+
+    public void testAdvancedSearchUserHasNoAccessToAnyRepository()
+        throws Exception
+    {
+        List<String> managedRepos = new ArrayList<String>();
+
+        action.setGroupId( "org.apache.archiva" );
+        action.setManagedRepositoryList( managedRepos );
+
+        String result = action.filteredSearch();
+
+        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
+    }
+
+    public void testAdvancedSearchNoSpecifiedCriteria()
+        throws Exception
+    {
+        List<String> managedRepos = new ArrayList<String>();
+
+        action.setManagedRepositoryList( managedRepos );
+
+        String result = action.filteredSearch();
+
+        assertEquals( Action.INPUT, result );
+        assertFalse( action.getActionErrors().isEmpty() );
+        assertEquals( "Advanced Search - At least one search criteria must be provided.",
+                      (String) action.getActionErrors().iterator().next() );
+    }
+
+    // find artifact..
+    public void testFindArtifactWithOneHit()
+        throws Exception
+    {
+        action.setQ( TEST_CHECKSUM );
+
+        MockControl control = MockControl.createControl( MetadataRepository.class );
+        MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
+        when( session.getRepository() ).thenReturn( metadataRepository );
+
+        ArtifactMetadata artifact = createArtifact( "archiva-configuration", "1.0" );
+        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ),
+                                 Collections.singletonList( artifact ) );
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
+                                          Collections.singletonList( TEST_REPO ) );
+
+        control.replay();
+        userReposControl.replay();
+
+        String result = action.findArtifact();
+        assertEquals( "artifact", result );
+        assertEquals( 1, action.getDatabaseResults().size() );
+        assertEquals( artifact, action.getDatabaseResults().get( 0 ) );
+
+        control.verify();
+        userReposControl.verify();
+    }
+
+    public void testFindArtifactWithMultipleHits()
+        throws Exception
+    {
+        action.setQ( TEST_CHECKSUM );
+
+        MockControl control = MockControl.createControl( MetadataRepository.class );
+        MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
+        when( session.getRepository() ).thenReturn( metadataRepository );
+
+        List<ArtifactMetadata> artifacts = Arrays.asList( createArtifact( "archiva-configuration", "1.0" ),
+                                                          createArtifact( "archiva-indexer", "1.0" ) );
+        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ), artifacts );
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
+                                          Collections.singletonList( TEST_REPO ) );
+
+        control.replay();
+        userReposControl.replay();
+
+        String result = action.findArtifact();
+        assertEquals( "results", result );
+        assertFalse( action.getDatabaseResults().isEmpty() );
+        assertEquals( 2, action.getDatabaseResults().size() );
+
+        control.verify();
+        userReposControl.verify();
+    }
+
+    public void testFindArtifactNoChecksumSpecified()
+        throws Exception
+    {
+        String result = action.findArtifact();
+
+        assertEquals( Action.INPUT, result );
+        assertFalse( action.getActionErrors().isEmpty() );
+        assertEquals( "Unable to search for a blank checksum", (String) action.getActionErrors().iterator().next() );
+    }
+
+    public void testFindArtifactNoResults()
+        throws Exception
+    {
+        action.setQ( TEST_CHECKSUM );
+
+        MockControl control = MockControl.createControl( MetadataRepository.class );
+        MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
+        when( session.getRepository() ).thenReturn( metadataRepository );
+
+        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ),
+                                 Collections.<ArtifactMetadata>emptyList() );
+
+        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
+                                          Collections.singletonList( TEST_REPO ) );
+
+        control.replay();
+        userReposControl.replay();
+
+        String result = action.findArtifact();
+        assertEquals( Action.INPUT, result );
+        assertFalse( action.getActionErrors().isEmpty() );
+        assertEquals( "No results found", (String) action.getActionErrors().iterator().next() );
+
+        control.verify();
+        userReposControl.verify();
+    }
+
+    private ArtifactMetadata createArtifact( String project, String version )
+    {
+        ArtifactMetadata metadata = new ArtifactMetadata();
+        metadata.setNamespace( "org.apache.archiva" );
+        metadata.setProject( project );
+        metadata.setProjectVersion( version );
+        metadata.setVersion( version );
+        metadata.setRepositoryId( TEST_REPO );
+        metadata.setId( project + "-" + version + ".jar" );
+        return metadata;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java
new file mode 100644 (file)
index 0000000..32aafde
--- /dev/null
@@ -0,0 +1,736 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.Dependency;
+import org.apache.archiva.metadata.model.MailingList;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
+import org.apache.archiva.reports.RepositoryProblemFacet;
+import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ShowArtifactActionTest
+    extends AbstractActionTestCase
+{
+    private static final String ACTION_HINT = "showArtifactAction";
+
+    private static final String TEST_VERSION = "version";
+
+    private static final String TEST_SNAPSHOT_VERSION = "1.0-SNAPSHOT";
+
+    private static final String TEST_TS_SNAPSHOT_VERSION = "1.0-20091120.111111-1";
+
+    private static final String TEST_NAMESPACE = "namespace";
+
+    private static final String OTHER_TEST_REPO = "first-repo";
+
+    private ShowArtifactAction action;
+
+    private static final List<ArtifactMetadata> TEST_SNAPSHOT_ARTIFACTS =
+        Arrays.asList( createArtifact( TEST_TS_SNAPSHOT_VERSION ),
+                       createArtifact( "1.0-20091120.222222-2", "20091120.222222", 2 ),
+                       createArtifact( "1.0-20091123.333333-3", "20091123.333333", 3 ) );
+
+    private static final long TEST_SIZE = 12345L;
+
+    private static final String TEST_TYPE = "jar";
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        action = (ShowArtifactAction) getActionProxy( "/showArtifact.action" ).getAction();
+
+        metadataResolver = new TestMetadataResolver();
+        MetadataRepository repo = mock( MetadataRepository.class );
+        RepositorySession repositorySession = mock( RepositorySession.class );
+        when( repositorySession.getResolver() ).thenReturn( metadataResolver );
+        when( repositorySession.getRepository() ).thenReturn( repo );
+        TestRepositorySessionFactory repositorySessionFactory =
+            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
+        repositorySessionFactory.setRepositorySession( repositorySession );
+
+        RepositoryContentFactory factory = mock( RepositoryContentFactory.class );
+
+        action.setRepositoryFactory( factory );
+
+        ManagedRepository config = new ManagedRepository();
+        config.setId( TEST_REPO );
+        config.setLocation( new File( "target/test-repo" ).getAbsolutePath() );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        content.setRepository( config );
+        when( factory.getManagedRepositoryContent( TEST_REPO ) ).thenReturn( content );
+
+        ArchivaConfiguration archivaConfig = mock( ArchivaConfiguration.class );
+
+        Configuration configuration = new Configuration();
+        configuration.addManagedRepository(
+            new BeanReplicator().replicateBean( config, ManagedRepositoryConfiguration.class ) );
+        when( archivaConfig.getConfiguration() ).thenReturn( configuration );
+
+        when( factory.getArchivaConfiguration() ).thenReturn( archivaConfig );
+
+    }
+
+    public void testInstantiation()
+    {
+        assertFalse( action == getActionProxy( "/showArtifact.action" ).getAction() );
+    }
+
+    public void testGetArtifactUniqueRelease()
+    {
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_VERSION ) );
+
+        setActionParameters();
+
+        String result = action.artifact();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testGetArtifactUniqueSnapshot()
+    {
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_SNAPSHOT_VERSION ) );
+        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
+                                       TEST_SNAPSHOT_ARTIFACTS );
+
+        action.setGroupId( TEST_GROUP_ID );
+        action.setArtifactId( TEST_ARTIFACT_ID );
+        action.setVersion( TEST_SNAPSHOT_VERSION );
+
+        String result = action.artifact();
+
+        assertActionSuccess( action, result );
+
+        assertEquals( TEST_GROUP_ID, action.getGroupId() );
+        assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
+        assertEquals( TEST_SNAPSHOT_VERSION, action.getVersion() );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model, TEST_SNAPSHOT_VERSION );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+
+        assertArtifacts( TEST_SNAPSHOT_ARTIFACTS, action.getArtifacts() );
+
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+    }
+
+    public void testGetArtifactUniqueSnapshotTimestamped()
+    {
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_SNAPSHOT_VERSION ) );
+        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
+                                       TEST_SNAPSHOT_ARTIFACTS );
+
+        action.setGroupId( TEST_GROUP_ID );
+        action.setArtifactId( TEST_ARTIFACT_ID );
+        action.setVersion( TEST_TS_SNAPSHOT_VERSION );
+
+        String result = action.artifact();
+        assertError( result );
+        assertNoOutputFields();
+    }
+
+    public void testGetMissingProject()
+    {
+        setActionParameters();
+
+        String result = action.artifact();
+        assertError( result );
+
+        assertActionParameters( action );
+        assertNoOutputFields();
+    }
+
+    public void testGetArtifactNoObservableRepos()
+    {
+        setObservableRepos( Collections.<String>emptyList() );
+
+        setActionParameters();
+
+        String result = action.artifact();
+
+        // Actually, it'd be better to have an error:
+        assertError( result );
+        assertActionParameters( action );
+        assertNoOutputFields();
+    }
+
+    public void testGetArtifactNotInObservableRepos()
+    {
+        metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_VERSION ) );
+
+        setActionParameters();
+
+        String result = action.artifact();
+        assertError( result );
+
+        assertActionParameters( action );
+        assertNoOutputFields();
+    }
+
+    public void testGetArtifactOnlySeenInSecondObservableRepo()
+    {
+        setObservableRepos( Arrays.asList( OTHER_TEST_REPO, TEST_REPO ) );
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_VERSION ) );
+
+        setActionParameters();
+
+        String result = action.artifact();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testGetArtifactSeenInBothObservableRepo()
+    {
+        setObservableRepos( Arrays.asList( TEST_REPO, OTHER_TEST_REPO ) );
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_VERSION ) );
+        metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_VERSION ) );
+
+        setActionParameters();
+
+        String result = action.artifact();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testGetArtifactCanOnlyObserveInOneOfTwoRepos()
+    {
+        setObservableRepos( Arrays.asList( TEST_REPO ) );
+        metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_VERSION ) );
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                            createProjectModel( TEST_VERSION ) );
+
+        setActionParameters();
+
+        String result = action.artifact();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testGetArtifactNoMavenFacet()
+    {
+        ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
+        versionMetadata.setId( TEST_VERSION );
+        versionMetadata.setUrl( TEST_URL );
+        versionMetadata.setName( TEST_NAME );
+        versionMetadata.setDescription( TEST_DESCRIPTION );
+
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+
+        setActionParameters();
+
+        String result = action.artifact();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertEquals( TEST_VERSION, model.getVersion() );
+        assertEquals( TEST_URL, model.getUrl() );
+        assertEquals( TEST_NAME, model.getName() );
+        assertEquals( TEST_DESCRIPTION, model.getDescription() );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testMetadataHasRepositoryFacetProblem()
+    {
+        String errMsg = "Error in resolving artifact's parent POM file: Sample Parent POM not found";
+        ProjectVersionMetadata metaData = createProjectModel( TEST_SNAPSHOT_VERSION );
+        metaData.addFacet(
+            createRepositoryProblemFacet( TEST_REPO, errMsg, TEST_GROUP_ID, TEST_SNAPSHOT_VERSION, TEST_NAMESPACE ) );
+
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, metaData );
+
+        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
+                                       TEST_SNAPSHOT_ARTIFACTS );
+
+        action.setGroupId( TEST_GROUP_ID );
+        action.setArtifactId( TEST_ARTIFACT_ID );
+        action.setVersion( TEST_SNAPSHOT_VERSION );
+
+        String result = action.artifact();
+
+        assertEquals( Action.SUCCESS, result );
+
+        assertTrue( action.hasActionErrors() );
+        assertFalse( action.hasActionMessages() );
+        assertEquals( "Artifact metadata is incomplete: " + errMsg, action.getActionErrors().toArray()[0].toString() );
+    }
+
+    public void testMetadataIncomplete()
+    {
+        ProjectVersionMetadata metaData = createProjectModel( TEST_SNAPSHOT_VERSION );
+        metaData.setIncomplete( true );
+
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, metaData );
+
+        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
+                                       TEST_SNAPSHOT_ARTIFACTS );
+
+        action.setGroupId( TEST_GROUP_ID );
+        action.setArtifactId( TEST_ARTIFACT_ID );
+        action.setVersion( TEST_SNAPSHOT_VERSION );
+        ;
+
+        String result = action.artifact();
+
+        assertEquals( Action.SUCCESS, result );
+
+        assertTrue( action.hasActionErrors() );
+        assertFalse( action.hasActionMessages() );
+
+        assertEquals( "Artifact metadata is incomplete.", action.getActionErrors().toArray()[0].toString() );
+    }
+
+    public void testGetMailingLists()
+    {
+        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
+        MailingList ml1 = createMailingList( "Users List", "users" );
+        MailingList ml2 = createMailingList( "Developers List", "dev" );
+        versionMetadata.setMailingLists( Arrays.asList( ml1, ml2 ) );
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+
+        setActionParameters();
+
+        String result = action.mailingLists();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model );
+
+        assertNotNull( action.getMailingLists() );
+        assertMailingList( action.getMailingLists().get( 0 ), "Users List", "users" );
+        assertMailingList( action.getMailingLists().get( 1 ), "Developers List", "dev" );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testGetDependencies()
+    {
+        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
+        Dependency dependency1 = createDependencyBasic( "artifactId1" );
+        Dependency dependency2 = createDependencyExtended( "artifactId2" );
+        versionMetadata.setDependencies( Arrays.asList( dependency1, dependency2 ) );
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+
+        setActionParameters();
+
+        String result = action.dependencies();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model );
+
+        assertNotNull( action.getDependencies() );
+        assertDependencyBasic( action.getDependencies().get( 0 ), "artifactId1" );
+        assertDependencyExtended( action.getDependencies().get( 1 ), "artifactId2" );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+        assertNull( action.getDependees() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testGetDependees()
+        throws Exception
+    {
+        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+        ProjectVersionReference dependee1 = createReference( "artifactId1" );
+        ProjectVersionReference dependee2 = createReference( "artifactId2" );
+        metadataResolver.setProjectReferences( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION,
+                                               Arrays.asList( dependee1, dependee2 ) );
+
+        setActionParameters();
+
+        String result = action.dependees();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ProjectVersionMetadata model = action.getModel();
+        assertDefaultModel( model );
+
+        assertNotNull( action.getDependees() );
+        assertCoordinate( action.getDependees().get( 0 ), "artifactId1" );
+        assertCoordinate( action.getDependees().get( 1 ), "artifactId2" );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testGetProjectMetadata()
+    {
+        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
+
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+
+        setActionParameters();
+
+        String result = action.projectMetadata();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+
+        Map<String, String> genericMetadata = action.getGenericMetadata();
+        assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
+        assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
+                      TEST_GENERIC_METADATA_PROPERTY_VALUE );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+        assertNotNull( action.getModel() );
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    public void testAddAndDeleteMetadataProperty()
+    {
+        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
+
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+
+        setActionParameters();
+        action.setPropertyName( "foo" );
+        action.setPropertyValue( "bar" );
+        action.setRepositoryId( TEST_REPO );
+
+        String result = action.addMetadataProperty();
+
+        assertActionSuccess( action, result );
+        assertActionParameters( action );
+
+        Map<String, String> genericMetadata = action.getGenericMetadata();
+        assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
+        assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
+                      TEST_GENERIC_METADATA_PROPERTY_VALUE );
+
+        assertNotNull( genericMetadata.get( "foo" ) );
+        assertEquals( "bar", genericMetadata.get( "foo" ) );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+        assertNotNull( action.getModel() );
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+
+        // test delete property
+        setActionParameters();
+        action.setDeleteItem( "foo" );
+
+        result = action.deleteMetadataEntry();
+
+        assertEquals( Action.SUCCESS, result );
+        assertActionParameters( action );
+        assertTrue( !action.getActionMessages().isEmpty() );
+        assertTrue( action.getActionMessages().contains( "Property successfully deleted." ) );
+
+        genericMetadata = action.getGenericMetadata();
+        assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
+        assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
+                      TEST_GENERIC_METADATA_PROPERTY_VALUE );
+
+        assertNull( genericMetadata.get( "foo" ) );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+        assertNotNull( action.getModel() );
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    private void assertArtifacts( List<ArtifactMetadata> expectedArtifacts,
+                                  Map<String, List<ShowArtifactAction.ArtifactDownloadInfo>> artifactMap )
+    {
+        // assuming only one of each version at this point
+        assertEquals( expectedArtifacts.size(), artifactMap.size() );
+        for ( ArtifactMetadata artifact : expectedArtifacts )
+        {
+            assertTrue( artifactMap.containsKey( artifact.getVersion() ) );
+            List<ShowArtifactAction.ArtifactDownloadInfo> list = artifactMap.get( artifact.getVersion() );
+            ShowArtifactAction.ArtifactDownloadInfo actual = list.get( 0 );
+            assertEquals( artifact.getNamespace(), actual.getNamespace() );
+            assertEquals( artifact.getId(), actual.getId() );
+            assertEquals( artifact.getProject(), actual.getProject() );
+            assertEquals( artifact.getRepositoryId(), actual.getRepositoryId() );
+            assertEquals( artifact.getVersion(), actual.getVersion() );
+            assertEquals( TEST_TYPE, actual.getType() );
+            assertEquals( "12.06 K", actual.getSize() );
+            assertEquals( artifact.getNamespace() + "/" + artifact.getProject() + "/" + TEST_SNAPSHOT_VERSION + "/"
+                              + artifact.getId(), actual.getPath() );
+        }
+    }
+
+    private static ArtifactMetadata createArtifact( String version )
+    {
+        return createArtifact( version, null, 0 );
+    }
+
+    private static ArtifactMetadata createArtifact( String version, String timestamp, int buildNumber )
+    {
+        ArtifactMetadata metadata = new ArtifactMetadata();
+        metadata.setProject( TEST_ARTIFACT_ID );
+        metadata.setId( TEST_ARTIFACT_ID + "-" + version + ".jar" );
+        metadata.setNamespace( TEST_GROUP_ID );
+        metadata.setRepositoryId( TEST_REPO );
+        metadata.setSize( TEST_SIZE );
+        metadata.setProjectVersion( VersionUtil.getBaseVersion( version ) );
+        metadata.setVersion( version );
+
+        MavenArtifactFacet facet = new MavenArtifactFacet();
+        facet.setType( "jar" );
+        facet.setTimestamp( timestamp );
+        facet.setBuildNumber( buildNumber );
+        metadata.addFacet( facet );
+
+        return metadata;
+    }
+
+    private ProjectVersionReference createReference( String projectId )
+    {
+        ProjectVersionReference reference = new ProjectVersionReference();
+        reference.setNamespace( "groupId" );
+        reference.setProjectId( projectId );
+        reference.setProjectVersion( "version" );
+        reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
+        return reference;
+    }
+
+    private void assertCoordinate( ProjectVersionReference dependee, String artifactId )
+    {
+        assertEquals( artifactId, dependee.getProjectId() );
+        assertEquals( "groupId", dependee.getNamespace() );
+        assertEquals( "version", dependee.getProjectVersion() );
+    }
+
+    private void assertDependencyBasic( Dependency dependency, String artifactId )
+    {
+        assertEquals( artifactId, dependency.getArtifactId() );
+        assertEquals( "groupId", dependency.getGroupId() );
+        assertEquals( "version", dependency.getVersion() );
+    }
+
+    private void assertDependencyExtended( Dependency dependency, String artifactId )
+    {
+        assertDependencyBasic( dependency, artifactId );
+        assertEquals( true, dependency.isOptional() );
+        assertEquals( "classifier", dependency.getClassifier() );
+        assertEquals( "type", dependency.getType() );
+        assertEquals( "scope", dependency.getScope() );
+        assertEquals( "systemPath", dependency.getSystemPath() );
+    }
+
+    private Dependency createDependencyExtended( String artifactId )
+    {
+        Dependency dependency = createDependencyBasic( artifactId );
+        dependency.setClassifier( "classifier" );
+        dependency.setOptional( true );
+        dependency.setScope( "scope" );
+        dependency.setSystemPath( "systemPath" );
+        dependency.setType( "type" );
+        return dependency;
+    }
+
+    private Dependency createDependencyBasic( String artifactId )
+    {
+        Dependency dependency = new Dependency();
+        dependency.setArtifactId( artifactId );
+        dependency.setGroupId( "groupId" );
+        dependency.setVersion( "version" );
+        return dependency;
+    }
+
+    private void assertMailingList( MailingList mailingList, String name, String prefix )
+    {
+        assertEquals( name, mailingList.getName() );
+        assertEquals( prefix + "-post@", mailingList.getPostAddress() );
+        assertEquals( prefix + "-subscribe@", mailingList.getSubscribeAddress() );
+        assertEquals( prefix + "-unsubscribe@", mailingList.getUnsubscribeAddress() );
+        assertEquals( prefix + "-archive-url", mailingList.getMainArchiveUrl() );
+        assertEquals( Arrays.asList( "other-" + prefix + "-archive-url-1", "other-" + prefix + "-archive-url-2" ),
+                      mailingList.getOtherArchives() );
+    }
+
+    private MailingList createMailingList( String name, String prefix )
+    {
+        MailingList ml1 = new MailingList();
+        ml1.setName( name );
+        ml1.setPostAddress( prefix + "-post@" );
+        ml1.setSubscribeAddress( prefix + "-subscribe@" );
+        ml1.setUnsubscribeAddress( prefix + "-unsubscribe@" );
+        ml1.setMainArchiveUrl( prefix + "-archive-url" );
+        ml1.setOtherArchives(
+            Arrays.asList( "other-" + prefix + "-archive-url-1", "other-" + prefix + "-archive-url-2" ) );
+        return ml1;
+    }
+
+    private void assertNoOutputFields()
+    {
+        assertNull( action.getModel() );
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getArtifacts().isEmpty() );
+    }
+
+    private void assertError( String result )
+    {
+        assertEquals( Action.ERROR, result );
+        assertEquals( 1, action.getActionErrors().size() );
+    }
+
+    private void assertDefaultModel( ProjectVersionMetadata model )
+    {
+        assertDefaultModel( model, TEST_VERSION );
+    }
+
+    private void setActionParameters()
+    {
+        action.setGroupId( TEST_GROUP_ID );
+        action.setArtifactId( TEST_ARTIFACT_ID );
+        action.setVersion( TEST_VERSION );
+    }
+
+    private void assertActionParameters( ShowArtifactAction action )
+    {
+        assertEquals( TEST_GROUP_ID, action.getGroupId() );
+        assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
+        assertEquals( TEST_VERSION, action.getVersion() );
+    }
+
+    private void assertActionSuccess( ShowArtifactAction action, String result )
+    {
+        assertEquals( Action.SUCCESS, result );
+        assertTrue( action.getActionErrors().isEmpty() );
+        assertTrue( action.getActionMessages().isEmpty() );
+    }
+
+    private RepositoryProblemFacet createRepositoryProblemFacet( String repoId, String errMsg, String projectId,
+                                                                 String projectVersion, String namespace )
+    {
+        RepositoryProblemFacet repoProblemFacet = new RepositoryProblemFacet();
+        repoProblemFacet.setRepositoryId( repoId );
+        repoProblemFacet.setId( repoId );
+        repoProblemFacet.setMessage( errMsg );
+        repoProblemFacet.setProblem( errMsg );
+        repoProblemFacet.setProject( projectId );
+        repoProblemFacet.setVersion( projectVersion );
+        repoProblemFacet.setNamespace( namespace );
+        return repoProblemFacet;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/UploadActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/UploadActionTest.java
new file mode 100644 (file)
index 0000000..f3722f3
--- /dev/null
@@ -0,0 +1,854 @@
+package org.apache.archiva.web.action;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
+import org.apache.archiva.checksum.ChecksumAlgorithm;
+import org.apache.archiva.checksum.ChecksummedFile;
+import org.apache.archiva.scheduler.ArchivaTaskScheduler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.common.utils.FileUtil;
+import org.apache.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.archiva.model.SnapshotVersion;
+import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryNotFoundException;
+import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
+import org.apache.archiva.repository.metadata.MetadataTools;
+import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
+/**
+ * UploadActionTest
+ */
+public class UploadActionTest
+    extends AbstractActionTestCase
+{
+    private UploadAction uploadAction;
+
+    private RepositoryContentFactory repoFactory;
+
+    private MockControl repoFactoryControl;
+
+    private MockControl managedRepoAdminControl;
+
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    private MockControl archivaAdminControl;
+
+    private ArchivaAdministration archivaAdministration;
+
+    private static final String REPOSITORY_ID = "test-repo";
+
+
+    private ManagedRepository managedRepository;
+
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        MockControl schedulerControl = MockControl.createControl( ArchivaTaskScheduler.class );
+        ArchivaTaskScheduler scheduler = (ArchivaTaskScheduler) schedulerControl.getMock();
+
+        repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
+        repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
+
+        managedRepoAdminControl = MockControl.createControl( ManagedRepositoryAdmin.class );
+        managedRepositoryAdmin = (ManagedRepositoryAdmin) managedRepoAdminControl.getMock();
+
+        archivaAdminControl = MockControl.createControl( ArchivaAdministration.class );
+        archivaAdministration = (ArchivaAdministration) archivaAdminControl.getMock();
+
+        uploadAction = new UploadAction();
+        uploadAction.setScheduler( scheduler );
+        uploadAction.setManagedRepositoryAdmin( managedRepositoryAdmin );
+        uploadAction.setArchivaAdministration( archivaAdministration );
+
+        uploadAction.setRepositoryFactory( repoFactory );
+
+        File testRepo = new File( FileUtil.getBasedir(), "target/test-classes/test-repo" );
+        testRepo.mkdirs();
+
+        assertTrue( testRepo.exists() );
+
+        managedRepository = new ManagedRepository();
+        managedRepository.setId( REPOSITORY_ID );
+        managedRepository.setLayout( "default" );
+        managedRepository.setLocation( testRepo.getPath() );
+        managedRepository.setName( REPOSITORY_ID );
+        managedRepository.setBlockRedeployments( true );
+
+    }
+
+    public void tearDown()
+        throws Exception
+    {
+        File testRepo = new File( this.managedRepository.getLocation() );
+        FileUtils.deleteDirectory( testRepo );
+
+        assertFalse( testRepo.exists() );
+
+        super.tearDown();
+    }
+
+    private void setUploadParameters( String version, String classifier, File artifact, File pomFile,
+                                      boolean generatePom )
+    {
+        uploadAction.setRepositoryId( REPOSITORY_ID );
+        uploadAction.setGroupId( "org.apache.archiva" );
+        uploadAction.setArtifactId( "artifact-upload" );
+        uploadAction.setVersion( version );
+        uploadAction.setPackaging( "jar" );
+
+        uploadAction.setClassifier( classifier );
+        uploadAction.setArtifact( artifact );
+        uploadAction.setPom( pomFile );
+        uploadAction.setGeneratePom( generatePom );
+    }
+
+    private void assertAllArtifactsIncludingSupportArtifactsArePresent( String repoLocation, String artifact,
+                                                                        String version )
+    {
+        assertTrue( new File( repoLocation,
+                              "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar" ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+            + ".jar.sha1" ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+            + ".jar.md5" ).exists() );
+
+        assertTrue( new File( repoLocation,
+                              "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom" ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+            + ".pom.sha1" ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
+            + ".pom.md5" ).exists() );
+
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+            + ".sha1" ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+            + ".md5" ).exists() );
+    }
+
+    private void verifyVersionMetadataChecksums( String repoLocation, String version )
+        throws IOException
+    {
+        ChecksummedFile checksum = new ChecksummedFile( new File( repoLocation,
+                                                                  "/org/apache/archiva/artifact-upload/" + version + "/"
+                                                                      + MetadataTools.MAVEN_METADATA ) );
+        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        String contents = FileUtils.readFileToString( new File( repoLocation,
+                                                                "/org/apache/archiva/artifact-upload/" + version + "/"
+                                                                    + MetadataTools.MAVEN_METADATA + ".sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents = FileUtils.readFileToString( new File( repoLocation,
+                                                         "/org/apache/archiva/artifact-upload/" + version + "/"
+                                                             + MetadataTools.MAVEN_METADATA + ".md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+    }
+
+    private void verifyProjectMetadataChecksums( String repoLocation )
+        throws IOException
+    {
+        ChecksummedFile checksum = new ChecksummedFile(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ) );
+        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        String contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+    }
+
+    private void verifyPomChecksums( String repoLocation, String artifact, String version )
+        throws IOException
+    {
+        ChecksummedFile checksum;
+        String sha1;
+        String md5;
+        String contents;
+        checksum = new ChecksummedFile(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom" ) );
+        sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom.sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom.md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+    }
+
+    private void verifyArtifactChecksums( String repoLocation, String artifact, String version )
+        throws IOException
+    {
+        ChecksummedFile checksum = new ChecksummedFile(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar" ) );
+        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        String contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar.sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar.md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+    }
+
+    private String getTimestamp( String[] artifactsList, int startIndex, int index )
+    {
+        int endIndex = -1;
+        String timestamp;
+
+        if ( artifactsList[index].contains( "jar" ) )
+        {
+            endIndex = artifactsList[index].indexOf( ".jar" );
+        }
+        else
+        {
+            endIndex = artifactsList[index].indexOf( ".pom" );
+        }
+
+        timestamp = artifactsList[index].substring( startIndex, endIndex );
+
+        return timestamp;
+    }
+
+    private MockControl mockAuditLogs( List<String> resources )
+    {
+        return mockAuditLogs( AuditEvent.UPLOAD_FILE, resources );
+    }
+
+    private MockControl mockAuditLogs( String action, List<String> resources )
+    {
+        MockControl control = MockControl.createControl( AuditListener.class );
+        AuditListener listener = (AuditListener) control.getMock();
+        boolean matcherSet = false;
+        for ( String resource : resources )
+        {
+            listener.auditEvent( new AuditEvent( REPOSITORY_ID, "guest", resource, action ) );
+            if ( !matcherSet )
+            {
+                control.setMatcher( new AuditEventArgumentsMatcher() );
+                matcherSet = true;
+            }
+        }
+        control.replay();
+
+        uploadAction.setAuditListeners( Collections.singletonList( listener ) );
+        return control;
+    }
+
+    public void testArtifactUploadWithPomSuccessful()
+        throws Exception
+    {
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ),
+                             false );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        content.setRepository( getManagedRepository() );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+        repoFactoryControl.replay();
+
+        MockControl control = mockAuditLogs(
+            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
+                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
+
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyProjectMetadataChecksums( repoLocation );
+    }
+
+    public void testArtifactUploadWithClassifier()
+        throws Exception
+    {
+        setUploadParameters( "1.0", "tests", new File( FileUtil.getBasedir(),
+                                                       "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ),
+                             false );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        content.setRepository( getManagedRepository() );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        MockControl control = mockAuditLogs(
+            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar",
+                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertTrue( new File( repoLocation,
+                              "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar" ).exists() );
+        assertTrue( new File( repoLocation,
+                              "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar.sha1" ).exists() );
+        assertTrue( new File( repoLocation,
+                              "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar.md5" ).exists() );
+
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.sha1" ).exists() );
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.md5" ).exists() );
+
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+            + ".sha1" ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+            + ".md5" ).exists() );
+
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0-tests", "1.0" );
+        verifyProjectMetadataChecksums( repoLocation );
+    }
+
+    public void testArtifactUploadGeneratePomSuccessful()
+        throws Exception
+    {
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        content.setRepository( getManagedRepository() );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        MockControl control = mockAuditLogs(
+            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
+                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
+
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyProjectMetadataChecksums( repoLocation );
+    }
+
+    public void testArtifactUploadNoPomSuccessful()
+        throws Exception
+    {
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, false );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        content.setRepository( getManagedRepository() );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        MockControl control =
+            mockAuditLogs( Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ) );
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.sha1" ).exists() );
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.md5" ).exists() );
+
+        assertFalse(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
+        assertFalse(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.sha1" ).exists() );
+        assertFalse(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.md5" ).exists() );
+
+        assertTrue(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+            + ".sha1" ).exists() );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
+            + ".md5" ).exists() );
+
+        // verify checksums of jar file
+        ChecksummedFile checksum = new ChecksummedFile(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ) );
+        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        String contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+
+        // verify checksums of metadata file
+        checksum = new ChecksummedFile(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ) );
+        sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents = FileUtils.readFileToString(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+    }
+
+    public void testArtifactUploadFailedRepositoryNotFound()
+        throws Exception
+    {
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, false );
+
+        repoFactoryControl.expectAndThrow( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ),
+                                           new RepositoryNotFoundException() );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.ERROR, returnString );
+
+        repoFactoryControl.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertFalse(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
+
+        assertFalse(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
+
+        assertFalse(
+            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
+    }
+
+    public void testArtifactUploadSnapshots()
+        throws Exception
+    {
+        setUploadParameters( "1.0-SNAPSHOT", null, new File( FileUtil.getBasedir(),
+                                                             "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        content.setRepository( getManagedRepository() );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        SimpleDateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
+        fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
+        String timestamp = fmt.format( new Date() );
+        MockControl control = mockAuditLogs( Arrays.asList(
+            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-1.jar",
+            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-1.pom" ) );
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        String[] artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
+        Arrays.sort( artifactsList );
+
+        assertEquals( 9, artifactsList.length );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
+            + MetadataTools.MAVEN_METADATA ).exists() );
+        assertTrue( new File( repoLocation,
+                              "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA
+                                  + ".sha1" ).exists() );
+        assertTrue( new File( repoLocation,
+                              "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA
+                                  + ".md5" ).exists() );
+
+        int startIndex = "artifact-upload-1.0-".length();
+        String timestampPath = getTimestamp( artifactsList, startIndex, 0 );
+
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0-" + timestampPath,
+                                                               "1.0-SNAPSHOT" );
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
+        verifyProjectMetadataChecksums( repoLocation );
+        verifyVersionMetadataChecksums( repoLocation, "1.0-SNAPSHOT" );
+
+        // verify build number
+        File metadataFile = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
+            + MetadataTools.MAVEN_METADATA );
+        ArchivaRepositoryMetadata artifactMetadata = RepositoryMetadataReader.read( metadataFile );
+
+        SnapshotVersion snapshotVersion = artifactMetadata.getSnapshotVersion();
+        assertEquals( "Incorrect build number set in artifact metadata.", 1, snapshotVersion.getBuildNumber() );
+
+        String timestampPart = StringUtils.substringBeforeLast( timestampPath, "-" );
+        assertEquals( "Incorrect timestamp set in artifact metadata.", timestampPart, snapshotVersion.getTimestamp() );
+
+        String buildnumber = StringUtils.substringAfterLast( timestampPath, "-" );
+        assertEquals( "Incorrect build number in filename.", "1", buildnumber );
+
+        repoFactoryControl.reset();
+        control.reset();
+
+        control.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+
+        // MRM-1353
+        // upload snapshot artifact again and check if build number was incremented
+        setUploadParameters( "1.0-SNAPSHOT", null, new File( FileUtil.getBasedir(),
+                                                             "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        repoFactoryControl.replay();
+
+        fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
+        fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
+        timestamp = fmt.format( new Date() );
+
+        control = mockAuditLogs( Arrays.asList(
+            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.jar",
+            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.pom" ) );
+
+        returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
+        Arrays.sort( artifactsList );
+
+        assertEquals( 15, artifactsList.length );
+
+        timestampPath = getTimestamp( artifactsList, startIndex, 6 );
+
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0-" + timestampPath,
+                                                               "1.0-SNAPSHOT" );
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
+        verifyProjectMetadataChecksums( repoLocation );
+        verifyVersionMetadataChecksums( repoLocation, "1.0-SNAPSHOT" );
+
+        // verify build number set in metadata and in filename
+        metadataFile = new File( repoLocation,
+                                 "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA );
+        artifactMetadata = RepositoryMetadataReader.read( metadataFile );
+
+        snapshotVersion = artifactMetadata.getSnapshotVersion();
+        assertEquals( "Incorrect build number set in artifact metadata.", 2, snapshotVersion.getBuildNumber() );
+
+        timestampPart = StringUtils.substringBeforeLast( timestampPath, "-" );
+        assertEquals( "Incorrect timestamp set in artifact metadata.", timestampPart, snapshotVersion.getTimestamp() );
+
+        buildnumber = StringUtils.substringAfterLast( timestampPath, "-" );
+        assertEquals( "Incorrect build number in filename.", "2", buildnumber );
+    }
+
+    public void testChecksumIsCorrectWhenArtifactIsReUploaded()
+        throws Exception
+    {
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        ManagedRepository repoConfig = getManagedRepository();
+        repoConfig.setBlockRedeployments( false );
+        content.setRepository( repoConfig );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 repoConfig, 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+
+        repoFactoryControl.reset();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
+
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyProjectMetadataChecksums( repoLocation );
+
+        // RE-upload artifact
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-reuploaded.jar" ),
+                             null, true );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+
+        repoFactoryControl.replay();
+
+        // TODO: track modifications?
+//        MockControl control = mockAuditLogs( AuditEvent.MODIFY_FILE, Arrays.asList(
+        MockControl control = mockAuditLogs(
+            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
+                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
+
+        returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        repoLocation = getManagedRepository().getLocation();
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
+
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyProjectMetadataChecksums( repoLocation );
+    }
+
+    public void testUploadArtifactAlreadyExistingRedeploymentsBlocked()
+        throws Exception
+    {
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        content.setRepository( getManagedRepository() );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 1, 8 );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        MockControl control = mockAuditLogs( Collections.<String>emptyList() );
+
+        returnString = uploadAction.doUpload();
+        assertEquals( Action.ERROR, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
+
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyProjectMetadataChecksums( repoLocation );
+    }
+
+    public void testUploadArtifactAlreadyExistingRedeploymentsAllowed()
+        throws Exception
+    {
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
+        ManagedRepository repoConfig = getManagedRepository();
+        repoConfig.setBlockRedeployments( false );
+        content.setRepository( repoConfig );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 1, 8 );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 repoConfig, 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
+        repoFactoryControl.replay();
+
+        String returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
+                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
+                             null, true );
+
+        // TODO: track modifications?
+//        MockControl control = mockAuditLogs( AuditEvent.MODIFY_FILE, Arrays.asList(
+        MockControl control = mockAuditLogs(
+            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
+                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
+
+        returnString = uploadAction.doUpload();
+        assertEquals( Action.SUCCESS, returnString );
+
+        repoFactoryControl.verify();
+        control.verify();
+
+        String repoLocation = getManagedRepository().getLocation();
+        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
+
+        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
+        verifyProjectMetadataChecksums( repoLocation );
+    }
+
+    ManagedRepository getManagedRepository()
+    {
+        return new BeanReplicator().replicateBean( this.managedRepository, ManagedRepository.class );
+    }
+
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java
new file mode 100644 (file)
index 0000000..d4d7580
--- /dev/null
@@ -0,0 +1,72 @@
+package org.apache.archiva.web.action.admin.appearance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.admin.repository.admin.DefaultArchivaAdministration;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.easymock.MockControl;
+
+/**
+ */
+public abstract class AbstractOrganizationInfoActionTest
+    extends AbstractWebworkTestCase
+{
+    protected MockControl archivaConfigurationControl;
+
+    protected ArchivaConfiguration configuration;
+
+    protected AbstractAppearanceAction action;
+
+    protected Configuration config;
+
+    protected abstract AbstractAppearanceAction getAction();
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        config = new Configuration();
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        configuration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        configuration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( config, 1, 5 );
+
+        configuration.save( config );
+        archivaConfigurationControl.setVoidCallable( 1, 4 );
+
+        archivaConfigurationControl.replay();
+
+        DefaultArchivaAdministration defaultArchivaAdministration = new DefaultArchivaAdministration();
+        defaultArchivaAdministration.setArchivaConfiguration( configuration );
+        getAction().setArchivaAdministration( defaultArchivaAdministration );
+    }
+
+    protected void reloadAction()
+    {
+        action = getAction();
+        ( (DefaultArchivaAdministration) action.getArchivaAdministration() ).setArchivaConfiguration( configuration );
+
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java
new file mode 100644 (file)
index 0000000..aec68de
--- /dev/null
@@ -0,0 +1,216 @@
+package org.apache.archiva.web.action.admin.appearance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import org.apache.archiva.web.validator.utils.ValidatorUtil;
+import org.apache.archiva.configuration.OrganisationInformation;
+import org.apache.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ */
+public class EditOrganizationInfoActionTest
+    extends AbstractOrganizationInfoActionTest
+{
+    private static final String EMPTY_STRING = "";
+
+    // valid inputs
+    private static final String ORGANISATION_NAME_VALID_INPUT = "abcXYZ0129.   _/\\~   :?!&=-";
+
+    private static final String ORGANISATION_URL_VALID_INPUT = "file://home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
+
+    private static final String ORGANISATION_LOGO_VALID_INPUT = "file://home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
+
+    // invalid inputs
+    private static final String ORGANISATION_NAME_INVALID_INPUT = "<>~+[ ]'\"";
+
+    private static final String ORGANISATION_URL_INVALID_INPUT = "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
+
+    private static final String ORGANISATION_LOGO_INVALID_INPUT = "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
+
+    // testing requisite
+    private ActionValidatorManager actionValidatorManager;
+
+    @Override
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        DefaultActionValidatorManagerFactory factory = new DefaultActionValidatorManagerFactory();
+
+        actionValidatorManager = factory.createDefaultActionValidatorManager();
+    }
+
+    public void testOrganisationInfoSaves()
+        throws Exception
+    {
+        config.setOrganisationInfo( new OrganisationInformation() );
+        OrganisationInformation orginfo = config.getOrganisationInfo();
+        orginfo.setLogoLocation( "LOGO" );
+        orginfo.setName( "NAME" );
+        orginfo.setUrl( "URL" );
+
+        configuration.save( config );
+
+        reloadAction();
+
+        action.prepare();
+
+        assertEquals( "LOGO", action.getOrganisationLogo() );
+        assertEquals( "NAME", action.getOrganisationName() );
+        assertEquals( "URL", action.getOrganisationUrl() );
+
+        action.setOrganisationLogo( "LOGO1" );
+        action.setOrganisationName( "NAME1" );
+        action.setOrganisationUrl( "URL1" );
+
+        action.execute();
+
+        orginfo = config.getOrganisationInfo();
+
+        assertEquals( "LOGO1", orginfo.getLogoLocation() );
+        assertEquals( "NAME1", orginfo.getName() );
+        assertEquals( "URL1", orginfo.getUrl() );
+    }
+
+    public void testStruts2ValidationFrameworkWithNullInputs()
+        throws Exception
+    {
+        // prep
+        action = getAction();
+        populateOrganisationValues( action, null, null, null );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a name" );
+        expectedFieldErrors.put( "organisationName", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithBlankInputs()
+        throws Exception
+    {
+        // prep
+        action = getAction();
+        populateOrganisationValues( action, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a name" );
+        expectedFieldErrors.put( "organisationName", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithInvalidInputs()
+        throws Exception
+    {
+        // prep
+        action = getAction();
+        populateOrganisationValues( action, ORGANISATION_NAME_INVALID_INPUT, ORGANISATION_URL_INVALID_INPUT,
+                                    ORGANISATION_LOGO_INVALID_INPUT );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+        expectedFieldErrors.put( "organisationName", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a URL." );
+        expectedFieldErrors.put( "organisationUrl", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a URL for your logo." );
+        expectedFieldErrors.put( "organisationLogo", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithValidInputs()
+        throws Exception
+    {
+        // prep
+        action = getAction();
+        populateOrganisationValues( action, ORGANISATION_NAME_VALID_INPUT, ORGANISATION_URL_VALID_INPUT,
+                                    ORGANISATION_LOGO_VALID_INPUT );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertFalse( action.hasFieldErrors() );
+    }
+
+    private void populateOrganisationValues( AbstractAppearanceAction abstractAppearanceAction, String name, String url,
+                                             String logo )
+    {
+        abstractAppearanceAction.setOrganisationName( name );
+        abstractAppearanceAction.setOrganisationUrl( url );
+        abstractAppearanceAction.setOrganisationLogo( logo );
+    }
+
+    @Override
+    protected AbstractAppearanceAction getAction()
+    {
+        //return (EditOrganisationInfoAction) lookup( Action.class.getName(), "editOrganisationInfo" );
+        return (EditOrganisationInfoAction) getActionProxy( "/admin/editAppearance.action" ).getAction();
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java
new file mode 100644 (file)
index 0000000..de5adfa
--- /dev/null
@@ -0,0 +1,54 @@
+package org.apache.archiva.web.action.admin.appearance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.configuration.OrganisationInformation;
+
+/**
+ */
+public class OrganizationInfoActionTest
+    extends AbstractOrganizationInfoActionTest
+{
+    public void testOrganisationInfoLoads()
+        throws Exception
+    {
+        config.setOrganisationInfo( new OrganisationInformation() );
+        OrganisationInformation orginfo = config.getOrganisationInfo();
+        orginfo.setLogoLocation( "LOGO" );
+        orginfo.setName( "NAME" );
+        orginfo.setUrl( "URL" );
+
+        configuration.save( config );
+
+        reloadAction();
+
+        action.prepare();
+
+        assertEquals( "URL", action.getOrganisationUrl() );
+        assertEquals( "NAME", action.getOrganisationName() );
+        assertEquals( "LOGO", action.getOrganisationLogo() );
+    }
+
+    @Override
+    protected AbstractAppearanceAction getAction()
+    {
+        return (OrganisationInfoAction) getActionProxy( "/components/companyInfo.action" ).getAction();
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
new file mode 100644 (file)
index 0000000..504d9d3
--- /dev/null
@@ -0,0 +1,431 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.policies.CachedFailuresPolicy;
+import org.apache.archiva.policies.ChecksumPolicy;
+import org.apache.archiva.policies.PropagateErrorsDownloadPolicy;
+import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
+import org.apache.archiva.policies.ReleasesPolicy;
+import org.apache.archiva.policies.SnapshotsPolicy;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.easymock.MockControl;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AddProxyConnectorActionTest
+ *
+ * @version $Id$
+ */
+public class AddProxyConnectorActionTest
+    extends AbstractWebworkTestCase
+{
+    private AddProxyConnectorAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (AddProxyConnectorAction) getActionProxy( "/admin/addProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testAddBlackListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        populateProxyConnector( connector );
+
+        // Perform Test w/no values.
+        preRequest( action );
+        String status = action.addBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no blacklist pattern added.
+        assertHasErrors( action );
+        assertEquals( 0, connector.getBlackListPatterns().size() );
+
+        // Try again, but now with a pattern to add.
+        action.setBlackListPattern( "**/*-javadoc.jar" );
+        preRequest( action );
+        status = action.addBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 blacklist pattern added.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getBlackListPatterns().size() );
+    }
+
+    public void testAddProperty()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        populateProxyConnector( connector );
+
+        // Perform Test w/no values.
+        preRequest( action );
+        String status = action.addProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no property pattern added.
+        assertHasErrors( action );
+        assertEquals( 0, connector.getProperties().size() );
+
+        // Try again, but now with a property key/value to add.
+        action.setPropertyKey( "eat-a" );
+        action.setPropertyValue( "gramov-a-bits" );
+        preRequest( action );
+        status = action.addProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 property added.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getProperties().size() );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void testAddProxyConnectorCommit()
+        throws Exception
+    {
+        expectConfigurationRequests( 9 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        populateProxyConnector( connector );
+        // forms will use an array
+        //connector.getProperties().put( "eat-a", new String[] { "gramov-a-bits" } );
+        // FIXME olamy check the array mode !!!
+        connector.getProperties().put( "eat-a", "gramov-a-bits" );
+
+        // Create the input screen.
+        assertRequestStatus( action, Action.SUCCESS, "commit" );
+        assertNoErrors( action );
+
+        // Test configuration.
+        List<ProxyConnectorConfiguration> proxyConfigs = archivaConfiguration.getConfiguration().getProxyConnectors();
+        assertNotNull( proxyConfigs );
+        assertEquals( 1, proxyConfigs.size() );
+
+        ProxyConnectorConfiguration actualConnector = proxyConfigs.get( 0 );
+
+        assertNotNull( actualConnector );
+        // The use of "(direct connection)" should result in a proxyId which is <null>.
+        assertNull( actualConnector.getProxyId() );
+        assertEquals( "corporate", actualConnector.getSourceRepoId() );
+        assertEquals( "central", actualConnector.getTargetRepoId() );
+        assertEquals( "gramov-a-bits", actualConnector.getProperties().get( "eat-a" ) );
+    }
+
+    public void testAddProxyConnectorInitialPage()
+        throws Exception
+    {
+        expectConfigurationRequests( 3 );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        ProxyConnector configuration = action.getConnector();
+        assertNotNull( configuration );
+        assertNull( configuration.getProxyId() );
+        assertNull( configuration.getSourceRepoId() );
+        assertNull( configuration.getTargetRepoId() );
+        assertTrue( configuration.getPolicies().isEmpty() );
+        assertTrue( configuration.getProperties().isEmpty() );
+        assertTrue( configuration.getBlackListPatterns().isEmpty() );
+        assertTrue( configuration.getWhiteListPatterns().isEmpty() );
+
+        String status = action.input();
+        assertEquals( Action.INPUT, status );
+    }
+
+    public void testAddWhiteListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        populateProxyConnector( connector );
+
+        // Perform Test w/no values.
+        preRequest( action );
+        String status = action.addWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no whitelist pattern added.
+        assertHasErrors( action );
+        assertEquals( 0, connector.getWhiteListPatterns().size() );
+
+        // Try again, but now with a pattern to add.
+        action.setWhiteListPattern( "**/*.jar" );
+        preRequest( action );
+        status = action.addWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 whitelist pattern added.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getWhiteListPatterns().size() );
+    }
+
+    public void testRemoveBlackListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        populateProxyConnector( connector );
+
+        // Add some arbitrary blacklist patterns.
+        connector.addBlackListPattern( "**/*-javadoc.jar" );
+        connector.addBlackListPattern( "**/*.war" );
+
+        // Perform Test w/no pattern value.
+        preRequest( action );
+        String status = action.removeBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no blacklist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getBlackListPatterns().size() );
+
+        // Perform test w/invalid (non-existant) pattern value to remove.
+        preRequest( action );
+        action.setPattern( "**/*oops*" );
+        status = action.removeBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no blacklist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getBlackListPatterns().size() );
+
+        // Try again, but now with a valid pattern to remove.
+        action.setPattern( "**/*-javadoc.jar" );
+        preRequest( action );
+        status = action.removeBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 blacklist pattern left.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getBlackListPatterns().size() );
+        assertEquals( "Should have left 1 blacklist pattern", "**/*.war", connector.getBlackListPatterns().get( 0 ) );
+    }
+
+    public void testRemoveProperty()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        populateProxyConnector( connector );
+
+        // Add some arbitrary properties.
+        connector.addProperty( "username", "general-tso" );
+        connector.addProperty( "password", "chicken" );
+
+        // Perform Test w/no property key.
+        preRequest( action );
+        String status = action.removeProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no properties removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getProperties().size() );
+
+        // Perform test w/invalid (non-existant) property key to remove.
+        preRequest( action );
+        action.setPropertyKey( "slurm" );
+        status = action.removeProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no properties removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getProperties().size() );
+
+        // Try again, but now with a valid property to remove.
+        preRequest( action );
+        action.setPropertyKey( "password" );
+        status = action.removeProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 property left.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getProperties().size() );
+        assertEquals( "Should have left 1 property", "general-tso", connector.getProperties().get( "username" ) );
+    }
+
+    public void testRemoveWhiteListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        populateProxyConnector( connector );
+
+        // Add some arbitrary whitelist patterns.
+        connector.addWhiteListPattern( "javax/**/*" );
+        connector.addWhiteListPattern( "com/sun/**/*" );
+
+        // Perform Test w/no pattern value.
+        preRequest( action );
+        String status = action.removeWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no whitelist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getWhiteListPatterns().size() );
+
+        // Perform test w/invalid (non-existant) pattern value to remove.
+        preRequest( action );
+        action.setPattern( "**/*oops*" );
+        status = action.removeWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no whitelist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getWhiteListPatterns().size() );
+
+        // Try again, but now with a valid pattern to remove.
+        action.setPattern( "com/sun/**/*" );
+        preRequest( action );
+        status = action.removeWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 whitelist pattern left.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getWhiteListPatterns().size() );
+        assertEquals( "Should have left 1 whitelist pattern", "javax/**/*", connector.getWhiteListPatterns().get( 0 ) );
+    }
+
+    public void testSecureActionBundle()
+        throws Exception
+    {
+        expectConfigurationRequests( 3 );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( "corporate" );
+        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+        managedRepo.setReleases( true );
+
+        config.addManagedRepository( managedRepo );
+
+        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( "central" );
+        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+        config.addRemoteRepository( remoteRepo );
+
+        return config;
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        for ( int i = 0; i < requestConfigCount; i++ )
+        {
+            archivaConfiguration.getConfiguration();
+            archivaConfigurationControl.setReturnValue( config );
+        }
+
+        archivaConfiguration.save( config );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private void populateProxyConnector( ProxyConnector connector )
+    {
+        connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
+        connector.setSourceRepoId( "corporate" );
+        connector.setTargetRepoId( "central" );
+
+        // TODO: Set these options programatically via list of available policies.
+        Map<String, String> policies = connector.getPolicies();
+        policies.put( "releases", new ReleasesPolicy().getDefaultOption() );
+        policies.put( "snapshots", new SnapshotsPolicy().getDefaultOption() );
+        policies.put( "checksum", new ChecksumPolicy().getDefaultOption() );
+        policies.put( "cache-failures", new CachedFailuresPolicy().getDefaultOption() );
+        policies.put( "propagate-errors", new PropagateErrorsDownloadPolicy().getDefaultOption() );
+        policies.put( "propagate-errors-on-update", new PropagateErrorsOnUpdateDownloadPolicy().getDefaultOption() );
+    }
+
+
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java
new file mode 100644 (file)
index 0000000..f052b26
--- /dev/null
@@ -0,0 +1,232 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.easymock.MockControl;
+
+/**
+ * DeleteProxyConnectorActionTest
+ *
+ * @version $Id$
+ */
+public class DeleteProxyConnectorActionTest
+    extends AbstractWebworkTestCase
+{
+    private static final String TEST_TARGET_ID = "central";
+
+    private static final String TEST_SOURCE_ID = "corporate";
+
+    private DeleteProxyConnectorAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (DeleteProxyConnectorAction) getActionProxy( "/admin/deleteProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testConfirmDelete()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        // Show the confirm the delete of proxy connector screen.
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        String status = action.confirmDelete();
+        assertEquals( Action.INPUT, status );
+        assertNoErrors( action );
+    }
+
+    public void testConfirmDeleteBadSourceOrTarget()
+        throws Exception
+    {
+        expectConfigurationRequests( 4 );
+        archivaConfigurationControl.replay();
+
+        // Attempt to show the confirm delete screen, but provide
+        // a bad source id or target id to actually delete
+
+        preRequest( action );
+        action.setSource( "bad-source" ); // id doesn't exist.
+        action.setTarget( "bad-target" ); // id doesn't exist.
+        String status = action.confirmDelete();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( "bad" ); // Bad doesn't exist.
+        action.setTarget( TEST_TARGET_ID );
+        status = action.confirmDelete();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( "bad" ); // Bad doesn't exist.
+        status = action.confirmDelete();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+    }
+
+    public void testConfirmDeleteNoSourceOrTarget()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        // Attempt to show the confirm delete screen, but don't provide
+        // the source id or target id to actually delete
+
+        preRequest( action );
+        action.setSource( null ); // No source Id.
+        action.setTarget( null ); // No target Id.
+        String status = action.confirmDelete();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( null ); // No target Id.
+        status = action.confirmDelete();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( null ); // No source Id.
+        action.setTarget( TEST_TARGET_ID );
+        status = action.confirmDelete();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+    }
+
+    public void testDelete()
+        throws Exception
+    {
+        expectConfigurationRequests( 5 );
+        archivaConfigurationControl.replay();
+
+        // Show the confirm the delete of proxy connector screen.
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        String status = action.confirmDelete();
+        assertEquals( Action.INPUT, status );
+        assertNoErrors( action );
+
+        // Perform the delete.
+        preRequest( action );
+        status = action.delete();
+        assertEquals( Action.SUCCESS, status );
+        assertNoErrors( action );
+        assertHasMessages( action );
+
+        // Test the configuration.
+        assertEquals( 0, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
+    }
+
+    public void testSecureActionBundle()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( TEST_SOURCE_ID );
+        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+        managedRepo.setReleases( true );
+
+        config.addManagedRepository( managedRepo );
+
+        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( TEST_TARGET_ID );
+        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+        config.addRemoteRepository( remoteRepo );
+
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( TEST_SOURCE_ID );
+        connector.setTargetRepoId( TEST_TARGET_ID );
+
+        config.addProxyConnector( connector );
+
+        return config;
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        for ( int i = 0; i < requestConfigCount; i++ )
+        {
+            archivaConfiguration.getConfiguration();
+            archivaConfigurationControl.setReturnValue( config );
+        }
+
+        archivaConfiguration.save( config );
+    }
+
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java
new file mode 100644 (file)
index 0000000..9ae2022
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ *  Copyright 2008 jdumay.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.easymock.MockControl;
+
+public class DisableProxyConnectorActionTest
+    extends AbstractWebworkTestCase
+{
+    private static final String TEST_TARGET_ID = "central";
+
+    private static final String TEST_SOURCE_ID = "corporate";
+
+    private DisableProxyConnectorAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (DisableProxyConnectorAction) getActionProxy( "/admin/disableProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
+    }
+
+    public void testConfirmDisableBadSourceOrTarget()
+        throws Exception
+    {
+        expectConfigurationRequests( 4 );
+        archivaConfigurationControl.replay();
+
+        // Attempt to show the confirm disable screen, but provide
+        // a bad source id or target id to actually delete
+
+        preRequest( action );
+        action.setSource( "bad-source" ); // id doesn't exist.
+        action.setTarget( "bad-target" ); // id doesn't exist.
+        String status = action.confirmDisable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( "bad" ); // Bad doesn't exist.
+        action.setTarget( TEST_TARGET_ID );
+        status = action.confirmDisable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( "bad" ); // Bad doesn't exist.
+        status = action.confirmDisable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+    }
+
+    public void testConfirmDisableNoSourceOrTarget()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        // Attempt to show the confirm disable screen, but don't provide
+        // the source id or target id to actually delete
+
+        preRequest( action );
+        action.setSource( null ); // No source Id.
+        action.setTarget( null ); // No target Id.
+        String status = action.confirmDisable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( null ); // No target Id.
+        status = action.confirmDisable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( null ); // No source Id.
+        action.setTarget( TEST_TARGET_ID );
+        status = action.confirmDisable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+    }
+
+    public void testDelete()
+        throws Exception
+    {
+        expectConfigurationRequests( 5 );
+        archivaConfigurationControl.replay();
+
+        // Show the confirm the disable of proxy connector screen.
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        String status = action.confirmDisable();
+        assertEquals( Action.INPUT, status );
+        assertNoErrors( action );
+
+        // Perform the disable.
+        preRequest( action );
+        status = action.disable();
+        assertEquals( Action.SUCCESS, status );
+        assertNoErrors( action );
+        assertHasMessages( action );
+
+        // Test the configuration.
+        assertEquals( 1, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
+        ProxyConnectorConfiguration config =
+            (ProxyConnectorConfiguration) archivaConfiguration.getConfiguration().getProxyConnectors().get( 0 );
+        assertTrue( config.isDisabled() );
+    }
+
+    public void testSecureActionBundle()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testConfirmEnable()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        // Show the confirm the disable of proxy connector screen.
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        String status = action.confirmDisable();
+        assertEquals( Action.INPUT, status );
+        assertNoErrors( action );
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( TEST_SOURCE_ID );
+        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+        managedRepo.setReleases( true );
+
+        config.addManagedRepository( managedRepo );
+
+        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( TEST_TARGET_ID );
+        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+        config.addRemoteRepository( remoteRepo );
+
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( TEST_SOURCE_ID );
+        connector.setTargetRepoId( TEST_TARGET_ID );
+
+        connector.setDisabled( false );
+
+        config.addProxyConnector( connector );
+
+        return config;
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        for ( int i = 0; i < requestConfigCount; i++ )
+        {
+            archivaConfiguration.getConfiguration();
+            archivaConfigurationControl.setReturnValue( config );
+        }
+
+        archivaConfiguration.save( config );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java
new file mode 100644 (file)
index 0000000..23c18cc
--- /dev/null
@@ -0,0 +1,473 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.policies.CachedFailuresPolicy;
+import org.apache.archiva.policies.ChecksumPolicy;
+import org.apache.archiva.policies.PropagateErrorsDownloadPolicy;
+import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
+import org.apache.archiva.policies.ReleasesPolicy;
+import org.apache.archiva.policies.SnapshotsPolicy;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.easymock.MockControl;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * EditProxyConnectorActionTest
+ *
+ * @version $Id$
+ */
+public class EditProxyConnectorActionTest
+    extends AbstractWebworkTestCase
+{
+    private static final String TEST_TARGET_ID = "central";
+
+    private static final String TEST_SOURCE_ID = "corporate";
+
+    private EditProxyConnectorAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (EditProxyConnectorAction) getActionProxy( "/admin/editProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+
+
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        expectConfigurationRequests( requestConfigCount, 1 );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount, int saveRequestCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config,
+                                                     requestConfigCount , 20);
+        //archivaConfiguration.getConfiguration();
+        //archivaConfigurationControl.setReturnValue( config, requestConfigCount );
+
+        for ( int i = 0; i <= saveRequestCount; i++ )
+        {
+            archivaConfiguration.save( config );
+        }
+
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testAddBlackListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+
+        // Perform Test w/no values.
+        preRequest( action );
+        String status = action.addBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no blacklist pattern added.
+        assertHasErrors( action );
+        assertEquals( 0, connector.getBlackListPatterns().size() );
+
+        // Try again, but now with a pattern to add.
+        action.setBlackListPattern( "**/*-javadoc.jar" );
+        preRequest( action );
+        status = action.addBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 blacklist pattern added.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getBlackListPatterns().size() );
+    }
+
+    public void testAddProperty()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+
+        // Perform Test w/no values.
+        preRequest( action );
+        String status = action.addProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no property pattern added.
+        assertHasErrors( action );
+        assertEquals( 0, connector.getProperties().size() );
+
+        // Try again, but now with a property key/value to add.
+        action.setPropertyKey( "eat-a" );
+        action.setPropertyValue( "gramov-a-bits" );
+        preRequest( action );
+        status = action.addProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 property added.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getProperties().size() );
+        assertEquals( "gramov-a-bits", connector.getProperties().get( "eat-a" ) );
+    }
+
+    public void testAddWhiteListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+
+        // Perform Test w/no values.
+        preRequest( action );
+        String status = action.addWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no whitelist pattern added.
+        assertHasErrors( action );
+        assertEquals( 0, connector.getWhiteListPatterns().size() );
+
+        // Try again, but now with a pattern to add.
+        action.setWhiteListPattern( "**/*.jar" );
+        preRequest( action );
+        status = action.addWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 whitelist pattern added.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getWhiteListPatterns().size() );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void testEditProxyConnectorCommit()
+        throws Exception
+    {
+        expectConfigurationRequests( 9, 2 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+        // forms will use an array
+        //connector.getProperties().put( "eat-a", new String[]{ "gramov-a-bits" } );
+        // FIXME check the array mode
+        connector.getProperties().put( "eat-a", "gramov-a-bits" );
+
+        // Create the input screen.
+        assertRequestStatus( action, Action.SUCCESS, "commit" );
+        assertNoErrors( action );
+
+        // Test configuration.
+        List<ProxyConnectorConfiguration> proxyConfigs = archivaConfiguration.getConfiguration().getProxyConnectors();
+        assertNotNull( proxyConfigs );
+        assertEquals( 1, proxyConfigs.size() );
+
+        ProxyConnectorConfiguration actualConnector = proxyConfigs.get( 0 );
+
+        assertNotNull( actualConnector );
+        // The use of "(direct connection)" should result in a proxyId which is <null>.
+        assertNull( actualConnector.getProxyId() );
+        assertEquals( "corporate", actualConnector.getSourceRepoId() );
+        assertEquals( "central", actualConnector.getTargetRepoId() );
+
+    }
+
+    public void testEditProxyConnectorInitialPage()
+        throws Exception
+    {
+        expectConfigurationRequests( 3 );
+        archivaConfigurationControl.replay();
+
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+
+        String status = action.input();
+        assertEquals( Action.INPUT, status );
+    }
+
+    public void testRemoveBlackListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+
+        // Add some arbitrary blacklist patterns.
+        connector.addBlackListPattern( "**/*-javadoc.jar" );
+        connector.addBlackListPattern( "**/*.war" );
+
+        // Perform Test w/no pattern value.
+        preRequest( action );
+        String status = action.removeBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no blacklist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getBlackListPatterns().size() );
+
+        // Perform test w/invalid (non-existant) pattern value to remove.
+        preRequest( action );
+        action.setPattern( "**/*oops*" );
+        status = action.removeBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no blacklist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getBlackListPatterns().size() );
+
+        // Try again, but now with a valid pattern to remove.
+        action.setPattern( "**/*-javadoc.jar" );
+        preRequest( action );
+        status = action.removeBlackListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 blacklist pattern left.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getBlackListPatterns().size() );
+        assertEquals( "Should have left 1 blacklist pattern", "**/*.war", connector.getBlackListPatterns().get( 0 ) );
+    }
+
+    public void testRemoveProperty()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+
+        // Add some arbitrary properties.
+        connector.addProperty( "username", "general-tso" );
+        connector.addProperty( "password", "chicken" );
+
+        // Perform Test w/no property key.
+        preRequest( action );
+        String status = action.removeProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no properties removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getProperties().size() );
+
+        // Perform test w/invalid (non-existant) property key to remove.
+        preRequest( action );
+        action.setPropertyKey( "slurm" );
+        status = action.removeProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no properties removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getProperties().size() );
+
+        // Try again, but now with a valid property to remove.
+        preRequest( action );
+        action.setPropertyKey( "password" );
+        status = action.removeProperty();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 property left.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getProperties().size() );
+        assertEquals( "Should have left 1 property", "general-tso", connector.getProperties().get( "username" ) );
+    }
+
+    public void testRemoveWhiteListPattern()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Prepare Test.
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        action.prepare();
+        ProxyConnector connector = action.getConnector();
+        assertInitialProxyConnector( connector );
+
+        // Add some arbitrary whitelist patterns.
+        connector.addWhiteListPattern( "javax/**/*" );
+        connector.addWhiteListPattern( "com/sun/**/*" );
+
+        // Perform Test w/no pattern value.
+        preRequest( action );
+        String status = action.removeWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no whitelist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getWhiteListPatterns().size() );
+
+        // Perform test w/invalid (non-existant) pattern value to remove.
+        preRequest( action );
+        action.setPattern( "**/*oops*" );
+        status = action.removeWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have returned an error, with no whitelist pattern removed.
+        assertHasErrors( action );
+        assertEquals( 2, connector.getWhiteListPatterns().size() );
+
+        // Try again, but now with a valid pattern to remove.
+        action.setPattern( "com/sun/**/*" );
+        preRequest( action );
+        status = action.removeWhiteListPattern();
+        assertEquals( Action.INPUT, status );
+
+        // Should have no error, and 1 whitelist pattern left.
+        assertNoErrors( action );
+        assertEquals( 1, connector.getWhiteListPatterns().size() );
+        assertEquals( "Should have left 1 whitelist pattern", "javax/**/*", connector.getWhiteListPatterns().get( 0 ) );
+    }
+
+    public void testSecureActionBundle()
+        throws Exception
+    {
+        /* Configuration will be requested at least 3 times. */
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    private void assertInitialProxyConnector( ProxyConnector connector )
+    {
+        assertNotNull( connector );
+        assertNotNull( connector.getBlackListPatterns() );
+        assertNotNull( connector.getWhiteListPatterns() );
+        assertNotNull( connector.getProperties() );
+
+        assertEquals( TEST_SOURCE_ID, connector.getSourceRepoId() );
+        assertEquals( TEST_TARGET_ID, connector.getTargetRepoId() );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( TEST_SOURCE_ID );
+        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+        managedRepo.setReleases( true );
+
+        config.addManagedRepository( managedRepo );
+
+        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( TEST_TARGET_ID );
+        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+        config.addRemoteRepository( remoteRepo );
+
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( TEST_SOURCE_ID );
+        connector.setTargetRepoId( TEST_TARGET_ID );
+
+        // TODO: Set these options programatically via list of available policies.
+        Map<String, String> policies = connector.getPolicies();
+        policies.put( "releases", new ReleasesPolicy().getDefaultOption() );
+        policies.put( "snapshots", new SnapshotsPolicy().getDefaultOption() );
+        policies.put( "checksum", new ChecksumPolicy().getDefaultOption() );
+        policies.put( "cache-failures", new CachedFailuresPolicy().getDefaultOption() );
+        policies.put( "propagate-errors", new PropagateErrorsDownloadPolicy().getDefaultOption() );
+        policies.put( "propagate-errors-on-update", new PropagateErrorsOnUpdateDownloadPolicy().getDefaultOption() );
+
+        config.addProxyConnector( connector );
+
+        return config;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.java
new file mode 100644 (file)
index 0000000..5c42556
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ *  Copyright 2008 jdumay.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.easymock.MockControl;
+
+public class EnableProxyConnectorActionTest
+    extends AbstractWebworkTestCase
+{
+    private static final String TEST_TARGET_ID = "central";
+
+    private static final String TEST_SOURCE_ID = "corporate";
+
+    private EnableProxyConnectorAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        action = (EnableProxyConnectorAction) getActionProxy( "/admin/enableProxyConnector.action" ).getAction();
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( config, requestConfigCount );
+        archivaConfiguration.save( config );
+    }
+
+    public void testConfirmDeleteBadSourceOrTarget()
+        throws Exception
+    {
+        expectConfigurationRequests( 4 );
+        archivaConfigurationControl.replay();
+
+        // Attempt to show the confirm enable screen, but provide
+        // a bad source id or target id to actually enable
+
+        preRequest( action );
+        action.setSource( "bad-source" ); // id doesn't exist.
+        action.setTarget( "bad-target" ); // id doesn't exist.
+        String status = action.confirmEnable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( "bad" ); // Bad doesn't exist.
+        action.setTarget( TEST_TARGET_ID );
+        status = action.confirmEnable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( "bad" ); // Bad doesn't exist.
+        status = action.confirmEnable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+    }
+
+    public void testConfirmEnableNoSourceOrTarget()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        // Attempt to show the confirm enable screen, but don't provide
+        // the source id or target id to actually delete
+
+        preRequest( action );
+        action.setSource( null ); // No source Id.
+        action.setTarget( null ); // No target Id.
+        String status = action.confirmEnable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( null ); // No target Id.
+        status = action.confirmEnable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+
+        preRequest( action );
+        action.setSource( null ); // No source Id.
+        action.setTarget( TEST_TARGET_ID );
+        status = action.confirmEnable();
+        // Should have resulted in an error.
+        assertEquals( Action.ERROR, status );
+        assertHasErrors( action );
+    }
+
+    public void testEnable()
+        throws Exception
+    {
+        expectConfigurationRequests( 5 );
+        archivaConfigurationControl.replay();
+
+        // Show the confirm the enable of proxy connector screen.
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        String status = action.confirmEnable();
+        assertEquals( Action.INPUT, status );
+        assertNoErrors( action );
+
+        // Perform the delete.
+        preRequest( action );
+        status = action.enable();
+        assertEquals( Action.SUCCESS, status );
+        assertNoErrors( action );
+        assertHasMessages( action );
+
+        // Test the configuration.
+        assertEquals( 1, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
+        ProxyConnectorConfiguration config =
+            (ProxyConnectorConfiguration) archivaConfiguration.getConfiguration().getProxyConnectors().get( 0 );
+        assertFalse( config.isDisabled() );
+    }
+
+    public void testSecureActionBundle()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testConfirmEnable()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        // Show the confirm the enable of proxy connector screen.
+        preRequest( action );
+        action.setSource( TEST_SOURCE_ID );
+        action.setTarget( TEST_TARGET_ID );
+        String status = action.confirmEnable();
+        assertEquals( Action.INPUT, status );
+        assertNoErrors( action );
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( TEST_SOURCE_ID );
+        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+        managedRepo.setReleases( true );
+
+        config.addManagedRepository( managedRepo );
+
+        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( TEST_TARGET_ID );
+        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+        config.addRemoteRepository( remoteRepo );
+
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( TEST_SOURCE_ID );
+        connector.setTargetRepoId( TEST_TARGET_ID );
+        connector.setDisabled( true );
+
+        config.addProxyConnector( connector );
+
+        return config;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java
new file mode 100644 (file)
index 0000000..12adeb4
--- /dev/null
@@ -0,0 +1,157 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.plexus.registry.RegistryException;
+import org.easymock.MockControl;
+
+/**
+ * ProxyConnectorsActionTest 
+ *
+ * @version $Id$
+ */
+public class ProxyConnectorsActionTest
+    extends AbstractWebworkTestCase
+{
+    private static final String JAVAX = "javax";
+
+    private static final String CENTRAL = "central";
+
+    private static final String CORPORATE = "corporate";
+
+    private ProxyConnectorsAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (ProxyConnectorsAction) getActionProxy("/admin/proxyConnectors.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
+    }
+
+    public void testSecureActionBundle()
+        throws Exception
+    {
+        expectConfigurationRequests( 4 );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testExecute()
+        throws Exception
+    {
+        expectConfigurationRequests( 5 );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+
+        String status = action.execute();
+        assertEquals( Action.SUCCESS, status );
+        assertNoErrors( action );
+        
+        assertNotNull( action.getProxyConnectorMap() );
+        assertNotNull( action.getRepoMap() );
+
+        assertEquals( 1, action.getProxyConnectorMap().size() );
+        assertEquals( 3, action.getRepoMap().size() );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        for ( int i = 0; i < requestConfigCount; i++ )
+        {
+            archivaConfiguration.getConfiguration();
+            archivaConfigurationControl.setReturnValue( config );
+        }
+
+        archivaConfiguration.save( config );
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( CORPORATE );
+        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+        managedRepo.setReleases( true );
+
+        config.addManagedRepository( managedRepo );
+
+        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( CENTRAL );
+        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+        config.addRemoteRepository( remoteRepo );
+
+        remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( JAVAX );
+        remoteRepo.setUrl( "http://download.java.net/maven/2/" );
+
+        config.addRemoteRepository( remoteRepo );
+
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( CORPORATE );
+        connector.setTargetRepoId( CENTRAL );
+
+        config.addProxyConnector( connector );
+
+        connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( CORPORATE );
+        connector.setTargetRepoId( JAVAX );
+
+        config.addProxyConnector( connector );
+
+        return config;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java
new file mode 100644 (file)
index 0000000..462c8d2
--- /dev/null
@@ -0,0 +1,256 @@
+package org.apache.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.commons.lang.StringUtils;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.configuration.functors.ProxyConnectorConfigurationOrderComparator;
+import org.apache.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.easymock.MockControl;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * SortProxyConnectorsActionTest
+ *
+ * @version $Id$
+ */
+public class SortProxyConnectorsActionTest
+    extends AbstractWebworkTestCase
+{
+    private static final String JAVAX = "javax";
+
+    private static final String CENTRAL = "central";
+
+    private static final String CORPORATE = "corporate";
+
+    private static final String CODEHAUS = "codehaus";
+
+    private SortProxyConnectorsAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (SortProxyConnectorsAction) getActionProxy( "/admin/sortUpProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( config, requestConfigCount );
+
+        archivaConfiguration.save( config );
+    }
+
+    public void testSecureActionBundle()
+        throws Exception
+    {
+        expectConfigurationRequests( 1 );
+        archivaConfigurationControl.replay();
+
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testSortDown()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        action.setSource( CORPORATE );
+        action.setTarget( CENTRAL );
+        String status = action.sortDown();
+        assertEquals( Action.SUCCESS, status );
+
+        assertOrder( new String[]{ JAVAX, CENTRAL, CODEHAUS } );
+    }
+
+    public void testSortDownPastEnd()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Ask the last connector to sort down (essentially a no-op)
+        action.setSource( CORPORATE );
+        action.setTarget( CODEHAUS );
+        String status = action.sortDown();
+        assertEquals( Action.SUCCESS, status );
+
+        // No order change.
+        assertOrder( new String[]{ CENTRAL, JAVAX, CODEHAUS } );
+    }
+
+    public void testSortUp()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        action.setSource( CORPORATE );
+        action.setTarget( CODEHAUS );
+        String status = action.sortUp();
+        assertEquals( Action.SUCCESS, status );
+
+        assertOrder( new String[]{ CENTRAL, CODEHAUS, JAVAX } );
+    }
+
+    public void testSortUpPastBeginning()
+        throws Exception
+    {
+        expectConfigurationRequests( 7 );
+        archivaConfigurationControl.replay();
+
+        // Ask the first connector to sort up (essentially a no-op)
+        action.setSource( CORPORATE );
+        action.setTarget( CENTRAL );
+        String status = action.sortUp();
+        assertEquals( Action.SUCCESS, status );
+
+        // No order change.
+        assertOrder( new String[]{ CENTRAL, JAVAX, CODEHAUS } );
+    }
+
+    private void assertOrder( String[] targetRepoOrder )
+    {
+        List<ProxyConnectorConfiguration> connectors = archivaConfiguration.getConfiguration().getProxyConnectors();
+        Collections.sort( connectors, ProxyConnectorConfigurationOrderComparator.getInstance() );
+
+        for ( ProxyConnectorConfiguration connector : connectors )
+        {
+            assertEquals( "All connectors in list should have the same source id (in this test)", CORPORATE,
+                          connector.getSourceRepoId() );
+        }
+
+        assertEquals( targetRepoOrder.length, connectors.size() );
+
+        int orderFailedAt = ( -1 );
+        for ( int i = 0; i < targetRepoOrder.length; i++ )
+        {
+            if ( !StringUtils.equals( targetRepoOrder[i], connectors.get( i ).getTargetRepoId() ) )
+            {
+                orderFailedAt = i;
+                break;
+            }
+        }
+
+        if ( orderFailedAt >= 0 )
+        {
+            StringBuffer msg = new StringBuffer();
+
+            msg.append( "Failed expected order of the proxy connectors <" );
+            msg.append( StringUtils.join( targetRepoOrder, ", " ) );
+            msg.append( ">, actual <" );
+
+            boolean needsComma = false;
+            for ( ProxyConnectorConfiguration proxy : connectors )
+            {
+                if ( needsComma )
+                {
+                    msg.append( ", " );
+                }
+                msg.append( proxy.getTargetRepoId() );
+                needsComma = true;
+            }
+            msg.append( "> failure at index <" ).append( orderFailedAt ).append( ">." );
+
+            fail( msg.toString() );
+        }
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+        managedRepo.setId( CORPORATE );
+        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+        managedRepo.setReleases( true );
+        config.addManagedRepository( managedRepo );
+
+        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( CENTRAL );
+        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+        config.addRemoteRepository( remoteRepo );
+
+        remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( JAVAX );
+        remoteRepo.setUrl( "http://download.java.net/maven/2/" );
+        config.addRemoteRepository( remoteRepo );
+
+        remoteRepo = new RemoteRepositoryConfiguration();
+        remoteRepo.setId( CODEHAUS );
+        remoteRepo.setUrl( "http://repository.codehaus.org/" );
+        config.addRemoteRepository( remoteRepo );
+
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( CORPORATE );
+        connector.setTargetRepoId( CENTRAL );
+        connector.setOrder( 1 );
+        config.addProxyConnector( connector );
+
+        connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( CORPORATE );
+        connector.setTargetRepoId( JAVAX );
+        connector.setOrder( 2 );
+        config.addProxyConnector( connector );
+
+        connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( CORPORATE );
+        connector.setTargetRepoId( CODEHAUS );
+        connector.setOrder( 3 );
+        config.addProxyConnector( connector );
+
+        return config;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/legacy/AddLegacyArtifactPathActionTest.java
new file mode 100644 (file)
index 0000000..b0803a6
--- /dev/null
@@ -0,0 +1,256 @@
+package org.apache.archiva.web.action.admin.legacy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import junit.framework.TestCase;
+import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.web.validator.utils.ValidatorUtil;
+import org.apache.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AddLegacyArtifactPathActionTest
+    extends TestCase
+{
+    private static final String EMPTY_STRING = "";
+
+    // valid inputs
+    private static final String LEGACY_ARTIFACT_PATH_PATH_VALID_INPUT = "-abcXYZ0129._/\\";
+
+    private static final String GROUP_ID_VALID_INPUT = "abcXYZ0129._-";
+
+    private static final String ARTIFACT_ID_VALID_INPUT = "abcXYZ0129._-";
+
+    private static final String VERSION_VALID_INPUT = "abcXYZ0129._-";
+
+    private static final String CLASSIFIER_VALID_INPUT = "abcXYZ0129._-";
+
+    private static final String TYPE_VALID_INPUT = "abcXYZ0129._-";
+
+    // invalid inputs
+    private static final String LEGACY_ARTIFACT_PATH_PATH_INVALID_INPUT = "<> ~+[ ]'\"";
+
+    private static final String GROUP_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
+
+    private static final String ARTIFACT_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
+
+    private static final String VERSION_INVALID_INPUT = "<> \\/~+[ ]'\"";
+
+    private static final String CLASSIFIER_INVALID_INPUT = "<> \\/~+[ ]'\"";
+
+    private static final String TYPE_INVALID_INPUT = "<> \\/~+[ ]'\"";
+
+    // testing requisite
+    private AddLegacyArtifactPathAction addLegacyArtifactPathAction;
+
+    private ActionValidatorManager actionValidatorManager;
+
+    @Override
+    public void setUp()
+        throws Exception
+    {
+        addLegacyArtifactPathAction = new AddLegacyArtifactPathAction();
+
+        DefaultActionValidatorManagerFactory factory = new DefaultActionValidatorManagerFactory();
+
+        actionValidatorManager = factory.createDefaultActionValidatorManager();
+    }
+
+    public void testStruts2ValidationFrameworkWithNullInputs()
+        throws Exception
+    {
+        // prep
+        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( null );
+        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath, null, null, null,
+                                                   null, null );
+
+        // test
+        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
+
+        // verify
+        assertTrue( addLegacyArtifactPathAction.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = addLegacyArtifactPathAction.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a legacy path." );
+        expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a groupId." );
+        expectedFieldErrors.put( "groupId", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter an artifactId." );
+        expectedFieldErrors.put( "artifactId", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a version." );
+        expectedFieldErrors.put( "version", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a type." );
+        expectedFieldErrors.put( "type", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithBlankInputs()
+        throws Exception
+    {
+        // prep
+        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( EMPTY_STRING );
+        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath, EMPTY_STRING,
+                                                   EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
+
+        // test
+        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
+
+        // verify
+        assertTrue( addLegacyArtifactPathAction.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = addLegacyArtifactPathAction.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a legacy path." );
+        expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a groupId." );
+        expectedFieldErrors.put( "groupId", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter an artifactId." );
+        expectedFieldErrors.put( "artifactId", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a version." );
+        expectedFieldErrors.put( "version", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a type." );
+        expectedFieldErrors.put( "type", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithInvalidInputs()
+        throws Exception
+    {
+        // prep
+        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_INVALID_INPUT );
+        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath,
+                                                   GROUP_ID_INVALID_INPUT, ARTIFACT_ID_INVALID_INPUT,
+                                                   VERSION_INVALID_INPUT, CLASSIFIER_INVALID_INPUT,
+                                                   TYPE_INVALID_INPUT );
+
+        // test
+        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
+
+        // verify
+        assertTrue( addLegacyArtifactPathAction.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = addLegacyArtifactPathAction.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "groupId", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "artifactId", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "version", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "classifier", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "type", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithValidInputs()
+        throws Exception
+    {
+        // prep
+        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_VALID_INPUT );
+        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath,
+                                                   GROUP_ID_VALID_INPUT, ARTIFACT_ID_VALID_INPUT, VERSION_VALID_INPUT,
+                                                   CLASSIFIER_VALID_INPUT, TYPE_VALID_INPUT );
+
+        // test
+        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
+
+        // verify
+        assertFalse( addLegacyArtifactPathAction.hasFieldErrors() );
+    }
+
+    private LegacyArtifactPath createLegacyArtifactPath( String path )
+    {
+        LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
+        legacyArtifactPath.setPath( path );
+        return legacyArtifactPath;
+    }
+
+    private void populateAddLegacyArtifactPathActionFields( AddLegacyArtifactPathAction addLegacyArtifactPathAction,
+                                                            LegacyArtifactPath legacyArtifactPath, String groupId,
+                                                            String artifactId, String version, String classifier,
+                                                            String type )
+    {
+        addLegacyArtifactPathAction.setLegacyArtifactPath( legacyArtifactPath );
+        addLegacyArtifactPathAction.setGroupId( groupId );
+        addLegacyArtifactPathAction.setArtifactId( artifactId );
+        addLegacyArtifactPathAction.setVersion( version );
+        addLegacyArtifactPathAction.setClassifier( classifier );
+        addLegacyArtifactPathAction.setType( type );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyActionTest.java
new file mode 100644 (file)
index 0000000..f4aaf27
--- /dev/null
@@ -0,0 +1,221 @@
+package org.apache.archiva.web.action.admin.networkproxies;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import junit.framework.TestCase;
+import org.apache.archiva.admin.model.beans.NetworkProxy;
+import org.apache.archiva.web.validator.utils.ValidatorUtil;
+import org.apache.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ConfigureNetworkProxyActionTest extends TestCase
+{
+    private static final String EMPTY_STRING = "";
+
+    private static final String VALIDATION_CONTEXT = "saveNetworkProxy";
+
+    // valid inputs
+    private static final String PROXY_ID_VALID_INPUT = "abcXYZ0129._-";
+
+    private static final String PROXY_PROTOCOL_VALID_INPUT = "-abcXYZ0129./:\\";
+
+    private static final String PROXY_HOST_VALID_INPUT = "abcXYZ0129._/\\~:?!&=-";
+
+    private static final int PROXY_PORT_VALID_INPUT = 8080;
+
+    private static final String PROXY_USERNAME_VALID_INPUT = "abcXYZ0129.@/_-\\";
+
+    // invalid inputs
+    private static final String PROXY_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
+
+    private static final String PROXY_PROTOCOL_INVALID_INPUT = "<> ~+[ ]'\"";
+
+    private static final String PROXY_HOST_INVALID_INPUT = "<> ~+[ ]'\"";
+
+    private static final int PROXY_PORT_INVALID_INPUT = 0;
+
+    private static final String PROXY_USERNAME_INVALID_INPUT = "<> ~+[ ]'\"";
+
+    // testing requisite
+    private ConfigureNetworkProxyAction configureNetworkProxyAction;
+
+    private ActionValidatorManager actionValidatorManager;
+    
+    @Override
+    public void setUp()
+        throws Exception
+    {
+        configureNetworkProxyAction = new ConfigureNetworkProxyAction();
+
+        DefaultActionValidatorManagerFactory factory = new DefaultActionValidatorManagerFactory();
+
+        actionValidatorManager = factory.createDefaultActionValidatorManager();
+    }
+
+    public void testStruts2ValidationFrameworkWithNullInputs() throws Exception
+    {
+        // prep
+        NetworkProxy networkProxy = createNetworkProxy(null, null, null, null);
+        configureNetworkProxyAction.setProxy(networkProxy);
+
+        // test
+        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
+
+        // verify
+        assertTrue(configureNetworkProxyAction.hasFieldErrors());
+
+        Map<String, List<String>> fieldErrors = configureNetworkProxyAction.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("You must enter an identifier.");
+        expectedFieldErrors.put("proxy.id", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("You must enter a protocol.");
+        expectedFieldErrors.put("proxy.protocol", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("You must enter a host.");
+        expectedFieldErrors.put("proxy.host", expectedErrorMessages);
+
+        ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
+    }
+
+    public void testStruts2ValidationFrameworkWithBlankInputs() throws Exception
+    {
+        // prep
+        NetworkProxy networkProxy = createNetworkProxy(EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING);
+        configureNetworkProxyAction.setProxy(networkProxy);
+
+        // test
+        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
+
+        // verify
+        assertTrue(configureNetworkProxyAction.hasFieldErrors());
+
+        Map<String, List<String>> fieldErrors = configureNetworkProxyAction.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("You must enter an identifier.");
+        expectedFieldErrors.put("proxy.id", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("You must enter a protocol.");
+        expectedFieldErrors.put("proxy.protocol", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("You must enter a host.");
+        expectedFieldErrors.put("proxy.host", expectedErrorMessages);
+
+        ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
+    }
+
+    public void testStruts2ValidationFrameworkWithInvalidInputs() throws Exception
+    {
+        // prep
+        NetworkProxy networkProxy = createNetworkProxy( PROXY_ID_INVALID_INPUT, PROXY_HOST_INVALID_INPUT,
+                                                        PROXY_PORT_INVALID_INPUT, PROXY_PROTOCOL_INVALID_INPUT,
+                                                        PROXY_USERNAME_INVALID_INPUT );
+        configureNetworkProxyAction.setProxy(networkProxy);
+
+        // test
+        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
+
+        // verify
+        assertTrue(configureNetworkProxyAction.hasFieldErrors());
+
+        Map<String, List<String>> fieldErrors = configureNetworkProxyAction.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
+        expectedFieldErrors.put("proxy.id", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-).");
+        expectedFieldErrors.put("proxy.protocol", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).");
+        expectedFieldErrors.put("proxy.host", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("Port needs to be larger than 1");
+        expectedFieldErrors.put("proxy.port", expectedErrorMessages);
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add("Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-).");
+        expectedFieldErrors.put("proxy.username", expectedErrorMessages);
+
+        ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
+    }
+
+    public void testStruts2ValidationFrameworkWithValidInputs() throws Exception
+    {
+        // prep
+        NetworkProxy networkProxy = createNetworkProxy(PROXY_ID_VALID_INPUT, PROXY_HOST_VALID_INPUT, PROXY_PORT_VALID_INPUT, PROXY_PROTOCOL_VALID_INPUT, PROXY_USERNAME_VALID_INPUT);
+        configureNetworkProxyAction.setProxy(networkProxy);
+
+        // test
+        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
+
+        // verify
+        assertFalse(configureNetworkProxyAction.hasFieldErrors());
+    }
+
+    private NetworkProxy createNetworkProxy(String id, String host, int port, String protocol, String username)
+    {
+        NetworkProxy networkProxy = new NetworkProxy();
+        networkProxy.setId( id );
+        networkProxy.setHost( host );
+        networkProxy.setPort( port );
+        networkProxy.setProtocol( protocol );
+        networkProxy.setUsername( username );
+        return networkProxy;
+    }
+
+    // over-loaded
+    // for simulating empty/null form purposes; excluding primitive data-typed values
+    private NetworkProxy createNetworkProxy(String id, String host, String protocol, String username)
+    {
+        NetworkProxy networkProxy = new NetworkProxy();
+        networkProxy.setId( id );
+        networkProxy.setHost( host );
+        networkProxy.setProtocol( protocol );
+        networkProxy.setUsername( username );
+        return networkProxy;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AbstractManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AbstractManagedRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..41a3a25
--- /dev/null
@@ -0,0 +1,146 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.struts2.StrutsSpringTestCase;
+
+import java.io.File;
+
+public abstract class AbstractManagedRepositoryActionTest
+    extends StrutsSpringTestCase
+{
+    protected static final String EMPTY_STRING = "";
+
+    // valid inputs; validation testing
+    protected static final String REPOSITORY_ID_VALID_INPUT = "abcXYZ0129._-";
+
+    protected static final String REPOSITORY_LOCATION_VALID_INPUT = "abcXYZ0129._/\\~:?!&=-";
+
+    protected static final String REPOSITORY_INDEX_DIR_VALID_INPUT = "abcXYZ0129._/\\~:?!&=-";
+
+    protected static final String REPOSITORY_NAME_VALID_INPUT = "abcXYZ   0129.)/   _(-";
+
+    protected static final int REPOSITORY_RETENTION_COUNT_VALID_INPUT = 1;
+
+    protected static final int REPOSITORY_DAYS_OLDER_VALID_INPUT = 1;
+
+    // invalid inputs; validation testing
+    protected static final String REPOSITORY_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
+
+    protected static final String REPOSITORY_LOCATION_INVALID_INPUT = "<> ~+[ ]'\"";
+
+    protected static final String REPOSITORY_INDEX_DIR_INVALID_INPUT = "<> ~+[ ]'\"";
+
+    protected static final String REPOSITORY_NAME_INVALID_INPUT = "<>\\~+[]'\"";
+
+    protected static final int REPOSITORY_RETENTION_COUNT_INVALID_INPUT = 101;
+
+    protected static final int REPOSITORY_DAYS_OLDER_INVALID_INPUT = -1;
+
+    // testing requisite; validation testing
+    protected ActionValidatorManager actionValidatorManager;
+
+    protected static final String REPO_ID = "repo-ident";
+
+    protected File location;
+
+    @Override
+    protected String[] getContextLocations()
+    {
+        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
+    }
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        DefaultActionValidatorManagerFactory defaultActionValidatorManagerFactory =
+            new DefaultActionValidatorManagerFactory();
+
+        actionValidatorManager = defaultActionValidatorManagerFactory.createDefaultActionValidatorManager();
+    }
+
+    protected void populateRepository( ManagedRepository repository )
+    {
+        repository.setId( REPO_ID );
+        repository.setName( "repo name" );
+        repository.setLocation( location.getAbsolutePath() );
+        repository.setLayout( "default" );
+        repository.setCronExpression( "* 0/5 * * * ?" );
+        repository.setDaysOlder( 31 );
+        repository.setRetentionCount( 20 );
+        repository.setReleases( true );
+        repository.setSnapshots( false );
+        repository.setScanned( false );
+        repository.setDeleteReleasedSnapshots( true );
+    }
+
+    protected ManagedRepository createManagedRepository( String id, String name, String location )
+    {
+        ManagedRepository managedRepositoryConfiguration = new ManagedRepository();
+
+        managedRepositoryConfiguration.setId( id );
+        managedRepositoryConfiguration.setName( name );
+        managedRepositoryConfiguration.setLocation( location );
+
+        return managedRepositoryConfiguration;
+    }
+
+    // over-loaded
+    // for simulating empty/null form purposes; excluding primitive data-typed values
+    protected ManagedRepository createManagedRepository( String id, String name, String location,
+                                                                      String indexDir )
+    {
+        ManagedRepository managedRepositoryConfiguration = new ManagedRepository();
+
+        managedRepositoryConfiguration.setId( id );
+        managedRepositoryConfiguration.setName( name );
+        managedRepositoryConfiguration.setLocation( location );
+        managedRepositoryConfiguration.setIndexDirectory( indexDir );
+
+        return managedRepositoryConfiguration;
+    }
+
+    protected ManagedRepository createManagedRepository( String id, String name, String location, String indexDir,
+                                                         int daysOlder, int retentionCount )
+    {
+        ManagedRepository managedRepositoryConfiguration = new ManagedRepository();
+
+        managedRepositoryConfiguration.setId( id );
+        managedRepositoryConfiguration.setName( name );
+        managedRepositoryConfiguration.setLocation( location );
+        managedRepositoryConfiguration.setIndexDirectory( indexDir );
+        managedRepositoryConfiguration.setDaysOlder( daysOlder );
+        managedRepositoryConfiguration.setRetentionCount( retentionCount );
+
+        return managedRepositoryConfiguration;
+    }
+
+
+    protected ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return applicationContext.getBean( ManagedRepositoryAdmin.class );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..d068547
--- /dev/null
@@ -0,0 +1,393 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.repository.RepositoryCommonValidator;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
+import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.security.ArchivaRoleConstants;
+import org.apache.archiva.web.validator.utils.ValidatorUtil;
+import org.apache.commons.io.FileUtils;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.codehaus.plexus.redback.role.RoleManager;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AddManagedRepositoryActionTest
+ *
+ * @version $Id$
+ */
+public class AddManagedRepositoryActionTest
+    extends AbstractManagedRepositoryActionTest
+{
+    private AddManagedRepositoryAction action;
+
+    private RoleManager roleManager;
+
+    private MockControl roleManagerControl;
+
+    private MockControl archivaConfigurationControl;
+
+    private Registry registry;
+
+    private MockControl registryControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    private MockControl repositoryTaskSchedulerControl;
+
+    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
+
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = new AddManagedRepositoryAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        roleManagerControl = MockControl.createControl( RoleManager.class );
+        roleManager = (RoleManager) roleManagerControl.getMock();
+
+        registryControl = MockControl.createControl( Registry.class );
+        registry = (Registry) registryControl.getMock();
+        //action.setRegistry( registry );
+
+        repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
+        repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
+
+        location = new File( "target/test/location" );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRegistry( registry );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryTaskScheduler(
+            repositoryTaskScheduler );
+
+        RepositoryCommonValidator repositoryCommonValidator = new RepositoryCommonValidator();
+        repositoryCommonValidator.setArchivaConfiguration( archivaConfiguration );
+        repositoryCommonValidator.setRegistry( registry );
+
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryCommonValidator(
+            repositoryCommonValidator );
+
+        action.setRepositoryCommonValidator( repositoryCommonValidator );
+
+        action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
+
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testAddRepositoryInitialPage()
+        throws Exception
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        ManagedRepository configuration = action.getRepository();
+        assertNotNull( configuration );
+        assertNull( configuration.getId() );
+        // check all booleans are false
+        assertFalse( configuration.isDeleteReleasedSnapshots() );
+        assertFalse( configuration.isScanned() );
+        assertFalse( configuration.isReleases() );
+        assertFalse( configuration.isSnapshots() );
+
+        String status = action.input();
+        assertEquals( Action.INPUT, status );
+
+        // check defaults
+        assertFalse( configuration.isDeleteReleasedSnapshots() );
+        assertTrue( configuration.isScanned() );
+        assertTrue( configuration.isReleases() );
+        assertFalse( configuration.isSnapshots() );
+    }
+
+    public void testAddRepository()
+        throws Exception
+    {
+        FileUtils.deleteDirectory( location );
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManagerControl.setVoidCallable();
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.setVoidCallable();
+
+        roleManagerControl.replay();
+
+        registry.getString( "appserver.base", "${appserver.base}" );
+        registryControl.setReturnValue( "target/test" );
+        registry.getString( "appserver.home", "${appserver.home}" );
+        registryControl.setReturnValue( "target/test" );
+
+        registry.getString( "appserver.base", "${appserver.base}" );
+        registryControl.setReturnValue( "target/test" );
+        registry.getString( "appserver.home", "${appserver.home}" );
+        registryControl.setReturnValue( "target/test" );
+
+        registryControl.replay();
+
+        RepositoryTask task = new RepositoryTask();
+        task.setRepositoryId( REPO_ID );
+        repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
+        repositoryTaskSchedulerControl.setReturnValue( false );
+        repositoryTaskScheduler.queueTask( task );
+        repositoryTaskSchedulerControl.setVoidCallable();
+        repositoryTaskSchedulerControl.replay();
+
+        Configuration configuration = new Configuration();
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.save( configuration );
+
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        ManagedRepository repository = action.getRepository();
+        populateRepository( repository );
+
+        assertFalse( location.exists() );
+        String status = action.commit();
+        assertEquals( Action.SUCCESS, status );
+        assertTrue( location.exists() );
+
+        assertEquals( Collections.singletonList( repository ), getManagedRepositoryAdmin().getManagedRepositories() );
+        assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
+
+        roleManagerControl.verify();
+        archivaConfigurationControl.verify();
+        registryControl.verify();
+    }
+
+
+    public void testAddRepositoryExistingLocation()
+        throws Exception
+    {
+        if ( !location.exists() )
+        {
+            location.mkdirs();
+        }
+
+        registry.getString( "appserver.base", "${appserver.base}" );
+        registryControl.setReturnValue( "target/test" );
+        registry.getString( "appserver.home", "${appserver.home}" );
+        registryControl.setReturnValue( "target/test" );
+
+        registryControl.replay();
+
+        action.prepare();
+        ManagedRepository repository = action.getRepository();
+        populateRepository( repository );
+
+        assertTrue( location.exists() );
+        String status = action.commit();
+        assertEquals( AddManagedRepositoryAction.CONFIRM, status );
+        assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
+        registryControl.verify();
+    }
+
+    public void testStruts2ValidationFrameworkWithNullInputs()
+        throws Exception
+    {
+        // prep
+        // 0 is the default value for primitive int; null for objects
+        ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository identifier." );
+        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a directory." );
+        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository name." );
+        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithBlankInputs()
+        throws Exception
+    {
+        // prep
+        // 0 is the default value for primitive int
+        ManagedRepository managedRepositoryConfiguration =
+            createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository identifier." );
+        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a directory." );
+        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository name." );
+        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithInvalidInputs()
+        throws Exception
+    {
+        // prep
+        ManagedRepository managedRepositoryConfiguration =
+            createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
+                                     REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
+                                     REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+        expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
+        expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
+        expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithValidInputs()
+        throws Exception
+    {
+        // prep
+        ManagedRepository managedRepositoryConfiguration =
+            createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
+                                     REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
+                                     REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertFalse( action.hasFieldErrors() );
+    }
+
+    // TODO: test errors during add, other actions
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..6d4b8e2
--- /dev/null
@@ -0,0 +1,133 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.web.action.AbstractActionTestCase;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+
+import java.util.Collections;
+
+/**
+ * AddRemoteRepositoryActionTest
+ *
+ * @version $Id$
+ */
+public class AddRemoteRepositoryActionTest
+    extends AbstractActionTestCase
+{
+    private AddRemoteRepositoryAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    private static final String REPO_ID = "remote-repo-ident";
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (AddRemoteRepositoryAction) getActionProxy( "/admin/addRemoteRepository.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testAddRemoteRepositoryInitialPage()
+        throws Exception
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        RemoteRepository configuration = action.getRepository();
+        assertNotNull( configuration );
+        assertNull( configuration.getId() );
+
+        String status = action.input();
+        assertEquals( Action.INPUT, status );
+    }
+
+    public void testAddRemoteRepository()
+        throws Exception
+    {
+        Configuration configuration = new Configuration();
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.save( configuration );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        RemoteRepository repository = action.getRepository();
+        populateRepository( repository );
+
+        assertEquals( "url ", repository.getUrl() );
+
+        String status = action.commit();
+        assertEquals( Action.SUCCESS, status );
+
+        assertEquals( Collections.singletonList( repository ),
+                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
+
+        assertEquals( "url", repository.getUrl() );
+
+        archivaConfigurationControl.verify();
+    }
+
+    private void populateRepository( RemoteRepository repository )
+    {
+        repository.setId( REPO_ID );
+        repository.setName( "repo name" );
+        repository.setUrl( "url " );
+        repository.setLayout( "default" );
+    }
+
+    // TODO: test errors during add, other actions
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DefaultActionValidatorManagerFactory.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DefaultActionValidatorManagerFactory.java
new file mode 100644 (file)
index 0000000..6ad924b
--- /dev/null
@@ -0,0 +1,115 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.DefaultTextProvider;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.TextProvider;
+import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
+import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer;
+import com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter;
+import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Scope;
+import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
+import com.opensymphony.xwork2.ognl.OgnlUtil;
+import com.opensymphony.xwork2.ognl.OgnlValueStackFactory;
+import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
+import com.opensymphony.xwork2.util.CompoundRoot;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import com.opensymphony.xwork2.validator.DefaultActionValidatorManager;
+import com.opensymphony.xwork2.validator.DefaultValidatorFactory;
+import com.opensymphony.xwork2.validator.DefaultValidatorFileParser;
+import ognl.PropertyAccessor;
+
+import java.util.HashMap;
+
+/**
+ * Factory for creating the DefaultActionValidatorManager to be used for the validation tests.
+ */
+public class DefaultActionValidatorManagerFactory
+{
+    
+    // ObjectFactory.setObjectFactory(..) was removed in struts 2.1, so we have to workaround with this
+    //  to make the validation tests work
+    public ActionValidatorManager createDefaultActionValidatorManager()
+        throws ClassNotFoundException
+    {
+        Container container = createBootstrapContainer();
+
+        ActionContext context = new ActionContext( new HashMap<String, Object>() );
+        context.setValueStack( createValueStack( container ) );
+        ActionContext.setContext( context );
+
+        OgnlReflectionProvider reflectionProvider = new OgnlReflectionProvider();
+
+        reflectionProvider.setOgnlUtil( container.getInstance( OgnlUtil.class ) );
+
+        ObjectFactory objectFactory = new ObjectFactory();
+        objectFactory.setReflectionProvider( reflectionProvider );
+
+        DefaultValidatorFileParser fileParser = new DefaultValidatorFileParser();
+        fileParser.setObjectFactory( objectFactory );
+
+        DefaultValidatorFactory validatorFactory = new DefaultValidatorFactory( objectFactory, fileParser );
+
+        DefaultActionValidatorManager defaultValidatorManager = new DefaultActionValidatorManager();
+        defaultValidatorManager.setValidatorFactory( validatorFactory );
+        defaultValidatorManager.setValidatorFileParser( fileParser );
+
+        return defaultValidatorManager;
+    }
+
+    private ValueStack createValueStack( Container container )
+        throws ClassNotFoundException
+    {
+        OgnlValueStackFactory stackFactory = new OgnlValueStackFactory();
+
+        stackFactory.setXWorkConverter( container.getInstance( XWorkConverter.class ) );
+        stackFactory.setContainer( container );
+        stackFactory.setTextProvider( container.getInstance( TextProvider.class ) );
+
+        ValueStack stack = stackFactory.createValueStack();
+
+        return stack;
+    }
+
+    private Container createBootstrapContainer()
+    {
+        ContainerBuilder builder = new ContainerBuilder();
+        builder.factory( ObjectFactory.class, Scope.SINGLETON );
+        builder.factory( ReflectionProvider.class, OgnlReflectionProvider.class, Scope.SINGLETON );
+        builder.factory( ValueStackFactory.class, OgnlValueStackFactory.class, Scope.SINGLETON );
+        builder.factory( XWorkConverter.class, Scope.SINGLETON );
+        builder.factory( XWorkBasicConverter.class, Scope.SINGLETON );
+        builder.factory( TextProvider.class, "system", DefaultTextProvider.class, Scope.SINGLETON );
+        builder.factory( ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class, Scope.SINGLETON );
+        builder.factory( PropertyAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class, Scope.SINGLETON );
+        builder.factory( OgnlUtil.class, Scope.SINGLETON );
+        builder.constant( "devMode", "false" );
+
+        return builder.create( true );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..3d09c40
--- /dev/null
@@ -0,0 +1,474 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.security.ArchivaRoleConstants;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.archiva.web.action.AbstractActionTestCase;
+import org.apache.archiva.web.action.AuditEventArgumentsMatcher;
+import org.codehaus.plexus.redback.role.RoleManager;
+import org.codehaus.plexus.redback.role.RoleManagerException;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * DeleteManagedRepositoryActionTest
+ *
+ * @version $Id$
+ */
+public class DeleteManagedRepositoryActionTest
+    extends AbstractActionTestCase
+{
+    private DeleteManagedRepositoryAction action;
+
+    private RoleManager roleManager;
+
+    private MockControl roleManagerControl;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    private static final String REPO_ID = "repo-ident";
+
+    private File location;
+
+    private MockControl repositoryStatisticsManagerControl;
+
+    private RepositoryStatisticsManager repositoryStatisticsManager;
+
+    private MetadataRepository metadataRepository;
+
+    private RepositorySession respositorySession;
+
+    private MockControl metadataRepositoryControl;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        // TODO use getAction .??
+        action = new DeleteManagedRepositoryAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        roleManagerControl = MockControl.createControl( RoleManager.class );
+        roleManager = (RoleManager) roleManagerControl.getMock();
+        //action.setRoleManager( roleManager );
+        location = new File( "target/test/location" );
+
+        repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
+        repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
+
+        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
+        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+        metadataRepository.removeRepository( REPO_ID );
+
+        respositorySession = mock( RepositorySession.class );
+        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
+
+        TestRepositorySessionFactory factory = new TestRepositorySessionFactory();
+        factory.setRepositorySession( respositorySession );
+        action.setRepositorySessionFactory( factory );
+
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
+            repositoryStatisticsManager );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositorySessionFactory( factory );
+        action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
+
+        metadataRepositoryControl.replay();
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException, RepositoryAdminException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testDeleteRepositoryAndReposUnderRepoGroup()
+        throws Exception
+    {
+        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
+        repositoryStatisticsManagerControl.replay();
+
+        Configuration configuration = prepDeletionTest( createRepository(), 6 );
+        List<String> repoIds = new ArrayList<String>();
+        repoIds.add( REPO_ID );
+        configuration.addRepositoryGroup( createRepoGroup( repoIds, "repo.group" ) );
+
+        prepareRoleManagerMock();
+
+        assertEquals( 1, configuration.getRepositoryGroups().size() );
+
+        MockControl control = mockAuditListeners();
+        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
+        String status = action.deleteContents();
+        assertEquals( Action.SUCCESS, status );
+
+        assertTrue( configuration.getManagedRepositories().isEmpty() );
+        assertEquals( 0, configuration.getRepositoryGroups().get( 0 ).getRepositories().size() );
+
+        assertFalse( location.exists() );
+
+        repositoryStatisticsManagerControl.verify();
+        control.verify();
+        metadataRepositoryControl.verify();
+    }
+
+    public void testDeleteRepositoryConfirmation()
+        throws Exception
+    {
+        ManagedRepository originalRepository = createRepository();
+        Configuration configuration = createConfigurationForEditing( originalRepository );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        Configuration stageRepoConfiguration = new Configuration();
+        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
+        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
+
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        ManagedRepository repository = action.getRepository();
+        assertNotNull( repository );
+        assertRepositoryEquals( repository, createRepository() );
+
+        String status = action.execute();
+        assertEquals( Action.SUCCESS, status );
+
+        repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+        assertEquals( Collections.singletonList( originalRepository ),
+                      action.getManagedRepositoryAdmin().getManagedRepositories() );
+    }
+
+    public void testDeleteRepositoryKeepContent()
+        throws Exception
+    {
+        // even when we keep the content, we don't keep the metadata at this point
+        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
+        repositoryStatisticsManagerControl.replay();
+
+        prepareRoleManagerMock();
+
+        Configuration configuration = prepDeletionTest( createRepository(), 4 );
+
+        MockControl control = mockAuditListeners();
+
+        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
+
+        String status = action.deleteEntry();
+
+        assertEquals( Action.SUCCESS, status );
+
+        assertTrue( configuration.getManagedRepositories().isEmpty() );
+
+        assertTrue( location.exists() );
+
+        repositoryStatisticsManagerControl.verify();
+        control.verify();
+        metadataRepositoryControl.verify();
+    }
+
+    private MockControl mockAuditListeners()
+    {
+        MockControl control = MockControl.createControl( AuditListener.class );
+        AuditListener listener = (AuditListener) control.getMock();
+        listener.auditEvent( new AuditEvent( REPO_ID, "guest", null, AuditEvent.DELETE_MANAGED_REPO ) );
+        control.setMatcher( new AuditEventArgumentsMatcher() );
+        control.replay();
+        action.setAuditListeners( Arrays.asList( listener ) );
+
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setAuditListeners( Arrays.asList( listener ) );
+        return control;
+    }
+
+    public void testDeleteRepositoryDeleteContent()
+        throws Exception
+    {
+        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
+        repositoryStatisticsManagerControl.replay();
+
+        prepareRoleManagerMock();
+
+        Configuration configuration = prepDeletionTest( createRepository(), 4 );
+
+        MockControl control = mockAuditListeners();
+
+        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
+
+        String status = action.deleteContents();
+
+        assertEquals( Action.SUCCESS, status );
+
+        assertTrue( configuration.getManagedRepositories().isEmpty() );
+
+        assertFalse( location.exists() );
+
+        repositoryStatisticsManagerControl.verify();
+        control.verify();
+        metadataRepositoryControl.verify();
+    }
+
+    public void testDeleteRepositoryAndAssociatedProxyConnectors()
+        throws Exception
+    {
+        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
+        repositoryStatisticsManagerControl.replay();
+
+        Configuration configuration = prepDeletionTest( createRepository(), 5 );
+        configuration.addRemoteRepository( createRemoteRepository( "codehaus", "http://repository.codehaus.org" ) );
+        configuration.addRemoteRepository( createRemoteRepository( "java.net", "http://dev.java.net/maven2" ) );
+        configuration.addProxyConnector( createProxyConnector( REPO_ID, "codehaus" ) );
+
+        prepareRoleManagerMock();
+
+        assertEquals( 1, configuration.getProxyConnectors().size() );
+
+        MockControl control = mockAuditListeners();
+        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
+        String status = action.deleteContents();
+
+        assertEquals( Action.SUCCESS, status );
+
+        assertTrue( configuration.getManagedRepositories().isEmpty() );
+        assertEquals( 0, configuration.getProxyConnectors().size() );
+
+        assertFalse( location.exists() );
+
+        repositoryStatisticsManagerControl.verify();
+        control.verify();
+        metadataRepositoryControl.verify();
+    }
+
+    public void testDeleteRepositoryCancelled()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+
+        ManagedRepository originalRepository = createRepository();
+        Configuration configuration = prepDeletionTest( originalRepository, 3 );
+
+        String status = action.execute();
+        assertEquals( Action.SUCCESS, status );
+
+        ManagedRepository repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+        assertEquals( Collections.singletonList( originalRepository ),
+                      action.getManagedRepositoryAdmin().getManagedRepositories() );
+
+        assertTrue( location.exists() );
+
+        repositoryStatisticsManagerControl.verify();
+    }
+
+
+    private Configuration prepDeletionTest( ManagedRepository originalRepository, int expectCountGetConfig )
+        throws RegistryException, IndeterminateConfigurationException, RepositoryAdminException
+    {
+
+        //Configuration originalConfiguration =
+        //    ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).getArchivaConfiguration().getConfiguration();
+
+        location.mkdirs();
+
+        Configuration configuration = createConfigurationForEditing( originalRepository );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, expectCountGetConfig );
+
+        Configuration stageRepoConfiguration = new Configuration();
+        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
+        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
+
+        archivaConfiguration.save( configuration );
+
+        // save for staging repo delete
+        archivaConfiguration.save( configuration );
+
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        ManagedRepository repository = action.getRepository();
+        assertNotNull( repository );
+        assertRepositoryEquals( repository, createRepository() );
+
+        assertTrue( location.exists() );
+        return configuration;
+    }
+
+    private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
+    {
+        assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
+        assertEquals( expectedRepository.getId(), actualRepository.getId() );
+        assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
+        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
+        assertEquals( expectedRepository.getLocation(), actualRepository.getLocation() );
+        assertEquals( expectedRepository.getName(), actualRepository.getName() );
+        assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
+        assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
+        assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
+        assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
+        assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
+        assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
+    }
+
+    private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
+    {
+        Configuration configuration = new Configuration();
+        ManagedRepositoryConfiguration managedRepositoryConfiguration =
+            new BeanReplicator().replicateBean( repositoryConfiguration, ManagedRepositoryConfiguration.class );
+        managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
+        configuration.addManagedRepository( managedRepositoryConfiguration );
+        return configuration;
+    }
+
+    private ManagedRepository createRepository()
+    {
+        ManagedRepository r = new ManagedRepository();
+        r.setId( REPO_ID );
+        r.setName( "repo name" );
+        r.setLocation( location.getAbsolutePath() );
+        r.setLayout( "default" );
+        r.setCronExpression( "* 0/5 * * * ?" );
+        r.setDaysOlder( 0 );
+        r.setRetentionCount( 0 );
+        r.setReleases( true );
+        r.setSnapshots( true );
+        r.setScanned( false );
+        r.setDeleteReleasedSnapshots( false );
+        return r;
+    }
+
+    private ManagedRepositoryConfiguration createStagingRepository()
+    {
+        ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
+        r.setId( REPO_ID + "-stage" );
+        r.setName( "repo name" );
+        r.setLocation( location.getAbsolutePath() );
+        r.setLayout( "default" );
+        r.setRefreshCronExpression( "* 0/5 * * * ?" );
+        r.setDaysOlder( 0 );
+        r.setRetentionCount( 0 );
+        r.setReleases( true );
+        r.setSnapshots( true );
+        r.setScanned( false );
+        r.setDeleteReleasedSnapshots( false );
+        return r;
+    }
+
+    private RemoteRepositoryConfiguration createRemoteRepository( String id, String url )
+    {
+        RemoteRepositoryConfiguration r = new RemoteRepositoryConfiguration();
+        r.setId( id );
+        r.setUrl( url );
+        r.setLayout( "default" );
+
+        return r;
+    }
+
+    private ProxyConnectorConfiguration createProxyConnector( String managedRepoId, String remoteRepoId )
+    {
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( managedRepoId );
+        connector.setTargetRepoId( remoteRepoId );
+
+        return connector;
+    }
+
+    private RepositoryGroupConfiguration createRepoGroup( List<String> repoIds, String repoGroupId )
+    {
+        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
+        repoGroup.setId( repoGroupId );
+        repoGroup.setRepositories( repoIds );
+
+        return repoGroup;
+    }
+
+    private void prepareRoleManagerMock()
+        throws RoleManagerException
+    {
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManagerControl.setReturnValue( true );
+        roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.setReturnValue( true );
+        roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.replay();
+    }
+
+    protected ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return applicationContext.getBean( ManagedRepositoryAdmin.class );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..d4e8719
--- /dev/null
@@ -0,0 +1,222 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.web.action.AbstractActionTestCase;
+import org.codehaus.plexus.registry.RegistryException;
+import org.easymock.MockControl;
+
+import java.util.Collections;
+
+/**
+ * DeleteRemoteRepositoryActionTest
+ *
+ * @version $Id$
+ */
+public class DeleteRemoteRepositoryActionTest
+    extends AbstractActionTestCase
+{
+    private static final String REPO_ID = "remote-repo-ident";
+
+    private DeleteRemoteRepositoryAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        //action = (DeleteRemoteRepositoryAction) lookup( Action.class.getName(), "deleteRemoteRepositoryAction" );
+        action = (DeleteRemoteRepositoryAction) getActionProxy( "/admin/deleteRemoteRepository.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testDeleteRemoteRepositoryConfirmation()
+        throws Exception
+    {
+        RemoteRepository originalRepository = createRepository();
+        Configuration configuration = createConfigurationForEditing( originalRepository );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        RemoteRepository repository = action.getRepository();
+        assertNotNull( repository );
+        assertRepositoryEquals( repository, createRepository() );
+
+        String status = action.confirmDelete();
+        assertEquals( Action.INPUT, status );
+        repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+        assertEquals( Collections.singletonList( originalRepository ),
+                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
+    }
+
+    public void testDeleteRemoteRepository()
+        throws RegistryException, IndeterminateConfigurationException, RepositoryAdminException
+    {
+        Configuration configuration = createConfigurationForEditing( createRepository() );
+        configuration.addManagedRepository( createManagedRepository( "internal", "target/repo/internal" ) );
+        configuration.addManagedRepository( createManagedRepository( "snapshots", "target/repo/snapshots" ) );
+        configuration.addProxyConnector( createProxyConnector( "internal", REPO_ID ) );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 4 );
+
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        RemoteRepository repository = action.getRepository();
+        assertNotNull( repository );
+        assertRepositoryEquals( repository, createRepository() );
+
+        assertEquals( 1, configuration.getProxyConnectors().size() );
+
+        String status = action.delete();
+        assertEquals( Action.SUCCESS, status );
+
+        assertTrue( configuration.getRemoteRepositories().isEmpty() );
+        assertEquals( 0, configuration.getProxyConnectors().size() );
+    }
+
+    public void testDeleteRemoteRepositoryCancelled()
+        throws Exception
+    {
+        RemoteRepository originalRepository = createRepository();
+        Configuration configuration = createConfigurationForEditing( originalRepository );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 2 );
+
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        RemoteRepository repositoryConfiguration = action.getRepository();
+        assertNotNull( repositoryConfiguration );
+        assertRepositoryEquals( repositoryConfiguration, createRepository() );
+
+        String status = action.execute();
+        assertEquals( Action.SUCCESS, status );
+
+        RemoteRepository repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+        assertEquals( Collections.singletonList( originalRepository ),
+                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
+    }
+
+    private Configuration createConfigurationForEditing( RemoteRepository repositoryConfiguration )
+    {
+        Configuration configuration = new Configuration();
+        RemoteRepositoryConfiguration conf = new RemoteRepositoryConfiguration();
+        conf.setId( repositoryConfiguration.getId() );
+        conf.setLayout( repositoryConfiguration.getLayout() );
+        conf.setUrl( repositoryConfiguration.getUrl() );
+        conf.setName( repositoryConfiguration.getName() );
+        configuration.addRemoteRepository( conf );
+        return configuration;
+    }
+
+    private RemoteRepository createRepository()
+    {
+        RemoteRepository r = new RemoteRepository();
+        r.setId( REPO_ID );
+        populateRepository( r );
+        return r;
+    }
+
+    private void assertRepositoryEquals( RemoteRepository expectedRepository, RemoteRepository actualRepository )
+    {
+        assertEquals( expectedRepository.getId(), actualRepository.getId() );
+        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
+        assertEquals( expectedRepository.getUrl(), actualRepository.getUrl() );
+        assertEquals( expectedRepository.getName(), actualRepository.getName() );
+    }
+
+    private ManagedRepositoryConfiguration createManagedRepository( String string, String testPath )
+    {
+        ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
+        r.setId( REPO_ID );
+        r.setName( "repo name" );
+        r.setLocation( testPath );
+        r.setLayout( "default" );
+        r.setRefreshCronExpression( "* 0/5 * * * ?" );
+        r.setDaysOlder( 0 );
+        r.setRetentionCount( 0 );
+        r.setReleases( true );
+        r.setSnapshots( true );
+        r.setScanned( false );
+        r.setDeleteReleasedSnapshots( false );
+        return r;
+    }
+
+    private ProxyConnectorConfiguration createProxyConnector( String managedRepoId, String remoteRepoId )
+    {
+        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+        connector.setSourceRepoId( managedRepoId );
+        connector.setTargetRepoId( remoteRepoId );
+
+        return connector;
+    }
+
+    private void populateRepository( RemoteRepository repository )
+    {
+        repository.setId( REPO_ID );
+        repository.setName( "repo name" );
+        repository.setUrl( "url" );
+        repository.setLayout( "default" );
+    }
+
+    // TODO: what about removing proxied content if a proxy is removed?
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java
new file mode 100644 (file)
index 0000000..faa2c78
--- /dev/null
@@ -0,0 +1,160 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RepositoryGroup;
+import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.archiva.web.action.AbstractActionTestCase;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+
+import java.util.Collections;
+
+/**
+ * DeleteRepositoryGroupActionTest
+ */
+public class DeleteRepositoryGroupActionTest
+    extends AbstractActionTestCase
+{
+    private static final String REPO_GROUP_ID = "repo-group-ident";
+
+    private DeleteRepositoryGroupAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (DeleteRepositoryGroupAction) getActionProxy( "/admin/deleteRepositoryGroup.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException, RepositoryAdminException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testDeleteRepositoryGroupConfirmation()
+        throws Exception
+    {
+        RepositoryGroupConfiguration origRepoGroup = createRepositoryGroup();
+        Configuration configuration = createConfigurationForEditing( origRepoGroup );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoGroupId( REPO_GROUP_ID );
+
+        action.prepare();
+        assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
+        RepositoryGroup repoGroup = action.getRepositoryGroup();
+        assertNotNull( repoGroup );
+        assertEquals( repoGroup.getId(), action.getRepoGroupId() );
+        assertEquals( Collections.singletonList( origRepoGroup ), configuration.getRepositoryGroups() );
+    }
+
+    public void testDeleteRepositoryGroup()
+        throws Exception
+    {
+        Configuration configuration = createConfigurationForEditing( createRepositoryGroup() );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 5 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoGroupId( REPO_GROUP_ID );
+
+        action.prepare();
+        assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
+        RepositoryGroup repoGroup = action.getRepositoryGroup();
+        assertNotNull( repoGroup );
+        assertEquals( Collections.singletonList( repoGroup ),
+                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
+
+        String status = action.delete();
+        assertEquals( Action.SUCCESS, status );
+        assertTrue( configuration.getRepositoryGroups().isEmpty() );
+    }
+
+    public void testDeleteRepositoryGroupCancelled()
+        throws Exception
+    {
+        RepositoryGroupConfiguration origRepoGroup = createRepositoryGroup();
+        Configuration configuration = createConfigurationForEditing( origRepoGroup );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 2 );
+
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoGroupId( REPO_GROUP_ID );
+
+        action.prepare();
+        assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
+        RepositoryGroup repoGroup = action.getRepositoryGroup();
+        assertNotNull( repoGroup );
+
+        String status = action.execute();
+        assertEquals( Action.SUCCESS, status );
+        assertEquals( Collections.singletonList( repoGroup ),
+                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
+    }
+
+    private Configuration createConfigurationForEditing( RepositoryGroupConfiguration repoGroup )
+    {
+        Configuration configuration = new Configuration();
+        configuration.addRepositoryGroup( repoGroup );
+        return configuration;
+    }
+
+    private RepositoryGroupConfiguration createRepositoryGroup()
+    {
+        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
+        repoGroup.setId( REPO_GROUP_ID );
+
+        return repoGroup;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..7c5fede
--- /dev/null
@@ -0,0 +1,627 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.repository.RepositoryCommonValidator;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.audit.AuditListener;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
+import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.security.ArchivaRoleConstants;
+import org.apache.archiva.web.validator.utils.ValidatorUtil;
+import org.apache.commons.io.FileUtils;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.codehaus.plexus.redback.role.RoleManager;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * EditManagedRepositoryActionTest
+ *
+ * @version $Id$
+ */
+public class EditManagedRepositoryActionTest
+    extends AbstractManagedRepositoryActionTest
+{
+    private EditManagedRepositoryAction action;
+
+    private RoleManager roleManager;
+
+    private MockControl roleManagerControl;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    private Registry registry;
+
+    private MockControl registryControl;
+
+    private MetadataRepository metadataRepository;
+
+    private MockControl repositoryTaskSchedulerControl;
+
+    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = new EditManagedRepositoryAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        roleManagerControl = MockControl.createControl( RoleManager.class );
+        roleManager = (RoleManager) roleManagerControl.getMock();
+
+        registryControl = MockControl.createControl( Registry.class );
+        registry = (Registry) registryControl.getMock();
+
+        repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
+        repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
+
+        location = new File( "target/test/location" );
+
+        metadataRepository = mock( MetadataRepository.class );
+        RepositorySession repositorySession = mock( RepositorySession.class );
+        when( repositorySession.getRepository() ).thenReturn( metadataRepository );
+        TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
+        factory.setRepositorySession( repositorySession );
+
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryTaskScheduler(
+            repositoryTaskScheduler );
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositorySessionFactory( factory );
+
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRegistry( registry );
+
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setAuditListeners(
+            new ArrayList<AuditListener>( 0 ) );
+
+        RepositoryCommonValidator repositoryCommonValidator = new RepositoryCommonValidator();
+        repositoryCommonValidator.setArchivaConfiguration( archivaConfiguration );
+        repositoryCommonValidator.setRegistry( registry );
+
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryCommonValidator(
+            repositoryCommonValidator );
+
+        action.setRepositoryCommonValidator( repositoryCommonValidator );
+
+        action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
+
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException, RepositoryAdminException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testEditRepositoryInitialPage()
+        throws Exception
+    {
+        Configuration configuration = createConfigurationForEditing( createRepository() );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        Configuration stageRepoConfiguration = new Configuration();
+        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
+        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
+
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        ManagedRepository repository = action.getRepository();
+        assertNotNull( repository );
+
+        ManagedRepository newRepository = createRepository();
+        assertRepositoryEquals( repository, newRepository );
+        assertEquals( repository.getLocation(), newRepository.getLocation() );
+
+        String status = action.input();
+        assertEquals( Action.INPUT, status );
+        repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+    }
+
+    public void testEditRepository()
+        throws Exception
+    {
+        String stageRepoId = REPO_ID + "-stage";
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManagerControl.setVoidCallable();
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.setVoidCallable();
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
+        roleManagerControl.setVoidCallable();
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
+        roleManagerControl.setVoidCallable();
+
+        roleManagerControl.replay();
+
+        registry.getString( "appserver.base", "${appserver.base}" );
+        registryControl.setReturnValue( "target/test" );
+        registry.getString( "appserver.home", "${appserver.home}" );
+        registryControl.setReturnValue( "target/test" );
+
+        registry.getString( "appserver.base", "${appserver.base}" );
+        registryControl.setReturnValue( "target/test" );
+        registry.getString( "appserver.home", "${appserver.home}" );
+        registryControl.setReturnValue( "target/test" );
+
+        registryControl.replay();
+
+        RepositoryTask task = new RepositoryTask();
+        task.setRepositoryId( REPO_ID );
+        repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
+        repositoryTaskSchedulerControl.setReturnValue( false );
+        repositoryTaskScheduler.queueTask( task );
+        repositoryTaskSchedulerControl.setVoidCallable();
+
+        RepositoryTask stageTask = new RepositoryTask();
+        stageTask.setRepositoryId( stageRepoId );
+        repositoryTaskScheduler.isProcessingRepositoryTask( stageRepoId );
+        repositoryTaskSchedulerControl.setReturnValue( false );
+        repositoryTaskScheduler.queueTask( stageTask );
+        repositoryTaskSchedulerControl.setVoidCallable();
+
+        repositoryTaskSchedulerControl.replay();
+
+        Configuration configuration = createConfigurationForEditing( createRepository() );
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        Configuration stageRepoConfiguration = new Configuration();
+        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
+        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.save( configuration );
+        archivaConfiguration.save( configuration );
+
+        archivaConfiguration.save( configuration );
+
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        ManagedRepository repository = action.getRepository();
+        populateRepository( repository );
+        repository.setName( "new repo name" );
+
+        MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
+        RepositoryStatisticsManager repositoryStatisticsManager =
+            (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
+            repositoryStatisticsManager );
+        // no deletion
+        repositoryStatisticsManagerControl.replay();
+
+        new File( "target/test/" + REPO_ID + "-stage" ).mkdirs();
+
+        action.setRepository( repository );
+        action.setStageNeeded( true );
+        String status = action.commit();
+        assertEquals( Action.SUCCESS, status );
+
+        ManagedRepository newRepository = createRepository();
+        newRepository.setName( "new repo name" );
+        assertRepositoryEquals( repository, newRepository );
+        //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
+        //assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
+
+        roleManagerControl.verify();
+        //archivaConfigurationControl.verify();
+        repositoryStatisticsManagerControl.verify();
+        registryControl.verify();
+    }
+
+    public void testEditRepositoryLocationChanged()
+        throws Exception
+    {
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
+        roleManagerControl.setVoidCallable();
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
+        roleManagerControl.setVoidCallable();
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
+        roleManagerControl.setVoidCallable();
+
+        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
+        roleManagerControl.setReturnValue( false );
+        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
+        roleManagerControl.setVoidCallable();
+
+        roleManagerControl.replay();
+
+        registry.getString( "appserver.base", "${appserver.base}" );
+        registryControl.setReturnValue( "target/test" );
+        registry.getString( "appserver.home", "${appserver.home}" );
+        registryControl.setReturnValue( "target/test" );
+
+        registry.getString( "appserver.base", "${appserver.base}" );
+        registryControl.setReturnValue( "target/test" );
+        registry.getString( "appserver.home", "${appserver.home}" );
+        registryControl.setReturnValue( "target/test" );
+
+        registryControl.replay();
+
+        RepositoryTask task = new RepositoryTask();
+        task.setRepositoryId( REPO_ID );
+        repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
+        repositoryTaskSchedulerControl.setReturnValue( false );
+        repositoryTaskScheduler.queueTask( task );
+        repositoryTaskSchedulerControl.setVoidCallable();
+
+        repositoryTaskSchedulerControl.replay();
+
+        Configuration configuration = createConfigurationForEditing( createRepository() );
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfigurationControl.setReturnValue( buildEasyConfiguration() );
+
+        Configuration stageRepoConfiguration = buildEasyConfiguration();
+        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
+        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
+
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.save( configuration );
+        configuration.addManagedRepository( stageRepoConfiguration.getManagedRepositories().get( 0 ) );
+        archivaConfiguration.save( configuration );
+        archivaConfiguration.save( configuration );
+
+        archivaConfigurationControl.replay();
+
+        MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
+        RepositoryStatisticsManager repositoryStatisticsManager =
+            (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
+            repositoryStatisticsManager );
+        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
+        repositoryStatisticsManagerControl.replay();
+
+        new File( "target/test/location/" + REPO_ID + "-stage" ).mkdirs();
+
+        action.setStageNeeded( true );
+        action.setRepoid( REPO_ID );
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+
+        ManagedRepository repository = new ManagedRepository();
+        populateRepository( repository );
+        File testFile = new File( "target/test/location/new" );
+        FileUtils.deleteDirectory( testFile );
+        repository.setLocation( "${appserver.base}/location/new" );
+        action.setRepository( repository );
+        String status = action.commit();
+        assertEquals( Action.SUCCESS, status );
+        //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
+        //assertEquals( testFile.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
+
+        roleManagerControl.verify();
+        //archivaConfigurationControl.verify();
+        repositoryStatisticsManagerControl.verify();
+        registryControl.verify();
+    }
+
+    public void testStruts2ValidationFrameworkWithNullInputs()
+        throws Exception
+    {
+        // prep
+        // 0 is the default value for primitive int; null for objects
+        ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null, 1, 1 );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository identifier." );
+        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a directory." );
+        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository name." );
+        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithBlankInputs()
+        throws Exception
+    {
+        // prep
+        // 0 is the default value for primitive int
+        ManagedRepository managedRepositoryConfiguration =
+            createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, 1, 1 );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository identifier." );
+        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a directory." );
+        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "You must enter a repository name." );
+        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithInvalidInputs()
+        throws Exception
+    {
+        // prep
+        ManagedRepository managedRepositoryConfiguration =
+            createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
+                                     REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
+                                     REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertTrue( action.hasFieldErrors() );
+
+        Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+        // make an expected field error object
+        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
+
+        // populate
+        List<String> expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-)." );
+        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add(
+            "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
+        expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
+        expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
+
+        expectedErrorMessages = new ArrayList<String>();
+        expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
+        expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
+
+        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
+    }
+
+    public void testStruts2ValidationFrameworkWithValidInputs()
+        throws Exception
+    {
+        // prep
+        ManagedRepository managedRepositoryConfiguration =
+            createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
+                                     REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
+                                     REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
+        action.setRepository( managedRepositoryConfiguration );
+
+        // test
+        actionValidatorManager.validate( action, EMPTY_STRING );
+
+        // verify
+        assertFalse( action.hasFieldErrors() );
+    }
+
+    private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
+    {
+        assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
+        assertEquals( expectedRepository.getId(), actualRepository.getId() );
+        assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
+        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
+        assertEquals( expectedRepository.getName(), actualRepository.getName() );
+        assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
+        assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
+        assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
+        assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
+        assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
+        assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
+    }
+
+    private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
+        throws Exception
+    {
+        Configuration configuration = buildEasyConfiguration();
+
+        ManagedRepositoryConfiguration managedRepositoryConfiguration = new ManagedRepositoryConfiguration();
+
+        managedRepositoryConfiguration.setDaysOlder( repositoryConfiguration.getDaysOlder() );
+        managedRepositoryConfiguration.setIndexDir( repositoryConfiguration.getIndexDirectory() );
+        managedRepositoryConfiguration.setRetentionCount( repositoryConfiguration.getRetentionCount() );
+        managedRepositoryConfiguration.setBlockRedeployments( repositoryConfiguration.isBlockRedeployments() );
+        managedRepositoryConfiguration.setDeleteReleasedSnapshots(
+            repositoryConfiguration.isDeleteReleasedSnapshots() );
+        managedRepositoryConfiguration.setLocation( repositoryConfiguration.getLocation() );
+        managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
+        managedRepositoryConfiguration.setReleases( repositoryConfiguration.isReleases() );
+        managedRepositoryConfiguration.setScanned( repositoryConfiguration.isScanned() );
+        managedRepositoryConfiguration.setId( repositoryConfiguration.getId() );
+        managedRepositoryConfiguration.setName( repositoryConfiguration.getName() );
+        managedRepositoryConfiguration.setLayout( repositoryConfiguration.getLayout() );
+
+        configuration.addManagedRepository( managedRepositoryConfiguration );
+        return configuration;
+    }
+
+    // easy configuration for hashCode/equals
+    private Configuration buildEasyConfiguration()
+    {
+        return new Configuration()
+        {
+            @Override
+            public int hashCode()
+            {
+                return getManagedRepositories().size();
+            }
+
+            @Override
+            public boolean equals( Object o )
+            {
+                return true;
+            }
+        };
+    }
+
+    private ManagedRepository createRepository()
+        throws IOException
+    {
+        ManagedRepository r = new ManagedRepository();
+        r.setId( REPO_ID );
+        populateRepository( r );
+        return r;
+    }
+
+    private ManagedRepositoryConfiguration createStagingRepository()
+        throws IOException
+    {
+        ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
+        r.setId( REPO_ID + "-stage" );
+        populateStagingRepository( r );
+        return r;
+    }
+
+    private void populateStagingRepository( ManagedRepositoryConfiguration repository )
+        throws IOException
+    {
+        repository.setId( REPO_ID + "-stage" );
+        repository.setName( "repo name" );
+        repository.setLocation( "${appserver.base}/location" );
+        repository.setLayout( "default" );
+        repository.setRefreshCronExpression( "* 0/5 * * * ?" );
+        repository.setDaysOlder( 31 );
+        repository.setRetentionCount( 20 );
+        repository.setReleases( true );
+        repository.setSnapshots( true );
+        repository.setScanned( false );
+        repository.setDeleteReleasedSnapshots( true );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java
new file mode 100644 (file)
index 0000000..961d2ba
--- /dev/null
@@ -0,0 +1,174 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.struts2.StrutsSpringTestCase;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+
+import java.util.Collections;
+
+/**
+ * EditRemoteRepositoryActionTest
+ *
+ * @version $Id$
+ */
+public class EditRemoteRepositoryActionTest
+    extends StrutsSpringTestCase
+{
+    private static final String REPO_ID = "remote-repo-ident";
+
+    private EditRemoteRepositoryAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    @Override
+    protected String[] getContextLocations()
+    {
+        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
+    }
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (EditRemoteRepositoryAction) getActionProxy( "/admin/editRemoteRepository.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testEditRemoteRepository()
+        throws Exception
+    {
+        Configuration configuration = createConfigurationForEditing( createRepository() );
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+        action.prepare();
+
+        assertEquals( REPO_ID, action.getRepoid() );
+        RemoteRepository repository = action.getRepository();
+        populateRepository( repository );
+        repository.setName( "new repo name" );
+
+        String status = action.commit();
+        assertEquals( Action.SUCCESS, status );
+
+        RemoteRepository newRepository = createRepository();
+        newRepository.setName( "new repo name" );
+        assertRepositoryEquals( repository, newRepository );
+        assertEquals( Collections.singletonList( repository ),
+                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
+
+        archivaConfigurationControl.verify();
+    }
+
+    public void testEditRemoteRepositoryInitialPage()
+        throws Exception
+    {
+        Configuration configuration = createConfigurationForEditing( createRepository() );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        RemoteRepository repository = action.getRepository();
+        assertNotNull( repository );
+        assertRepositoryEquals( repository, createRepository() );
+
+        String status = action.input();
+        assertEquals( Action.INPUT, status );
+        repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException, RepositoryAdminException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    private void assertRepositoryEquals( RemoteRepository expectedRepository, RemoteRepository actualRepository )
+    {
+        assertEquals( expectedRepository.getId(), actualRepository.getId() );
+        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
+        assertEquals( expectedRepository.getUrl(), actualRepository.getUrl() );
+        assertEquals( expectedRepository.getName(), actualRepository.getName() );
+    }
+
+    private Configuration createConfigurationForEditing( RemoteRepository repositoryConfiguration )
+    {
+        Configuration configuration = new Configuration();
+        RemoteRepositoryConfiguration conf = new RemoteRepositoryConfiguration();
+        conf.setId( repositoryConfiguration.getId() );
+        conf.setLayout( repositoryConfiguration.getLayout() );
+        conf.setUrl( repositoryConfiguration.getUrl() );
+        conf.setName( repositoryConfiguration.getName() );
+        configuration.addRemoteRepository( conf );
+        return configuration;
+    }
+
+    private RemoteRepository createRepository()
+    {
+        RemoteRepository r = new RemoteRepository();
+        r.setId( REPO_ID );
+        populateRepository( r );
+        return r;
+    }
+
+    private void populateRepository( RemoteRepository repository )
+    {
+        repository.setId( REPO_ID );
+        repository.setName( "repo name" );
+        repository.setUrl( "url" );
+        repository.setLayout( "default" );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/RepositoriesActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/RepositoriesActionTest.java
new file mode 100644 (file)
index 0000000..601a554
--- /dev/null
@@ -0,0 +1,155 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.struts2.StrutsSpringTestCase;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test the repositories action returns the correct data.
+ */
+public class RepositoriesActionTest
+    extends StrutsSpringTestCase
+{
+    private Logger log = LoggerFactory.getLogger( getClass() );
+
+    private RepositoriesAction action;
+
+    ArchivaConfiguration originalArchivaConfiguration;
+
+    protected void setUp()
+        throws Exception
+    {
+
+        super.setUp();
+
+        action = (RepositoriesAction) getActionProxy( "/admin/index.action" ).getAction();
+        originalArchivaConfiguration =
+            ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).getArchivaConfiguration();
+        // some other test are modifying archivaConfiguration with a mocked instance : this test need the real one
+        // so use the real one from spring, backup the mock and restore it at the end (tearDown)
+        ArchivaConfiguration real = applicationContext.getBean( ArchivaConfiguration.class );
+        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration( real );
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration( real );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration( real );
+    }
+
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
+            originalArchivaConfiguration );
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            originalArchivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            originalArchivaConfiguration );
+    }
+
+    @Override
+    protected String[] getContextLocations()
+    {
+        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
+    }
+
+    public void testGetRepositories()
+        throws Exception
+    {
+        try
+        {
+            MockControl control = MockControl.createControl( MetadataRepository.class );
+            MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
+            control.expectAndReturn( metadataRepository.getMetadataFacets( "internal", RepositoryStatistics.FACET_ID ),
+                                     Arrays.asList( "20091125.123456.678" ) );
+            control.expectAndReturn(
+                metadataRepository.getMetadataFacet( "internal", RepositoryStatistics.FACET_ID, "20091125.123456.678" ),
+                new RepositoryStatistics() );
+            control.expectAndReturn( metadataRepository.getMetadataFacets( "snapshots", RepositoryStatistics.FACET_ID ),
+                                     Arrays.asList( "20091112.012345.012" ) );
+            control.expectAndReturn( metadataRepository.getMetadataFacet( "snapshots", RepositoryStatistics.FACET_ID,
+                                                                          "20091112.012345.012" ),
+                                     new RepositoryStatistics() );
+            control.replay();
+
+            RepositorySession session = mock( RepositorySession.class );
+            when( session.getRepository() ).thenReturn( metadataRepository );
+            TestRepositorySessionFactory factory =
+                applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
+            factory.setRepositorySession( session );
+
+            ServletRunner sr = new ServletRunner();
+            ServletUnitClient sc = sr.newClient();
+
+            action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositories.action" ).getRequest() );
+
+            action.prepare();
+            String result = action.execute();
+            assertEquals( Action.SUCCESS, result );
+
+            // TODO: for some reason servletunit is not populating the port of the servlet request
+            assertEquals( "http://localhost:0/repository", action.getBaseUrl() );
+
+            assertNotNull( action.getManagedRepositories() );
+            assertNotNull( action.getRemoteRepositories() );
+            assertNotNull( action.getRepositoryStatistics() );
+
+            assertEquals( 2, action.getManagedRepositories().size() );
+            assertEquals( 2, action.getRemoteRepositories().size() );
+            assertEquals( 2, action.getRepositoryStatistics().size() );
+
+            control.verify();
+        }
+        catch ( Exception e )
+        {
+            log.error( e.getMessage(), e );
+            throw e;
+        }
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java
new file mode 100644 (file)
index 0000000..655fa7b
--- /dev/null
@@ -0,0 +1,388 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.RepositoryGroup;
+import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.archiva.web.action.AbstractActionTestCase;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * RepositoryGroupsActionTest
+ */
+public class RepositoryGroupsActionTest
+    extends AbstractActionTestCase
+{
+    private static final String REPO_GROUP_ID = "repo-group-ident";
+
+    private static final String REPO1_ID = "managed-repo-ident-1";
+
+    private static final String REPO2_ID = "managed-repo-ident-2";
+
+    private RepositoryGroupsAction action;
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (RepositoryGroupsAction) getActionProxy( "/admin/repositoryGroups.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+
+        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultManagedRepositoryAdmin) ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException, RepositoryAdminException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testAddRepositoryGroup()
+        throws Exception
+    {
+        Configuration configuration = new Configuration();
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 6 );
+
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        RepositoryGroup repositoryGroup = action.getRepositoryGroup();
+        repositoryGroup.setId( REPO_GROUP_ID );
+
+        String status = action.addRepositoryGroup();
+        assertEquals( Action.SUCCESS, status );
+
+        assertEquals( Collections.singletonList( repositoryGroup ),
+                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
+
+        archivaConfigurationControl.verify();
+    }
+
+    public void testAddEmptyRepositoryGroup()
+        throws Exception
+    {
+        Configuration configuration = new Configuration();
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 5 );
+
+        archivaConfiguration.save( configuration );
+
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+
+        String status = action.addRepositoryGroup();
+        assertEquals( Action.ERROR, status );
+
+        assertEquals( 0, configuration.getRepositoryGroups().size() );
+    }
+
+    public void testAddDuplicateRepositoryGroup()
+        throws Exception
+    {
+        Configuration configuration = new Configuration();
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 8 );
+
+        archivaConfiguration.save( configuration );
+
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        RepositoryGroup repositoryGroup = action.getRepositoryGroup();
+        repositoryGroup.setId( REPO_GROUP_ID );
+
+        String status = action.addRepositoryGroup();
+        assertEquals( Action.SUCCESS, status );
+
+        assertEquals( Collections.singletonList( repositoryGroup ),
+                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
+
+        repositoryGroup.setId( REPO_GROUP_ID );
+        status = action.addRepositoryGroup();
+
+        assertEquals( Action.ERROR, status );
+        assertEquals( Collections.singletonList( repositoryGroup ),
+                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
+    }
+
+    public void testGetRepositoryGroups()
+        throws Exception
+    {
+        ServletRunner sr = new ServletRunner();
+        ServletUnitClient sc = sr.newClient();
+
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 6 );
+        archivaConfigurationControl.replay();
+
+        action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositoryGroups.action" ).getRequest() );
+        action.prepare();
+        String result = action.execute();
+        assertEquals( Action.SUCCESS, result );
+
+        assertEquals( "http://localhost:0/repository", action.getBaseUrl() );
+
+        assertNotNull( action.getRepositoryGroups() );
+        assertEquals( 1, action.getRepositoryGroups().size() );
+        assertEquals( 2, action.getManagedRepositories().size() );
+
+        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
+
+        assertEquals( 1, repoGroup.getRepositories().size() );
+        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
+        assertNotNull( action.getGroupToRepositoryMap() );
+        assertEquals( 1, action.getGroupToRepositoryMap().size() );
+
+        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
+        assertEquals( 1, repos.size() );
+        assertEquals( REPO2_ID, repos.get( 0 ) );
+    }
+
+    public void testAddRepositoryToGroup()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 17 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        String result = action.execute();
+        assertEquals( Action.SUCCESS, result );
+
+        assertNotNull( action.getRepositoryGroups() );
+        assertEquals( 1, action.getRepositoryGroups().size() );
+        assertEquals( 2, action.getManagedRepositories().size() );
+
+        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
+        assertEquals( 1, repoGroup.getRepositories().size() );
+        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
+
+        assertNotNull( action.getGroupToRepositoryMap() );
+        assertEquals( 1, action.getGroupToRepositoryMap().size() );
+
+        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
+        assertEquals( 1, repos.size() );
+        assertEquals( REPO2_ID, repos.get( 0 ) );
+
+        action.setRepoGroupId( REPO_GROUP_ID );
+        action.setRepoId( REPO2_ID );
+
+        result = action.addRepositoryToGroup();
+        assertEquals( Action.SUCCESS, result );
+
+        action.prepare();
+        result = action.execute();
+        assertEquals( Action.SUCCESS, result );
+
+        assertEquals( 1, action.getRepositoryGroups().size() );
+        repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
+        assertEquals( 2, repoGroup.getRepositories().size() );
+        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
+        assertEquals( REPO2_ID, repoGroup.getRepositories().get( 1 ) );
+
+        assertEquals( 0, action.getGroupToRepositoryMap().size() );
+        assertNull( action.getGroupToRepositoryMap().get( repoGroup.getId() ) );
+    }
+
+    public void testRemoveRepositoryFromGroup()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 13 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        String result = action.execute();
+        assertEquals( Action.SUCCESS, result );
+
+        assertNotNull( action.getRepositoryGroups() );
+        assertEquals( 1, action.getRepositoryGroups().size() );
+        assertEquals( 2, action.getManagedRepositories().size() );
+
+        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
+        assertEquals( 1, repoGroup.getRepositories().size() );
+        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
+
+        assertNotNull( action.getGroupToRepositoryMap() );
+        assertEquals( 1, action.getGroupToRepositoryMap().size() );
+
+        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
+        assertEquals( 1, repos.size() );
+        assertEquals( REPO2_ID, repos.get( 0 ) );
+
+        action.setRepoGroupId( REPO_GROUP_ID );
+        action.setRepoId( REPO1_ID );
+
+        result = action.removeRepositoryFromGroup();
+        assertEquals( Action.SUCCESS, result );
+
+        action.prepare();
+        result = action.execute();
+        assertEquals( Action.SUCCESS, result );
+
+        repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
+        assertEquals( 0, repoGroup.getRepositories().size() );
+
+        assertNotNull( action.getGroupToRepositoryMap() );
+        assertEquals( 1, action.getGroupToRepositoryMap().size() );
+
+        repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
+        assertEquals( 2, repos.size() );
+        assertEquals( REPO1_ID, repos.get( 0 ) );
+        assertEquals( REPO2_ID, repos.get( 1 ) );
+    }
+
+    public void testAddDuplicateRepositoryToGroup()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 6 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        String result = action.execute();
+        assertEquals( Action.SUCCESS, result );
+
+        assertNotNull( action.getRepositoryGroups() );
+        assertEquals( 1, action.getRepositoryGroups().size() );
+        assertEquals( 2, action.getManagedRepositories().size() );
+
+        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
+        assertEquals( 1, repoGroup.getRepositories().size() );
+        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
+
+        assertNotNull( action.getGroupToRepositoryMap() );
+        assertEquals( 1, action.getGroupToRepositoryMap().size() );
+
+        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
+        assertEquals( 1, repos.size() );
+        assertEquals( REPO2_ID, repos.get( 0 ) );
+
+        action.setRepoGroupId( REPO_GROUP_ID );
+        action.setRepoId( REPO1_ID );
+
+        result = action.addRepositoryToGroup();
+        assertEquals( Action.ERROR, result );
+    }
+
+    public void testRemoveRepositoryNotInGroup()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 6 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.prepare();
+        String result = action.execute();
+        assertEquals( Action.SUCCESS, result );
+
+        assertNotNull( action.getRepositoryGroups() );
+        assertEquals( 1, action.getRepositoryGroups().size() );
+        assertEquals( 2, action.getManagedRepositories().size() );
+
+        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
+        assertEquals( 1, repoGroup.getRepositories().size() );
+        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
+
+        assertNotNull( action.getGroupToRepositoryMap() );
+        assertEquals( 1, action.getGroupToRepositoryMap().size() );
+
+        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
+        assertEquals( 1, repos.size() );
+        assertEquals( REPO2_ID, repos.get( 0 ) );
+
+        action.setRepoGroupId( REPO_GROUP_ID );
+        action.setRepoId( REPO2_ID );
+
+        result = action.removeRepositoryFromGroup();
+        assertEquals( Action.ERROR, result );
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        ManagedRepositoryConfiguration managedRepo1 = new ManagedRepositoryConfiguration();
+        managedRepo1.setId( REPO1_ID );
+
+        config.addManagedRepository( managedRepo1 );
+
+        ManagedRepositoryConfiguration managedRepo2 = new ManagedRepositoryConfiguration();
+        managedRepo2.setId( REPO2_ID );
+
+        config.addManagedRepository( managedRepo2 );
+
+        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
+        repoGroup.setId( REPO_GROUP_ID );
+        repoGroup.addRepository( REPO1_ID );
+
+        config.addRepositoryGroup( repoGroup );
+
+        return config;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/SortRepositoriesActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/repositories/SortRepositoriesActionTest.java
new file mode 100644 (file)
index 0000000..5b31cdf
--- /dev/null
@@ -0,0 +1,240 @@
+package org.apache.archiva.web.action.admin.repositories;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.struts2.StrutsSpringTestCase;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+import org.easymock.MockControl;
+
+/**
+ * SortRepositoriesActionTest
+ */
+public class SortRepositoriesActionTest
+    extends StrutsSpringTestCase
+{
+    private static final String REPO_GROUP_ID = "repo-group-ident";
+
+    private static final String REPO1_ID = "managed-repo-ident-1";
+
+    private static final String REPO2_ID = "managed-repo-ident-2";
+
+    private static final String REPO3_ID = "managed-repo-ident-3";
+
+    private MockControl archivaConfigurationControl;
+
+    private ArchivaConfiguration archivaConfiguration;
+
+    private ArchivaConfiguration originalArchivaConfiguration;
+
+    private SortRepositoriesAction action;
+
+    @Override
+    protected String[] getContextLocations()
+    {
+        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
+    }
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        action = (SortRepositoriesAction) getActionProxy( "/admin/sortDownRepositoryFromGroup.action" ).getAction();
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        originalArchivaConfiguration = action.archivaConfiguration;
+        action.setArchivaConfiguration( archivaConfiguration );
+    }
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        action.archivaConfiguration = originalArchivaConfiguration;
+    }
+
+    public void testSecureActionBundle()
+        throws SecureActionException
+    {
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration() );
+        archivaConfigurationControl.replay();
+
+        SecureActionBundle bundle = action.getSecureActionBundle();
+        assertTrue( bundle.requiresAuthentication() );
+        assertEquals( 1, bundle.getAuthorizationTuples().size() );
+    }
+
+    public void testSortDownFirstRepository()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 4 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        RepositoryGroupConfiguration repoGroup =
+            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        java.util.List<String> repositories = repoGroup.getRepositories();
+
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO1_ID, repositories.get( 0 ) );
+        assertEquals( REPO2_ID, repositories.get( 1 ) );
+        assertEquals( REPO3_ID, repositories.get( 2 ) );
+
+        // sort down first repo
+        action.setRepoGroupId( repoGroup.getId() );
+        action.setTargetRepo( REPO1_ID );
+
+        String result = action.sortDown();
+        assertEquals( Action.SUCCESS, result );
+
+        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        repositories = repoGroup.getRepositories();
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO2_ID, repositories.get( 0 ) );
+        assertEquals( REPO1_ID, repositories.get( 1 ) );
+        assertEquals( REPO3_ID, repositories.get( 2 ) );
+    }
+
+    public void testSortDownLastRepository()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 4 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        RepositoryGroupConfiguration repoGroup =
+            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        java.util.List<String> repositories = repoGroup.getRepositories();
+
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO1_ID, repositories.get( 0 ) );
+        assertEquals( REPO2_ID, repositories.get( 1 ) );
+        assertEquals( REPO3_ID, repositories.get( 2 ) );
+
+        // sort down last repo
+        action.setRepoGroupId( repoGroup.getId() );
+        action.setTargetRepo( REPO3_ID );
+
+        String result = action.sortDown();
+        assertEquals( Action.SUCCESS, result );
+
+        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        repositories = repoGroup.getRepositories();
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO1_ID, repositories.get( 0 ) );
+        assertEquals( REPO2_ID, repositories.get( 1 ) );
+        assertEquals( REPO3_ID, repositories.get( 2 ) );
+    }
+
+    public void testSortUpLastRepository()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 4 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        RepositoryGroupConfiguration repoGroup =
+            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        java.util.List<String> repositories = repoGroup.getRepositories();
+
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO1_ID, repositories.get( 0 ) );
+        assertEquals( REPO2_ID, repositories.get( 1 ) );
+        assertEquals( REPO3_ID, repositories.get( 2 ) );
+
+        // sort up last repo
+        action.setRepoGroupId( repoGroup.getId() );
+        action.setTargetRepo( REPO3_ID );
+
+        String result = action.sortUp();
+        assertEquals( Action.SUCCESS, result );
+
+        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        repositories = repoGroup.getRepositories();
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO1_ID, repositories.get( 0 ) );
+        assertEquals( REPO3_ID, repositories.get( 1 ) );
+        assertEquals( REPO2_ID, repositories.get( 2 ) );
+    }
+
+    public void testSortUpFirstRepository()
+        throws Exception
+    {
+        Configuration configuration = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration, 4 );
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        RepositoryGroupConfiguration repoGroup =
+            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        java.util.List<String> repositories = repoGroup.getRepositories();
+
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO1_ID, repositories.get( 0 ) );
+        assertEquals( REPO2_ID, repositories.get( 1 ) );
+        assertEquals( REPO3_ID, repositories.get( 2 ) );
+
+        // sort up first repo
+        action.setRepoGroupId( repoGroup.getId() );
+        action.setTargetRepo( REPO1_ID );
+
+        String result = action.sortUp();
+        assertEquals( Action.SUCCESS, result );
+
+        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
+        repositories = repoGroup.getRepositories();
+        assertEquals( 3, repositories.size() );
+        assertEquals( REPO1_ID, repositories.get( 0 ) );
+        assertEquals( REPO2_ID, repositories.get( 1 ) );
+        assertEquals( REPO3_ID, repositories.get( 2 ) );
+    }
+
+    private Configuration createInitialConfiguration()
+    {
+        Configuration config = new Configuration();
+
+        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
+        repoGroup.setId( REPO_GROUP_ID );
+        repoGroup.addRepository( REPO1_ID );
+        repoGroup.addRepository( REPO2_ID );
+        repoGroup.addRepository( REPO3_ID );
+
+        config.addRepositoryGroup( repoGroup );
+
+        return config;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java
new file mode 100644 (file)
index 0000000..ce97851
--- /dev/null
@@ -0,0 +1,137 @@
+package org.apache.archiva.web.action.admin.scanning;
+
+import org.apache.archiva.admin.repository.admin.DefaultArchivaAdministration;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.RepositoryScanningConfiguration;
+import org.apache.archiva.web.action.AbstractActionTestCase;
+import org.easymock.MockControl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public class RepositoryScanningActionTest
+    extends AbstractActionTestCase
+{
+    private RepositoryScanningAction action;
+
+    private MockControl archivaConfigControl;
+
+    private ArchivaConfiguration archivaConfig;
+
+    private Configuration config;
+
+    protected void setUp()
+        throws Exception
+    {
+
+        super.setUp();
+
+        archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
+
+        action = new RepositoryScanningAction();
+
+        config = new Configuration();
+
+        RepositoryScanningConfiguration repositoryScanningConfig = new RepositoryScanningConfiguration();
+
+        repositoryScanningConfig.setKnownContentConsumers( createKnownContentConsumersList() );
+
+        config.setRepositoryScanning( repositoryScanningConfig );
+
+        DefaultArchivaAdministration archivaAdministration = new DefaultArchivaAdministration();
+        archivaAdministration.setArchivaConfiguration( archivaConfig );
+        action.setArchivaAdministration( archivaAdministration );
+
+    }
+
+    public void testUpdateKnownConsumers()
+        throws Exception
+    {
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 10 );
+
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfigControl.replay();
+
+        setEnabledKnownContentConsumers();
+
+        String returnString = action.updateKnownConsumers();
+
+        List<String> results = config.getRepositoryScanning().getKnownContentConsumers();
+
+        assertEquals( action.SUCCESS, returnString );
+        assertEquals( "results " + results, 8, results.size() );
+    }
+
+    public void testDisableAllKnownConsumers()
+        throws Exception
+    {
+        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 10 );
+
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfig.save( config );
+        archivaConfigControl.replay();
+
+        action.setEnabledKnownContentConsumers( null );
+
+        String returnString = action.updateKnownConsumers();
+
+        List<String> results = config.getRepositoryScanning().getKnownContentConsumers();
+
+        assertEquals( action.SUCCESS, returnString );
+        assertEquals( 0, results.size() );
+    }
+
+    private void setEnabledKnownContentConsumers()
+    {
+        action.setEnabledKnownContentConsumers( createKnownContentConsumersList() );
+    }
+
+    private List<String> createKnownContentConsumersList()
+    {
+        List<String> knownContentConsumers = new ArrayList<String>();
+        knownContentConsumers.add( "auto-remove" );
+        knownContentConsumers.add( "auto-rename" );
+        knownContentConsumers.add( "create-missing-checksums" );
+        knownContentConsumers.add( "index-content" );
+        knownContentConsumers.add( "metadata-updater" );
+        knownContentConsumers.add( "repository-purge" );
+        knownContentConsumers.add( "update-db-artifact" );
+        knownContentConsumers.add( "validate-checksums" );
+
+        return knownContentConsumers;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/reports/GenerateReportActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/reports/GenerateReportActionTest.java
new file mode 100644 (file)
index 0000000..d74aad4
--- /dev/null
@@ -0,0 +1,712 @@
+package org.apache.archiva.web.action.reports;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.google.common.collect.Lists;
+import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.metadata.model.MetadataFacet;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
+import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.reports.RepositoryProblemFacet;
+import org.apache.archiva.security.UserRepositoriesStub;
+import org.apache.commons.io.IOUtils;
+import org.apache.archiva.web.action.AbstractActionTestCase;
+import org.easymock.MockControl;
+import org.junit.After;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test the GenerationReportAction. Note that we are testing for <i>current</i> behaviour, however there are several
+ * instances below where other behaviour may actually be more appropriate (eg the error handling, download stats should
+ * never forward to HTML page, etc). This is also missing tests for various combinations of paging at this point.
+ */
+public class GenerateReportActionTest
+    extends AbstractActionTestCase
+{
+    private GenerateReportAction action;
+
+    private static final String SNAPSHOTS = "snapshots";
+
+    private static final String INTERNAL = "internal";
+
+    private static final String GROUP_ID = "groupId";
+
+    private RepositoryStatisticsManager repositoryStatisticsManager;
+
+    private MockControl repositoryStatisticsManagerControl;
+
+    private MockControl metadataRepositoryControl;
+
+    private MetadataRepository metadataRepository;
+
+    private static final String PROBLEM = "problem";
+
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        UserRepositoriesStub stub = applicationContext.getBean( "userRepositories", UserRepositoriesStub.class );
+        stub.setRepoIds( Lists.<String>newArrayList( "internal", "snapshots" ) );
+
+        action = (GenerateReportAction) getActionProxy( "/report/generateReport.action" ).getAction();
+
+        repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
+        repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
+        action.setRepositoryStatisticsManager( repositoryStatisticsManager );
+
+        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
+        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+
+        RepositorySession repositorySession = mock( RepositorySession.class );
+        when( repositorySession.getRepository() ).thenReturn( metadataRepository );
+
+        TestRepositorySessionFactory factory =
+            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
+        factory.setRepositorySession( repositorySession );
+    }
+
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        UserRepositoriesStub stub = applicationContext.getBean( "userRepositories", UserRepositoriesStub.class );
+        stub.setRepoIds( Lists.<String>newArrayList( "test-repo" ) );
+
+        super.tearDown();
+
+    }
+
+    private void prepareAction( List<String> selectedRepositories, List<String> availableRepositories )
+        throws Exception
+    {
+        MockControl managedRepositoryControl = MockControl.createControl( ManagedRepositoryAdmin.class );
+        ManagedRepositoryAdmin managedRepositoryAdmin = (ManagedRepositoryAdmin) managedRepositoryControl.getMock();
+
+        Map<String, ManagedRepository> map = new HashMap<String, ManagedRepository>( availableRepositories.size() );
+        for ( String repoId : availableRepositories )
+        {
+            map.put( repoId, new ManagedRepository() );
+        }
+
+        managedRepositoryControl.expectAndReturn( managedRepositoryAdmin.getManagedRepositoriesAsMap(), map, 1, 10 );
+
+        managedRepositoryControl.replay();
+        action.setManagedRepositoryAdmin( managedRepositoryAdmin );
+
+
+        action.setSelectedRepositories( selectedRepositories );
+        action.prepare();
+
+        List<String> repos = Arrays.asList( GenerateReportAction.ALL_REPOSITORIES, INTERNAL, SNAPSHOTS );
+
+        Collections.sort( repos );
+
+        Collections.sort( action.getRepositoryIds() );
+
+        assertEquals( repos, action.getRepositoryIds() );
+        Collections.sort( action.getAvailableRepositories() );
+
+        availableRepositories = new ArrayList<String>( availableRepositories );
+        Collections.sort( availableRepositories );
+
+
+        assertEquals( availableRepositories, action.getAvailableRepositories() );
+    }
+
+    public void testGenerateStatisticsInvalidRowCount()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
+
+        action.setRowCount( 0 );
+        String result = action.generateStatistics();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsInvalidEndDate()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
+
+        action.setStartDate( "2009/12/12" );
+        action.setEndDate( "2008/11/11" );
+        String result = action.generateStatistics();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsMalformedEndDate()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
+
+        action.setEndDate( "This is not a date" );
+        String result = action.generateStatistics();
+
+        // TODO: should be an input error
+        assertEquals( Action.ERROR, result );
+        assertTrue( action.hasActionErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsInvalidEndDateMultiRepo()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        action.setStartDate( "2009/12/12" );
+        action.setEndDate( "2008/11/11" );
+        String result = action.generateStatistics();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsMalformedEndDateMultiRepo()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        action.setEndDate( "This is not a date" );
+        String result = action.generateStatistics();
+
+        // TODO: should be an input error
+        assertEquals( Action.ERROR, result );
+        assertTrue( action.hasActionErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsNoRepos()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.generateStatistics();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsSingleRepo()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
+
+        String result = action.generateStatistics();
+        assertSuccessResult( result );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsSingleRepoNoStats()
+        throws Exception
+
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.<Object>emptyList() );
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
+
+        String result = action.generateStatistics();
+        assertEquals( Action.ERROR, result );
+        assertTrue( action.hasActionErrors() );
+
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsOvershotPages()
+        throws Exception
+
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+        repositoryStatisticsManagerControl.replay();
+        action.setPage( 2 );
+        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
+
+        String result = action.generateStatistics();
+        assertEquals( Action.ERROR, result );
+        assertTrue( action.hasActionErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsMultipleRepoNoResults()
+        throws Exception
+
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
+            Collections.<Object>emptyList() );
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.<Object>emptyList() );
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        String result = action.generateStatistics();
+        assertEquals( GenerateReportAction.BLANK, result );
+        assertFalse( action.hasActionErrors() );
+        assertFalse( action.hasActionMessages() );
+        assertFalse( action.hasFieldErrors() );
+
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testGenerateStatisticsMultipleRepo()
+        throws Exception
+
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        String result = action.generateStatistics();
+        assertSuccessResult( result );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsSingleRepo()
+        throws Exception
+    {
+        Date date = new Date();
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
+            Collections.singletonList( createStats( date ) ) );
+        repositoryStatisticsManagerControl.replay();
+
+        prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
+
+        String result = action.downloadStatisticsReport();
+        assertEquals( GenerateReportAction.SEND_FILE, result );
+        assertFalse( action.hasActionErrors() );
+        assertFalse( action.hasFieldErrors() );
+
+        assertEquals(
+            "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n"
+                + date + ",0,0,0,0,0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsMultipleRepos()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        String result = action.downloadStatisticsReport();
+        assertEquals( GenerateReportAction.SEND_FILE, result );
+        assertFalse( action.hasActionErrors() );
+        assertFalse( action.hasFieldErrors() );
+
+        assertMultiRepoCsvResult();
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsMalformedEndDateMultiRepo()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        action.setEndDate( "This is not a date" );
+        String result = action.downloadStatisticsReport();
+
+        // TODO: should be an input error
+        assertEquals( Action.ERROR, result );
+        assertTrue( action.hasActionErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsMalformedEndDateSingleRepo()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
+
+        action.setEndDate( "This is not a date" );
+        String result = action.downloadStatisticsReport();
+
+        // TODO: should be an input error
+        assertEquals( Action.ERROR, result );
+        assertTrue( action.hasActionErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsInvalidEndDateMultiRepo()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        action.setStartDate( "2009/12/12" );
+        action.setEndDate( "2008/11/11" );
+        String result = action.downloadStatisticsReport();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsInvalidEndDateSingleRepo()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
+
+        action.setStartDate( "2009/12/12" );
+        action.setEndDate( "2008/11/11" );
+        String result = action.downloadStatisticsReport();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsSingleRepoNoStats()
+        throws Exception
+
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.<Object>emptyList() );
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
+
+        String result = action.downloadStatisticsReport();
+        assertEquals( Action.ERROR, result );
+        assertTrue( action.hasActionErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsNoRepos()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.downloadStatisticsReport();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsMultipleRepoNoResults()
+        throws Exception
+
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
+            Collections.<Object>emptyList() );
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.<Object>emptyList() );
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        String result = action.downloadStatisticsReport();
+        assertEquals( GenerateReportAction.BLANK, result );
+        assertFalse( action.hasActionErrors() );
+        assertFalse( action.hasActionMessages() );
+        assertFalse( action.hasFieldErrors() );
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testDownloadStatisticsMultipleRepoInStrutsFormat()
+        throws Exception
+    {
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+        repositoryStatisticsManagerControl.expectAndReturn(
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
+            Collections.singletonList( createDefaultStats() ) );
+        repositoryStatisticsManagerControl.replay();
+        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
+
+        action.setSelectedRepositories( Collections.singletonList( "[" + SNAPSHOTS + "],[" + INTERNAL + "]" ) );
+        String result = action.downloadStatisticsReport();
+        assertEquals( GenerateReportAction.SEND_FILE, result );
+        assertFalse( action.hasActionErrors() );
+        assertFalse( action.hasFieldErrors() );
+
+        assertMultiRepoCsvResult();
+        repositoryStatisticsManagerControl.verify();
+    }
+
+    public void testHealthReportSingleRepo()
+        throws Exception
+    {
+        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
+        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL );
+
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
+            Arrays.asList( problem1.getName(), problem2.getName() ) );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
+            problem1 );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
+            problem2 );
+        metadataRepositoryControl.replay();
+
+        action.setRepositoryId( INTERNAL );
+
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.execute();
+        assertSuccessResult( result );
+
+        assertEquals( Collections.singleton( INTERNAL ), action.getRepositoriesMap().keySet() );
+        assertEquals( Arrays.asList( problem1, problem2 ), action.getRepositoriesMap().get( INTERNAL ) );
+
+        metadataRepositoryControl.verify();
+    }
+
+    public void testHealthReportInvalidRowCount()
+        throws Exception
+    {
+        metadataRepositoryControl.replay();
+
+        action.setRowCount( 0 );
+        action.setRepositoryId( INTERNAL );
+
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.execute();
+        assertEquals( Action.INPUT, result );
+        assertFalse( action.hasActionErrors() );
+        assertTrue( action.hasFieldErrors() );
+
+        metadataRepositoryControl.verify();
+    }
+
+    public void testHealthReportAllRepos()
+        throws Exception
+    {
+        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
+        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
+            Arrays.asList( problem1.getName() ) );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacets( SNAPSHOTS, RepositoryProblemFacet.FACET_ID ),
+            Arrays.asList( problem2.getName() ) );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
+            problem1 );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( SNAPSHOTS, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
+            problem2 );
+        metadataRepositoryControl.replay();
+
+        action.setRepositoryId( GenerateReportAction.ALL_REPOSITORIES );
+
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.execute();
+        assertSuccessResult( result );
+
+        assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ),
+                      new ArrayList<String>( action.getRepositoriesMap().keySet() ) );
+        assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) );
+        assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) );
+
+        metadataRepositoryControl.verify();
+    }
+
+    public void testHealthReportSingleRepoByCorrectGroupId()
+        throws Exception
+    {
+        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
+        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
+            Arrays.asList( problem1.getName(), problem2.getName() ) );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
+            problem1 );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
+            problem2 );
+        metadataRepositoryControl.replay();
+
+        action.setGroupId( GROUP_ID );
+        action.setRepositoryId( INTERNAL );
+
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.execute();
+        assertSuccessResult( result );
+
+        assertEquals( Collections.singleton( INTERNAL ), action.getRepositoriesMap().keySet() );
+        assertEquals( Arrays.asList( problem1, problem2 ), action.getRepositoriesMap().get( INTERNAL ) );
+
+        metadataRepositoryControl.verify();
+    }
+
+    public void testHealthReportSingleRepoByCorrectGroupIdAllRepositories()
+        throws Exception
+    {
+        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
+        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
+            Arrays.asList( problem1.getName() ) );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacets( SNAPSHOTS, RepositoryProblemFacet.FACET_ID ),
+            Arrays.asList( problem2.getName() ) );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
+            problem1 );
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacet( SNAPSHOTS, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
+            problem2 );
+        metadataRepositoryControl.replay();
+
+        action.setGroupId( GROUP_ID );
+        action.setRepositoryId( GenerateReportAction.ALL_REPOSITORIES );
+
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.execute();
+        assertSuccessResult( result );
+
+        assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ),
+                      new ArrayList<String>( action.getRepositoriesMap().keySet() ) );
+        assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) );
+        assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) );
+
+        metadataRepositoryControl.verify();
+    }
+
+    public void testHealthReportSingleRepoByIncorrectGroupId()
+        throws Exception
+    {
+        metadataRepositoryControl.expectAndReturn(
+            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
+            Collections.<MetadataFacet>emptyList() );
+        metadataRepositoryControl.replay();
+
+        action.setGroupId( "not.it" );
+        action.setRepositoryId( INTERNAL );
+
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.execute();
+        assertEquals( GenerateReportAction.BLANK, result );
+        assertFalse( action.hasActionErrors() );
+        assertFalse( action.hasFieldErrors() );
+
+        metadataRepositoryControl.verify();
+    }
+
+    private void assertMultiRepoCsvResult()
+        throws IOException
+    {
+        assertEquals(
+            "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n"
+                + "snapshots,0,0,0,0,0,0,0,0,0\n" + "internal,0,0,0,0,0,0,0,0,0\n",
+            IOUtils.toString( action.getInputStream() ) );
+    }
+
+    private RepositoryProblemFacet createProblem( String groupId, String artifactId, String repoId )
+    {
+        RepositoryProblemFacet problem = new RepositoryProblemFacet();
+        problem.setRepositoryId( repoId );
+        problem.setNamespace( groupId );
+        problem.setProject( artifactId );
+        problem.setProblem( PROBLEM );
+        return problem;
+    }
+
+    public void testHealthReportNoRepositoryId()
+        throws Exception
+    {
+        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
+
+        String result = action.execute();
+        assertEquals( Action.INPUT, result );
+        assertTrue( action.hasFieldErrors() );
+    }
+
+    private void assertSuccessResult( String result )
+    {
+        assertEquals( Action.SUCCESS, result );
+        assertFalse( action.hasActionErrors() );
+        assertFalse( action.hasFieldErrors() );
+    }
+
+    private RepositoryStatistics createDefaultStats()
+    {
+        return createStats( new Date() );
+    }
+
+    private RepositoryStatistics createStats( Date date )
+    {
+        RepositoryStatistics stats = new RepositoryStatistics();
+        stats.setScanStartTime( date );
+        return stats;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java
deleted file mode 100644 (file)
index 20c9b49..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.ConfigurationManager;
-import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import org.apache.archiva.metadata.generic.GenericMetadataFacet;
-import org.apache.archiva.metadata.model.CiManagement;
-import org.apache.archiva.metadata.model.IssueManagement;
-import org.apache.archiva.metadata.model.License;
-import org.apache.archiva.metadata.model.Organization;
-import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.model.Scm;
-import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
-import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
-import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectParent;
-import org.apache.archiva.security.UserRepositoriesStub;
-import org.apache.struts2.StrutsSpringTestCase;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class AbstractActionTestCase
-    extends StrutsSpringTestCase
-{
-    protected static final String TEST_REPO = "test-repo";
-
-    protected TestMetadataResolver metadataResolver;
-
-    protected static final String TEST_GROUP_ID = "groupId";
-
-    protected static final String TEST_ARTIFACT_ID = "artifactId";
-
-    protected static final String TEST_PACKAGING = "packaging";
-
-    protected static final String TEST_ISSUE_URL = "http://jira.codehaus.org/browse/MRM";
-
-    protected static final String TEST_ISSUE_SYSTEM = "jira";
-
-    protected static final String TEST_CI_SYSTEM = "continuum";
-
-    protected static final String TEST_CI_URL = "http://vmbuild.apache.org/";
-
-    protected static final String TEST_URL = "url";
-
-    protected static final String TEST_NAME = "name";
-
-    protected static final String TEST_DESCRIPTION = "description";
-
-    protected static final String TEST_PARENT_GROUP_ID = "parentGroupId";
-
-    protected static final String TEST_PARENT_ARTIFACT_ID = "parentArtifactId";
-
-    protected static final String TEST_PARENT_VERSION = "parentVersion";
-
-    protected static final String TEST_ORGANIZATION_NAME = "organizationName";
-
-    protected static final String TEST_ORGANIZATION_URL = "organizationUrl";
-
-    protected static final String TEST_LICENSE_URL = "licenseUrl";
-
-    protected static final String TEST_LICENSE_NAME = "licenseName";
-
-    protected static final String TEST_LICENSE_URL_2 = "licenseUrl_2";
-
-    protected static final String TEST_LICENSE_NAME_2 = "licenseName_2";
-
-    protected static final String TEST_SCM_CONNECTION = "scmConnection";
-
-    protected static final String TEST_SCM_DEV_CONNECTION = "scmDevConnection";
-
-    protected static final String TEST_SCM_URL = "scmUrl";
-
-    protected static final String TEST_GENERIC_METADATA_PROPERTY_NAME = "rating";
-
-    protected static final String TEST_GENERIC_METADATA_PROPERTY_VALUE = "5 stars";
-
-    @Override
-    protected String[] getContextLocations()
-    {
-        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
-    }
-
-    protected void setObservableRepos( List<String> repoIds )
-    {
-        UserRepositoriesStub repos = applicationContext.getBean( "userRepositories", UserRepositoriesStub.class );
-        repos.setObservableRepositoryIds( repoIds );
-    }
-
-    protected void assertDefaultModel( ProjectVersionMetadata model, String version )
-    {
-        assertDefaultModel( model, TEST_GROUP_ID, TEST_ARTIFACT_ID, version );
-    }
-
-    protected void assertDefaultModel( ProjectVersionMetadata model, String groupId, String artifactId, String version )
-    {
-        assertEquals( version, model.getVersion() );
-        assertEquals( TEST_URL, model.getUrl() );
-        assertEquals( TEST_NAME, model.getName() );
-        assertEquals( TEST_DESCRIPTION, model.getDescription() );
-        assertEquals( TEST_ORGANIZATION_NAME, model.getOrganization().getName() );
-        assertEquals( TEST_ORGANIZATION_URL, model.getOrganization().getUrl() );
-        assertEquals( 2, model.getLicenses().size() );
-        License l = model.getLicenses().get( 0 );
-        assertEquals( TEST_LICENSE_NAME, l.getName() );
-        assertEquals( TEST_LICENSE_URL, l.getUrl() );
-        l = model.getLicenses().get( 1 );
-        assertEquals( TEST_LICENSE_NAME_2, l.getName() );
-        assertEquals( TEST_LICENSE_URL_2, l.getUrl() );
-        assertEquals( TEST_ISSUE_SYSTEM, model.getIssueManagement().getSystem() );
-        assertEquals( TEST_ISSUE_URL, model.getIssueManagement().getUrl() );
-        assertEquals( TEST_CI_SYSTEM, model.getCiManagement().getSystem() );
-        assertEquals( TEST_CI_URL, model.getCiManagement().getUrl() );
-        assertEquals( TEST_SCM_CONNECTION, model.getScm().getConnection() );
-        assertEquals( TEST_SCM_DEV_CONNECTION, model.getScm().getDeveloperConnection() );
-        assertEquals( TEST_SCM_URL, model.getScm().getUrl() );
-
-        MavenProjectFacet mavenFacet = (MavenProjectFacet) model.getFacet( MavenProjectFacet.FACET_ID );
-        assertEquals( groupId, mavenFacet.getGroupId() );
-        assertEquals( artifactId, mavenFacet.getArtifactId() );
-        assertEquals( TEST_PACKAGING, mavenFacet.getPackaging() );
-        assertEquals( TEST_PARENT_GROUP_ID, mavenFacet.getParent().getGroupId() );
-        assertEquals( TEST_PARENT_ARTIFACT_ID, mavenFacet.getParent().getArtifactId() );
-        assertEquals( TEST_PARENT_VERSION, mavenFacet.getParent().getVersion() );
-    }
-
-    protected ProjectVersionMetadata createProjectModel( String version )
-    {
-        return createProjectModel( TEST_GROUP_ID, TEST_ARTIFACT_ID, version );
-    }
-
-    protected ProjectVersionMetadata createProjectModel( String groupId, String artifactId, String version )
-    {
-        ProjectVersionMetadata model = new ProjectVersionMetadata();
-        model.setId( version );
-        model.setUrl( TEST_URL );
-        model.setName( TEST_NAME );
-        model.setDescription( TEST_DESCRIPTION );
-        CiManagement ci = new CiManagement();
-        ci.setSystem( TEST_CI_SYSTEM );
-        ci.setUrl( TEST_CI_URL );
-        model.setCiManagement( ci );
-        IssueManagement issue = new IssueManagement();
-        issue.setSystem( TEST_ISSUE_SYSTEM );
-        issue.setUrl( TEST_ISSUE_URL );
-        model.setIssueManagement( issue );
-        Organization organization = new Organization();
-        organization.setName( TEST_ORGANIZATION_NAME );
-        organization.setUrl( TEST_ORGANIZATION_URL );
-        model.setOrganization( organization );
-        License l = new License();
-        l.setName( TEST_LICENSE_NAME );
-        l.setUrl( TEST_LICENSE_URL );
-        model.addLicense( l );
-        l = new License();
-        l.setName( TEST_LICENSE_NAME_2 );
-        l.setUrl( TEST_LICENSE_URL_2 );
-        model.addLicense( l );
-        Scm scm = new Scm();
-        scm.setConnection( TEST_SCM_CONNECTION );
-        scm.setDeveloperConnection( TEST_SCM_DEV_CONNECTION );
-        scm.setUrl( TEST_SCM_URL );
-        model.setScm( scm );
-
-        MavenProjectFacet mavenProjectFacet = new MavenProjectFacet();
-        mavenProjectFacet.setGroupId( groupId );
-        mavenProjectFacet.setArtifactId( artifactId );
-        mavenProjectFacet.setPackaging( TEST_PACKAGING );
-        MavenProjectParent parent = new MavenProjectParent();
-        parent.setGroupId( TEST_PARENT_GROUP_ID );
-        parent.setArtifactId( TEST_PARENT_ARTIFACT_ID );
-        parent.setVersion( TEST_PARENT_VERSION );
-        mavenProjectFacet.setParent( parent );
-        model.addFacet( mavenProjectFacet );
-
-        GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
-        Map<String, String> props = new HashMap<String, String>();
-        props.put( TEST_GENERIC_METADATA_PROPERTY_NAME, TEST_GENERIC_METADATA_PROPERTY_VALUE );
-        genericMetadataFacet.setAdditionalProperties( props );
-        model.addFacet( genericMetadataFacet );
-
-        return model;
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        ConfigurationManager configurationManager = new ConfigurationManager();
-        configurationManager.addContainerProvider( new XWorkConfigurationProvider() );
-        Configuration config = configurationManager.getConfiguration();
-        Container container = config.getContainer();
-
-        ValueStack stack = container.getInstance( ValueStackFactory.class ).createValueStack();
-        stack.getContext().put( ActionContext.CONTAINER, container );
-        ActionContext.setContext( new ActionContext( stack.getContext() ) );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java
deleted file mode 100644 (file)
index 3a38d11..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.ActionSupport;
-import org.apache.commons.lang.StringUtils;
-import org.apache.struts2.StrutsSpringTestCase;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * AbstractWebworkTestCase 
- *
- * @version $Id$
- */
-public abstract class AbstractWebworkTestCase
-    extends StrutsSpringTestCase
-{
-
-
-    @Override
-    protected String[] getContextLocations()
-    {
-        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
-    }
-
-    /**
-     * This is a conveinence method for mimicking how the webwork interceptors
-     * operate on an action, before the request is processed.
-     * 
-     * Call this before each major request to the action to be sure you mimic the webwork process correctly. 
-     */
-    protected void preRequest( ActionSupport action )
-    {
-        action.clearErrorsAndMessages();
-    }
-
-    /**
-     * Tests the action to ensure that it has errors.
-     * 
-     * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
-     */
-    protected void assertHasErrors( ActionSupport action )
-    {
-        assertNotNull( action.getActionErrors() );
-        assertTrue( "Expected an error to occur.", action.getActionErrors().size() > 0 );
-    }
-    
-    /**
-     * Tests the action to ensure that it has messages.
-     * 
-     * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
-     */
-    protected void assertHasMessages( ActionSupport action )
-    {
-        assertNotNull( action.getActionMessages() );
-        assertTrue( "Expected an message to be set.", action.getActionMessages().size() > 0 );
-    }
-
-    /**
-     * Tests the action to ensure that it has NO errors.
-     * 
-     * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
-     */
-    @SuppressWarnings("unchecked")
-    protected void assertNoErrors( ActionSupport action )
-    {
-        List<String> errors = (List<String>) action.getActionErrors();
-    
-        assertNotNull( errors );
-        if ( errors.size() > 0 )
-        {
-            StringBuffer msg = new StringBuffer();
-            msg.append( "Should have had no errors. but found the following errors." );
-    
-            for ( String error : errors )
-            {
-                msg.append( "\n " ).append( error );
-            }
-            fail( msg.toString() );
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    protected void assertRequestStatus( ActionSupport action, String expectedStatus, String methodName )
-        throws Exception
-    {
-        action.clearErrorsAndMessages();
-    
-        Method method = action.getClass().getDeclaredMethod( methodName, (Class[]) null );
-        Object actualStatus = method.invoke( action, (Object[]) null );
-        assertTrue( "return should be of type String", actualStatus instanceof String );
-    
-        if ( !StringUtils.equals( expectedStatus, (String) actualStatus ) )
-        {
-            StringBuffer msg = new StringBuffer();
-            msg.append( "Unexpected status returned from method <" );
-            msg.append( methodName ).append( "> on action <" );
-            String clazzname = action.getClass().getName();
-            msg.append( clazzname.substring( clazzname.lastIndexOf( '.' ) ) );
-            msg.append( ">: expected:<" ).append( expectedStatus ).append( "> but was:<" );
-            msg.append( (String) actualStatus ).append( ">. (see attached action messages and errors below)" );
-    
-            for ( String message : (Collection<String>) action.getActionMessages() )
-            {
-                msg.append( "\n  [MESSAGE]: " ).append( message );
-            }
-    
-            for ( String error : (Collection<String>) action.getActionErrors() )
-            {
-                msg.append( "\n  [ERROR]: " ).append( error );
-            }
-    
-            fail( msg.toString() );
-        }
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AuditEventArgumentsMatcher.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AuditEventArgumentsMatcher.java
deleted file mode 100644 (file)
index fcb92f3..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.audit.AuditEvent;
-import org.easymock.ArgumentsMatcher;
-
-import java.util.Arrays;
-
-public class AuditEventArgumentsMatcher
-    implements ArgumentsMatcher
-{
-    public boolean matches( Object[] objects, Object[] objects1 )
-    {
-        if ( objects.length != 1 || objects1.length != 1 )
-        {
-            return false;
-        }
-        else
-        {
-            AuditEvent o1 = (AuditEvent) objects[0];
-            AuditEvent o2 = (AuditEvent) objects1[0];
-            o2.setTimestamp( o1.getTimestamp() ); // effectively ignore the timestamp
-            return o1.equals( o2 );
-        }
-    }
-
-    public String toString( Object[] objects )
-    {
-        return Arrays.asList( objects ).toString();
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/BrowseActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/BrowseActionTest.java
deleted file mode 100644 (file)
index 2b5c6c0..0000000
+++ /dev/null
@@ -1,411 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.google.common.collect.Lists;
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class BrowseActionTest
-    extends AbstractActionTestCase
-{
-    private static final String ACTION_HINT = "browseAction";
-
-    private BrowseAction action;
-
-    private static final List<String> GROUPS =
-        Arrays.asList( "org.apache.archiva", "commons-lang", "org.apache.maven", "com.sun", "com.oracle",
-                       "repeat.repeat" );
-
-    private static final String OTHER_TEST_REPO = "other-repo";
-
-    public void testInstantiation()
-    {
-        assertFalse( action == (BrowseAction) getActionProxy( "/browse.action" ).getAction() );
-    }
-
-    public void testBrowse()
-        throws Exception
-    {
-        metadataResolver.setNamespaces( TEST_REPO, GROUPS );
-
-        String result = action.browse();
-        assertSuccessResult( result );
-
-        assertEquals( Arrays.asList( "com", "commons-lang", "org.apache", "repeat.repeat" ), action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-
-        assertNull( action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseNoObservableRepos()
-        throws Exception
-    {
-        setObservableRepos( Collections.<String>emptyList() );
-
-        String result = action.browse();
-        assertNoAccessResult( result );
-
-        assertNoOutputVariables();
-    }
-
-    public void testBrowseGroupNoObservableRepos()
-        throws Exception
-    {
-        setObservableRepos( Collections.<String>emptyList() );
-        String selectedGroupId = "org";
-
-        action.setGroupId( selectedGroupId );
-        String result = action.browseGroup();
-        assertNoAccessResult( result );
-
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertNull( action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseArtifactNoObservableRepos()
-        throws Exception
-    {
-        setObservableRepos( Collections.<String>emptyList() );
-        String selectedGroupId = "org.apache";
-        String selectedArtifactId = "apache";
-
-        action.setGroupId( selectedGroupId );
-        action.setArtifactId( selectedArtifactId );
-        String result = action.browseArtifact();
-        assertNoAccessResult( result );
-
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertEquals( selectedArtifactId, action.getArtifactId() );
-        assertNull( action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseGroupNoGroupId()
-        throws Exception
-    {
-        String result = action.browseGroup();
-        assertErrorResult( result );
-        assertNoOutputVariables();
-    }
-
-    public void testBrowseGroupNoArtifacts()
-        throws Exception
-    {
-        String selectedGroupId = "org";
-        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache.maven" );
-
-        metadataResolver.setNamespaces( TEST_REPO, groups );
-        action.setGroupId( selectedGroupId );
-        String result = action.browseGroup();
-        assertSuccessResult( result );
-
-        assertEquals( Collections.singletonList( "org.apache" ), action.getNamespaces() );
-        assertEquals( Collections.<String>emptyList(), action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseGroupWithArtifacts()
-        throws Exception
-    {
-        String artifacts = "apache";
-        String selectedGroupId = "org.apache";
-        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache.maven" );
-
-        metadataResolver.setNamespaces( TEST_REPO, groups );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, artifacts, new ProjectVersionMetadata() );
-        action.setGroupId( selectedGroupId );
-        String result = action.browseGroup();
-        assertSuccessResult( result );
-
-        assertEquals( groups, action.getNamespaces() );
-        assertEquals( Collections.singletonList( artifacts ), action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseWithCollapsedGroupsAndArtifacts()
-        throws Exception
-    {
-        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache" );
-
-        metadataResolver.setNamespaces( TEST_REPO, groups );
-        // add an artifact in the tree to make sure "single" is not collapsed
-        metadataResolver.setProjectVersion( TEST_REPO, "org.apache", "apache", new ProjectVersionMetadata() );
-
-        String result = action.browse();
-        assertSuccessResult( result );
-
-        assertEquals( Collections.singletonList( "org.apache" ), action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-
-        assertNull( action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseWithCollapsedGroupsAndArtifactsAcrossRepositories()
-        throws Exception
-    {
-        setObservableRepos( Arrays.asList( TEST_REPO, OTHER_TEST_REPO ) );
-
-        metadataResolver.setNamespaces( TEST_REPO, Arrays.asList( "org.apache.archiva", "org.apache" ) );
-        metadataResolver.setNamespaces( OTHER_TEST_REPO, Arrays.asList( "org.codehaus.plexus", "org.codehaus" ) );
-
-        // add an artifact in the tree to make sure "single" is not collapsed
-        metadataResolver.setProjectVersion( TEST_REPO, "org.apache", "apache", new ProjectVersionMetadata() );
-
-        String result = action.browse();
-        assertSuccessResult( result );
-
-        assertEquals( Collections.singletonList( "org" ), action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-
-        assertNull( action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseGroupWithCollapsedGroupsAndArtifacts()
-        throws Exception
-    {
-        String artifacts = "apache";
-        String selectedGroupId = "org.apache";
-        List<String> groups = Arrays.asList( "org.apache.archiva", "org.apache" );
-
-        metadataResolver.setNamespaces( TEST_REPO, groups );
-        // add an artifact in the tree to make sure "single" is not collapsed
-        metadataResolver.setProjectVersion( TEST_REPO, "org.apache", "apache", new ProjectVersionMetadata() );
-
-        action.setGroupId( selectedGroupId );
-        String result = action.browseGroup();
-        assertSuccessResult( result );
-
-        assertEquals( Collections.singletonList( "org.apache.archiva" ), action.getNamespaces() );
-        assertEquals( Collections.singletonList( artifacts ), action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseArtifactNoGroupId()
-        throws Exception
-    {
-        String selectedArtifactId = "apache";
-
-        action.setArtifactId( selectedArtifactId );
-        String result = action.browseArtifact();
-        assertErrorResult( result );
-
-        assertNull( action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-        assertNull( action.getGroupId() );
-        assertEquals( selectedArtifactId, action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseArtifactNoArtifactId()
-        throws Exception
-    {
-        String selectedGroupId = "org.apache";
-
-        action.setGroupId( selectedGroupId );
-        String result = action.browseArtifact();
-        assertErrorResult( result );
-
-        assertNull( action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    public void testBrowseArtifact()
-        throws Exception
-
-    {
-        String selectedGroupId = "org.apache";
-        String selectedArtifactId = "apache";
-
-        List<String> versions = Arrays.asList( "1", "2", "3", "4" );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "1" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "2" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "3" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "4" ) );
-
-        action.setGroupId( selectedGroupId );
-        action.setArtifactId( selectedArtifactId );
-        String result = action.browseArtifact();
-        assertSuccessResult( result );
-
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertEquals( selectedArtifactId, action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-
-        assertNull( action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertEquals( versions, action.getProjectVersions() );
-
-        ProjectVersionMetadata model = action.getSharedModel();
-        assertDefaultModel( model, selectedGroupId, selectedArtifactId, null );
-    }
-
-    public void testBrowseArtifactWithSnapshots()
-        throws Exception
-
-    {
-        String selectedGroupId = "org.apache";
-        String selectedArtifactId = "apache";
-
-        List<String> versions = Arrays.asList( "1", "2", "3", "4-SNAPSHOT", "4", "5-SNAPSHOT" );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "1" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "2" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "3" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "4-SNAPSHOT" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "4" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
-                                            createProjectModel( selectedGroupId, selectedArtifactId, "5-SNAPSHOT" ) );
-
-        action.setGroupId( selectedGroupId );
-        action.setArtifactId( selectedArtifactId );
-        String result = action.browseArtifact();
-        assertSuccessResult( result );
-
-        assertEquals( selectedGroupId, action.getGroupId() );
-        assertEquals( selectedArtifactId, action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-
-        assertNull( action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertEquals( versions, action.getProjectVersions() );
-
-        ProjectVersionMetadata model = action.getSharedModel();
-        assertDefaultModel( model, selectedGroupId, selectedArtifactId, null );
-    }
-
-    // TODO: test with restricted observable repos
-    // TODO: current behaviour is to ignore values that differ between models - instead, pick the latest and use that.
-    //       Need to update the tests to verify this as models are currently the same
-
-    private void assertNoAccessResult( String result )
-    {
-        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
-        assertEquals( 0, action.getActionErrors().size() );
-        assertEquals( 0, action.getActionMessages().size() );
-    }
-
-    private void assertSuccessResult( String result )
-    {
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( 0, action.getActionErrors().size() );
-        assertEquals( 0, action.getActionMessages().size() );
-    }
-
-    private void assertErrorResult( String result )
-    {
-        assertEquals( Action.ERROR, result );
-        assertEquals( 1, action.getActionErrors().size() );
-        assertEquals( 0, action.getActionMessages().size() );
-    }
-
-    private void assertNoOutputVariables()
-    {
-        assertNull( action.getNamespaces() );
-        assertNull( action.getProjectIds() );
-        assertNull( action.getProjectVersions() );
-        assertNull( action.getGroupId() );
-        assertNull( action.getArtifactId() );
-        assertNull( action.getRepositoryId() );
-        assertNull( action.getSharedModel() );
-    }
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-        setObservableRepos( Lists.<String>newArrayList( "test-repo" ) );
-        //action = (BrowseAction) lookup( Action.class, ACTION_HINT );
-        action = (BrowseAction) getActionProxy( "/browse.action" ).getAction();
-        metadataResolver = new TestMetadataResolver();
-        RepositorySession repositorySession = mock( RepositorySession.class );
-        when( repositorySession.getResolver() ).thenReturn( metadataResolver );
-        TestRepositorySessionFactory factory =
-            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
-        factory.setRepositorySession( repositorySession );
-    }
-
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        setObservableRepos( Lists.<String>newArrayList( "test-repo" ) );
-    }
-}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java
deleted file mode 100644 (file)
index f4ec209..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.RepositoryContentFactory;
-import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
-import org.apache.struts2.StrutsSpringTestCase;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class DeleteArtifactActionTest
-    extends StrutsSpringTestCase
-{
-    private DeleteArtifactAction action;
-
-    private ArchivaConfiguration configuration;
-
-    private MockControl configurationControl;
-
-    private RepositoryContentFactory repositoryFactory;
-
-    private MockControl repositoryFactoryControl;
-
-    private MetadataRepository metadataRepository;
-
-    private MockControl metadataRepositoryControl;
-
-    private static final String REPOSITORY_ID = "test-repo";
-
-    private static final String GROUP_ID = "org.apache.archiva";
-
-    private static final String ARTIFACT_ID = "npe-metadata";
-
-    private static final String VERSION = "1.0";
-
-    private static final String REPO_LOCATION = "target/test-classes/test-repo";
-
-    @Override
-    protected String[] getContextLocations()
-    {
-        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        //action = (DeleteArtifactAction) lookup( Action.class.getName(), "deleteArtifactAction" );
-        action = (DeleteArtifactAction) getActionProxy( "/deleteArtifact.action" ).getAction();
-        assertNotNull( action );
-
-        configurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        configuration = (ArchivaConfiguration) configurationControl.getMock();
-
-        repositoryFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
-        repositoryFactory = (RepositoryContentFactory) repositoryFactoryControl.getMock();
-
-        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
-        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
-
-        RepositorySession repositorySession = mock( RepositorySession.class );
-        when( repositorySession.getRepository() ).thenReturn( metadataRepository );
-
-        TestRepositorySessionFactory repositorySessionFactory =
-            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
-
-        repositorySessionFactory.setRepositorySession( repositorySession );
-
-        (( DefaultManagedRepositoryAdmin)action.getManagedRepositoryAdmin()).setArchivaConfiguration( configuration );
-        action.setRepositoryFactory( repositoryFactory );
-    }
-
-    @Override
-    protected void tearDown()
-        throws Exception
-    {
-        action = null;
-
-        super.tearDown();
-    }
-
-    public void testGetListeners()
-        throws Exception
-    {
-        assertNotNull( action.getListeners() );
-        assertFalse( action.getListeners().isEmpty() );
-    }
-
-    public void testNPEInDeleteArtifact()
-        throws Exception
-    {
-        action.setGroupId( GROUP_ID );
-        action.setArtifactId( ARTIFACT_ID );
-        action.setVersion( VERSION );
-        action.setRepositoryId( REPOSITORY_ID );
-
-        Configuration config = createConfiguration();
-
-        ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
-        repoContent.setRepository(
-            new BeanReplicator().replicateBean( config.findManagedRepositoryById( REPOSITORY_ID ),
-                                                ManagedRepository.class ) );
-
-        configurationControl.expectAndReturn( configuration.getConfiguration(), config );
-        repositoryFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( REPOSITORY_ID ),
-                                                  repoContent );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getArtifacts( REPOSITORY_ID, GROUP_ID, ARTIFACT_ID, VERSION ),
-            new ArrayList<ArtifactMetadata>() );
-
-        configurationControl.replay();
-        repositoryFactoryControl.replay();
-        metadataRepositoryControl.replay();
-
-        action.doDelete();
-
-        String artifactPath = REPO_LOCATION + "/" + StringUtils.replace( GROUP_ID, ".", "/" ) + "/"
-            + StringUtils.replace( ARTIFACT_ID, ".", "/" ) + "/" + VERSION + "/" + ARTIFACT_ID + "-" + VERSION;
-
-        assertFalse( new File( artifactPath + ".jar" ).exists() );
-        assertFalse( new File( artifactPath + ".jar.sha1" ).exists() );
-        assertFalse( new File( artifactPath + ".jar.md5" ).exists() );
-
-        assertFalse( new File( artifactPath + ".pom" ).exists() );
-        assertFalse( new File( artifactPath + ".pom.sha1" ).exists() );
-        assertFalse( new File( artifactPath + ".pom.md5" ).exists() );
-    }
-
-    private Configuration createConfiguration()
-    {
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( REPOSITORY_ID );
-        managedRepo.setName( "Test Repository" );
-
-        managedRepo.setLocation( REPO_LOCATION );
-        managedRepo.setReleases( true );
-
-        Configuration config = new Configuration();
-        config.addManagedRepository( managedRepo );
-
-        return config;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java
deleted file mode 100644 (file)
index 0dcffcf..0000000
+++ /dev/null
@@ -1,528 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.indexer.search.RepositorySearch;
-import org.apache.archiva.indexer.search.SearchFields;
-import org.apache.archiva.indexer.search.SearchResultHit;
-import org.apache.archiva.indexer.search.SearchResultLimits;
-import org.apache.archiva.indexer.search.SearchResults;
-import org.apache.archiva.indexer.util.SearchUtil;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.archiva.security.UserRepositories;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.easymock.MockControl;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- *
- */
-public class SearchActionTest
-    extends AbstractActionTestCase
-{
-    private SearchAction action;
-
-    private MockControl userReposControl;
-
-    private UserRepositories userRepos;
-
-    private MockControl searchControl;
-
-    private MockControl repoAdminControl;
-
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    private RepositorySearch search;
-
-    private static final String TEST_CHECKSUM = "afbcdeaadbcffceabbba1";
-
-    private static final String TEST_REPO = "test-repo";
-
-    private static final String GUEST = "guest";
-
-    private RepositorySession session;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = new SearchAction();
-
-        session = mock( RepositorySession.class );
-        //TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class );
-        TestRepositorySessionFactory factory = new TestRepositorySessionFactory();
-        factory.setRepositorySession( session );
-        action.setRepositorySessionFactory( factory );
-
-        MockControl archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
-        ArchivaConfiguration archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
-
-        userReposControl = MockControl.createControl( UserRepositories.class );
-        userRepos = (UserRepositories) userReposControl.getMock();
-
-        searchControl = MockControl.createControl( RepositorySearch.class );
-        searchControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
-        search = (RepositorySearch) searchControl.getMock();
-
-        repoAdminControl = MockControl.createControl( ManagedRepositoryAdmin.class );
-        managedRepositoryAdmin = (ManagedRepositoryAdmin) repoAdminControl.getMock();
-
-        //( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfig );
-
-        action.setManagedRepositoryAdmin( managedRepositoryAdmin );
-        action.setUserRepositories( userRepos );
-        action.setNexusSearch( search );
-    }
-
-    // quick search...
-
-    public void testQuickSearch()
-        throws Exception
-    {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
-        action.setSearchResultsOnly( false );
-        action.setCompleteQueryString( "" );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
-
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
-
-        SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
-
-        SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
-
-        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
-
-        userReposControl.replay();
-        searchControl.replay();
-
-        action.setPrincipal( "user" );
-        String result = action.quickSearch();
-
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
-
-        userReposControl.verify();
-        searchControl.verify();
-    }
-
-    public void testSearchWithinSearchResults()
-        throws Exception
-    {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
-        action.setSearchResultsOnly( true );
-        action.setCompleteQueryString( "org;apache" );
-
-        List<String> parsed = new ArrayList<String>();
-        parsed.add( "org" );
-        parsed.add( "apache" );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
-
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
-
-        SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
-
-        SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
-
-        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, parsed ), results );
-
-        userReposControl.replay();
-        searchControl.replay();
-
-        action.setPrincipal( "user" );
-        String result = action.quickSearch();
-
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( "org;apache;archiva", action.getCompleteQueryString() );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
-
-        userReposControl.verify();
-        searchControl.verify();
-    }
-
-    public void testQuickSearchUserHasNoAccessToAnyRepository()
-        throws Exception
-    {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
-
-        List<String> selectedRepos = new ArrayList<String>();
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
-
-        userReposControl.replay();
-
-        action.setPrincipal( "user" );
-        String result = action.quickSearch();
-
-        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
-
-        userReposControl.verify();
-    }
-
-    public void testQuickSearchNoSearchHits()
-        throws Exception
-    {
-        action.setQ( "archiva" );
-        action.setCurrentPage( 0 );
-        action.setSearchResultsOnly( false );
-        action.setCompleteQueryString( "" );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
-
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
-
-        SearchResults results = new SearchResults();
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
-
-        searchControl.expectAndReturn( search.search( "user", selectedRepos, "archiva", limits, null ), results );
-
-        userReposControl.replay();
-        searchControl.replay();
-
-        action.setPrincipal( "user" );
-        String result = action.quickSearch();
-
-        assertEquals( Action.INPUT, result );
-
-        userReposControl.verify();
-        searchControl.verify();
-    }
-
-    // advanced/filtered search...
-
-    public void testAdvancedSearchOneRepository()
-        throws Exception
-    {
-        List<String> managedRepos = new ArrayList<String>();
-        managedRepos.add( "internal" );
-        managedRepos.add( "snapshots" );
-
-        action.setRepositoryId( "internal" );
-        action.setManagedRepositoryList( managedRepos );
-        action.setCurrentPage( 0 );
-        action.setRowCount( 30 );
-        action.setGroupId( "org" );
-
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
-
-        SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
-
-        SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
-
-        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
-
-        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
-
-        searchControl.replay();
-
-        String result = action.filteredSearch();
-
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
-
-        searchControl.verify();
-    }
-
-    public void testAdvancedSearchAllRepositories()
-        throws Exception
-    {
-        List<String> managedRepos = new ArrayList<String>();
-        managedRepos.add( "internal" );
-        managedRepos.add( "snapshots" );
-
-        action.setRepositoryId( "all" );
-        action.setManagedRepositoryList( managedRepos );
-        action.setCurrentPage( 0 );
-        action.setRowCount( 30 );
-        action.setGroupId( "org" );
-
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
-
-        SearchResultHit hit = new SearchResultHit();
-        hit.setGroupId( "org.apache.archiva" );
-        hit.setArtifactId( "archiva-configuration" );
-        hit.setUrl( "url" );
-        hit.addVersion( "1.0" );
-        hit.addVersion( "1.1" );
-
-        SearchResults results = new SearchResults();
-        results.setLimits( limits );
-        results.setTotalHits( 1 );
-        results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-configuration", null, "jar" ), hit );
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-
-        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( "user" ), selectedRepos );
-
-        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
-
-        searchControl.replay();
-        userReposControl.replay();
-
-        action.setPrincipal( "user" );
-        String result = action.filteredSearch();
-
-        assertEquals( Action.SUCCESS, result );
-        assertEquals( 1, action.getTotalPages() );
-        assertEquals( 1, action.getResults().getTotalHits() );
-
-        searchControl.verify();
-        userReposControl.verify();
-    }
-
-    public void testAdvancedSearchNoSearchHits()
-        throws Exception
-    {
-        List<String> managedRepos = new ArrayList<String>();
-        managedRepos.add( "internal" );
-        managedRepos.add( "snapshots" );
-
-        action.setRepositoryId( "internal" );
-        action.setManagedRepositoryList( managedRepos );
-        action.setCurrentPage( 0 );
-        action.setRowCount( 30 );
-        action.setGroupId( "org" );
-
-        SearchResultLimits limits = new SearchResultLimits( action.getCurrentPage() );
-        limits.setPageSize( 30 );
-
-        SearchResults results = new SearchResults();
-
-        List<String> selectedRepos = new ArrayList<String>();
-        selectedRepos.add( "internal" );
-        selectedRepos.add( "snapshots" );
-
-        SearchFields searchFields = new SearchFields( "org", null, null, null, null, selectedRepos );
-
-        searchControl.expectAndReturn( search.search( "user", searchFields, limits ), results );
-
-        searchControl.replay();
-
-        String result = action.filteredSearch();
-
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "No results found", (String) action.getActionErrors().iterator().next() );
-
-        searchControl.verify();
-    }
-
-    public void testAdvancedSearchUserHasNoAccessToAnyRepository()
-        throws Exception
-    {
-        List<String> managedRepos = new ArrayList<String>();
-
-        action.setGroupId( "org.apache.archiva" );
-        action.setManagedRepositoryList( managedRepos );
-
-        String result = action.filteredSearch();
-
-        assertEquals( GlobalResults.ACCESS_TO_NO_REPOS, result );
-    }
-
-    public void testAdvancedSearchNoSpecifiedCriteria()
-        throws Exception
-    {
-        List<String> managedRepos = new ArrayList<String>();
-
-        action.setManagedRepositoryList( managedRepos );
-
-        String result = action.filteredSearch();
-
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "Advanced Search - At least one search criteria must be provided.",
-                      (String) action.getActionErrors().iterator().next() );
-    }
-
-    // find artifact..
-    public void testFindArtifactWithOneHit()
-        throws Exception
-    {
-        action.setQ( TEST_CHECKSUM );
-
-        MockControl control = MockControl.createControl( MetadataRepository.class );
-        MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
-        when( session.getRepository() ).thenReturn( metadataRepository );
-
-        ArtifactMetadata artifact = createArtifact( "archiva-configuration", "1.0" );
-        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ),
-                                 Collections.singletonList( artifact ) );
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
-                                          Collections.singletonList( TEST_REPO ) );
-
-        control.replay();
-        userReposControl.replay();
-
-        String result = action.findArtifact();
-        assertEquals( "artifact", result );
-        assertEquals( 1, action.getDatabaseResults().size() );
-        assertEquals( artifact, action.getDatabaseResults().get( 0 ) );
-
-        control.verify();
-        userReposControl.verify();
-    }
-
-    public void testFindArtifactWithMultipleHits()
-        throws Exception
-    {
-        action.setQ( TEST_CHECKSUM );
-
-        MockControl control = MockControl.createControl( MetadataRepository.class );
-        MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
-        when( session.getRepository() ).thenReturn( metadataRepository );
-
-        List<ArtifactMetadata> artifacts = Arrays.asList( createArtifact( "archiva-configuration", "1.0" ),
-                                                          createArtifact( "archiva-indexer", "1.0" ) );
-        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ), artifacts );
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
-                                          Collections.singletonList( TEST_REPO ) );
-
-        control.replay();
-        userReposControl.replay();
-
-        String result = action.findArtifact();
-        assertEquals( "results", result );
-        assertFalse( action.getDatabaseResults().isEmpty() );
-        assertEquals( 2, action.getDatabaseResults().size() );
-
-        control.verify();
-        userReposControl.verify();
-    }
-
-    public void testFindArtifactNoChecksumSpecified()
-        throws Exception
-    {
-        String result = action.findArtifact();
-
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "Unable to search for a blank checksum", (String) action.getActionErrors().iterator().next() );
-    }
-
-    public void testFindArtifactNoResults()
-        throws Exception
-    {
-        action.setQ( TEST_CHECKSUM );
-
-        MockControl control = MockControl.createControl( MetadataRepository.class );
-        MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
-        when( session.getRepository() ).thenReturn( metadataRepository );
-
-        control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ),
-                                 Collections.<ArtifactMetadata>emptyList() );
-
-        userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ),
-                                          Collections.singletonList( TEST_REPO ) );
-
-        control.replay();
-        userReposControl.replay();
-
-        String result = action.findArtifact();
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.getActionErrors().isEmpty() );
-        assertEquals( "No results found", (String) action.getActionErrors().iterator().next() );
-
-        control.verify();
-        userReposControl.verify();
-    }
-
-    private ArtifactMetadata createArtifact( String project, String version )
-    {
-        ArtifactMetadata metadata = new ArtifactMetadata();
-        metadata.setNamespace( "org.apache.archiva" );
-        metadata.setProject( project );
-        metadata.setProjectVersion( version );
-        metadata.setVersion( version );
-        metadata.setRepositoryId( TEST_REPO );
-        metadata.setId( project + "-" + version + ".jar" );
-        return metadata;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java
deleted file mode 100644 (file)
index f52a6b8..0000000
+++ /dev/null
@@ -1,736 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.model.Dependency;
-import org.apache.archiva.metadata.model.MailingList;
-import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.model.ProjectVersionReference;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
-import org.apache.archiva.reports.RepositoryProblemFacet;
-import org.apache.archiva.common.utils.VersionUtil;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.RepositoryContentFactory;
-import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ShowArtifactActionTest
-    extends AbstractActionTestCase
-{
-    private static final String ACTION_HINT = "showArtifactAction";
-
-    private static final String TEST_VERSION = "version";
-
-    private static final String TEST_SNAPSHOT_VERSION = "1.0-SNAPSHOT";
-
-    private static final String TEST_TS_SNAPSHOT_VERSION = "1.0-20091120.111111-1";
-
-    private static final String TEST_NAMESPACE = "namespace";
-
-    private static final String OTHER_TEST_REPO = "first-repo";
-
-    private ShowArtifactAction action;
-
-    private static final List<ArtifactMetadata> TEST_SNAPSHOT_ARTIFACTS =
-        Arrays.asList( createArtifact( TEST_TS_SNAPSHOT_VERSION ),
-                       createArtifact( "1.0-20091120.222222-2", "20091120.222222", 2 ),
-                       createArtifact( "1.0-20091123.333333-3", "20091123.333333", 3 ) );
-
-    private static final long TEST_SIZE = 12345L;
-
-    private static final String TEST_TYPE = "jar";
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-        action = (ShowArtifactAction) getActionProxy( "/showArtifact.action" ).getAction();
-
-        metadataResolver = new TestMetadataResolver();
-        MetadataRepository repo = mock( MetadataRepository.class );
-        RepositorySession repositorySession = mock( RepositorySession.class );
-        when( repositorySession.getResolver() ).thenReturn( metadataResolver );
-        when( repositorySession.getRepository() ).thenReturn( repo );
-        TestRepositorySessionFactory repositorySessionFactory =
-            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
-        repositorySessionFactory.setRepositorySession( repositorySession );
-
-        RepositoryContentFactory factory = mock( RepositoryContentFactory.class );
-
-        action.setRepositoryFactory( factory );
-
-        ManagedRepository config = new ManagedRepository();
-        config.setId( TEST_REPO );
-        config.setLocation( new File( "target/test-repo" ).getAbsolutePath() );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( config );
-        when( factory.getManagedRepositoryContent( TEST_REPO ) ).thenReturn( content );
-
-        ArchivaConfiguration archivaConfig = mock( ArchivaConfiguration.class );
-
-        Configuration configuration = new Configuration();
-        configuration.addManagedRepository(
-            new BeanReplicator().replicateBean( config, ManagedRepositoryConfiguration.class ) );
-        when( archivaConfig.getConfiguration() ).thenReturn( configuration );
-
-        when( factory.getArchivaConfiguration() ).thenReturn( archivaConfig );
-
-    }
-
-    public void testInstantiation()
-    {
-        assertFalse( action == getActionProxy( "/showArtifact.action" ).getAction() );
-    }
-
-    public void testGetArtifactUniqueRelease()
-    {
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_VERSION ) );
-
-        setActionParameters();
-
-        String result = action.artifact();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testGetArtifactUniqueSnapshot()
-    {
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_SNAPSHOT_VERSION ) );
-        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
-                                       TEST_SNAPSHOT_ARTIFACTS );
-
-        action.setGroupId( TEST_GROUP_ID );
-        action.setArtifactId( TEST_ARTIFACT_ID );
-        action.setVersion( TEST_SNAPSHOT_VERSION );
-
-        String result = action.artifact();
-
-        assertActionSuccess( action, result );
-
-        assertEquals( TEST_GROUP_ID, action.getGroupId() );
-        assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
-        assertEquals( TEST_SNAPSHOT_VERSION, action.getVersion() );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model, TEST_SNAPSHOT_VERSION );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-
-        assertArtifacts( TEST_SNAPSHOT_ARTIFACTS, action.getArtifacts() );
-
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-    }
-
-    public void testGetArtifactUniqueSnapshotTimestamped()
-    {
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_SNAPSHOT_VERSION ) );
-        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
-                                       TEST_SNAPSHOT_ARTIFACTS );
-
-        action.setGroupId( TEST_GROUP_ID );
-        action.setArtifactId( TEST_ARTIFACT_ID );
-        action.setVersion( TEST_TS_SNAPSHOT_VERSION );
-
-        String result = action.artifact();
-        assertError( result );
-        assertNoOutputFields();
-    }
-
-    public void testGetMissingProject()
-    {
-        setActionParameters();
-
-        String result = action.artifact();
-        assertError( result );
-
-        assertActionParameters( action );
-        assertNoOutputFields();
-    }
-
-    public void testGetArtifactNoObservableRepos()
-    {
-        setObservableRepos( Collections.<String>emptyList() );
-
-        setActionParameters();
-
-        String result = action.artifact();
-
-        // Actually, it'd be better to have an error:
-        assertError( result );
-        assertActionParameters( action );
-        assertNoOutputFields();
-    }
-
-    public void testGetArtifactNotInObservableRepos()
-    {
-        metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_VERSION ) );
-
-        setActionParameters();
-
-        String result = action.artifact();
-        assertError( result );
-
-        assertActionParameters( action );
-        assertNoOutputFields();
-    }
-
-    public void testGetArtifactOnlySeenInSecondObservableRepo()
-    {
-        setObservableRepos( Arrays.asList( OTHER_TEST_REPO, TEST_REPO ) );
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_VERSION ) );
-
-        setActionParameters();
-
-        String result = action.artifact();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testGetArtifactSeenInBothObservableRepo()
-    {
-        setObservableRepos( Arrays.asList( TEST_REPO, OTHER_TEST_REPO ) );
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_VERSION ) );
-        metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_VERSION ) );
-
-        setActionParameters();
-
-        String result = action.artifact();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testGetArtifactCanOnlyObserveInOneOfTwoRepos()
-    {
-        setObservableRepos( Arrays.asList( TEST_REPO ) );
-        metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_VERSION ) );
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                            createProjectModel( TEST_VERSION ) );
-
-        setActionParameters();
-
-        String result = action.artifact();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testGetArtifactNoMavenFacet()
-    {
-        ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
-        versionMetadata.setId( TEST_VERSION );
-        versionMetadata.setUrl( TEST_URL );
-        versionMetadata.setName( TEST_NAME );
-        versionMetadata.setDescription( TEST_DESCRIPTION );
-
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
-
-        setActionParameters();
-
-        String result = action.artifact();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertEquals( TEST_VERSION, model.getVersion() );
-        assertEquals( TEST_URL, model.getUrl() );
-        assertEquals( TEST_NAME, model.getName() );
-        assertEquals( TEST_DESCRIPTION, model.getDescription() );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testMetadataHasRepositoryFacetProblem()
-    {
-        String errMsg = "Error in resolving artifact's parent POM file: Sample Parent POM not found";
-        ProjectVersionMetadata metaData = createProjectModel( TEST_SNAPSHOT_VERSION );
-        metaData.addFacet(
-            createRepositoryProblemFacet( TEST_REPO, errMsg, TEST_GROUP_ID, TEST_SNAPSHOT_VERSION, TEST_NAMESPACE ) );
-
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, metaData );
-
-        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
-                                       TEST_SNAPSHOT_ARTIFACTS );
-
-        action.setGroupId( TEST_GROUP_ID );
-        action.setArtifactId( TEST_ARTIFACT_ID );
-        action.setVersion( TEST_SNAPSHOT_VERSION );
-
-        String result = action.artifact();
-
-        assertEquals( Action.SUCCESS, result );
-
-        assertTrue( action.hasActionErrors() );
-        assertFalse( action.hasActionMessages() );
-        assertEquals( "Artifact metadata is incomplete: " + errMsg, action.getActionErrors().toArray()[0].toString() );
-    }
-
-    public void testMetadataIncomplete()
-    {
-        ProjectVersionMetadata metaData = createProjectModel( TEST_SNAPSHOT_VERSION );
-        metaData.setIncomplete( true );
-
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, metaData );
-
-        metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
-                                       TEST_SNAPSHOT_ARTIFACTS );
-
-        action.setGroupId( TEST_GROUP_ID );
-        action.setArtifactId( TEST_ARTIFACT_ID );
-        action.setVersion( TEST_SNAPSHOT_VERSION );
-        ;
-
-        String result = action.artifact();
-
-        assertEquals( Action.SUCCESS, result );
-
-        assertTrue( action.hasActionErrors() );
-        assertFalse( action.hasActionMessages() );
-
-        assertEquals( "Artifact metadata is incomplete.", action.getActionErrors().toArray()[0].toString() );
-    }
-
-    public void testGetMailingLists()
-    {
-        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
-        MailingList ml1 = createMailingList( "Users List", "users" );
-        MailingList ml2 = createMailingList( "Developers List", "dev" );
-        versionMetadata.setMailingLists( Arrays.asList( ml1, ml2 ) );
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
-
-        setActionParameters();
-
-        String result = action.mailingLists();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model );
-
-        assertNotNull( action.getMailingLists() );
-        assertMailingList( action.getMailingLists().get( 0 ), "Users List", "users" );
-        assertMailingList( action.getMailingLists().get( 1 ), "Developers List", "dev" );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testGetDependencies()
-    {
-        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
-        Dependency dependency1 = createDependencyBasic( "artifactId1" );
-        Dependency dependency2 = createDependencyExtended( "artifactId2" );
-        versionMetadata.setDependencies( Arrays.asList( dependency1, dependency2 ) );
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
-
-        setActionParameters();
-
-        String result = action.dependencies();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model );
-
-        assertNotNull( action.getDependencies() );
-        assertDependencyBasic( action.getDependencies().get( 0 ), "artifactId1" );
-        assertDependencyExtended( action.getDependencies().get( 1 ), "artifactId2" );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-        assertNull( action.getDependees() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testGetDependees()
-        throws Exception
-    {
-        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
-        ProjectVersionReference dependee1 = createReference( "artifactId1" );
-        ProjectVersionReference dependee2 = createReference( "artifactId2" );
-        metadataResolver.setProjectReferences( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION,
-                                               Arrays.asList( dependee1, dependee2 ) );
-
-        setActionParameters();
-
-        String result = action.dependees();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-        ProjectVersionMetadata model = action.getModel();
-        assertDefaultModel( model );
-
-        assertNotNull( action.getDependees() );
-        assertCoordinate( action.getDependees().get( 0 ), "artifactId1" );
-        assertCoordinate( action.getDependees().get( 1 ), "artifactId2" );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testGetProjectMetadata()
-    {
-        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
-
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
-
-        setActionParameters();
-
-        String result = action.projectMetadata();
-
-        assertActionSuccess( action, result );
-
-        assertActionParameters( action );
-
-        Map<String, String> genericMetadata = action.getGenericMetadata();
-        assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
-        assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
-                      TEST_GENERIC_METADATA_PROPERTY_VALUE );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-        assertNotNull( action.getModel() );
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    public void testAddAndDeleteMetadataProperty()
-    {
-        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
-
-        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
-
-        setActionParameters();
-        action.setPropertyName( "foo" );
-        action.setPropertyValue( "bar" );
-        action.setRepositoryId( TEST_REPO );
-
-        String result = action.addMetadataProperty();
-
-        assertActionSuccess( action, result );
-        assertActionParameters( action );
-
-        Map<String, String> genericMetadata = action.getGenericMetadata();
-        assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
-        assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
-                      TEST_GENERIC_METADATA_PROPERTY_VALUE );
-
-        assertNotNull( genericMetadata.get( "foo" ) );
-        assertEquals( "bar", genericMetadata.get( "foo" ) );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-        assertNotNull( action.getModel() );
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-
-        // test delete property
-        setActionParameters();
-        action.setDeleteItem( "foo" );
-
-        result = action.deleteMetadataEntry();
-
-        assertEquals( Action.SUCCESS, result );
-        assertActionParameters( action );
-        assertTrue( !action.getActionMessages().isEmpty() );
-        assertTrue( action.getActionMessages().contains( "Property successfully deleted." ) );
-
-        genericMetadata = action.getGenericMetadata();
-        assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
-        assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
-                      TEST_GENERIC_METADATA_PROPERTY_VALUE );
-
-        assertNull( genericMetadata.get( "foo" ) );
-
-        assertEquals( TEST_REPO, action.getRepositoryId() );
-        assertNotNull( action.getModel() );
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    private void assertArtifacts( List<ArtifactMetadata> expectedArtifacts,
-                                  Map<String, List<ShowArtifactAction.ArtifactDownloadInfo>> artifactMap )
-    {
-        // assuming only one of each version at this point
-        assertEquals( expectedArtifacts.size(), artifactMap.size() );
-        for ( ArtifactMetadata artifact : expectedArtifacts )
-        {
-            assertTrue( artifactMap.containsKey( artifact.getVersion() ) );
-            List<ShowArtifactAction.ArtifactDownloadInfo> list = artifactMap.get( artifact.getVersion() );
-            ShowArtifactAction.ArtifactDownloadInfo actual = list.get( 0 );
-            assertEquals( artifact.getNamespace(), actual.getNamespace() );
-            assertEquals( artifact.getId(), actual.getId() );
-            assertEquals( artifact.getProject(), actual.getProject() );
-            assertEquals( artifact.getRepositoryId(), actual.getRepositoryId() );
-            assertEquals( artifact.getVersion(), actual.getVersion() );
-            assertEquals( TEST_TYPE, actual.getType() );
-            assertEquals( "12.06 K", actual.getSize() );
-            assertEquals( artifact.getNamespace() + "/" + artifact.getProject() + "/" + TEST_SNAPSHOT_VERSION + "/"
-                              + artifact.getId(), actual.getPath() );
-        }
-    }
-
-    private static ArtifactMetadata createArtifact( String version )
-    {
-        return createArtifact( version, null, 0 );
-    }
-
-    private static ArtifactMetadata createArtifact( String version, String timestamp, int buildNumber )
-    {
-        ArtifactMetadata metadata = new ArtifactMetadata();
-        metadata.setProject( TEST_ARTIFACT_ID );
-        metadata.setId( TEST_ARTIFACT_ID + "-" + version + ".jar" );
-        metadata.setNamespace( TEST_GROUP_ID );
-        metadata.setRepositoryId( TEST_REPO );
-        metadata.setSize( TEST_SIZE );
-        metadata.setProjectVersion( VersionUtil.getBaseVersion( version ) );
-        metadata.setVersion( version );
-
-        MavenArtifactFacet facet = new MavenArtifactFacet();
-        facet.setType( "jar" );
-        facet.setTimestamp( timestamp );
-        facet.setBuildNumber( buildNumber );
-        metadata.addFacet( facet );
-
-        return metadata;
-    }
-
-    private ProjectVersionReference createReference( String projectId )
-    {
-        ProjectVersionReference reference = new ProjectVersionReference();
-        reference.setNamespace( "groupId" );
-        reference.setProjectId( projectId );
-        reference.setProjectVersion( "version" );
-        reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
-        return reference;
-    }
-
-    private void assertCoordinate( ProjectVersionReference dependee, String artifactId )
-    {
-        assertEquals( artifactId, dependee.getProjectId() );
-        assertEquals( "groupId", dependee.getNamespace() );
-        assertEquals( "version", dependee.getProjectVersion() );
-    }
-
-    private void assertDependencyBasic( Dependency dependency, String artifactId )
-    {
-        assertEquals( artifactId, dependency.getArtifactId() );
-        assertEquals( "groupId", dependency.getGroupId() );
-        assertEquals( "version", dependency.getVersion() );
-    }
-
-    private void assertDependencyExtended( Dependency dependency, String artifactId )
-    {
-        assertDependencyBasic( dependency, artifactId );
-        assertEquals( true, dependency.isOptional() );
-        assertEquals( "classifier", dependency.getClassifier() );
-        assertEquals( "type", dependency.getType() );
-        assertEquals( "scope", dependency.getScope() );
-        assertEquals( "systemPath", dependency.getSystemPath() );
-    }
-
-    private Dependency createDependencyExtended( String artifactId )
-    {
-        Dependency dependency = createDependencyBasic( artifactId );
-        dependency.setClassifier( "classifier" );
-        dependency.setOptional( true );
-        dependency.setScope( "scope" );
-        dependency.setSystemPath( "systemPath" );
-        dependency.setType( "type" );
-        return dependency;
-    }
-
-    private Dependency createDependencyBasic( String artifactId )
-    {
-        Dependency dependency = new Dependency();
-        dependency.setArtifactId( artifactId );
-        dependency.setGroupId( "groupId" );
-        dependency.setVersion( "version" );
-        return dependency;
-    }
-
-    private void assertMailingList( MailingList mailingList, String name, String prefix )
-    {
-        assertEquals( name, mailingList.getName() );
-        assertEquals( prefix + "-post@", mailingList.getPostAddress() );
-        assertEquals( prefix + "-subscribe@", mailingList.getSubscribeAddress() );
-        assertEquals( prefix + "-unsubscribe@", mailingList.getUnsubscribeAddress() );
-        assertEquals( prefix + "-archive-url", mailingList.getMainArchiveUrl() );
-        assertEquals( Arrays.asList( "other-" + prefix + "-archive-url-1", "other-" + prefix + "-archive-url-2" ),
-                      mailingList.getOtherArchives() );
-    }
-
-    private MailingList createMailingList( String name, String prefix )
-    {
-        MailingList ml1 = new MailingList();
-        ml1.setName( name );
-        ml1.setPostAddress( prefix + "-post@" );
-        ml1.setSubscribeAddress( prefix + "-subscribe@" );
-        ml1.setUnsubscribeAddress( prefix + "-unsubscribe@" );
-        ml1.setMainArchiveUrl( prefix + "-archive-url" );
-        ml1.setOtherArchives(
-            Arrays.asList( "other-" + prefix + "-archive-url-1", "other-" + prefix + "-archive-url-2" ) );
-        return ml1;
-    }
-
-    private void assertNoOutputFields()
-    {
-        assertNull( action.getModel() );
-        assertNull( action.getDependees() );
-        assertNull( action.getDependencies() );
-        assertNull( action.getMailingLists() );
-        assertTrue( action.getArtifacts().isEmpty() );
-    }
-
-    private void assertError( String result )
-    {
-        assertEquals( Action.ERROR, result );
-        assertEquals( 1, action.getActionErrors().size() );
-    }
-
-    private void assertDefaultModel( ProjectVersionMetadata model )
-    {
-        assertDefaultModel( model, TEST_VERSION );
-    }
-
-    private void setActionParameters()
-    {
-        action.setGroupId( TEST_GROUP_ID );
-        action.setArtifactId( TEST_ARTIFACT_ID );
-        action.setVersion( TEST_VERSION );
-    }
-
-    private void assertActionParameters( ShowArtifactAction action )
-    {
-        assertEquals( TEST_GROUP_ID, action.getGroupId() );
-        assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
-        assertEquals( TEST_VERSION, action.getVersion() );
-    }
-
-    private void assertActionSuccess( ShowArtifactAction action, String result )
-    {
-        assertEquals( Action.SUCCESS, result );
-        assertTrue( action.getActionErrors().isEmpty() );
-        assertTrue( action.getActionMessages().isEmpty() );
-    }
-
-    private RepositoryProblemFacet createRepositoryProblemFacet( String repoId, String errMsg, String projectId,
-                                                                 String projectVersion, String namespace )
-    {
-        RepositoryProblemFacet repoProblemFacet = new RepositoryProblemFacet();
-        repoProblemFacet.setRepositoryId( repoId );
-        repoProblemFacet.setId( repoId );
-        repoProblemFacet.setMessage( errMsg );
-        repoProblemFacet.setProblem( errMsg );
-        repoProblemFacet.setProject( projectId );
-        repoProblemFacet.setVersion( projectVersion );
-        repoProblemFacet.setNamespace( namespace );
-        return repoProblemFacet;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
deleted file mode 100644 (file)
index 2b85443..0000000
+++ /dev/null
@@ -1,854 +0,0 @@
-package org.apache.maven.archiva.web.action;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.model.admin.ArchivaAdministration;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.AuditListener;
-import org.apache.archiva.checksum.ChecksumAlgorithm;
-import org.apache.archiva.checksum.ChecksummedFile;
-import org.apache.archiva.scheduler.ArchivaTaskScheduler;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.common.utils.FileUtil;
-import org.apache.archiva.model.ArchivaRepositoryMetadata;
-import org.apache.archiva.model.SnapshotVersion;
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.RepositoryContentFactory;
-import org.apache.archiva.repository.RepositoryNotFoundException;
-import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
-import org.apache.archiva.repository.metadata.MetadataTools;
-import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- * UploadActionTest
- */
-public class UploadActionTest
-    extends AbstractActionTestCase
-{
-    private UploadAction uploadAction;
-
-    private RepositoryContentFactory repoFactory;
-
-    private MockControl repoFactoryControl;
-
-    private MockControl managedRepoAdminControl;
-
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    private MockControl archivaAdminControl;
-
-    private ArchivaAdministration archivaAdministration;
-
-    private static final String REPOSITORY_ID = "test-repo";
-
-
-    private ManagedRepository managedRepository;
-
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        MockControl schedulerControl = MockControl.createControl( ArchivaTaskScheduler.class );
-        ArchivaTaskScheduler scheduler = (ArchivaTaskScheduler) schedulerControl.getMock();
-
-        repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
-        repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
-
-        managedRepoAdminControl = MockControl.createControl( ManagedRepositoryAdmin.class );
-        managedRepositoryAdmin = (ManagedRepositoryAdmin) managedRepoAdminControl.getMock();
-
-        archivaAdminControl = MockControl.createControl( ArchivaAdministration.class );
-        archivaAdministration = (ArchivaAdministration) archivaAdminControl.getMock();
-
-        uploadAction = new UploadAction();
-        uploadAction.setScheduler( scheduler );
-        uploadAction.setManagedRepositoryAdmin( managedRepositoryAdmin );
-        uploadAction.setArchivaAdministration( archivaAdministration );
-
-        uploadAction.setRepositoryFactory( repoFactory );
-
-        File testRepo = new File( FileUtil.getBasedir(), "target/test-classes/test-repo" );
-        testRepo.mkdirs();
-
-        assertTrue( testRepo.exists() );
-
-        managedRepository = new ManagedRepository();
-        managedRepository.setId( REPOSITORY_ID );
-        managedRepository.setLayout( "default" );
-        managedRepository.setLocation( testRepo.getPath() );
-        managedRepository.setName( REPOSITORY_ID );
-        managedRepository.setBlockRedeployments( true );
-
-    }
-
-    public void tearDown()
-        throws Exception
-    {
-        File testRepo = new File( this.managedRepository.getLocation() );
-        FileUtils.deleteDirectory( testRepo );
-
-        assertFalse( testRepo.exists() );
-
-        super.tearDown();
-    }
-
-    private void setUploadParameters( String version, String classifier, File artifact, File pomFile,
-                                      boolean generatePom )
-    {
-        uploadAction.setRepositoryId( REPOSITORY_ID );
-        uploadAction.setGroupId( "org.apache.archiva" );
-        uploadAction.setArtifactId( "artifact-upload" );
-        uploadAction.setVersion( version );
-        uploadAction.setPackaging( "jar" );
-
-        uploadAction.setClassifier( classifier );
-        uploadAction.setArtifact( artifact );
-        uploadAction.setPom( pomFile );
-        uploadAction.setGeneratePom( generatePom );
-    }
-
-    private void assertAllArtifactsIncludingSupportArtifactsArePresent( String repoLocation, String artifact,
-                                                                        String version )
-    {
-        assertTrue( new File( repoLocation,
-                              "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar" ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
-            + ".jar.sha1" ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
-            + ".jar.md5" ).exists() );
-
-        assertTrue( new File( repoLocation,
-                              "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom" ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
-            + ".pom.sha1" ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact
-            + ".pom.md5" ).exists() );
-
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
-            + ".sha1" ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
-            + ".md5" ).exists() );
-    }
-
-    private void verifyVersionMetadataChecksums( String repoLocation, String version )
-        throws IOException
-    {
-        ChecksummedFile checksum = new ChecksummedFile( new File( repoLocation,
-                                                                  "/org/apache/archiva/artifact-upload/" + version + "/"
-                                                                      + MetadataTools.MAVEN_METADATA ) );
-        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
-        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
-
-        String contents = FileUtils.readFileToString( new File( repoLocation,
-                                                                "/org/apache/archiva/artifact-upload/" + version + "/"
-                                                                    + MetadataTools.MAVEN_METADATA + ".sha1" ) );
-        assertTrue( StringUtils.contains( contents, sha1 ) );
-
-        contents = FileUtils.readFileToString( new File( repoLocation,
-                                                         "/org/apache/archiva/artifact-upload/" + version + "/"
-                                                             + MetadataTools.MAVEN_METADATA + ".md5" ) );
-        assertTrue( StringUtils.contains( contents, md5 ) );
-    }
-
-    private void verifyProjectMetadataChecksums( String repoLocation )
-        throws IOException
-    {
-        ChecksummedFile checksum = new ChecksummedFile(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ) );
-        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
-        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
-
-        String contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".sha1" ) );
-        assertTrue( StringUtils.contains( contents, sha1 ) );
-
-        contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".md5" ) );
-        assertTrue( StringUtils.contains( contents, md5 ) );
-    }
-
-    private void verifyPomChecksums( String repoLocation, String artifact, String version )
-        throws IOException
-    {
-        ChecksummedFile checksum;
-        String sha1;
-        String md5;
-        String contents;
-        checksum = new ChecksummedFile(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom" ) );
-        sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
-        md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
-
-        contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom.sha1" ) );
-        assertTrue( StringUtils.contains( contents, sha1 ) );
-
-        contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".pom.md5" ) );
-        assertTrue( StringUtils.contains( contents, md5 ) );
-    }
-
-    private void verifyArtifactChecksums( String repoLocation, String artifact, String version )
-        throws IOException
-    {
-        ChecksummedFile checksum = new ChecksummedFile(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar" ) );
-        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
-        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
-
-        String contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar.sha1" ) );
-        assertTrue( StringUtils.contains( contents, sha1 ) );
-
-        contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + version + "/" + artifact + ".jar.md5" ) );
-        assertTrue( StringUtils.contains( contents, md5 ) );
-    }
-
-    private String getTimestamp( String[] artifactsList, int startIndex, int index )
-    {
-        int endIndex = -1;
-        String timestamp;
-
-        if ( artifactsList[index].contains( "jar" ) )
-        {
-            endIndex = artifactsList[index].indexOf( ".jar" );
-        }
-        else
-        {
-            endIndex = artifactsList[index].indexOf( ".pom" );
-        }
-
-        timestamp = artifactsList[index].substring( startIndex, endIndex );
-
-        return timestamp;
-    }
-
-    private MockControl mockAuditLogs( List<String> resources )
-    {
-        return mockAuditLogs( AuditEvent.UPLOAD_FILE, resources );
-    }
-
-    private MockControl mockAuditLogs( String action, List<String> resources )
-    {
-        MockControl control = MockControl.createControl( AuditListener.class );
-        AuditListener listener = (AuditListener) control.getMock();
-        boolean matcherSet = false;
-        for ( String resource : resources )
-        {
-            listener.auditEvent( new AuditEvent( REPOSITORY_ID, "guest", resource, action ) );
-            if ( !matcherSet )
-            {
-                control.setMatcher( new AuditEventArgumentsMatcher() );
-                matcherSet = true;
-            }
-        }
-        control.replay();
-
-        uploadAction.setAuditListeners( Collections.singletonList( listener ) );
-        return control;
-    }
-
-    public void testArtifactUploadWithPomSuccessful()
-        throws Exception
-    {
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ),
-                             false );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository() );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 getManagedRepository(), 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-        repoFactoryControl.replay();
-
-        MockControl control = mockAuditLogs(
-            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
-                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
-
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyProjectMetadataChecksums( repoLocation );
-    }
-
-    public void testArtifactUploadWithClassifier()
-        throws Exception
-    {
-        setUploadParameters( "1.0", "tests", new File( FileUtil.getBasedir(),
-                                                       "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ),
-                             false );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository() );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 getManagedRepository(), 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        MockControl control = mockAuditLogs(
-            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar",
-                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertTrue( new File( repoLocation,
-                              "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar" ).exists() );
-        assertTrue( new File( repoLocation,
-                              "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar.sha1" ).exists() );
-        assertTrue( new File( repoLocation,
-                              "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar.md5" ).exists() );
-
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.sha1" ).exists() );
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.md5" ).exists() );
-
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
-            + ".sha1" ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
-            + ".md5" ).exists() );
-
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0-tests", "1.0" );
-        verifyProjectMetadataChecksums( repoLocation );
-    }
-
-    public void testArtifactUploadGeneratePomSuccessful()
-        throws Exception
-    {
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository() );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 getManagedRepository(), 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        MockControl control = mockAuditLogs(
-            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
-                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
-
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyProjectMetadataChecksums( repoLocation );
-    }
-
-    public void testArtifactUploadNoPomSuccessful()
-        throws Exception
-    {
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, false );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository() );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 getManagedRepository(), 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        MockControl control =
-            mockAuditLogs( Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ) );
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.sha1" ).exists() );
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.md5" ).exists() );
-
-        assertFalse(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
-        assertFalse(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.sha1" ).exists() );
-        assertFalse(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.md5" ).exists() );
-
-        assertTrue(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
-            + ".sha1" ).exists() );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA
-            + ".md5" ).exists() );
-
-        // verify checksums of jar file
-        ChecksummedFile checksum = new ChecksummedFile(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ) );
-        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
-        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
-
-        String contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.sha1" ) );
-        assertTrue( StringUtils.contains( contents, sha1 ) );
-
-        contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.md5" ) );
-        assertTrue( StringUtils.contains( contents, md5 ) );
-
-        // verify checksums of metadata file
-        checksum = new ChecksummedFile(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ) );
-        sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
-        md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
-
-        contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".sha1" ) );
-        assertTrue( StringUtils.contains( contents, sha1 ) );
-
-        contents = FileUtils.readFileToString(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA + ".md5" ) );
-        assertTrue( StringUtils.contains( contents, md5 ) );
-    }
-
-    public void testArtifactUploadFailedRepositoryNotFound()
-        throws Exception
-    {
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, false );
-
-        repoFactoryControl.expectAndThrow( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ),
-                                           new RepositoryNotFoundException() );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 getManagedRepository(), 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.ERROR, returnString );
-
-        repoFactoryControl.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertFalse(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
-
-        assertFalse(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ).exists() );
-
-        assertFalse(
-            new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
-    }
-
-    public void testArtifactUploadSnapshots()
-        throws Exception
-    {
-        setUploadParameters( "1.0-SNAPSHOT", null, new File( FileUtil.getBasedir(),
-                                                             "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository() );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 getManagedRepository(), 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2, 5 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        SimpleDateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
-        fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
-        String timestamp = fmt.format( new Date() );
-        MockControl control = mockAuditLogs( Arrays.asList(
-            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-1.jar",
-            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-1.pom" ) );
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        String[] artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
-        Arrays.sort( artifactsList );
-
-        assertEquals( 9, artifactsList.length );
-        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
-            + MetadataTools.MAVEN_METADATA ).exists() );
-        assertTrue( new File( repoLocation,
-                              "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA
-                                  + ".sha1" ).exists() );
-        assertTrue( new File( repoLocation,
-                              "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA
-                                  + ".md5" ).exists() );
-
-        int startIndex = "artifact-upload-1.0-".length();
-        String timestampPath = getTimestamp( artifactsList, startIndex, 0 );
-
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0-" + timestampPath,
-                                                               "1.0-SNAPSHOT" );
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
-        verifyProjectMetadataChecksums( repoLocation );
-        verifyVersionMetadataChecksums( repoLocation, "1.0-SNAPSHOT" );
-
-        // verify build number
-        File metadataFile = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/"
-            + MetadataTools.MAVEN_METADATA );
-        ArchivaRepositoryMetadata artifactMetadata = RepositoryMetadataReader.read( metadataFile );
-
-        SnapshotVersion snapshotVersion = artifactMetadata.getSnapshotVersion();
-        assertEquals( "Incorrect build number set in artifact metadata.", 1, snapshotVersion.getBuildNumber() );
-
-        String timestampPart = StringUtils.substringBeforeLast( timestampPath, "-" );
-        assertEquals( "Incorrect timestamp set in artifact metadata.", timestampPart, snapshotVersion.getTimestamp() );
-
-        String buildnumber = StringUtils.substringAfterLast( timestampPath, "-" );
-        assertEquals( "Incorrect build number in filename.", "1", buildnumber );
-
-        repoFactoryControl.reset();
-        control.reset();
-
-        control.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
-
-        // MRM-1353
-        // upload snapshot artifact again and check if build number was incremented
-        setUploadParameters( "1.0-SNAPSHOT", null, new File( FileUtil.getBasedir(),
-                                                             "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        repoFactoryControl.replay();
-
-        fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
-        fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
-        timestamp = fmt.format( new Date() );
-
-        control = mockAuditLogs( Arrays.asList(
-            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.jar",
-            "org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + "-2.pom" ) );
-
-        returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
-        Arrays.sort( artifactsList );
-
-        assertEquals( 15, artifactsList.length );
-
-        timestampPath = getTimestamp( artifactsList, startIndex, 6 );
-
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0-" + timestampPath,
-                                                               "1.0-SNAPSHOT" );
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0-" + timestampPath, "1.0-SNAPSHOT" );
-        verifyProjectMetadataChecksums( repoLocation );
-        verifyVersionMetadataChecksums( repoLocation, "1.0-SNAPSHOT" );
-
-        // verify build number set in metadata and in filename
-        metadataFile = new File( repoLocation,
-                                 "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" + MetadataTools.MAVEN_METADATA );
-        artifactMetadata = RepositoryMetadataReader.read( metadataFile );
-
-        snapshotVersion = artifactMetadata.getSnapshotVersion();
-        assertEquals( "Incorrect build number set in artifact metadata.", 2, snapshotVersion.getBuildNumber() );
-
-        timestampPart = StringUtils.substringBeforeLast( timestampPath, "-" );
-        assertEquals( "Incorrect timestamp set in artifact metadata.", timestampPart, snapshotVersion.getTimestamp() );
-
-        buildnumber = StringUtils.substringAfterLast( timestampPath, "-" );
-        assertEquals( "Incorrect build number in filename.", "2", buildnumber );
-    }
-
-    public void testChecksumIsCorrectWhenArtifactIsReUploaded()
-        throws Exception
-    {
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        ManagedRepository repoConfig = getManagedRepository();
-        repoConfig.setBlockRedeployments( false );
-        content.setRepository( repoConfig );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 repoConfig, 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2, 5 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-
-        repoFactoryControl.reset();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
-
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyProjectMetadataChecksums( repoLocation );
-
-        // RE-upload artifact
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-reuploaded.jar" ),
-                             null, true );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
-        repoFactoryControl.replay();
-
-        // TODO: track modifications?
-//        MockControl control = mockAuditLogs( AuditEvent.MODIFY_FILE, Arrays.asList(
-        MockControl control = mockAuditLogs(
-            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
-                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
-
-        returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        repoLocation = getManagedRepository().getLocation();
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
-
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyProjectMetadataChecksums( repoLocation );
-    }
-
-    public void testUploadArtifactAlreadyExistingRedeploymentsBlocked()
-        throws Exception
-    {
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository() );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 1, 8 );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 getManagedRepository(), 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2, 5 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        MockControl control = mockAuditLogs( Collections.<String>emptyList() );
-
-        returnString = uploadAction.doUpload();
-        assertEquals( Action.ERROR, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
-
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyProjectMetadataChecksums( repoLocation );
-    }
-
-    public void testUploadArtifactAlreadyExistingRedeploymentsAllowed()
-        throws Exception
-    {
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        ManagedRepository repoConfig = getManagedRepository();
-        repoConfig.setBlockRedeployments( false );
-        content.setRepository( repoConfig );
-
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 1, 8 );
-
-        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
-                                                 repoConfig, 1, 8 );
-
-        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
-                                             2, 5 );
-
-        managedRepoAdminControl.replay();
-        archivaAdminControl.replay();
-
-        repoFactoryControl.replay();
-
-        String returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
-                                                    "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             null, true );
-
-        // TODO: track modifications?
-//        MockControl control = mockAuditLogs( AuditEvent.MODIFY_FILE, Arrays.asList(
-        MockControl control = mockAuditLogs(
-            Arrays.asList( "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar",
-                           "org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
-
-        returnString = uploadAction.doUpload();
-        assertEquals( Action.SUCCESS, returnString );
-
-        repoFactoryControl.verify();
-        control.verify();
-
-        String repoLocation = getManagedRepository().getLocation();
-        assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
-
-        verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyPomChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
-        verifyProjectMetadataChecksums( repoLocation );
-    }
-
-    ManagedRepository getManagedRepository()
-    {
-        return new BeanReplicator().replicateBean( this.managedRepository, ManagedRepository.class );
-    }
-
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java
deleted file mode 100644 (file)
index e345c04..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.appearance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.admin.repository.admin.DefaultArchivaAdministration;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.easymock.MockControl;
-
-/**
- */
-public abstract class AbstractOrganizationInfoActionTest
-    extends AbstractWebworkTestCase
-{
-    protected MockControl archivaConfigurationControl;
-
-    protected ArchivaConfiguration configuration;
-
-    protected AbstractAppearanceAction action;
-
-    protected Configuration config;
-
-    protected abstract AbstractAppearanceAction getAction();
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        config = new Configuration();
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        configuration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        configuration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( config, 1, 5 );
-
-        configuration.save( config );
-        archivaConfigurationControl.setVoidCallable( 1, 4 );
-
-        archivaConfigurationControl.replay();
-
-        DefaultArchivaAdministration defaultArchivaAdministration = new DefaultArchivaAdministration();
-        defaultArchivaAdministration.setArchivaConfiguration( configuration );
-        getAction().setArchivaAdministration( defaultArchivaAdministration );
-    }
-
-    protected void reloadAction()
-    {
-        action = getAction();
-        ( (DefaultArchivaAdministration) action.getArchivaAdministration() ).setArchivaConfiguration( configuration );
-
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java
deleted file mode 100644 (file)
index 49b6bba..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.appearance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import org.apache.archiva.web.validator.utils.ValidatorUtil;
-import org.apache.archiva.configuration.OrganisationInformation;
-import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- */
-public class EditOrganizationInfoActionTest
-    extends AbstractOrganizationInfoActionTest
-{
-    private static final String EMPTY_STRING = "";
-
-    // valid inputs
-    private static final String ORGANISATION_NAME_VALID_INPUT = "abcXYZ0129.   _/\\~   :?!&=-";
-
-    private static final String ORGANISATION_URL_VALID_INPUT = "file://home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
-
-    private static final String ORGANISATION_LOGO_VALID_INPUT = "file://home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
-
-    // invalid inputs
-    private static final String ORGANISATION_NAME_INVALID_INPUT = "<>~+[ ]'\"";
-
-    private static final String ORGANISATION_URL_INVALID_INPUT = "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
-
-    private static final String ORGANISATION_LOGO_INVALID_INPUT = "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"";
-
-    // testing requisite
-    private ActionValidatorManager actionValidatorManager;
-
-    @Override
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        DefaultActionValidatorManagerFactory factory = new DefaultActionValidatorManagerFactory();
-
-        actionValidatorManager = factory.createDefaultActionValidatorManager();
-    }
-
-    public void testOrganisationInfoSaves()
-        throws Exception
-    {
-        config.setOrganisationInfo( new OrganisationInformation() );
-        OrganisationInformation orginfo = config.getOrganisationInfo();
-        orginfo.setLogoLocation( "LOGO" );
-        orginfo.setName( "NAME" );
-        orginfo.setUrl( "URL" );
-
-        configuration.save( config );
-
-        reloadAction();
-
-        action.prepare();
-
-        assertEquals( "LOGO", action.getOrganisationLogo() );
-        assertEquals( "NAME", action.getOrganisationName() );
-        assertEquals( "URL", action.getOrganisationUrl() );
-
-        action.setOrganisationLogo( "LOGO1" );
-        action.setOrganisationName( "NAME1" );
-        action.setOrganisationUrl( "URL1" );
-
-        action.execute();
-
-        orginfo = config.getOrganisationInfo();
-
-        assertEquals( "LOGO1", orginfo.getLogoLocation() );
-        assertEquals( "NAME1", orginfo.getName() );
-        assertEquals( "URL1", orginfo.getUrl() );
-    }
-
-    public void testStruts2ValidationFrameworkWithNullInputs()
-        throws Exception
-    {
-        // prep
-        action = getAction();
-        populateOrganisationValues( action, null, null, null );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a name" );
-        expectedFieldErrors.put( "organisationName", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithBlankInputs()
-        throws Exception
-    {
-        // prep
-        action = getAction();
-        populateOrganisationValues( action, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a name" );
-        expectedFieldErrors.put( "organisationName", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithInvalidInputs()
-        throws Exception
-    {
-        // prep
-        action = getAction();
-        populateOrganisationValues( action, ORGANISATION_NAME_INVALID_INPUT, ORGANISATION_URL_INVALID_INPUT,
-                                    ORGANISATION_LOGO_INVALID_INPUT );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
-        expectedFieldErrors.put( "organisationName", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a URL." );
-        expectedFieldErrors.put( "organisationUrl", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a URL for your logo." );
-        expectedFieldErrors.put( "organisationLogo", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithValidInputs()
-        throws Exception
-    {
-        // prep
-        action = getAction();
-        populateOrganisationValues( action, ORGANISATION_NAME_VALID_INPUT, ORGANISATION_URL_VALID_INPUT,
-                                    ORGANISATION_LOGO_VALID_INPUT );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertFalse( action.hasFieldErrors() );
-    }
-
-    private void populateOrganisationValues( AbstractAppearanceAction abstractAppearanceAction, String name, String url,
-                                             String logo )
-    {
-        abstractAppearanceAction.setOrganisationName( name );
-        abstractAppearanceAction.setOrganisationUrl( url );
-        abstractAppearanceAction.setOrganisationLogo( logo );
-    }
-
-    @Override
-    protected AbstractAppearanceAction getAction()
-    {
-        //return (EditOrganisationInfoAction) lookup( Action.class.getName(), "editOrganisationInfo" );
-        return (EditOrganisationInfoAction) getActionProxy( "/admin/editAppearance.action" ).getAction();
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java
deleted file mode 100644 (file)
index 5b5ca60..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.appearance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.configuration.OrganisationInformation;
-
-/**
- */
-public class OrganizationInfoActionTest
-    extends AbstractOrganizationInfoActionTest
-{
-    public void testOrganisationInfoLoads()
-        throws Exception
-    {
-        config.setOrganisationInfo( new OrganisationInformation() );
-        OrganisationInformation orginfo = config.getOrganisationInfo();
-        orginfo.setLogoLocation( "LOGO" );
-        orginfo.setName( "NAME" );
-        orginfo.setUrl( "URL" );
-
-        configuration.save( config );
-
-        reloadAction();
-
-        action.prepare();
-
-        assertEquals( "URL", action.getOrganisationUrl() );
-        assertEquals( "NAME", action.getOrganisationName() );
-        assertEquals( "LOGO", action.getOrganisationLogo() );
-    }
-
-    @Override
-    protected AbstractAppearanceAction getAction()
-    {
-        return (OrganisationInfoAction) getActionProxy( "/components/companyInfo.action" ).getAction();
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
deleted file mode 100644 (file)
index 9ccfb47..0000000
+++ /dev/null
@@ -1,431 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.policies.CachedFailuresPolicy;
-import org.apache.archiva.policies.ChecksumPolicy;
-import org.apache.archiva.policies.PropagateErrorsDownloadPolicy;
-import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
-import org.apache.archiva.policies.ReleasesPolicy;
-import org.apache.archiva.policies.SnapshotsPolicy;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.easymock.MockControl;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * AddProxyConnectorActionTest
- *
- * @version $Id$
- */
-public class AddProxyConnectorActionTest
-    extends AbstractWebworkTestCase
-{
-    private AddProxyConnectorAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (AddProxyConnectorAction) getActionProxy( "/admin/addProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testAddBlackListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        populateProxyConnector( connector );
-
-        // Perform Test w/no values.
-        preRequest( action );
-        String status = action.addBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no blacklist pattern added.
-        assertHasErrors( action );
-        assertEquals( 0, connector.getBlackListPatterns().size() );
-
-        // Try again, but now with a pattern to add.
-        action.setBlackListPattern( "**/*-javadoc.jar" );
-        preRequest( action );
-        status = action.addBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 blacklist pattern added.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getBlackListPatterns().size() );
-    }
-
-    public void testAddProperty()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        populateProxyConnector( connector );
-
-        // Perform Test w/no values.
-        preRequest( action );
-        String status = action.addProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no property pattern added.
-        assertHasErrors( action );
-        assertEquals( 0, connector.getProperties().size() );
-
-        // Try again, but now with a property key/value to add.
-        action.setPropertyKey( "eat-a" );
-        action.setPropertyValue( "gramov-a-bits" );
-        preRequest( action );
-        status = action.addProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 property added.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getProperties().size() );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public void testAddProxyConnectorCommit()
-        throws Exception
-    {
-        expectConfigurationRequests( 9 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        populateProxyConnector( connector );
-        // forms will use an array
-        //connector.getProperties().put( "eat-a", new String[] { "gramov-a-bits" } );
-        // FIXME olamy check the array mode !!!
-        connector.getProperties().put( "eat-a", "gramov-a-bits" );
-
-        // Create the input screen.
-        assertRequestStatus( action, Action.SUCCESS, "commit" );
-        assertNoErrors( action );
-
-        // Test configuration.
-        List<ProxyConnectorConfiguration> proxyConfigs = archivaConfiguration.getConfiguration().getProxyConnectors();
-        assertNotNull( proxyConfigs );
-        assertEquals( 1, proxyConfigs.size() );
-
-        ProxyConnectorConfiguration actualConnector = proxyConfigs.get( 0 );
-
-        assertNotNull( actualConnector );
-        // The use of "(direct connection)" should result in a proxyId which is <null>.
-        assertNull( actualConnector.getProxyId() );
-        assertEquals( "corporate", actualConnector.getSourceRepoId() );
-        assertEquals( "central", actualConnector.getTargetRepoId() );
-        assertEquals( "gramov-a-bits", actualConnector.getProperties().get( "eat-a" ) );
-    }
-
-    public void testAddProxyConnectorInitialPage()
-        throws Exception
-    {
-        expectConfigurationRequests( 3 );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        ProxyConnector configuration = action.getConnector();
-        assertNotNull( configuration );
-        assertNull( configuration.getProxyId() );
-        assertNull( configuration.getSourceRepoId() );
-        assertNull( configuration.getTargetRepoId() );
-        assertTrue( configuration.getPolicies().isEmpty() );
-        assertTrue( configuration.getProperties().isEmpty() );
-        assertTrue( configuration.getBlackListPatterns().isEmpty() );
-        assertTrue( configuration.getWhiteListPatterns().isEmpty() );
-
-        String status = action.input();
-        assertEquals( Action.INPUT, status );
-    }
-
-    public void testAddWhiteListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        populateProxyConnector( connector );
-
-        // Perform Test w/no values.
-        preRequest( action );
-        String status = action.addWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no whitelist pattern added.
-        assertHasErrors( action );
-        assertEquals( 0, connector.getWhiteListPatterns().size() );
-
-        // Try again, but now with a pattern to add.
-        action.setWhiteListPattern( "**/*.jar" );
-        preRequest( action );
-        status = action.addWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 whitelist pattern added.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getWhiteListPatterns().size() );
-    }
-
-    public void testRemoveBlackListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        populateProxyConnector( connector );
-
-        // Add some arbitrary blacklist patterns.
-        connector.addBlackListPattern( "**/*-javadoc.jar" );
-        connector.addBlackListPattern( "**/*.war" );
-
-        // Perform Test w/no pattern value.
-        preRequest( action );
-        String status = action.removeBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no blacklist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getBlackListPatterns().size() );
-
-        // Perform test w/invalid (non-existant) pattern value to remove.
-        preRequest( action );
-        action.setPattern( "**/*oops*" );
-        status = action.removeBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no blacklist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getBlackListPatterns().size() );
-
-        // Try again, but now with a valid pattern to remove.
-        action.setPattern( "**/*-javadoc.jar" );
-        preRequest( action );
-        status = action.removeBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 blacklist pattern left.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getBlackListPatterns().size() );
-        assertEquals( "Should have left 1 blacklist pattern", "**/*.war", connector.getBlackListPatterns().get( 0 ) );
-    }
-
-    public void testRemoveProperty()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        populateProxyConnector( connector );
-
-        // Add some arbitrary properties.
-        connector.addProperty( "username", "general-tso" );
-        connector.addProperty( "password", "chicken" );
-
-        // Perform Test w/no property key.
-        preRequest( action );
-        String status = action.removeProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no properties removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getProperties().size() );
-
-        // Perform test w/invalid (non-existant) property key to remove.
-        preRequest( action );
-        action.setPropertyKey( "slurm" );
-        status = action.removeProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no properties removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getProperties().size() );
-
-        // Try again, but now with a valid property to remove.
-        preRequest( action );
-        action.setPropertyKey( "password" );
-        status = action.removeProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 property left.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getProperties().size() );
-        assertEquals( "Should have left 1 property", "general-tso", connector.getProperties().get( "username" ) );
-    }
-
-    public void testRemoveWhiteListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        populateProxyConnector( connector );
-
-        // Add some arbitrary whitelist patterns.
-        connector.addWhiteListPattern( "javax/**/*" );
-        connector.addWhiteListPattern( "com/sun/**/*" );
-
-        // Perform Test w/no pattern value.
-        preRequest( action );
-        String status = action.removeWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no whitelist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getWhiteListPatterns().size() );
-
-        // Perform test w/invalid (non-existant) pattern value to remove.
-        preRequest( action );
-        action.setPattern( "**/*oops*" );
-        status = action.removeWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no whitelist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getWhiteListPatterns().size() );
-
-        // Try again, but now with a valid pattern to remove.
-        action.setPattern( "com/sun/**/*" );
-        preRequest( action );
-        status = action.removeWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 whitelist pattern left.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getWhiteListPatterns().size() );
-        assertEquals( "Should have left 1 whitelist pattern", "javax/**/*", connector.getWhiteListPatterns().get( 0 ) );
-    }
-
-    public void testSecureActionBundle()
-        throws Exception
-    {
-        expectConfigurationRequests( 3 );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( "corporate" );
-        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
-        managedRepo.setReleases( true );
-
-        config.addManagedRepository( managedRepo );
-
-        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( "central" );
-        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
-
-        config.addRemoteRepository( remoteRepo );
-
-        return config;
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        for ( int i = 0; i < requestConfigCount; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( config );
-        }
-
-        archivaConfiguration.save( config );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private void populateProxyConnector( ProxyConnector connector )
-    {
-        connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
-        connector.setSourceRepoId( "corporate" );
-        connector.setTargetRepoId( "central" );
-
-        // TODO: Set these options programatically via list of available policies.
-        Map<String, String> policies = connector.getPolicies();
-        policies.put( "releases", new ReleasesPolicy().getDefaultOption() );
-        policies.put( "snapshots", new SnapshotsPolicy().getDefaultOption() );
-        policies.put( "checksum", new ChecksumPolicy().getDefaultOption() );
-        policies.put( "cache-failures", new CachedFailuresPolicy().getDefaultOption() );
-        policies.put( "propagate-errors", new PropagateErrorsDownloadPolicy().getDefaultOption() );
-        policies.put( "propagate-errors-on-update", new PropagateErrorsOnUpdateDownloadPolicy().getDefaultOption() );
-    }
-
-
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java
deleted file mode 100644 (file)
index f0ec5f1..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.easymock.MockControl;
-
-/**
- * DeleteProxyConnectorActionTest
- *
- * @version $Id$
- */
-public class DeleteProxyConnectorActionTest
-    extends AbstractWebworkTestCase
-{
-    private static final String TEST_TARGET_ID = "central";
-
-    private static final String TEST_SOURCE_ID = "corporate";
-
-    private DeleteProxyConnectorAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (DeleteProxyConnectorAction) getActionProxy( "/admin/deleteProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testConfirmDelete()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        // Show the confirm the delete of proxy connector screen.
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        String status = action.confirmDelete();
-        assertEquals( Action.INPUT, status );
-        assertNoErrors( action );
-    }
-
-    public void testConfirmDeleteBadSourceOrTarget()
-        throws Exception
-    {
-        expectConfigurationRequests( 4 );
-        archivaConfigurationControl.replay();
-
-        // Attempt to show the confirm delete screen, but provide
-        // a bad source id or target id to actually delete
-
-        preRequest( action );
-        action.setSource( "bad-source" ); // id doesn't exist.
-        action.setTarget( "bad-target" ); // id doesn't exist.
-        String status = action.confirmDelete();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( "bad" ); // Bad doesn't exist.
-        action.setTarget( TEST_TARGET_ID );
-        status = action.confirmDelete();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( "bad" ); // Bad doesn't exist.
-        status = action.confirmDelete();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-    }
-
-    public void testConfirmDeleteNoSourceOrTarget()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        // Attempt to show the confirm delete screen, but don't provide
-        // the source id or target id to actually delete
-
-        preRequest( action );
-        action.setSource( null ); // No source Id.
-        action.setTarget( null ); // No target Id.
-        String status = action.confirmDelete();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( null ); // No target Id.
-        status = action.confirmDelete();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( null ); // No source Id.
-        action.setTarget( TEST_TARGET_ID );
-        status = action.confirmDelete();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-    }
-
-    public void testDelete()
-        throws Exception
-    {
-        expectConfigurationRequests( 5 );
-        archivaConfigurationControl.replay();
-
-        // Show the confirm the delete of proxy connector screen.
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        String status = action.confirmDelete();
-        assertEquals( Action.INPUT, status );
-        assertNoErrors( action );
-
-        // Perform the delete.
-        preRequest( action );
-        status = action.delete();
-        assertEquals( Action.SUCCESS, status );
-        assertNoErrors( action );
-        assertHasMessages( action );
-
-        // Test the configuration.
-        assertEquals( 0, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
-    }
-
-    public void testSecureActionBundle()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( TEST_SOURCE_ID );
-        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
-        managedRepo.setReleases( true );
-
-        config.addManagedRepository( managedRepo );
-
-        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( TEST_TARGET_ID );
-        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
-
-        config.addRemoteRepository( remoteRepo );
-
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( TEST_SOURCE_ID );
-        connector.setTargetRepoId( TEST_TARGET_ID );
-
-        config.addProxyConnector( connector );
-
-        return config;
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        for ( int i = 0; i < requestConfigCount; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( config );
-        }
-
-        archivaConfiguration.save( config );
-    }
-
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java
deleted file mode 100644 (file)
index 3f3c580..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- *  Copyright 2008 jdumay.
- * 
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *       http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  under the License.
- */
-
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.easymock.MockControl;
-
-public class DisableProxyConnectorActionTest
-    extends AbstractWebworkTestCase
-{
-    private static final String TEST_TARGET_ID = "central";
-
-    private static final String TEST_SOURCE_ID = "corporate";
-
-    private DisableProxyConnectorAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (DisableProxyConnectorAction) getActionProxy( "/admin/disableProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
-    }
-
-    public void testConfirmDisableBadSourceOrTarget()
-        throws Exception
-    {
-        expectConfigurationRequests( 4 );
-        archivaConfigurationControl.replay();
-
-        // Attempt to show the confirm disable screen, but provide
-        // a bad source id or target id to actually delete
-
-        preRequest( action );
-        action.setSource( "bad-source" ); // id doesn't exist.
-        action.setTarget( "bad-target" ); // id doesn't exist.
-        String status = action.confirmDisable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( "bad" ); // Bad doesn't exist.
-        action.setTarget( TEST_TARGET_ID );
-        status = action.confirmDisable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( "bad" ); // Bad doesn't exist.
-        status = action.confirmDisable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-    }
-
-    public void testConfirmDisableNoSourceOrTarget()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        // Attempt to show the confirm disable screen, but don't provide
-        // the source id or target id to actually delete
-
-        preRequest( action );
-        action.setSource( null ); // No source Id.
-        action.setTarget( null ); // No target Id.
-        String status = action.confirmDisable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( null ); // No target Id.
-        status = action.confirmDisable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( null ); // No source Id.
-        action.setTarget( TEST_TARGET_ID );
-        status = action.confirmDisable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-    }
-
-    public void testDelete()
-        throws Exception
-    {
-        expectConfigurationRequests( 5 );
-        archivaConfigurationControl.replay();
-
-        // Show the confirm the disable of proxy connector screen.
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        String status = action.confirmDisable();
-        assertEquals( Action.INPUT, status );
-        assertNoErrors( action );
-
-        // Perform the disable.
-        preRequest( action );
-        status = action.disable();
-        assertEquals( Action.SUCCESS, status );
-        assertNoErrors( action );
-        assertHasMessages( action );
-
-        // Test the configuration.
-        assertEquals( 1, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
-        ProxyConnectorConfiguration config =
-            (ProxyConnectorConfiguration) archivaConfiguration.getConfiguration().getProxyConnectors().get( 0 );
-        assertTrue( config.isDisabled() );
-    }
-
-    public void testSecureActionBundle()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testConfirmEnable()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        // Show the confirm the disable of proxy connector screen.
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        String status = action.confirmDisable();
-        assertEquals( Action.INPUT, status );
-        assertNoErrors( action );
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( TEST_SOURCE_ID );
-        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
-        managedRepo.setReleases( true );
-
-        config.addManagedRepository( managedRepo );
-
-        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( TEST_TARGET_ID );
-        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
-
-        config.addRemoteRepository( remoteRepo );
-
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( TEST_SOURCE_ID );
-        connector.setTargetRepoId( TEST_TARGET_ID );
-
-        connector.setDisabled( false );
-
-        config.addProxyConnector( connector );
-
-        return config;
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        for ( int i = 0; i < requestConfigCount; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( config );
-        }
-
-        archivaConfiguration.save( config );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java
deleted file mode 100644 (file)
index 8934736..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.policies.CachedFailuresPolicy;
-import org.apache.archiva.policies.ChecksumPolicy;
-import org.apache.archiva.policies.PropagateErrorsDownloadPolicy;
-import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
-import org.apache.archiva.policies.ReleasesPolicy;
-import org.apache.archiva.policies.SnapshotsPolicy;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.easymock.MockControl;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * EditProxyConnectorActionTest
- *
- * @version $Id$
- */
-public class EditProxyConnectorActionTest
-    extends AbstractWebworkTestCase
-{
-    private static final String TEST_TARGET_ID = "central";
-
-    private static final String TEST_SOURCE_ID = "corporate";
-
-    private EditProxyConnectorAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (EditProxyConnectorAction) getActionProxy( "/admin/editProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-
-
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        expectConfigurationRequests( requestConfigCount, 1 );
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount, int saveRequestCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config,
-                                                     requestConfigCount , 20);
-        //archivaConfiguration.getConfiguration();
-        //archivaConfigurationControl.setReturnValue( config, requestConfigCount );
-
-        for ( int i = 0; i <= saveRequestCount; i++ )
-        {
-            archivaConfiguration.save( config );
-        }
-
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testAddBlackListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-
-        // Perform Test w/no values.
-        preRequest( action );
-        String status = action.addBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no blacklist pattern added.
-        assertHasErrors( action );
-        assertEquals( 0, connector.getBlackListPatterns().size() );
-
-        // Try again, but now with a pattern to add.
-        action.setBlackListPattern( "**/*-javadoc.jar" );
-        preRequest( action );
-        status = action.addBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 blacklist pattern added.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getBlackListPatterns().size() );
-    }
-
-    public void testAddProperty()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-
-        // Perform Test w/no values.
-        preRequest( action );
-        String status = action.addProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no property pattern added.
-        assertHasErrors( action );
-        assertEquals( 0, connector.getProperties().size() );
-
-        // Try again, but now with a property key/value to add.
-        action.setPropertyKey( "eat-a" );
-        action.setPropertyValue( "gramov-a-bits" );
-        preRequest( action );
-        status = action.addProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 property added.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getProperties().size() );
-        assertEquals( "gramov-a-bits", connector.getProperties().get( "eat-a" ) );
-    }
-
-    public void testAddWhiteListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-
-        // Perform Test w/no values.
-        preRequest( action );
-        String status = action.addWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no whitelist pattern added.
-        assertHasErrors( action );
-        assertEquals( 0, connector.getWhiteListPatterns().size() );
-
-        // Try again, but now with a pattern to add.
-        action.setWhiteListPattern( "**/*.jar" );
-        preRequest( action );
-        status = action.addWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 whitelist pattern added.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getWhiteListPatterns().size() );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public void testEditProxyConnectorCommit()
-        throws Exception
-    {
-        expectConfigurationRequests( 9, 2 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-        // forms will use an array
-        //connector.getProperties().put( "eat-a", new String[]{ "gramov-a-bits" } );
-        // FIXME check the array mode
-        connector.getProperties().put( "eat-a", "gramov-a-bits" );
-
-        // Create the input screen.
-        assertRequestStatus( action, Action.SUCCESS, "commit" );
-        assertNoErrors( action );
-
-        // Test configuration.
-        List<ProxyConnectorConfiguration> proxyConfigs = archivaConfiguration.getConfiguration().getProxyConnectors();
-        assertNotNull( proxyConfigs );
-        assertEquals( 1, proxyConfigs.size() );
-
-        ProxyConnectorConfiguration actualConnector = proxyConfigs.get( 0 );
-
-        assertNotNull( actualConnector );
-        // The use of "(direct connection)" should result in a proxyId which is <null>.
-        assertNull( actualConnector.getProxyId() );
-        assertEquals( "corporate", actualConnector.getSourceRepoId() );
-        assertEquals( "central", actualConnector.getTargetRepoId() );
-
-    }
-
-    public void testEditProxyConnectorInitialPage()
-        throws Exception
-    {
-        expectConfigurationRequests( 3 );
-        archivaConfigurationControl.replay();
-
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-
-        String status = action.input();
-        assertEquals( Action.INPUT, status );
-    }
-
-    public void testRemoveBlackListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-
-        // Add some arbitrary blacklist patterns.
-        connector.addBlackListPattern( "**/*-javadoc.jar" );
-        connector.addBlackListPattern( "**/*.war" );
-
-        // Perform Test w/no pattern value.
-        preRequest( action );
-        String status = action.removeBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no blacklist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getBlackListPatterns().size() );
-
-        // Perform test w/invalid (non-existant) pattern value to remove.
-        preRequest( action );
-        action.setPattern( "**/*oops*" );
-        status = action.removeBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no blacklist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getBlackListPatterns().size() );
-
-        // Try again, but now with a valid pattern to remove.
-        action.setPattern( "**/*-javadoc.jar" );
-        preRequest( action );
-        status = action.removeBlackListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 blacklist pattern left.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getBlackListPatterns().size() );
-        assertEquals( "Should have left 1 blacklist pattern", "**/*.war", connector.getBlackListPatterns().get( 0 ) );
-    }
-
-    public void testRemoveProperty()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-
-        // Add some arbitrary properties.
-        connector.addProperty( "username", "general-tso" );
-        connector.addProperty( "password", "chicken" );
-
-        // Perform Test w/no property key.
-        preRequest( action );
-        String status = action.removeProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no properties removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getProperties().size() );
-
-        // Perform test w/invalid (non-existant) property key to remove.
-        preRequest( action );
-        action.setPropertyKey( "slurm" );
-        status = action.removeProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no properties removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getProperties().size() );
-
-        // Try again, but now with a valid property to remove.
-        preRequest( action );
-        action.setPropertyKey( "password" );
-        status = action.removeProperty();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 property left.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getProperties().size() );
-        assertEquals( "Should have left 1 property", "general-tso", connector.getProperties().get( "username" ) );
-    }
-
-    public void testRemoveWhiteListPattern()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Prepare Test.
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        action.prepare();
-        ProxyConnector connector = action.getConnector();
-        assertInitialProxyConnector( connector );
-
-        // Add some arbitrary whitelist patterns.
-        connector.addWhiteListPattern( "javax/**/*" );
-        connector.addWhiteListPattern( "com/sun/**/*" );
-
-        // Perform Test w/no pattern value.
-        preRequest( action );
-        String status = action.removeWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no whitelist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getWhiteListPatterns().size() );
-
-        // Perform test w/invalid (non-existant) pattern value to remove.
-        preRequest( action );
-        action.setPattern( "**/*oops*" );
-        status = action.removeWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have returned an error, with no whitelist pattern removed.
-        assertHasErrors( action );
-        assertEquals( 2, connector.getWhiteListPatterns().size() );
-
-        // Try again, but now with a valid pattern to remove.
-        action.setPattern( "com/sun/**/*" );
-        preRequest( action );
-        status = action.removeWhiteListPattern();
-        assertEquals( Action.INPUT, status );
-
-        // Should have no error, and 1 whitelist pattern left.
-        assertNoErrors( action );
-        assertEquals( 1, connector.getWhiteListPatterns().size() );
-        assertEquals( "Should have left 1 whitelist pattern", "javax/**/*", connector.getWhiteListPatterns().get( 0 ) );
-    }
-
-    public void testSecureActionBundle()
-        throws Exception
-    {
-        /* Configuration will be requested at least 3 times. */
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    private void assertInitialProxyConnector( ProxyConnector connector )
-    {
-        assertNotNull( connector );
-        assertNotNull( connector.getBlackListPatterns() );
-        assertNotNull( connector.getWhiteListPatterns() );
-        assertNotNull( connector.getProperties() );
-
-        assertEquals( TEST_SOURCE_ID, connector.getSourceRepoId() );
-        assertEquals( TEST_TARGET_ID, connector.getTargetRepoId() );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( TEST_SOURCE_ID );
-        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
-        managedRepo.setReleases( true );
-
-        config.addManagedRepository( managedRepo );
-
-        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( TEST_TARGET_ID );
-        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
-
-        config.addRemoteRepository( remoteRepo );
-
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( TEST_SOURCE_ID );
-        connector.setTargetRepoId( TEST_TARGET_ID );
-
-        // TODO: Set these options programatically via list of available policies.
-        Map<String, String> policies = connector.getPolicies();
-        policies.put( "releases", new ReleasesPolicy().getDefaultOption() );
-        policies.put( "snapshots", new SnapshotsPolicy().getDefaultOption() );
-        policies.put( "checksum", new ChecksumPolicy().getDefaultOption() );
-        policies.put( "cache-failures", new CachedFailuresPolicy().getDefaultOption() );
-        policies.put( "propagate-errors", new PropagateErrorsDownloadPolicy().getDefaultOption() );
-        policies.put( "propagate-errors-on-update", new PropagateErrorsOnUpdateDownloadPolicy().getDefaultOption() );
-
-        config.addProxyConnector( connector );
-
-        return config;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.java
deleted file mode 100644 (file)
index 72b5143..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- *  Copyright 2008 jdumay.
- * 
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *       http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  under the License.
- */
-
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.easymock.MockControl;
-
-public class EnableProxyConnectorActionTest
-    extends AbstractWebworkTestCase
-{
-    private static final String TEST_TARGET_ID = "central";
-
-    private static final String TEST_SOURCE_ID = "corporate";
-
-    private EnableProxyConnectorAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-        action = (EnableProxyConnectorAction) getActionProxy( "/admin/enableProxyConnector.action" ).getAction();
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( config, requestConfigCount );
-        archivaConfiguration.save( config );
-    }
-
-    public void testConfirmDeleteBadSourceOrTarget()
-        throws Exception
-    {
-        expectConfigurationRequests( 4 );
-        archivaConfigurationControl.replay();
-
-        // Attempt to show the confirm enable screen, but provide
-        // a bad source id or target id to actually enable
-
-        preRequest( action );
-        action.setSource( "bad-source" ); // id doesn't exist.
-        action.setTarget( "bad-target" ); // id doesn't exist.
-        String status = action.confirmEnable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( "bad" ); // Bad doesn't exist.
-        action.setTarget( TEST_TARGET_ID );
-        status = action.confirmEnable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( "bad" ); // Bad doesn't exist.
-        status = action.confirmEnable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-    }
-
-    public void testConfirmEnableNoSourceOrTarget()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        // Attempt to show the confirm enable screen, but don't provide
-        // the source id or target id to actually delete
-
-        preRequest( action );
-        action.setSource( null ); // No source Id.
-        action.setTarget( null ); // No target Id.
-        String status = action.confirmEnable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( null ); // No target Id.
-        status = action.confirmEnable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-
-        preRequest( action );
-        action.setSource( null ); // No source Id.
-        action.setTarget( TEST_TARGET_ID );
-        status = action.confirmEnable();
-        // Should have resulted in an error.
-        assertEquals( Action.ERROR, status );
-        assertHasErrors( action );
-    }
-
-    public void testEnable()
-        throws Exception
-    {
-        expectConfigurationRequests( 5 );
-        archivaConfigurationControl.replay();
-
-        // Show the confirm the enable of proxy connector screen.
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        String status = action.confirmEnable();
-        assertEquals( Action.INPUT, status );
-        assertNoErrors( action );
-
-        // Perform the delete.
-        preRequest( action );
-        status = action.enable();
-        assertEquals( Action.SUCCESS, status );
-        assertNoErrors( action );
-        assertHasMessages( action );
-
-        // Test the configuration.
-        assertEquals( 1, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
-        ProxyConnectorConfiguration config =
-            (ProxyConnectorConfiguration) archivaConfiguration.getConfiguration().getProxyConnectors().get( 0 );
-        assertFalse( config.isDisabled() );
-    }
-
-    public void testSecureActionBundle()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testConfirmEnable()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        // Show the confirm the enable of proxy connector screen.
-        preRequest( action );
-        action.setSource( TEST_SOURCE_ID );
-        action.setTarget( TEST_TARGET_ID );
-        String status = action.confirmEnable();
-        assertEquals( Action.INPUT, status );
-        assertNoErrors( action );
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( TEST_SOURCE_ID );
-        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
-        managedRepo.setReleases( true );
-
-        config.addManagedRepository( managedRepo );
-
-        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( TEST_TARGET_ID );
-        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
-
-        config.addRemoteRepository( remoteRepo );
-
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( TEST_SOURCE_ID );
-        connector.setTargetRepoId( TEST_TARGET_ID );
-        connector.setDisabled( true );
-
-        config.addProxyConnector( connector );
-
-        return config;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java
deleted file mode 100644 (file)
index 765d117..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.plexus.registry.RegistryException;
-import org.easymock.MockControl;
-
-/**
- * ProxyConnectorsActionTest 
- *
- * @version $Id$
- */
-public class ProxyConnectorsActionTest
-    extends AbstractWebworkTestCase
-{
-    private static final String JAVAX = "javax";
-
-    private static final String CENTRAL = "central";
-
-    private static final String CORPORATE = "corporate";
-
-    private ProxyConnectorsAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (ProxyConnectorsAction) getActionProxy("/admin/proxyConnectors.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
-    }
-
-    public void testSecureActionBundle()
-        throws Exception
-    {
-        expectConfigurationRequests( 4 );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testExecute()
-        throws Exception
-    {
-        expectConfigurationRequests( 5 );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-
-        String status = action.execute();
-        assertEquals( Action.SUCCESS, status );
-        assertNoErrors( action );
-        
-        assertNotNull( action.getProxyConnectorMap() );
-        assertNotNull( action.getRepoMap() );
-
-        assertEquals( 1, action.getProxyConnectorMap().size() );
-        assertEquals( 3, action.getRepoMap().size() );
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        for ( int i = 0; i < requestConfigCount; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( config );
-        }
-
-        archivaConfiguration.save( config );
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( CORPORATE );
-        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
-        managedRepo.setReleases( true );
-
-        config.addManagedRepository( managedRepo );
-
-        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( CENTRAL );
-        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
-
-        config.addRemoteRepository( remoteRepo );
-
-        remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( JAVAX );
-        remoteRepo.setUrl( "http://download.java.net/maven/2/" );
-
-        config.addRemoteRepository( remoteRepo );
-
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( CORPORATE );
-        connector.setTargetRepoId( CENTRAL );
-
-        config.addProxyConnector( connector );
-
-        connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( CORPORATE );
-        connector.setTargetRepoId( JAVAX );
-
-        config.addProxyConnector( connector );
-
-        return config;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java
deleted file mode 100644 (file)
index b99bcae..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.connectors.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.configuration.functors.ProxyConnectorConfigurationOrderComparator;
-import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.easymock.MockControl;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * SortProxyConnectorsActionTest
- *
- * @version $Id$
- */
-public class SortProxyConnectorsActionTest
-    extends AbstractWebworkTestCase
-{
-    private static final String JAVAX = "javax";
-
-    private static final String CENTRAL = "central";
-
-    private static final String CORPORATE = "corporate";
-
-    private static final String CODEHAUS = "codehaus";
-
-    private SortProxyConnectorsAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (SortProxyConnectorsAction) getActionProxy( "/admin/sortUpProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( config, requestConfigCount );
-
-        archivaConfiguration.save( config );
-    }
-
-    public void testSecureActionBundle()
-        throws Exception
-    {
-        expectConfigurationRequests( 1 );
-        archivaConfigurationControl.replay();
-
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testSortDown()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        action.setSource( CORPORATE );
-        action.setTarget( CENTRAL );
-        String status = action.sortDown();
-        assertEquals( Action.SUCCESS, status );
-
-        assertOrder( new String[]{ JAVAX, CENTRAL, CODEHAUS } );
-    }
-
-    public void testSortDownPastEnd()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Ask the last connector to sort down (essentially a no-op)
-        action.setSource( CORPORATE );
-        action.setTarget( CODEHAUS );
-        String status = action.sortDown();
-        assertEquals( Action.SUCCESS, status );
-
-        // No order change.
-        assertOrder( new String[]{ CENTRAL, JAVAX, CODEHAUS } );
-    }
-
-    public void testSortUp()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        action.setSource( CORPORATE );
-        action.setTarget( CODEHAUS );
-        String status = action.sortUp();
-        assertEquals( Action.SUCCESS, status );
-
-        assertOrder( new String[]{ CENTRAL, CODEHAUS, JAVAX } );
-    }
-
-    public void testSortUpPastBeginning()
-        throws Exception
-    {
-        expectConfigurationRequests( 7 );
-        archivaConfigurationControl.replay();
-
-        // Ask the first connector to sort up (essentially a no-op)
-        action.setSource( CORPORATE );
-        action.setTarget( CENTRAL );
-        String status = action.sortUp();
-        assertEquals( Action.SUCCESS, status );
-
-        // No order change.
-        assertOrder( new String[]{ CENTRAL, JAVAX, CODEHAUS } );
-    }
-
-    private void assertOrder( String[] targetRepoOrder )
-    {
-        List<ProxyConnectorConfiguration> connectors = archivaConfiguration.getConfiguration().getProxyConnectors();
-        Collections.sort( connectors, ProxyConnectorConfigurationOrderComparator.getInstance() );
-
-        for ( ProxyConnectorConfiguration connector : connectors )
-        {
-            assertEquals( "All connectors in list should have the same source id (in this test)", CORPORATE,
-                          connector.getSourceRepoId() );
-        }
-
-        assertEquals( targetRepoOrder.length, connectors.size() );
-
-        int orderFailedAt = ( -1 );
-        for ( int i = 0; i < targetRepoOrder.length; i++ )
-        {
-            if ( !StringUtils.equals( targetRepoOrder[i], connectors.get( i ).getTargetRepoId() ) )
-            {
-                orderFailedAt = i;
-                break;
-            }
-        }
-
-        if ( orderFailedAt >= 0 )
-        {
-            StringBuffer msg = new StringBuffer();
-
-            msg.append( "Failed expected order of the proxy connectors <" );
-            msg.append( StringUtils.join( targetRepoOrder, ", " ) );
-            msg.append( ">, actual <" );
-
-            boolean needsComma = false;
-            for ( ProxyConnectorConfiguration proxy : connectors )
-            {
-                if ( needsComma )
-                {
-                    msg.append( ", " );
-                }
-                msg.append( proxy.getTargetRepoId() );
-                needsComma = true;
-            }
-            msg.append( "> failure at index <" ).append( orderFailedAt ).append( ">." );
-
-            fail( msg.toString() );
-        }
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
-        managedRepo.setId( CORPORATE );
-        managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
-        managedRepo.setReleases( true );
-        config.addManagedRepository( managedRepo );
-
-        RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( CENTRAL );
-        remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
-        config.addRemoteRepository( remoteRepo );
-
-        remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( JAVAX );
-        remoteRepo.setUrl( "http://download.java.net/maven/2/" );
-        config.addRemoteRepository( remoteRepo );
-
-        remoteRepo = new RemoteRepositoryConfiguration();
-        remoteRepo.setId( CODEHAUS );
-        remoteRepo.setUrl( "http://repository.codehaus.org/" );
-        config.addRemoteRepository( remoteRepo );
-
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( CORPORATE );
-        connector.setTargetRepoId( CENTRAL );
-        connector.setOrder( 1 );
-        config.addProxyConnector( connector );
-
-        connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( CORPORATE );
-        connector.setTargetRepoId( JAVAX );
-        connector.setOrder( 2 );
-        config.addProxyConnector( connector );
-
-        connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( CORPORATE );
-        connector.setTargetRepoId( CODEHAUS );
-        connector.setOrder( 3 );
-        config.addProxyConnector( connector );
-
-        return config;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/legacy/AddLegacyArtifactPathActionTest.java
deleted file mode 100644 (file)
index c331821..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.legacy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import junit.framework.TestCase;
-import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
-import org.apache.archiva.web.validator.utils.ValidatorUtil;
-import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class AddLegacyArtifactPathActionTest
-    extends TestCase
-{
-    private static final String EMPTY_STRING = "";
-
-    // valid inputs
-    private static final String LEGACY_ARTIFACT_PATH_PATH_VALID_INPUT = "-abcXYZ0129._/\\";
-
-    private static final String GROUP_ID_VALID_INPUT = "abcXYZ0129._-";
-
-    private static final String ARTIFACT_ID_VALID_INPUT = "abcXYZ0129._-";
-
-    private static final String VERSION_VALID_INPUT = "abcXYZ0129._-";
-
-    private static final String CLASSIFIER_VALID_INPUT = "abcXYZ0129._-";
-
-    private static final String TYPE_VALID_INPUT = "abcXYZ0129._-";
-
-    // invalid inputs
-    private static final String LEGACY_ARTIFACT_PATH_PATH_INVALID_INPUT = "<> ~+[ ]'\"";
-
-    private static final String GROUP_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
-
-    private static final String ARTIFACT_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
-
-    private static final String VERSION_INVALID_INPUT = "<> \\/~+[ ]'\"";
-
-    private static final String CLASSIFIER_INVALID_INPUT = "<> \\/~+[ ]'\"";
-
-    private static final String TYPE_INVALID_INPUT = "<> \\/~+[ ]'\"";
-
-    // testing requisite
-    private AddLegacyArtifactPathAction addLegacyArtifactPathAction;
-
-    private ActionValidatorManager actionValidatorManager;
-
-    @Override
-    public void setUp()
-        throws Exception
-    {
-        addLegacyArtifactPathAction = new AddLegacyArtifactPathAction();
-
-        DefaultActionValidatorManagerFactory factory = new DefaultActionValidatorManagerFactory();
-
-        actionValidatorManager = factory.createDefaultActionValidatorManager();
-    }
-
-    public void testStruts2ValidationFrameworkWithNullInputs()
-        throws Exception
-    {
-        // prep
-        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( null );
-        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath, null, null, null,
-                                                   null, null );
-
-        // test
-        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
-
-        // verify
-        assertTrue( addLegacyArtifactPathAction.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = addLegacyArtifactPathAction.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a legacy path." );
-        expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a groupId." );
-        expectedFieldErrors.put( "groupId", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter an artifactId." );
-        expectedFieldErrors.put( "artifactId", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a version." );
-        expectedFieldErrors.put( "version", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a type." );
-        expectedFieldErrors.put( "type", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithBlankInputs()
-        throws Exception
-    {
-        // prep
-        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( EMPTY_STRING );
-        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath, EMPTY_STRING,
-                                                   EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
-
-        // test
-        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
-
-        // verify
-        assertTrue( addLegacyArtifactPathAction.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = addLegacyArtifactPathAction.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a legacy path." );
-        expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a groupId." );
-        expectedFieldErrors.put( "groupId", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter an artifactId." );
-        expectedFieldErrors.put( "artifactId", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a version." );
-        expectedFieldErrors.put( "version", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a type." );
-        expectedFieldErrors.put( "type", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithInvalidInputs()
-        throws Exception
-    {
-        // prep
-        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_INVALID_INPUT );
-        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath,
-                                                   GROUP_ID_INVALID_INPUT, ARTIFACT_ID_INVALID_INPUT,
-                                                   VERSION_INVALID_INPUT, CLASSIFIER_INVALID_INPUT,
-                                                   TYPE_INVALID_INPUT );
-
-        // test
-        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
-
-        // verify
-        assertTrue( addLegacyArtifactPathAction.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = addLegacyArtifactPathAction.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "groupId", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "artifactId", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "version", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "classifier", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "type", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithValidInputs()
-        throws Exception
-    {
-        // prep
-        LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_VALID_INPUT );
-        populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath,
-                                                   GROUP_ID_VALID_INPUT, ARTIFACT_ID_VALID_INPUT, VERSION_VALID_INPUT,
-                                                   CLASSIFIER_VALID_INPUT, TYPE_VALID_INPUT );
-
-        // test
-        actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
-
-        // verify
-        assertFalse( addLegacyArtifactPathAction.hasFieldErrors() );
-    }
-
-    private LegacyArtifactPath createLegacyArtifactPath( String path )
-    {
-        LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
-        legacyArtifactPath.setPath( path );
-        return legacyArtifactPath;
-    }
-
-    private void populateAddLegacyArtifactPathActionFields( AddLegacyArtifactPathAction addLegacyArtifactPathAction,
-                                                            LegacyArtifactPath legacyArtifactPath, String groupId,
-                                                            String artifactId, String version, String classifier,
-                                                            String type )
-    {
-        addLegacyArtifactPathAction.setLegacyArtifactPath( legacyArtifactPath );
-        addLegacyArtifactPathAction.setGroupId( groupId );
-        addLegacyArtifactPathAction.setArtifactId( artifactId );
-        addLegacyArtifactPathAction.setVersion( version );
-        addLegacyArtifactPathAction.setClassifier( classifier );
-        addLegacyArtifactPathAction.setType( type );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyActionTest.java
deleted file mode 100644 (file)
index 7990d40..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.networkproxies;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import junit.framework.TestCase;
-import org.apache.archiva.admin.model.beans.NetworkProxy;
-import org.apache.archiva.web.validator.utils.ValidatorUtil;
-import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ConfigureNetworkProxyActionTest extends TestCase
-{
-    private static final String EMPTY_STRING = "";
-
-    private static final String VALIDATION_CONTEXT = "saveNetworkProxy";
-
-    // valid inputs
-    private static final String PROXY_ID_VALID_INPUT = "abcXYZ0129._-";
-
-    private static final String PROXY_PROTOCOL_VALID_INPUT = "-abcXYZ0129./:\\";
-
-    private static final String PROXY_HOST_VALID_INPUT = "abcXYZ0129._/\\~:?!&=-";
-
-    private static final int PROXY_PORT_VALID_INPUT = 8080;
-
-    private static final String PROXY_USERNAME_VALID_INPUT = "abcXYZ0129.@/_-\\";
-
-    // invalid inputs
-    private static final String PROXY_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
-
-    private static final String PROXY_PROTOCOL_INVALID_INPUT = "<> ~+[ ]'\"";
-
-    private static final String PROXY_HOST_INVALID_INPUT = "<> ~+[ ]'\"";
-
-    private static final int PROXY_PORT_INVALID_INPUT = 0;
-
-    private static final String PROXY_USERNAME_INVALID_INPUT = "<> ~+[ ]'\"";
-
-    // testing requisite
-    private ConfigureNetworkProxyAction configureNetworkProxyAction;
-
-    private ActionValidatorManager actionValidatorManager;
-    
-    @Override
-    public void setUp()
-        throws Exception
-    {
-        configureNetworkProxyAction = new ConfigureNetworkProxyAction();
-
-        DefaultActionValidatorManagerFactory factory = new DefaultActionValidatorManagerFactory();
-
-        actionValidatorManager = factory.createDefaultActionValidatorManager();
-    }
-
-    public void testStruts2ValidationFrameworkWithNullInputs() throws Exception
-    {
-        // prep
-        NetworkProxy networkProxy = createNetworkProxy(null, null, null, null);
-        configureNetworkProxyAction.setProxy(networkProxy);
-
-        // test
-        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
-
-        // verify
-        assertTrue(configureNetworkProxyAction.hasFieldErrors());
-
-        Map<String, List<String>> fieldErrors = configureNetworkProxyAction.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("You must enter an identifier.");
-        expectedFieldErrors.put("proxy.id", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("You must enter a protocol.");
-        expectedFieldErrors.put("proxy.protocol", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("You must enter a host.");
-        expectedFieldErrors.put("proxy.host", expectedErrorMessages);
-
-        ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
-    }
-
-    public void testStruts2ValidationFrameworkWithBlankInputs() throws Exception
-    {
-        // prep
-        NetworkProxy networkProxy = createNetworkProxy(EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING);
-        configureNetworkProxyAction.setProxy(networkProxy);
-
-        // test
-        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
-
-        // verify
-        assertTrue(configureNetworkProxyAction.hasFieldErrors());
-
-        Map<String, List<String>> fieldErrors = configureNetworkProxyAction.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("You must enter an identifier.");
-        expectedFieldErrors.put("proxy.id", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("You must enter a protocol.");
-        expectedFieldErrors.put("proxy.protocol", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("You must enter a host.");
-        expectedFieldErrors.put("proxy.host", expectedErrorMessages);
-
-        ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
-    }
-
-    public void testStruts2ValidationFrameworkWithInvalidInputs() throws Exception
-    {
-        // prep
-        NetworkProxy networkProxy = createNetworkProxy( PROXY_ID_INVALID_INPUT, PROXY_HOST_INVALID_INPUT,
-                                                        PROXY_PORT_INVALID_INPUT, PROXY_PROTOCOL_INVALID_INPUT,
-                                                        PROXY_USERNAME_INVALID_INPUT );
-        configureNetworkProxyAction.setProxy(networkProxy);
-
-        // test
-        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
-
-        // verify
-        assertTrue(configureNetworkProxyAction.hasFieldErrors());
-
-        Map<String, List<String>> fieldErrors = configureNetworkProxyAction.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("Proxy id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
-        expectedFieldErrors.put("proxy.id", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("Protocol must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), dots(.), colons(:), and dashes(-).");
-        expectedFieldErrors.put("proxy.protocol", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("Host must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).");
-        expectedFieldErrors.put("proxy.host", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("Port needs to be larger than 1");
-        expectedFieldErrors.put("proxy.port", expectedErrorMessages);
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add("Username must only contain alphanumeric characters, at's(@), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-).");
-        expectedFieldErrors.put("proxy.username", expectedErrorMessages);
-
-        ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
-    }
-
-    public void testStruts2ValidationFrameworkWithValidInputs() throws Exception
-    {
-        // prep
-        NetworkProxy networkProxy = createNetworkProxy(PROXY_ID_VALID_INPUT, PROXY_HOST_VALID_INPUT, PROXY_PORT_VALID_INPUT, PROXY_PROTOCOL_VALID_INPUT, PROXY_USERNAME_VALID_INPUT);
-        configureNetworkProxyAction.setProxy(networkProxy);
-
-        // test
-        actionValidatorManager.validate(configureNetworkProxyAction, VALIDATION_CONTEXT);
-
-        // verify
-        assertFalse(configureNetworkProxyAction.hasFieldErrors());
-    }
-
-    private NetworkProxy createNetworkProxy(String id, String host, int port, String protocol, String username)
-    {
-        NetworkProxy networkProxy = new NetworkProxy();
-        networkProxy.setId( id );
-        networkProxy.setHost( host );
-        networkProxy.setPort( port );
-        networkProxy.setProtocol( protocol );
-        networkProxy.setUsername( username );
-        return networkProxy;
-    }
-
-    // over-loaded
-    // for simulating empty/null form purposes; excluding primitive data-typed values
-    private NetworkProxy createNetworkProxy(String id, String host, String protocol, String username)
-    {
-        NetworkProxy networkProxy = new NetworkProxy();
-        networkProxy.setId( id );
-        networkProxy.setHost( host );
-        networkProxy.setProtocol( protocol );
-        networkProxy.setUsername( username );
-        return networkProxy;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoryActionTest.java
deleted file mode 100644 (file)
index b535ea9..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.struts2.StrutsSpringTestCase;
-
-import java.io.File;
-
-public abstract class AbstractManagedRepositoryActionTest
-    extends StrutsSpringTestCase
-{
-    protected static final String EMPTY_STRING = "";
-
-    // valid inputs; validation testing
-    protected static final String REPOSITORY_ID_VALID_INPUT = "abcXYZ0129._-";
-
-    protected static final String REPOSITORY_LOCATION_VALID_INPUT = "abcXYZ0129._/\\~:?!&=-";
-
-    protected static final String REPOSITORY_INDEX_DIR_VALID_INPUT = "abcXYZ0129._/\\~:?!&=-";
-
-    protected static final String REPOSITORY_NAME_VALID_INPUT = "abcXYZ   0129.)/   _(-";
-
-    protected static final int REPOSITORY_RETENTION_COUNT_VALID_INPUT = 1;
-
-    protected static final int REPOSITORY_DAYS_OLDER_VALID_INPUT = 1;
-
-    // invalid inputs; validation testing
-    protected static final String REPOSITORY_ID_INVALID_INPUT = "<> \\/~+[ ]'\"";
-
-    protected static final String REPOSITORY_LOCATION_INVALID_INPUT = "<> ~+[ ]'\"";
-
-    protected static final String REPOSITORY_INDEX_DIR_INVALID_INPUT = "<> ~+[ ]'\"";
-
-    protected static final String REPOSITORY_NAME_INVALID_INPUT = "<>\\~+[]'\"";
-
-    protected static final int REPOSITORY_RETENTION_COUNT_INVALID_INPUT = 101;
-
-    protected static final int REPOSITORY_DAYS_OLDER_INVALID_INPUT = -1;
-
-    // testing requisite; validation testing
-    protected ActionValidatorManager actionValidatorManager;
-
-    protected static final String REPO_ID = "repo-ident";
-
-    protected File location;
-
-    @Override
-    protected String[] getContextLocations()
-    {
-        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        DefaultActionValidatorManagerFactory defaultActionValidatorManagerFactory =
-            new DefaultActionValidatorManagerFactory();
-
-        actionValidatorManager = defaultActionValidatorManagerFactory.createDefaultActionValidatorManager();
-    }
-
-    protected void populateRepository( ManagedRepository repository )
-    {
-        repository.setId( REPO_ID );
-        repository.setName( "repo name" );
-        repository.setLocation( location.getAbsolutePath() );
-        repository.setLayout( "default" );
-        repository.setCronExpression( "* 0/5 * * * ?" );
-        repository.setDaysOlder( 31 );
-        repository.setRetentionCount( 20 );
-        repository.setReleases( true );
-        repository.setSnapshots( false );
-        repository.setScanned( false );
-        repository.setDeleteReleasedSnapshots( true );
-    }
-
-    protected ManagedRepository createManagedRepository( String id, String name, String location )
-    {
-        ManagedRepository managedRepositoryConfiguration = new ManagedRepository();
-
-        managedRepositoryConfiguration.setId( id );
-        managedRepositoryConfiguration.setName( name );
-        managedRepositoryConfiguration.setLocation( location );
-
-        return managedRepositoryConfiguration;
-    }
-
-    // over-loaded
-    // for simulating empty/null form purposes; excluding primitive data-typed values
-    protected ManagedRepository createManagedRepository( String id, String name, String location,
-                                                                      String indexDir )
-    {
-        ManagedRepository managedRepositoryConfiguration = new ManagedRepository();
-
-        managedRepositoryConfiguration.setId( id );
-        managedRepositoryConfiguration.setName( name );
-        managedRepositoryConfiguration.setLocation( location );
-        managedRepositoryConfiguration.setIndexDirectory( indexDir );
-
-        return managedRepositoryConfiguration;
-    }
-
-    protected ManagedRepository createManagedRepository( String id, String name, String location, String indexDir,
-                                                         int daysOlder, int retentionCount )
-    {
-        ManagedRepository managedRepositoryConfiguration = new ManagedRepository();
-
-        managedRepositoryConfiguration.setId( id );
-        managedRepositoryConfiguration.setName( name );
-        managedRepositoryConfiguration.setLocation( location );
-        managedRepositoryConfiguration.setIndexDirectory( indexDir );
-        managedRepositoryConfiguration.setDaysOlder( daysOlder );
-        managedRepositoryConfiguration.setRetentionCount( retentionCount );
-
-        return managedRepositoryConfiguration;
-    }
-
-
-    protected ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return applicationContext.getBean( ManagedRepositoryAdmin.class );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java
deleted file mode 100644 (file)
index 2f5bb4f..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.repository.RepositoryCommonValidator;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
-import org.apache.archiva.scheduler.repository.RepositoryTask;
-import org.apache.archiva.security.ArchivaRoleConstants;
-import org.apache.archiva.web.validator.utils.ValidatorUtil;
-import org.apache.commons.io.FileUtils;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.codehaus.plexus.redback.role.RoleManager;
-import org.codehaus.plexus.registry.Registry;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * AddManagedRepositoryActionTest
- *
- * @version $Id$
- */
-public class AddManagedRepositoryActionTest
-    extends AbstractManagedRepositoryActionTest
-{
-    private AddManagedRepositoryAction action;
-
-    private RoleManager roleManager;
-
-    private MockControl roleManagerControl;
-
-    private MockControl archivaConfigurationControl;
-
-    private Registry registry;
-
-    private MockControl registryControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    private MockControl repositoryTaskSchedulerControl;
-
-    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
-
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = new AddManagedRepositoryAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        roleManagerControl = MockControl.createControl( RoleManager.class );
-        roleManager = (RoleManager) roleManagerControl.getMock();
-
-        registryControl = MockControl.createControl( Registry.class );
-        registry = (Registry) registryControl.getMock();
-        //action.setRegistry( registry );
-
-        repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
-        repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
-
-        location = new File( "target/test/location" );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRegistry( registry );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryTaskScheduler(
-            repositoryTaskScheduler );
-
-        RepositoryCommonValidator repositoryCommonValidator = new RepositoryCommonValidator();
-        repositoryCommonValidator.setArchivaConfiguration( archivaConfiguration );
-        repositoryCommonValidator.setRegistry( registry );
-
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryCommonValidator(
-            repositoryCommonValidator );
-
-        action.setRepositoryCommonValidator( repositoryCommonValidator );
-
-        action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
-
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testAddRepositoryInitialPage()
-        throws Exception
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        ManagedRepository configuration = action.getRepository();
-        assertNotNull( configuration );
-        assertNull( configuration.getId() );
-        // check all booleans are false
-        assertFalse( configuration.isDeleteReleasedSnapshots() );
-        assertFalse( configuration.isScanned() );
-        assertFalse( configuration.isReleases() );
-        assertFalse( configuration.isSnapshots() );
-
-        String status = action.input();
-        assertEquals( Action.INPUT, status );
-
-        // check defaults
-        assertFalse( configuration.isDeleteReleasedSnapshots() );
-        assertTrue( configuration.isScanned() );
-        assertTrue( configuration.isReleases() );
-        assertFalse( configuration.isSnapshots() );
-    }
-
-    public void testAddRepository()
-        throws Exception
-    {
-        FileUtils.deleteDirectory( location );
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManagerControl.setVoidCallable();
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.setVoidCallable();
-
-        roleManagerControl.replay();
-
-        registry.getString( "appserver.base", "${appserver.base}" );
-        registryControl.setReturnValue( "target/test" );
-        registry.getString( "appserver.home", "${appserver.home}" );
-        registryControl.setReturnValue( "target/test" );
-
-        registry.getString( "appserver.base", "${appserver.base}" );
-        registryControl.setReturnValue( "target/test" );
-        registry.getString( "appserver.home", "${appserver.home}" );
-        registryControl.setReturnValue( "target/test" );
-
-        registryControl.replay();
-
-        RepositoryTask task = new RepositoryTask();
-        task.setRepositoryId( REPO_ID );
-        repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
-        repositoryTaskSchedulerControl.setReturnValue( false );
-        repositoryTaskScheduler.queueTask( task );
-        repositoryTaskSchedulerControl.setVoidCallable();
-        repositoryTaskSchedulerControl.replay();
-
-        Configuration configuration = new Configuration();
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfiguration.save( configuration );
-
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        ManagedRepository repository = action.getRepository();
-        populateRepository( repository );
-
-        assertFalse( location.exists() );
-        String status = action.commit();
-        assertEquals( Action.SUCCESS, status );
-        assertTrue( location.exists() );
-
-        assertEquals( Collections.singletonList( repository ), getManagedRepositoryAdmin().getManagedRepositories() );
-        assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
-
-        roleManagerControl.verify();
-        archivaConfigurationControl.verify();
-        registryControl.verify();
-    }
-
-
-    public void testAddRepositoryExistingLocation()
-        throws Exception
-    {
-        if ( !location.exists() )
-        {
-            location.mkdirs();
-        }
-
-        registry.getString( "appserver.base", "${appserver.base}" );
-        registryControl.setReturnValue( "target/test" );
-        registry.getString( "appserver.home", "${appserver.home}" );
-        registryControl.setReturnValue( "target/test" );
-
-        registryControl.replay();
-
-        action.prepare();
-        ManagedRepository repository = action.getRepository();
-        populateRepository( repository );
-
-        assertTrue( location.exists() );
-        String status = action.commit();
-        assertEquals( AddManagedRepositoryAction.CONFIRM, status );
-        assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
-        registryControl.verify();
-    }
-
-    public void testStruts2ValidationFrameworkWithNullInputs()
-        throws Exception
-    {
-        // prep
-        // 0 is the default value for primitive int; null for objects
-        ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository identifier." );
-        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a directory." );
-        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository name." );
-        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithBlankInputs()
-        throws Exception
-    {
-        // prep
-        // 0 is the default value for primitive int
-        ManagedRepository managedRepositoryConfiguration =
-            createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository identifier." );
-        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a directory." );
-        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository name." );
-        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithInvalidInputs()
-        throws Exception
-    {
-        // prep
-        ManagedRepository managedRepositoryConfiguration =
-            createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
-                                     REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
-                                     REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
-        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
-        expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
-        expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
-        expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithValidInputs()
-        throws Exception
-    {
-        // prep
-        ManagedRepository managedRepositoryConfiguration =
-            createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
-                                     REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
-                                     REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertFalse( action.hasFieldErrors() );
-    }
-
-    // TODO: test errors during add, other actions
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.java
deleted file mode 100644 (file)
index f4fbf32..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.maven.archiva.web.action.AbstractActionTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-
-import java.util.Collections;
-
-/**
- * AddRemoteRepositoryActionTest
- *
- * @version $Id$
- */
-public class AddRemoteRepositoryActionTest
-    extends AbstractActionTestCase
-{
-    private AddRemoteRepositoryAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    private static final String REPO_ID = "remote-repo-ident";
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (AddRemoteRepositoryAction) getActionProxy( "/admin/addRemoteRepository.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testAddRemoteRepositoryInitialPage()
-        throws Exception
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        RemoteRepository configuration = action.getRepository();
-        assertNotNull( configuration );
-        assertNull( configuration.getId() );
-
-        String status = action.input();
-        assertEquals( Action.INPUT, status );
-    }
-
-    public void testAddRemoteRepository()
-        throws Exception
-    {
-        Configuration configuration = new Configuration();
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfiguration.save( configuration );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        RemoteRepository repository = action.getRepository();
-        populateRepository( repository );
-
-        assertEquals( "url ", repository.getUrl() );
-
-        String status = action.commit();
-        assertEquals( Action.SUCCESS, status );
-
-        assertEquals( Collections.singletonList( repository ),
-                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
-
-        assertEquals( "url", repository.getUrl() );
-
-        archivaConfigurationControl.verify();
-    }
-
-    private void populateRepository( RemoteRepository repository )
-    {
-        repository.setId( REPO_ID );
-        repository.setName( "repo name" );
-        repository.setUrl( "url " );
-        repository.setLayout( "default" );
-    }
-
-    // TODO: test errors during add, other actions
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DefaultActionValidatorManagerFactory.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DefaultActionValidatorManagerFactory.java
deleted file mode 100644 (file)
index f1b248e..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.DefaultTextProvider;
-import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.TextProvider;
-import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
-import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer;
-import com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter;
-import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.inject.ContainerBuilder;
-import com.opensymphony.xwork2.inject.Scope;
-import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
-import com.opensymphony.xwork2.ognl.OgnlUtil;
-import com.opensymphony.xwork2.ognl.OgnlValueStackFactory;
-import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
-import com.opensymphony.xwork2.util.CompoundRoot;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import com.opensymphony.xwork2.validator.DefaultActionValidatorManager;
-import com.opensymphony.xwork2.validator.DefaultValidatorFactory;
-import com.opensymphony.xwork2.validator.DefaultValidatorFileParser;
-import ognl.PropertyAccessor;
-
-import java.util.HashMap;
-
-/**
- * Factory for creating the DefaultActionValidatorManager to be used for the validation tests.
- */
-public class DefaultActionValidatorManagerFactory
-{
-    
-    // ObjectFactory.setObjectFactory(..) was removed in struts 2.1, so we have to workaround with this
-    //  to make the validation tests work
-    public ActionValidatorManager createDefaultActionValidatorManager()
-        throws ClassNotFoundException
-    {
-        Container container = createBootstrapContainer();
-
-        ActionContext context = new ActionContext( new HashMap<String, Object>() );
-        context.setValueStack( createValueStack( container ) );
-        ActionContext.setContext( context );
-
-        OgnlReflectionProvider reflectionProvider = new OgnlReflectionProvider();
-
-        reflectionProvider.setOgnlUtil( container.getInstance( OgnlUtil.class ) );
-
-        ObjectFactory objectFactory = new ObjectFactory();
-        objectFactory.setReflectionProvider( reflectionProvider );
-
-        DefaultValidatorFileParser fileParser = new DefaultValidatorFileParser();
-        fileParser.setObjectFactory( objectFactory );
-
-        DefaultValidatorFactory validatorFactory = new DefaultValidatorFactory( objectFactory, fileParser );
-
-        DefaultActionValidatorManager defaultValidatorManager = new DefaultActionValidatorManager();
-        defaultValidatorManager.setValidatorFactory( validatorFactory );
-        defaultValidatorManager.setValidatorFileParser( fileParser );
-
-        return defaultValidatorManager;
-    }
-
-    private ValueStack createValueStack( Container container )
-        throws ClassNotFoundException
-    {
-        OgnlValueStackFactory stackFactory = new OgnlValueStackFactory();
-
-        stackFactory.setXWorkConverter( container.getInstance( XWorkConverter.class ) );
-        stackFactory.setContainer( container );
-        stackFactory.setTextProvider( container.getInstance( TextProvider.class ) );
-
-        ValueStack stack = stackFactory.createValueStack();
-
-        return stack;
-    }
-
-    private Container createBootstrapContainer()
-    {
-        ContainerBuilder builder = new ContainerBuilder();
-        builder.factory( ObjectFactory.class, Scope.SINGLETON );
-        builder.factory( ReflectionProvider.class, OgnlReflectionProvider.class, Scope.SINGLETON );
-        builder.factory( ValueStackFactory.class, OgnlValueStackFactory.class, Scope.SINGLETON );
-        builder.factory( XWorkConverter.class, Scope.SINGLETON );
-        builder.factory( XWorkBasicConverter.class, Scope.SINGLETON );
-        builder.factory( TextProvider.class, "system", DefaultTextProvider.class, Scope.SINGLETON );
-        builder.factory( ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class, Scope.SINGLETON );
-        builder.factory( PropertyAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class, Scope.SINGLETON );
-        builder.factory( OgnlUtil.class, Scope.SINGLETON );
-        builder.constant( "devMode", "false" );
-
-        return builder.create( true );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
deleted file mode 100644 (file)
index c24217b..0000000
+++ /dev/null
@@ -1,474 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.audit.AuditEvent;
-import org.apache.archiva.audit.AuditListener;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
-import org.apache.archiva.security.ArchivaRoleConstants;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.maven.archiva.web.action.AbstractActionTestCase;
-import org.apache.maven.archiva.web.action.AuditEventArgumentsMatcher;
-import org.codehaus.plexus.redback.role.RoleManager;
-import org.codehaus.plexus.redback.role.RoleManagerException;
-import org.codehaus.plexus.registry.RegistryException;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * DeleteManagedRepositoryActionTest
- *
- * @version $Id$
- */
-public class DeleteManagedRepositoryActionTest
-    extends AbstractActionTestCase
-{
-    private DeleteManagedRepositoryAction action;
-
-    private RoleManager roleManager;
-
-    private MockControl roleManagerControl;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    private static final String REPO_ID = "repo-ident";
-
-    private File location;
-
-    private MockControl repositoryStatisticsManagerControl;
-
-    private RepositoryStatisticsManager repositoryStatisticsManager;
-
-    private MetadataRepository metadataRepository;
-
-    private RepositorySession respositorySession;
-
-    private MockControl metadataRepositoryControl;
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        // TODO use getAction .??
-        action = new DeleteManagedRepositoryAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        roleManagerControl = MockControl.createControl( RoleManager.class );
-        roleManager = (RoleManager) roleManagerControl.getMock();
-        //action.setRoleManager( roleManager );
-        location = new File( "target/test/location" );
-
-        repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
-        repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
-
-        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
-        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
-        metadataRepository.removeRepository( REPO_ID );
-
-        respositorySession = mock( RepositorySession.class );
-        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
-
-        TestRepositorySessionFactory factory = new TestRepositorySessionFactory();
-        factory.setRepositorySession( respositorySession );
-        action.setRepositorySessionFactory( factory );
-
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
-            repositoryStatisticsManager );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositorySessionFactory( factory );
-        action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
-
-        metadataRepositoryControl.replay();
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException, RepositoryAdminException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testDeleteRepositoryAndReposUnderRepoGroup()
-        throws Exception
-    {
-        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
-        repositoryStatisticsManagerControl.replay();
-
-        Configuration configuration = prepDeletionTest( createRepository(), 6 );
-        List<String> repoIds = new ArrayList<String>();
-        repoIds.add( REPO_ID );
-        configuration.addRepositoryGroup( createRepoGroup( repoIds, "repo.group" ) );
-
-        prepareRoleManagerMock();
-
-        assertEquals( 1, configuration.getRepositoryGroups().size() );
-
-        MockControl control = mockAuditListeners();
-        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
-        String status = action.deleteContents();
-        assertEquals( Action.SUCCESS, status );
-
-        assertTrue( configuration.getManagedRepositories().isEmpty() );
-        assertEquals( 0, configuration.getRepositoryGroups().get( 0 ).getRepositories().size() );
-
-        assertFalse( location.exists() );
-
-        repositoryStatisticsManagerControl.verify();
-        control.verify();
-        metadataRepositoryControl.verify();
-    }
-
-    public void testDeleteRepositoryConfirmation()
-        throws Exception
-    {
-        ManagedRepository originalRepository = createRepository();
-        Configuration configuration = createConfigurationForEditing( originalRepository );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        Configuration stageRepoConfiguration = new Configuration();
-        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
-        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
-
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        ManagedRepository repository = action.getRepository();
-        assertNotNull( repository );
-        assertRepositoryEquals( repository, createRepository() );
-
-        String status = action.execute();
-        assertEquals( Action.SUCCESS, status );
-
-        repository = action.getRepository();
-        assertRepositoryEquals( repository, createRepository() );
-        assertEquals( Collections.singletonList( originalRepository ),
-                      action.getManagedRepositoryAdmin().getManagedRepositories() );
-    }
-
-    public void testDeleteRepositoryKeepContent()
-        throws Exception
-    {
-        // even when we keep the content, we don't keep the metadata at this point
-        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
-        repositoryStatisticsManagerControl.replay();
-
-        prepareRoleManagerMock();
-
-        Configuration configuration = prepDeletionTest( createRepository(), 4 );
-
-        MockControl control = mockAuditListeners();
-
-        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
-
-        String status = action.deleteEntry();
-
-        assertEquals( Action.SUCCESS, status );
-
-        assertTrue( configuration.getManagedRepositories().isEmpty() );
-
-        assertTrue( location.exists() );
-
-        repositoryStatisticsManagerControl.verify();
-        control.verify();
-        metadataRepositoryControl.verify();
-    }
-
-    private MockControl mockAuditListeners()
-    {
-        MockControl control = MockControl.createControl( AuditListener.class );
-        AuditListener listener = (AuditListener) control.getMock();
-        listener.auditEvent( new AuditEvent( REPO_ID, "guest", null, AuditEvent.DELETE_MANAGED_REPO ) );
-        control.setMatcher( new AuditEventArgumentsMatcher() );
-        control.replay();
-        action.setAuditListeners( Arrays.asList( listener ) );
-
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setAuditListeners( Arrays.asList( listener ) );
-        return control;
-    }
-
-    public void testDeleteRepositoryDeleteContent()
-        throws Exception
-    {
-        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
-        repositoryStatisticsManagerControl.replay();
-
-        prepareRoleManagerMock();
-
-        Configuration configuration = prepDeletionTest( createRepository(), 4 );
-
-        MockControl control = mockAuditListeners();
-
-        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
-
-        String status = action.deleteContents();
-
-        assertEquals( Action.SUCCESS, status );
-
-        assertTrue( configuration.getManagedRepositories().isEmpty() );
-
-        assertFalse( location.exists() );
-
-        repositoryStatisticsManagerControl.verify();
-        control.verify();
-        metadataRepositoryControl.verify();
-    }
-
-    public void testDeleteRepositoryAndAssociatedProxyConnectors()
-        throws Exception
-    {
-        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
-        repositoryStatisticsManagerControl.replay();
-
-        Configuration configuration = prepDeletionTest( createRepository(), 5 );
-        configuration.addRemoteRepository( createRemoteRepository( "codehaus", "http://repository.codehaus.org" ) );
-        configuration.addRemoteRepository( createRemoteRepository( "java.net", "http://dev.java.net/maven2" ) );
-        configuration.addProxyConnector( createProxyConnector( REPO_ID, "codehaus" ) );
-
-        prepareRoleManagerMock();
-
-        assertEquals( 1, configuration.getProxyConnectors().size() );
-
-        MockControl control = mockAuditListeners();
-        when( respositorySession.getRepository() ).thenReturn( metadataRepository );
-        String status = action.deleteContents();
-
-        assertEquals( Action.SUCCESS, status );
-
-        assertTrue( configuration.getManagedRepositories().isEmpty() );
-        assertEquals( 0, configuration.getProxyConnectors().size() );
-
-        assertFalse( location.exists() );
-
-        repositoryStatisticsManagerControl.verify();
-        control.verify();
-        metadataRepositoryControl.verify();
-    }
-
-    public void testDeleteRepositoryCancelled()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-
-        ManagedRepository originalRepository = createRepository();
-        Configuration configuration = prepDeletionTest( originalRepository, 3 );
-
-        String status = action.execute();
-        assertEquals( Action.SUCCESS, status );
-
-        ManagedRepository repository = action.getRepository();
-        assertRepositoryEquals( repository, createRepository() );
-        assertEquals( Collections.singletonList( originalRepository ),
-                      action.getManagedRepositoryAdmin().getManagedRepositories() );
-
-        assertTrue( location.exists() );
-
-        repositoryStatisticsManagerControl.verify();
-    }
-
-
-    private Configuration prepDeletionTest( ManagedRepository originalRepository, int expectCountGetConfig )
-        throws RegistryException, IndeterminateConfigurationException, RepositoryAdminException
-    {
-
-        //Configuration originalConfiguration =
-        //    ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).getArchivaConfiguration().getConfiguration();
-
-        location.mkdirs();
-
-        Configuration configuration = createConfigurationForEditing( originalRepository );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, expectCountGetConfig );
-
-        Configuration stageRepoConfiguration = new Configuration();
-        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
-        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
-
-        archivaConfiguration.save( configuration );
-
-        // save for staging repo delete
-        archivaConfiguration.save( configuration );
-
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        ManagedRepository repository = action.getRepository();
-        assertNotNull( repository );
-        assertRepositoryEquals( repository, createRepository() );
-
-        assertTrue( location.exists() );
-        return configuration;
-    }
-
-    private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
-    {
-        assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
-        assertEquals( expectedRepository.getId(), actualRepository.getId() );
-        assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
-        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
-        assertEquals( expectedRepository.getLocation(), actualRepository.getLocation() );
-        assertEquals( expectedRepository.getName(), actualRepository.getName() );
-        assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
-        assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
-        assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
-        assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
-        assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
-        assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
-    }
-
-    private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
-    {
-        Configuration configuration = new Configuration();
-        ManagedRepositoryConfiguration managedRepositoryConfiguration =
-            new BeanReplicator().replicateBean( repositoryConfiguration, ManagedRepositoryConfiguration.class );
-        managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
-        configuration.addManagedRepository( managedRepositoryConfiguration );
-        return configuration;
-    }
-
-    private ManagedRepository createRepository()
-    {
-        ManagedRepository r = new ManagedRepository();
-        r.setId( REPO_ID );
-        r.setName( "repo name" );
-        r.setLocation( location.getAbsolutePath() );
-        r.setLayout( "default" );
-        r.setCronExpression( "* 0/5 * * * ?" );
-        r.setDaysOlder( 0 );
-        r.setRetentionCount( 0 );
-        r.setReleases( true );
-        r.setSnapshots( true );
-        r.setScanned( false );
-        r.setDeleteReleasedSnapshots( false );
-        return r;
-    }
-
-    private ManagedRepositoryConfiguration createStagingRepository()
-    {
-        ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
-        r.setId( REPO_ID + "-stage" );
-        r.setName( "repo name" );
-        r.setLocation( location.getAbsolutePath() );
-        r.setLayout( "default" );
-        r.setRefreshCronExpression( "* 0/5 * * * ?" );
-        r.setDaysOlder( 0 );
-        r.setRetentionCount( 0 );
-        r.setReleases( true );
-        r.setSnapshots( true );
-        r.setScanned( false );
-        r.setDeleteReleasedSnapshots( false );
-        return r;
-    }
-
-    private RemoteRepositoryConfiguration createRemoteRepository( String id, String url )
-    {
-        RemoteRepositoryConfiguration r = new RemoteRepositoryConfiguration();
-        r.setId( id );
-        r.setUrl( url );
-        r.setLayout( "default" );
-
-        return r;
-    }
-
-    private ProxyConnectorConfiguration createProxyConnector( String managedRepoId, String remoteRepoId )
-    {
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( managedRepoId );
-        connector.setTargetRepoId( remoteRepoId );
-
-        return connector;
-    }
-
-    private RepositoryGroupConfiguration createRepoGroup( List<String> repoIds, String repoGroupId )
-    {
-        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
-        repoGroup.setId( repoGroupId );
-        repoGroup.setRepositories( repoIds );
-
-        return repoGroup;
-    }
-
-    private void prepareRoleManagerMock()
-        throws RoleManagerException
-    {
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManagerControl.setReturnValue( true );
-        roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.setReturnValue( true );
-        roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.replay();
-    }
-
-    protected ManagedRepositoryAdmin getManagedRepositoryAdmin()
-    {
-        return applicationContext.getBean( ManagedRepositoryAdmin.class );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java
deleted file mode 100644 (file)
index 9871fb7..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.IndeterminateConfigurationException;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.web.action.AbstractActionTestCase;
-import org.codehaus.plexus.registry.RegistryException;
-import org.easymock.MockControl;
-
-import java.util.Collections;
-
-/**
- * DeleteRemoteRepositoryActionTest
- *
- * @version $Id$
- */
-public class DeleteRemoteRepositoryActionTest
-    extends AbstractActionTestCase
-{
-    private static final String REPO_ID = "remote-repo-ident";
-
-    private DeleteRemoteRepositoryAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        //action = (DeleteRemoteRepositoryAction) lookup( Action.class.getName(), "deleteRemoteRepositoryAction" );
-        action = (DeleteRemoteRepositoryAction) getActionProxy( "/admin/deleteRemoteRepository.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testDeleteRemoteRepositoryConfirmation()
-        throws Exception
-    {
-        RemoteRepository originalRepository = createRepository();
-        Configuration configuration = createConfigurationForEditing( originalRepository );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        RemoteRepository repository = action.getRepository();
-        assertNotNull( repository );
-        assertRepositoryEquals( repository, createRepository() );
-
-        String status = action.confirmDelete();
-        assertEquals( Action.INPUT, status );
-        repository = action.getRepository();
-        assertRepositoryEquals( repository, createRepository() );
-        assertEquals( Collections.singletonList( originalRepository ),
-                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
-    }
-
-    public void testDeleteRemoteRepository()
-        throws RegistryException, IndeterminateConfigurationException, RepositoryAdminException
-    {
-        Configuration configuration = createConfigurationForEditing( createRepository() );
-        configuration.addManagedRepository( createManagedRepository( "internal", "target/repo/internal" ) );
-        configuration.addManagedRepository( createManagedRepository( "snapshots", "target/repo/snapshots" ) );
-        configuration.addProxyConnector( createProxyConnector( "internal", REPO_ID ) );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 4 );
-
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        RemoteRepository repository = action.getRepository();
-        assertNotNull( repository );
-        assertRepositoryEquals( repository, createRepository() );
-
-        assertEquals( 1, configuration.getProxyConnectors().size() );
-
-        String status = action.delete();
-        assertEquals( Action.SUCCESS, status );
-
-        assertTrue( configuration.getRemoteRepositories().isEmpty() );
-        assertEquals( 0, configuration.getProxyConnectors().size() );
-    }
-
-    public void testDeleteRemoteRepositoryCancelled()
-        throws Exception
-    {
-        RemoteRepository originalRepository = createRepository();
-        Configuration configuration = createConfigurationForEditing( originalRepository );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 2 );
-
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        RemoteRepository repositoryConfiguration = action.getRepository();
-        assertNotNull( repositoryConfiguration );
-        assertRepositoryEquals( repositoryConfiguration, createRepository() );
-
-        String status = action.execute();
-        assertEquals( Action.SUCCESS, status );
-
-        RemoteRepository repository = action.getRepository();
-        assertRepositoryEquals( repository, createRepository() );
-        assertEquals( Collections.singletonList( originalRepository ),
-                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
-    }
-
-    private Configuration createConfigurationForEditing( RemoteRepository repositoryConfiguration )
-    {
-        Configuration configuration = new Configuration();
-        RemoteRepositoryConfiguration conf = new RemoteRepositoryConfiguration();
-        conf.setId( repositoryConfiguration.getId() );
-        conf.setLayout( repositoryConfiguration.getLayout() );
-        conf.setUrl( repositoryConfiguration.getUrl() );
-        conf.setName( repositoryConfiguration.getName() );
-        configuration.addRemoteRepository( conf );
-        return configuration;
-    }
-
-    private RemoteRepository createRepository()
-    {
-        RemoteRepository r = new RemoteRepository();
-        r.setId( REPO_ID );
-        populateRepository( r );
-        return r;
-    }
-
-    private void assertRepositoryEquals( RemoteRepository expectedRepository, RemoteRepository actualRepository )
-    {
-        assertEquals( expectedRepository.getId(), actualRepository.getId() );
-        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
-        assertEquals( expectedRepository.getUrl(), actualRepository.getUrl() );
-        assertEquals( expectedRepository.getName(), actualRepository.getName() );
-    }
-
-    private ManagedRepositoryConfiguration createManagedRepository( String string, String testPath )
-    {
-        ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
-        r.setId( REPO_ID );
-        r.setName( "repo name" );
-        r.setLocation( testPath );
-        r.setLayout( "default" );
-        r.setRefreshCronExpression( "* 0/5 * * * ?" );
-        r.setDaysOlder( 0 );
-        r.setRetentionCount( 0 );
-        r.setReleases( true );
-        r.setSnapshots( true );
-        r.setScanned( false );
-        r.setDeleteReleasedSnapshots( false );
-        return r;
-    }
-
-    private ProxyConnectorConfiguration createProxyConnector( String managedRepoId, String remoteRepoId )
-    {
-        ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
-        connector.setSourceRepoId( managedRepoId );
-        connector.setTargetRepoId( remoteRepoId );
-
-        return connector;
-    }
-
-    private void populateRepository( RemoteRepository repository )
-    {
-        repository.setId( REPO_ID );
-        repository.setName( "repo name" );
-        repository.setUrl( "url" );
-        repository.setLayout( "default" );
-    }
-
-    // TODO: what about removing proxied content if a proxy is removed?
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java
deleted file mode 100644 (file)
index 96edb5d..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RepositoryGroup;
-import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.maven.archiva.web.action.AbstractActionTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-
-import java.util.Collections;
-
-/**
- * DeleteRepositoryGroupActionTest
- */
-public class DeleteRepositoryGroupActionTest
-    extends AbstractActionTestCase
-{
-    private static final String REPO_GROUP_ID = "repo-group-ident";
-
-    private DeleteRepositoryGroupAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (DeleteRepositoryGroupAction) getActionProxy( "/admin/deleteRepositoryGroup.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException, RepositoryAdminException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testDeleteRepositoryGroupConfirmation()
-        throws Exception
-    {
-        RepositoryGroupConfiguration origRepoGroup = createRepositoryGroup();
-        Configuration configuration = createConfigurationForEditing( origRepoGroup );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.replay();
-
-        action.setRepoGroupId( REPO_GROUP_ID );
-
-        action.prepare();
-        assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
-        RepositoryGroup repoGroup = action.getRepositoryGroup();
-        assertNotNull( repoGroup );
-        assertEquals( repoGroup.getId(), action.getRepoGroupId() );
-        assertEquals( Collections.singletonList( origRepoGroup ), configuration.getRepositoryGroups() );
-    }
-
-    public void testDeleteRepositoryGroup()
-        throws Exception
-    {
-        Configuration configuration = createConfigurationForEditing( createRepositoryGroup() );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 5 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.setRepoGroupId( REPO_GROUP_ID );
-
-        action.prepare();
-        assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
-        RepositoryGroup repoGroup = action.getRepositoryGroup();
-        assertNotNull( repoGroup );
-        assertEquals( Collections.singletonList( repoGroup ),
-                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
-
-        String status = action.delete();
-        assertEquals( Action.SUCCESS, status );
-        assertTrue( configuration.getRepositoryGroups().isEmpty() );
-    }
-
-    public void testDeleteRepositoryGroupCancelled()
-        throws Exception
-    {
-        RepositoryGroupConfiguration origRepoGroup = createRepositoryGroup();
-        Configuration configuration = createConfigurationForEditing( origRepoGroup );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 2 );
-
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.setRepoGroupId( REPO_GROUP_ID );
-
-        action.prepare();
-        assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
-        RepositoryGroup repoGroup = action.getRepositoryGroup();
-        assertNotNull( repoGroup );
-
-        String status = action.execute();
-        assertEquals( Action.SUCCESS, status );
-        assertEquals( Collections.singletonList( repoGroup ),
-                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
-    }
-
-    private Configuration createConfigurationForEditing( RepositoryGroupConfiguration repoGroup )
-    {
-        Configuration configuration = new Configuration();
-        configuration.addRepositoryGroup( repoGroup );
-        return configuration;
-    }
-
-    private RepositoryGroupConfiguration createRepositoryGroup()
-    {
-        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
-        repoGroup.setId( REPO_GROUP_ID );
-
-        return repoGroup;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java
deleted file mode 100644 (file)
index 80de09f..0000000
+++ /dev/null
@@ -1,627 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.repository.RepositoryCommonValidator;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.audit.AuditListener;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
-import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
-import org.apache.archiva.scheduler.repository.RepositoryTask;
-import org.apache.archiva.security.ArchivaRoleConstants;
-import org.apache.archiva.web.validator.utils.ValidatorUtil;
-import org.apache.commons.io.FileUtils;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.codehaus.plexus.redback.role.RoleManager;
-import org.codehaus.plexus.registry.Registry;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * EditManagedRepositoryActionTest
- *
- * @version $Id$
- */
-public class EditManagedRepositoryActionTest
-    extends AbstractManagedRepositoryActionTest
-{
-    private EditManagedRepositoryAction action;
-
-    private RoleManager roleManager;
-
-    private MockControl roleManagerControl;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    private Registry registry;
-
-    private MockControl registryControl;
-
-    private MetadataRepository metadataRepository;
-
-    private MockControl repositoryTaskSchedulerControl;
-
-    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = new EditManagedRepositoryAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        roleManagerControl = MockControl.createControl( RoleManager.class );
-        roleManager = (RoleManager) roleManagerControl.getMock();
-
-        registryControl = MockControl.createControl( Registry.class );
-        registry = (Registry) registryControl.getMock();
-
-        repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
-        repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
-
-        location = new File( "target/test/location" );
-
-        metadataRepository = mock( MetadataRepository.class );
-        RepositorySession repositorySession = mock( RepositorySession.class );
-        when( repositorySession.getRepository() ).thenReturn( metadataRepository );
-        TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
-        factory.setRepositorySession( repositorySession );
-
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryTaskScheduler(
-            repositoryTaskScheduler );
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositorySessionFactory( factory );
-
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRegistry( registry );
-
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setAuditListeners(
-            new ArrayList<AuditListener>( 0 ) );
-
-        RepositoryCommonValidator repositoryCommonValidator = new RepositoryCommonValidator();
-        repositoryCommonValidator.setArchivaConfiguration( archivaConfiguration );
-        repositoryCommonValidator.setRegistry( registry );
-
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryCommonValidator(
-            repositoryCommonValidator );
-
-        action.setRepositoryCommonValidator( repositoryCommonValidator );
-
-        action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
-
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException, RepositoryAdminException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testEditRepositoryInitialPage()
-        throws Exception
-    {
-        Configuration configuration = createConfigurationForEditing( createRepository() );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-        Configuration stageRepoConfiguration = new Configuration();
-        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
-        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
-
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        ManagedRepository repository = action.getRepository();
-        assertNotNull( repository );
-
-        ManagedRepository newRepository = createRepository();
-        assertRepositoryEquals( repository, newRepository );
-        assertEquals( repository.getLocation(), newRepository.getLocation() );
-
-        String status = action.input();
-        assertEquals( Action.INPUT, status );
-        repository = action.getRepository();
-        assertRepositoryEquals( repository, createRepository() );
-    }
-
-    public void testEditRepository()
-        throws Exception
-    {
-        String stageRepoId = REPO_ID + "-stage";
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManagerControl.setVoidCallable();
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.setVoidCallable();
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
-        roleManagerControl.setVoidCallable();
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
-        roleManagerControl.setVoidCallable();
-
-        roleManagerControl.replay();
-
-        registry.getString( "appserver.base", "${appserver.base}" );
-        registryControl.setReturnValue( "target/test" );
-        registry.getString( "appserver.home", "${appserver.home}" );
-        registryControl.setReturnValue( "target/test" );
-
-        registry.getString( "appserver.base", "${appserver.base}" );
-        registryControl.setReturnValue( "target/test" );
-        registry.getString( "appserver.home", "${appserver.home}" );
-        registryControl.setReturnValue( "target/test" );
-
-        registryControl.replay();
-
-        RepositoryTask task = new RepositoryTask();
-        task.setRepositoryId( REPO_ID );
-        repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
-        repositoryTaskSchedulerControl.setReturnValue( false );
-        repositoryTaskScheduler.queueTask( task );
-        repositoryTaskSchedulerControl.setVoidCallable();
-
-        RepositoryTask stageTask = new RepositoryTask();
-        stageTask.setRepositoryId( stageRepoId );
-        repositoryTaskScheduler.isProcessingRepositoryTask( stageRepoId );
-        repositoryTaskSchedulerControl.setReturnValue( false );
-        repositoryTaskScheduler.queueTask( stageTask );
-        repositoryTaskSchedulerControl.setVoidCallable();
-
-        repositoryTaskSchedulerControl.replay();
-
-        Configuration configuration = createConfigurationForEditing( createRepository() );
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        Configuration stageRepoConfiguration = new Configuration();
-        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
-        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfiguration.save( configuration );
-        archivaConfiguration.save( configuration );
-
-        archivaConfiguration.save( configuration );
-
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        ManagedRepository repository = action.getRepository();
-        populateRepository( repository );
-        repository.setName( "new repo name" );
-
-        MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
-        RepositoryStatisticsManager repositoryStatisticsManager =
-            (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
-            repositoryStatisticsManager );
-        // no deletion
-        repositoryStatisticsManagerControl.replay();
-
-        new File( "target/test/" + REPO_ID + "-stage" ).mkdirs();
-
-        action.setRepository( repository );
-        action.setStageNeeded( true );
-        String status = action.commit();
-        assertEquals( Action.SUCCESS, status );
-
-        ManagedRepository newRepository = createRepository();
-        newRepository.setName( "new repo name" );
-        assertRepositoryEquals( repository, newRepository );
-        //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
-        //assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
-
-        roleManagerControl.verify();
-        //archivaConfigurationControl.verify();
-        repositoryStatisticsManagerControl.verify();
-        registryControl.verify();
-    }
-
-    public void testEditRepositoryLocationChanged()
-        throws Exception
-    {
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
-        roleManagerControl.setVoidCallable();
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
-        roleManagerControl.setVoidCallable();
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
-        roleManagerControl.setVoidCallable();
-
-        roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
-        roleManagerControl.setReturnValue( false );
-        roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
-        roleManagerControl.setVoidCallable();
-
-        roleManagerControl.replay();
-
-        registry.getString( "appserver.base", "${appserver.base}" );
-        registryControl.setReturnValue( "target/test" );
-        registry.getString( "appserver.home", "${appserver.home}" );
-        registryControl.setReturnValue( "target/test" );
-
-        registry.getString( "appserver.base", "${appserver.base}" );
-        registryControl.setReturnValue( "target/test" );
-        registry.getString( "appserver.home", "${appserver.home}" );
-        registryControl.setReturnValue( "target/test" );
-
-        registryControl.replay();
-
-        RepositoryTask task = new RepositoryTask();
-        task.setRepositoryId( REPO_ID );
-        repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
-        repositoryTaskSchedulerControl.setReturnValue( false );
-        repositoryTaskScheduler.queueTask( task );
-        repositoryTaskSchedulerControl.setVoidCallable();
-
-        repositoryTaskSchedulerControl.replay();
-
-        Configuration configuration = createConfigurationForEditing( createRepository() );
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfigurationControl.setReturnValue( buildEasyConfiguration() );
-
-        Configuration stageRepoConfiguration = buildEasyConfiguration();
-        stageRepoConfiguration.addManagedRepository( createStagingRepository() );
-        archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
-
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-
-        archivaConfiguration.save( configuration );
-        configuration.addManagedRepository( stageRepoConfiguration.getManagedRepositories().get( 0 ) );
-        archivaConfiguration.save( configuration );
-        archivaConfiguration.save( configuration );
-
-        archivaConfigurationControl.replay();
-
-        MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
-        RepositoryStatisticsManager repositoryStatisticsManager =
-            (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
-        ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
-            repositoryStatisticsManager );
-        repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
-        repositoryStatisticsManagerControl.replay();
-
-        new File( "target/test/location/" + REPO_ID + "-stage" ).mkdirs();
-
-        action.setStageNeeded( true );
-        action.setRepoid( REPO_ID );
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-
-        ManagedRepository repository = new ManagedRepository();
-        populateRepository( repository );
-        File testFile = new File( "target/test/location/new" );
-        FileUtils.deleteDirectory( testFile );
-        repository.setLocation( "${appserver.base}/location/new" );
-        action.setRepository( repository );
-        String status = action.commit();
-        assertEquals( Action.SUCCESS, status );
-        //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
-        //assertEquals( testFile.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
-
-        roleManagerControl.verify();
-        //archivaConfigurationControl.verify();
-        repositoryStatisticsManagerControl.verify();
-        registryControl.verify();
-    }
-
-    public void testStruts2ValidationFrameworkWithNullInputs()
-        throws Exception
-    {
-        // prep
-        // 0 is the default value for primitive int; null for objects
-        ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null, 1, 1 );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository identifier." );
-        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a directory." );
-        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository name." );
-        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithBlankInputs()
-        throws Exception
-    {
-        // prep
-        // 0 is the default value for primitive int
-        ManagedRepository managedRepositoryConfiguration =
-            createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, 1, 1 );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository identifier." );
-        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a directory." );
-        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "You must enter a repository name." );
-        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithInvalidInputs()
-        throws Exception
-    {
-        // prep
-        ManagedRepository managedRepositoryConfiguration =
-            createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
-                                     REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
-                                     REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertTrue( action.hasFieldErrors() );
-
-        Map<String, List<String>> fieldErrors = action.getFieldErrors();
-
-        // make an expected field error object
-        Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
-
-        // populate
-        List<String> expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "repository.id", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
-        expectedFieldErrors.put( "repository.location", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'),  underscores(_), dots(.), and dashes(-)." );
-        expectedFieldErrors.put( "repository.name", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add(
-            "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
-        expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
-        expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
-
-        expectedErrorMessages = new ArrayList<String>();
-        expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
-        expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
-
-        ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
-    }
-
-    public void testStruts2ValidationFrameworkWithValidInputs()
-        throws Exception
-    {
-        // prep
-        ManagedRepository managedRepositoryConfiguration =
-            createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
-                                     REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
-                                     REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
-        action.setRepository( managedRepositoryConfiguration );
-
-        // test
-        actionValidatorManager.validate( action, EMPTY_STRING );
-
-        // verify
-        assertFalse( action.hasFieldErrors() );
-    }
-
-    private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
-    {
-        assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
-        assertEquals( expectedRepository.getId(), actualRepository.getId() );
-        assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
-        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
-        assertEquals( expectedRepository.getName(), actualRepository.getName() );
-        assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
-        assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
-        assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
-        assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
-        assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
-        assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
-    }
-
-    private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
-        throws Exception
-    {
-        Configuration configuration = buildEasyConfiguration();
-
-        ManagedRepositoryConfiguration managedRepositoryConfiguration = new ManagedRepositoryConfiguration();
-
-        managedRepositoryConfiguration.setDaysOlder( repositoryConfiguration.getDaysOlder() );
-        managedRepositoryConfiguration.setIndexDir( repositoryConfiguration.getIndexDirectory() );
-        managedRepositoryConfiguration.setRetentionCount( repositoryConfiguration.getRetentionCount() );
-        managedRepositoryConfiguration.setBlockRedeployments( repositoryConfiguration.isBlockRedeployments() );
-        managedRepositoryConfiguration.setDeleteReleasedSnapshots(
-            repositoryConfiguration.isDeleteReleasedSnapshots() );
-        managedRepositoryConfiguration.setLocation( repositoryConfiguration.getLocation() );
-        managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
-        managedRepositoryConfiguration.setReleases( repositoryConfiguration.isReleases() );
-        managedRepositoryConfiguration.setScanned( repositoryConfiguration.isScanned() );
-        managedRepositoryConfiguration.setId( repositoryConfiguration.getId() );
-        managedRepositoryConfiguration.setName( repositoryConfiguration.getName() );
-        managedRepositoryConfiguration.setLayout( repositoryConfiguration.getLayout() );
-
-        configuration.addManagedRepository( managedRepositoryConfiguration );
-        return configuration;
-    }
-
-    // easy configuration for hashCode/equals
-    private Configuration buildEasyConfiguration()
-    {
-        return new Configuration()
-        {
-            @Override
-            public int hashCode()
-            {
-                return getManagedRepositories().size();
-            }
-
-            @Override
-            public boolean equals( Object o )
-            {
-                return true;
-            }
-        };
-    }
-
-    private ManagedRepository createRepository()
-        throws IOException
-    {
-        ManagedRepository r = new ManagedRepository();
-        r.setId( REPO_ID );
-        populateRepository( r );
-        return r;
-    }
-
-    private ManagedRepositoryConfiguration createStagingRepository()
-        throws IOException
-    {
-        ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
-        r.setId( REPO_ID + "-stage" );
-        populateStagingRepository( r );
-        return r;
-    }
-
-    private void populateStagingRepository( ManagedRepositoryConfiguration repository )
-        throws IOException
-    {
-        repository.setId( REPO_ID + "-stage" );
-        repository.setName( "repo name" );
-        repository.setLocation( "${appserver.base}/location" );
-        repository.setLayout( "default" );
-        repository.setRefreshCronExpression( "* 0/5 * * * ?" );
-        repository.setDaysOlder( 31 );
-        repository.setRetentionCount( 20 );
-        repository.setReleases( true );
-        repository.setSnapshots( true );
-        repository.setScanned( false );
-        repository.setDeleteReleasedSnapshots( true );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java
deleted file mode 100644 (file)
index 7f60535..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.struts2.StrutsSpringTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-
-import java.util.Collections;
-
-/**
- * EditRemoteRepositoryActionTest
- *
- * @version $Id$
- */
-public class EditRemoteRepositoryActionTest
-    extends StrutsSpringTestCase
-{
-    private static final String REPO_ID = "remote-repo-ident";
-
-    private EditRemoteRepositoryAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    @Override
-    protected String[] getContextLocations()
-    {
-        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
-    }
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (EditRemoteRepositoryAction) getActionProxy( "/admin/editRemoteRepository.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testEditRemoteRepository()
-        throws Exception
-    {
-        Configuration configuration = createConfigurationForEditing( createRepository() );
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-        action.prepare();
-
-        assertEquals( REPO_ID, action.getRepoid() );
-        RemoteRepository repository = action.getRepository();
-        populateRepository( repository );
-        repository.setName( "new repo name" );
-
-        String status = action.commit();
-        assertEquals( Action.SUCCESS, status );
-
-        RemoteRepository newRepository = createRepository();
-        newRepository.setName( "new repo name" );
-        assertRepositoryEquals( repository, newRepository );
-        assertEquals( Collections.singletonList( repository ),
-                      action.getRemoteRepositoryAdmin().getRemoteRepositories() );
-
-        archivaConfigurationControl.verify();
-    }
-
-    public void testEditRemoteRepositoryInitialPage()
-        throws Exception
-    {
-        Configuration configuration = createConfigurationForEditing( createRepository() );
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration );
-        archivaConfigurationControl.replay();
-
-        action.setRepoid( REPO_ID );
-
-        action.prepare();
-        assertEquals( REPO_ID, action.getRepoid() );
-        RemoteRepository repository = action.getRepository();
-        assertNotNull( repository );
-        assertRepositoryEquals( repository, createRepository() );
-
-        String status = action.input();
-        assertEquals( Action.INPUT, status );
-        repository = action.getRepository();
-        assertRepositoryEquals( repository, createRepository() );
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException, RepositoryAdminException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    private void assertRepositoryEquals( RemoteRepository expectedRepository, RemoteRepository actualRepository )
-    {
-        assertEquals( expectedRepository.getId(), actualRepository.getId() );
-        assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
-        assertEquals( expectedRepository.getUrl(), actualRepository.getUrl() );
-        assertEquals( expectedRepository.getName(), actualRepository.getName() );
-    }
-
-    private Configuration createConfigurationForEditing( RemoteRepository repositoryConfiguration )
-    {
-        Configuration configuration = new Configuration();
-        RemoteRepositoryConfiguration conf = new RemoteRepositoryConfiguration();
-        conf.setId( repositoryConfiguration.getId() );
-        conf.setLayout( repositoryConfiguration.getLayout() );
-        conf.setUrl( repositoryConfiguration.getUrl() );
-        conf.setName( repositoryConfiguration.getName() );
-        configuration.addRemoteRepository( conf );
-        return configuration;
-    }
-
-    private RemoteRepository createRepository()
-    {
-        RemoteRepository r = new RemoteRepository();
-        r.setId( REPO_ID );
-        populateRepository( r );
-        return r;
-    }
-
-    private void populateRepository( RemoteRepository repository )
-    {
-        repository.setId( REPO_ID );
-        repository.setName( "repo name" );
-        repository.setUrl( "url" );
-        repository.setLayout( "default" );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesActionTest.java
deleted file mode 100644 (file)
index e20a97c..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.servletunit.ServletRunner;
-import com.meterware.servletunit.ServletUnitClient;
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.struts2.StrutsSpringTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * Test the repositories action returns the correct data.
- */
-public class RepositoriesActionTest
-    extends StrutsSpringTestCase
-{
-    private Logger log = LoggerFactory.getLogger( getClass() );
-
-    private RepositoriesAction action;
-
-    ArchivaConfiguration originalArchivaConfiguration;
-
-    protected void setUp()
-        throws Exception
-    {
-
-        super.setUp();
-
-        action = (RepositoriesAction) getActionProxy( "/admin/index.action" ).getAction();
-        originalArchivaConfiguration =
-            ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).getArchivaConfiguration();
-        // some other test are modifying archivaConfiguration with a mocked instance : this test need the real one
-        // so use the real one from spring, backup the mock and restore it at the end (tearDown)
-        ArchivaConfiguration real = applicationContext.getBean( ArchivaConfiguration.class );
-        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration( real );
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration( real );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration( real );
-    }
-
-
-    @Override
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
-            originalArchivaConfiguration );
-        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            originalArchivaConfiguration );
-        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
-            originalArchivaConfiguration );
-    }
-
-    @Override
-    protected String[] getContextLocations()
-    {
-        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
-    }
-
-    public void testGetRepositories()
-        throws Exception
-    {
-        try
-        {
-            MockControl control = MockControl.createControl( MetadataRepository.class );
-            MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
-            control.expectAndReturn( metadataRepository.getMetadataFacets( "internal", RepositoryStatistics.FACET_ID ),
-                                     Arrays.asList( "20091125.123456.678" ) );
-            control.expectAndReturn(
-                metadataRepository.getMetadataFacet( "internal", RepositoryStatistics.FACET_ID, "20091125.123456.678" ),
-                new RepositoryStatistics() );
-            control.expectAndReturn( metadataRepository.getMetadataFacets( "snapshots", RepositoryStatistics.FACET_ID ),
-                                     Arrays.asList( "20091112.012345.012" ) );
-            control.expectAndReturn( metadataRepository.getMetadataFacet( "snapshots", RepositoryStatistics.FACET_ID,
-                                                                          "20091112.012345.012" ),
-                                     new RepositoryStatistics() );
-            control.replay();
-
-            RepositorySession session = mock( RepositorySession.class );
-            when( session.getRepository() ).thenReturn( metadataRepository );
-            TestRepositorySessionFactory factory =
-                applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
-            factory.setRepositorySession( session );
-
-            ServletRunner sr = new ServletRunner();
-            ServletUnitClient sc = sr.newClient();
-
-            action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositories.action" ).getRequest() );
-
-            action.prepare();
-            String result = action.execute();
-            assertEquals( Action.SUCCESS, result );
-
-            // TODO: for some reason servletunit is not populating the port of the servlet request
-            assertEquals( "http://localhost:0/repository", action.getBaseUrl() );
-
-            assertNotNull( action.getManagedRepositories() );
-            assertNotNull( action.getRemoteRepositories() );
-            assertNotNull( action.getRepositoryStatistics() );
-
-            assertEquals( 2, action.getManagedRepositories().size() );
-            assertEquals( 2, action.getRemoteRepositories().size() );
-            assertEquals( 2, action.getRepositoryStatistics().size() );
-
-            control.verify();
-        }
-        catch ( Exception e )
-        {
-            log.error( e.getMessage(), e );
-            throw e;
-        }
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java
deleted file mode 100644 (file)
index 7215729..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.meterware.servletunit.ServletRunner;
-import com.meterware.servletunit.ServletUnitClient;
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.RepositoryGroup;
-import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
-import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.maven.archiva.web.action.AbstractActionTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * RepositoryGroupsActionTest
- */
-public class RepositoryGroupsActionTest
-    extends AbstractActionTestCase
-{
-    private static final String REPO_GROUP_ID = "repo-group-ident";
-
-    private static final String REPO1_ID = "managed-repo-ident-1";
-
-    private static final String REPO2_ID = "managed-repo-ident-2";
-
-    private RepositoryGroupsAction action;
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        action = (RepositoryGroupsAction) getActionProxy( "/admin/repositoryGroups.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
-        ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-        ( (DefaultManagedRepositoryAdmin) ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).getManagedRepositoryAdmin() ).setArchivaConfiguration(
-            archivaConfiguration );
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException, RepositoryAdminException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testAddRepositoryGroup()
-        throws Exception
-    {
-        Configuration configuration = new Configuration();
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 6 );
-
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        RepositoryGroup repositoryGroup = action.getRepositoryGroup();
-        repositoryGroup.setId( REPO_GROUP_ID );
-
-        String status = action.addRepositoryGroup();
-        assertEquals( Action.SUCCESS, status );
-
-        assertEquals( Collections.singletonList( repositoryGroup ),
-                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
-
-        archivaConfigurationControl.verify();
-    }
-
-    public void testAddEmptyRepositoryGroup()
-        throws Exception
-    {
-        Configuration configuration = new Configuration();
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 5 );
-
-        archivaConfiguration.save( configuration );
-
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-
-        String status = action.addRepositoryGroup();
-        assertEquals( Action.ERROR, status );
-
-        assertEquals( 0, configuration.getRepositoryGroups().size() );
-    }
-
-    public void testAddDuplicateRepositoryGroup()
-        throws Exception
-    {
-        Configuration configuration = new Configuration();
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 8 );
-
-        archivaConfiguration.save( configuration );
-
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        RepositoryGroup repositoryGroup = action.getRepositoryGroup();
-        repositoryGroup.setId( REPO_GROUP_ID );
-
-        String status = action.addRepositoryGroup();
-        assertEquals( Action.SUCCESS, status );
-
-        assertEquals( Collections.singletonList( repositoryGroup ),
-                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
-
-        repositoryGroup.setId( REPO_GROUP_ID );
-        status = action.addRepositoryGroup();
-
-        assertEquals( Action.ERROR, status );
-        assertEquals( Collections.singletonList( repositoryGroup ),
-                      action.getRepositoryGroupAdmin().getRepositoriesGroups() );
-    }
-
-    public void testGetRepositoryGroups()
-        throws Exception
-    {
-        ServletRunner sr = new ServletRunner();
-        ServletUnitClient sc = sr.newClient();
-
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 6 );
-        archivaConfigurationControl.replay();
-
-        action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositoryGroups.action" ).getRequest() );
-        action.prepare();
-        String result = action.execute();
-        assertEquals( Action.SUCCESS, result );
-
-        assertEquals( "http://localhost:0/repository", action.getBaseUrl() );
-
-        assertNotNull( action.getRepositoryGroups() );
-        assertEquals( 1, action.getRepositoryGroups().size() );
-        assertEquals( 2, action.getManagedRepositories().size() );
-
-        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
-
-        assertEquals( 1, repoGroup.getRepositories().size() );
-        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
-        assertNotNull( action.getGroupToRepositoryMap() );
-        assertEquals( 1, action.getGroupToRepositoryMap().size() );
-
-        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
-        assertEquals( 1, repos.size() );
-        assertEquals( REPO2_ID, repos.get( 0 ) );
-    }
-
-    public void testAddRepositoryToGroup()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 17 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        String result = action.execute();
-        assertEquals( Action.SUCCESS, result );
-
-        assertNotNull( action.getRepositoryGroups() );
-        assertEquals( 1, action.getRepositoryGroups().size() );
-        assertEquals( 2, action.getManagedRepositories().size() );
-
-        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
-        assertEquals( 1, repoGroup.getRepositories().size() );
-        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
-
-        assertNotNull( action.getGroupToRepositoryMap() );
-        assertEquals( 1, action.getGroupToRepositoryMap().size() );
-
-        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
-        assertEquals( 1, repos.size() );
-        assertEquals( REPO2_ID, repos.get( 0 ) );
-
-        action.setRepoGroupId( REPO_GROUP_ID );
-        action.setRepoId( REPO2_ID );
-
-        result = action.addRepositoryToGroup();
-        assertEquals( Action.SUCCESS, result );
-
-        action.prepare();
-        result = action.execute();
-        assertEquals( Action.SUCCESS, result );
-
-        assertEquals( 1, action.getRepositoryGroups().size() );
-        repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
-        assertEquals( 2, repoGroup.getRepositories().size() );
-        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
-        assertEquals( REPO2_ID, repoGroup.getRepositories().get( 1 ) );
-
-        assertEquals( 0, action.getGroupToRepositoryMap().size() );
-        assertNull( action.getGroupToRepositoryMap().get( repoGroup.getId() ) );
-    }
-
-    public void testRemoveRepositoryFromGroup()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 13 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        String result = action.execute();
-        assertEquals( Action.SUCCESS, result );
-
-        assertNotNull( action.getRepositoryGroups() );
-        assertEquals( 1, action.getRepositoryGroups().size() );
-        assertEquals( 2, action.getManagedRepositories().size() );
-
-        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
-        assertEquals( 1, repoGroup.getRepositories().size() );
-        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
-
-        assertNotNull( action.getGroupToRepositoryMap() );
-        assertEquals( 1, action.getGroupToRepositoryMap().size() );
-
-        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
-        assertEquals( 1, repos.size() );
-        assertEquals( REPO2_ID, repos.get( 0 ) );
-
-        action.setRepoGroupId( REPO_GROUP_ID );
-        action.setRepoId( REPO1_ID );
-
-        result = action.removeRepositoryFromGroup();
-        assertEquals( Action.SUCCESS, result );
-
-        action.prepare();
-        result = action.execute();
-        assertEquals( Action.SUCCESS, result );
-
-        repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
-        assertEquals( 0, repoGroup.getRepositories().size() );
-
-        assertNotNull( action.getGroupToRepositoryMap() );
-        assertEquals( 1, action.getGroupToRepositoryMap().size() );
-
-        repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
-        assertEquals( 2, repos.size() );
-        assertEquals( REPO1_ID, repos.get( 0 ) );
-        assertEquals( REPO2_ID, repos.get( 1 ) );
-    }
-
-    public void testAddDuplicateRepositoryToGroup()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 6 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        String result = action.execute();
-        assertEquals( Action.SUCCESS, result );
-
-        assertNotNull( action.getRepositoryGroups() );
-        assertEquals( 1, action.getRepositoryGroups().size() );
-        assertEquals( 2, action.getManagedRepositories().size() );
-
-        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
-        assertEquals( 1, repoGroup.getRepositories().size() );
-        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
-
-        assertNotNull( action.getGroupToRepositoryMap() );
-        assertEquals( 1, action.getGroupToRepositoryMap().size() );
-
-        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
-        assertEquals( 1, repos.size() );
-        assertEquals( REPO2_ID, repos.get( 0 ) );
-
-        action.setRepoGroupId( REPO_GROUP_ID );
-        action.setRepoId( REPO1_ID );
-
-        result = action.addRepositoryToGroup();
-        assertEquals( Action.ERROR, result );
-    }
-
-    public void testRemoveRepositoryNotInGroup()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 6 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        action.prepare();
-        String result = action.execute();
-        assertEquals( Action.SUCCESS, result );
-
-        assertNotNull( action.getRepositoryGroups() );
-        assertEquals( 1, action.getRepositoryGroups().size() );
-        assertEquals( 2, action.getManagedRepositories().size() );
-
-        RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
-        assertEquals( 1, repoGroup.getRepositories().size() );
-        assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
-
-        assertNotNull( action.getGroupToRepositoryMap() );
-        assertEquals( 1, action.getGroupToRepositoryMap().size() );
-
-        List<String> repos = action.getGroupToRepositoryMap().get( repoGroup.getId() );
-        assertEquals( 1, repos.size() );
-        assertEquals( REPO2_ID, repos.get( 0 ) );
-
-        action.setRepoGroupId( REPO_GROUP_ID );
-        action.setRepoId( REPO2_ID );
-
-        result = action.removeRepositoryFromGroup();
-        assertEquals( Action.ERROR, result );
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        ManagedRepositoryConfiguration managedRepo1 = new ManagedRepositoryConfiguration();
-        managedRepo1.setId( REPO1_ID );
-
-        config.addManagedRepository( managedRepo1 );
-
-        ManagedRepositoryConfiguration managedRepo2 = new ManagedRepositoryConfiguration();
-        managedRepo2.setId( REPO2_ID );
-
-        config.addManagedRepository( managedRepo2 );
-
-        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
-        repoGroup.setId( REPO_GROUP_ID );
-        repoGroup.addRepository( REPO1_ID );
-
-        config.addRepositoryGroup( repoGroup );
-
-        return config;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesActionTest.java
deleted file mode 100644 (file)
index e330969..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.repositories;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.struts2.StrutsSpringTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
-import org.codehaus.redback.integration.interceptor.SecureActionException;
-import org.easymock.MockControl;
-
-/**
- * SortRepositoriesActionTest
- */
-public class SortRepositoriesActionTest
-    extends StrutsSpringTestCase
-{
-    private static final String REPO_GROUP_ID = "repo-group-ident";
-
-    private static final String REPO1_ID = "managed-repo-ident-1";
-
-    private static final String REPO2_ID = "managed-repo-ident-2";
-
-    private static final String REPO3_ID = "managed-repo-ident-3";
-
-    private MockControl archivaConfigurationControl;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    private ArchivaConfiguration originalArchivaConfiguration;
-
-    private SortRepositoriesAction action;
-
-    @Override
-    protected String[] getContextLocations()
-    {
-        return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" };
-    }
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-        action = (SortRepositoriesAction) getActionProxy( "/admin/sortDownRepositoryFromGroup.action" ).getAction();
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        originalArchivaConfiguration = action.archivaConfiguration;
-        action.setArchivaConfiguration( archivaConfiguration );
-    }
-
-    @Override
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        action.archivaConfiguration = originalArchivaConfiguration;
-    }
-
-    public void testSecureActionBundle()
-        throws SecureActionException
-    {
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( new Configuration() );
-        archivaConfigurationControl.replay();
-
-        SecureActionBundle bundle = action.getSecureActionBundle();
-        assertTrue( bundle.requiresAuthentication() );
-        assertEquals( 1, bundle.getAuthorizationTuples().size() );
-    }
-
-    public void testSortDownFirstRepository()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 4 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        RepositoryGroupConfiguration repoGroup =
-            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        java.util.List<String> repositories = repoGroup.getRepositories();
-
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO1_ID, repositories.get( 0 ) );
-        assertEquals( REPO2_ID, repositories.get( 1 ) );
-        assertEquals( REPO3_ID, repositories.get( 2 ) );
-
-        // sort down first repo
-        action.setRepoGroupId( repoGroup.getId() );
-        action.setTargetRepo( REPO1_ID );
-
-        String result = action.sortDown();
-        assertEquals( Action.SUCCESS, result );
-
-        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        repositories = repoGroup.getRepositories();
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO2_ID, repositories.get( 0 ) );
-        assertEquals( REPO1_ID, repositories.get( 1 ) );
-        assertEquals( REPO3_ID, repositories.get( 2 ) );
-    }
-
-    public void testSortDownLastRepository()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 4 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        RepositoryGroupConfiguration repoGroup =
-            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        java.util.List<String> repositories = repoGroup.getRepositories();
-
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO1_ID, repositories.get( 0 ) );
-        assertEquals( REPO2_ID, repositories.get( 1 ) );
-        assertEquals( REPO3_ID, repositories.get( 2 ) );
-
-        // sort down last repo
-        action.setRepoGroupId( repoGroup.getId() );
-        action.setTargetRepo( REPO3_ID );
-
-        String result = action.sortDown();
-        assertEquals( Action.SUCCESS, result );
-
-        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        repositories = repoGroup.getRepositories();
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO1_ID, repositories.get( 0 ) );
-        assertEquals( REPO2_ID, repositories.get( 1 ) );
-        assertEquals( REPO3_ID, repositories.get( 2 ) );
-    }
-
-    public void testSortUpLastRepository()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 4 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        RepositoryGroupConfiguration repoGroup =
-            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        java.util.List<String> repositories = repoGroup.getRepositories();
-
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO1_ID, repositories.get( 0 ) );
-        assertEquals( REPO2_ID, repositories.get( 1 ) );
-        assertEquals( REPO3_ID, repositories.get( 2 ) );
-
-        // sort up last repo
-        action.setRepoGroupId( repoGroup.getId() );
-        action.setTargetRepo( REPO3_ID );
-
-        String result = action.sortUp();
-        assertEquals( Action.SUCCESS, result );
-
-        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        repositories = repoGroup.getRepositories();
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO1_ID, repositories.get( 0 ) );
-        assertEquals( REPO3_ID, repositories.get( 1 ) );
-        assertEquals( REPO2_ID, repositories.get( 2 ) );
-    }
-
-    public void testSortUpFirstRepository()
-        throws Exception
-    {
-        Configuration configuration = createInitialConfiguration();
-
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( configuration, 4 );
-        archivaConfiguration.save( configuration );
-        archivaConfigurationControl.replay();
-
-        RepositoryGroupConfiguration repoGroup =
-            (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        java.util.List<String> repositories = repoGroup.getRepositories();
-
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO1_ID, repositories.get( 0 ) );
-        assertEquals( REPO2_ID, repositories.get( 1 ) );
-        assertEquals( REPO3_ID, repositories.get( 2 ) );
-
-        // sort up first repo
-        action.setRepoGroupId( repoGroup.getId() );
-        action.setTargetRepo( REPO1_ID );
-
-        String result = action.sortUp();
-        assertEquals( Action.SUCCESS, result );
-
-        repoGroup = (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 );
-        repositories = repoGroup.getRepositories();
-        assertEquals( 3, repositories.size() );
-        assertEquals( REPO1_ID, repositories.get( 0 ) );
-        assertEquals( REPO2_ID, repositories.get( 1 ) );
-        assertEquals( REPO3_ID, repositories.get( 2 ) );
-    }
-
-    private Configuration createInitialConfiguration()
-    {
-        Configuration config = new Configuration();
-
-        RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
-        repoGroup.setId( REPO_GROUP_ID );
-        repoGroup.addRepository( REPO1_ID );
-        repoGroup.addRepository( REPO2_ID );
-        repoGroup.addRepository( REPO3_ID );
-
-        config.addRepositoryGroup( repoGroup );
-
-        return config;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java
deleted file mode 100644 (file)
index cf67f69..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.apache.maven.archiva.web.action.admin.scanning;
-
-import org.apache.archiva.admin.repository.admin.DefaultArchivaAdministration;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.RepositoryScanningConfiguration;
-import org.apache.maven.archiva.web.action.AbstractActionTestCase;
-import org.easymock.MockControl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class RepositoryScanningActionTest
-    extends AbstractActionTestCase
-{
-    private RepositoryScanningAction action;
-
-    private MockControl archivaConfigControl;
-
-    private ArchivaConfiguration archivaConfig;
-
-    private Configuration config;
-
-    protected void setUp()
-        throws Exception
-    {
-
-        super.setUp();
-
-        archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
-
-        action = new RepositoryScanningAction();
-
-        config = new Configuration();
-
-        RepositoryScanningConfiguration repositoryScanningConfig = new RepositoryScanningConfiguration();
-
-        repositoryScanningConfig.setKnownContentConsumers( createKnownContentConsumersList() );
-
-        config.setRepositoryScanning( repositoryScanningConfig );
-
-        DefaultArchivaAdministration archivaAdministration = new DefaultArchivaAdministration();
-        archivaAdministration.setArchivaConfiguration( archivaConfig );
-        action.setArchivaAdministration( archivaAdministration );
-
-    }
-
-    public void testUpdateKnownConsumers()
-        throws Exception
-    {
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 10 );
-
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfigControl.replay();
-
-        setEnabledKnownContentConsumers();
-
-        String returnString = action.updateKnownConsumers();
-
-        List<String> results = config.getRepositoryScanning().getKnownContentConsumers();
-
-        assertEquals( action.SUCCESS, returnString );
-        assertEquals( "results " + results, 8, results.size() );
-    }
-
-    public void testDisableAllKnownConsumers()
-        throws Exception
-    {
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 10 );
-
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfig.save( config );
-        archivaConfigControl.replay();
-
-        action.setEnabledKnownContentConsumers( null );
-
-        String returnString = action.updateKnownConsumers();
-
-        List<String> results = config.getRepositoryScanning().getKnownContentConsumers();
-
-        assertEquals( action.SUCCESS, returnString );
-        assertEquals( 0, results.size() );
-    }
-
-    private void setEnabledKnownContentConsumers()
-    {
-        action.setEnabledKnownContentConsumers( createKnownContentConsumersList() );
-    }
-
-    private List<String> createKnownContentConsumersList()
-    {
-        List<String> knownContentConsumers = new ArrayList<String>();
-        knownContentConsumers.add( "auto-remove" );
-        knownContentConsumers.add( "auto-rename" );
-        knownContentConsumers.add( "create-missing-checksums" );
-        knownContentConsumers.add( "index-content" );
-        knownContentConsumers.add( "metadata-updater" );
-        knownContentConsumers.add( "repository-purge" );
-        knownContentConsumers.add( "update-db-artifact" );
-        knownContentConsumers.add( "validate-checksums" );
-
-        return knownContentConsumers;
-    }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java
deleted file mode 100644 (file)
index a4c18ef..0000000
+++ /dev/null
@@ -1,712 +0,0 @@
-package org.apache.maven.archiva.web.action.reports;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.google.common.collect.Lists;
-import com.opensymphony.xwork2.Action;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.metadata.model.MetadataFacet;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
-import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
-import org.apache.archiva.reports.RepositoryProblemFacet;
-import org.apache.archiva.security.UserRepositoriesStub;
-import org.apache.commons.io.IOUtils;
-import org.apache.maven.archiva.web.action.AbstractActionTestCase;
-import org.easymock.MockControl;
-import org.junit.After;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * Test the GenerationReportAction. Note that we are testing for <i>current</i> behaviour, however there are several
- * instances below where other behaviour may actually be more appropriate (eg the error handling, download stats should
- * never forward to HTML page, etc). This is also missing tests for various combinations of paging at this point.
- */
-public class GenerateReportActionTest
-    extends AbstractActionTestCase
-{
-    private GenerateReportAction action;
-
-    private static final String SNAPSHOTS = "snapshots";
-
-    private static final String INTERNAL = "internal";
-
-    private static final String GROUP_ID = "groupId";
-
-    private RepositoryStatisticsManager repositoryStatisticsManager;
-
-    private MockControl repositoryStatisticsManagerControl;
-
-    private MockControl metadataRepositoryControl;
-
-    private MetadataRepository metadataRepository;
-
-    private static final String PROBLEM = "problem";
-
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        UserRepositoriesStub stub = applicationContext.getBean( "userRepositories", UserRepositoriesStub.class );
-        stub.setRepoIds( Lists.<String>newArrayList( "internal", "snapshots" ) );
-
-        action = (GenerateReportAction) getActionProxy( "/report/generateReport.action" ).getAction();
-
-        repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
-        repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
-        action.setRepositoryStatisticsManager( repositoryStatisticsManager );
-
-        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
-        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
-
-        RepositorySession repositorySession = mock( RepositorySession.class );
-        when( repositorySession.getRepository() ).thenReturn( metadataRepository );
-
-        TestRepositorySessionFactory factory =
-            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
-        factory.setRepositorySession( repositorySession );
-    }
-
-    @After
-    public void tearDown()
-        throws Exception
-    {
-        UserRepositoriesStub stub = applicationContext.getBean( "userRepositories", UserRepositoriesStub.class );
-        stub.setRepoIds( Lists.<String>newArrayList( "test-repo" ) );
-
-        super.tearDown();
-
-    }
-
-    private void prepareAction( List<String> selectedRepositories, List<String> availableRepositories )
-        throws Exception
-    {
-        MockControl managedRepositoryControl = MockControl.createControl( ManagedRepositoryAdmin.class );
-        ManagedRepositoryAdmin managedRepositoryAdmin = (ManagedRepositoryAdmin) managedRepositoryControl.getMock();
-
-        Map<String, ManagedRepository> map = new HashMap<String, ManagedRepository>( availableRepositories.size() );
-        for ( String repoId : availableRepositories )
-        {
-            map.put( repoId, new ManagedRepository() );
-        }
-
-        managedRepositoryControl.expectAndReturn( managedRepositoryAdmin.getManagedRepositoriesAsMap(), map, 1, 10 );
-
-        managedRepositoryControl.replay();
-        action.setManagedRepositoryAdmin( managedRepositoryAdmin );
-
-
-        action.setSelectedRepositories( selectedRepositories );
-        action.prepare();
-
-        List<String> repos = Arrays.asList( GenerateReportAction.ALL_REPOSITORIES, INTERNAL, SNAPSHOTS );
-
-        Collections.sort( repos );
-
-        Collections.sort( action.getRepositoryIds() );
-
-        assertEquals( repos, action.getRepositoryIds() );
-        Collections.sort( action.getAvailableRepositories() );
-
-        availableRepositories = new ArrayList<String>( availableRepositories );
-        Collections.sort( availableRepositories );
-
-
-        assertEquals( availableRepositories, action.getAvailableRepositories() );
-    }
-
-    public void testGenerateStatisticsInvalidRowCount()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
-
-        action.setRowCount( 0 );
-        String result = action.generateStatistics();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsInvalidEndDate()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
-
-        action.setStartDate( "2009/12/12" );
-        action.setEndDate( "2008/11/11" );
-        String result = action.generateStatistics();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsMalformedEndDate()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
-
-        action.setEndDate( "This is not a date" );
-        String result = action.generateStatistics();
-
-        // TODO: should be an input error
-        assertEquals( Action.ERROR, result );
-        assertTrue( action.hasActionErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsInvalidEndDateMultiRepo()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        action.setStartDate( "2009/12/12" );
-        action.setEndDate( "2008/11/11" );
-        String result = action.generateStatistics();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsMalformedEndDateMultiRepo()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        action.setEndDate( "This is not a date" );
-        String result = action.generateStatistics();
-
-        // TODO: should be an input error
-        assertEquals( Action.ERROR, result );
-        assertTrue( action.hasActionErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsNoRepos()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.generateStatistics();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsSingleRepo()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
-
-        String result = action.generateStatistics();
-        assertSuccessResult( result );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsSingleRepoNoStats()
-        throws Exception
-
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.<Object>emptyList() );
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
-
-        String result = action.generateStatistics();
-        assertEquals( Action.ERROR, result );
-        assertTrue( action.hasActionErrors() );
-
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsOvershotPages()
-        throws Exception
-
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-        repositoryStatisticsManagerControl.replay();
-        action.setPage( 2 );
-        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
-
-        String result = action.generateStatistics();
-        assertEquals( Action.ERROR, result );
-        assertTrue( action.hasActionErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsMultipleRepoNoResults()
-        throws Exception
-
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
-            Collections.<Object>emptyList() );
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.<Object>emptyList() );
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        String result = action.generateStatistics();
-        assertEquals( GenerateReportAction.BLANK, result );
-        assertFalse( action.hasActionErrors() );
-        assertFalse( action.hasActionMessages() );
-        assertFalse( action.hasFieldErrors() );
-
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testGenerateStatisticsMultipleRepo()
-        throws Exception
-
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        String result = action.generateStatistics();
-        assertSuccessResult( result );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsSingleRepo()
-        throws Exception
-    {
-        Date date = new Date();
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
-            Collections.singletonList( createStats( date ) ) );
-        repositoryStatisticsManagerControl.replay();
-
-        prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
-
-        String result = action.downloadStatisticsReport();
-        assertEquals( GenerateReportAction.SEND_FILE, result );
-        assertFalse( action.hasActionErrors() );
-        assertFalse( action.hasFieldErrors() );
-
-        assertEquals(
-            "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n"
-                + date + ",0,0,0,0,0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsMultipleRepos()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        String result = action.downloadStatisticsReport();
-        assertEquals( GenerateReportAction.SEND_FILE, result );
-        assertFalse( action.hasActionErrors() );
-        assertFalse( action.hasFieldErrors() );
-
-        assertMultiRepoCsvResult();
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsMalformedEndDateMultiRepo()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        action.setEndDate( "This is not a date" );
-        String result = action.downloadStatisticsReport();
-
-        // TODO: should be an input error
-        assertEquals( Action.ERROR, result );
-        assertTrue( action.hasActionErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsMalformedEndDateSingleRepo()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
-
-        action.setEndDate( "This is not a date" );
-        String result = action.downloadStatisticsReport();
-
-        // TODO: should be an input error
-        assertEquals( Action.ERROR, result );
-        assertTrue( action.hasActionErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsInvalidEndDateMultiRepo()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        action.setStartDate( "2009/12/12" );
-        action.setEndDate( "2008/11/11" );
-        String result = action.downloadStatisticsReport();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsInvalidEndDateSingleRepo()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
-
-        action.setStartDate( "2009/12/12" );
-        action.setEndDate( "2008/11/11" );
-        String result = action.downloadStatisticsReport();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsSingleRepoNoStats()
-        throws Exception
-
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.<Object>emptyList() );
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
-
-        String result = action.downloadStatisticsReport();
-        assertEquals( Action.ERROR, result );
-        assertTrue( action.hasActionErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsNoRepos()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.downloadStatisticsReport();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsMultipleRepoNoResults()
-        throws Exception
-
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
-            Collections.<Object>emptyList() );
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.<Object>emptyList() );
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        String result = action.downloadStatisticsReport();
-        assertEquals( GenerateReportAction.BLANK, result );
-        assertFalse( action.hasActionErrors() );
-        assertFalse( action.hasActionMessages() );
-        assertFalse( action.hasFieldErrors() );
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testDownloadStatisticsMultipleRepoInStrutsFormat()
-        throws Exception
-    {
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-        repositoryStatisticsManagerControl.expectAndReturn(
-            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ),
-            Collections.singletonList( createDefaultStats() ) );
-        repositoryStatisticsManagerControl.replay();
-        prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
-
-        action.setSelectedRepositories( Collections.singletonList( "[" + SNAPSHOTS + "],[" + INTERNAL + "]" ) );
-        String result = action.downloadStatisticsReport();
-        assertEquals( GenerateReportAction.SEND_FILE, result );
-        assertFalse( action.hasActionErrors() );
-        assertFalse( action.hasFieldErrors() );
-
-        assertMultiRepoCsvResult();
-        repositoryStatisticsManagerControl.verify();
-    }
-
-    public void testHealthReportSingleRepo()
-        throws Exception
-    {
-        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
-        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL );
-
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
-            Arrays.asList( problem1.getName(), problem2.getName() ) );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
-            problem1 );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
-            problem2 );
-        metadataRepositoryControl.replay();
-
-        action.setRepositoryId( INTERNAL );
-
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.execute();
-        assertSuccessResult( result );
-
-        assertEquals( Collections.singleton( INTERNAL ), action.getRepositoriesMap().keySet() );
-        assertEquals( Arrays.asList( problem1, problem2 ), action.getRepositoriesMap().get( INTERNAL ) );
-
-        metadataRepositoryControl.verify();
-    }
-
-    public void testHealthReportInvalidRowCount()
-        throws Exception
-    {
-        metadataRepositoryControl.replay();
-
-        action.setRowCount( 0 );
-        action.setRepositoryId( INTERNAL );
-
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.execute();
-        assertEquals( Action.INPUT, result );
-        assertFalse( action.hasActionErrors() );
-        assertTrue( action.hasFieldErrors() );
-
-        metadataRepositoryControl.verify();
-    }
-
-    public void testHealthReportAllRepos()
-        throws Exception
-    {
-        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
-        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
-            Arrays.asList( problem1.getName() ) );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacets( SNAPSHOTS, RepositoryProblemFacet.FACET_ID ),
-            Arrays.asList( problem2.getName() ) );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
-            problem1 );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( SNAPSHOTS, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
-            problem2 );
-        metadataRepositoryControl.replay();
-
-        action.setRepositoryId( GenerateReportAction.ALL_REPOSITORIES );
-
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.execute();
-        assertSuccessResult( result );
-
-        assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ),
-                      new ArrayList<String>( action.getRepositoriesMap().keySet() ) );
-        assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) );
-        assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) );
-
-        metadataRepositoryControl.verify();
-    }
-
-    public void testHealthReportSingleRepoByCorrectGroupId()
-        throws Exception
-    {
-        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
-        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
-            Arrays.asList( problem1.getName(), problem2.getName() ) );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
-            problem1 );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
-            problem2 );
-        metadataRepositoryControl.replay();
-
-        action.setGroupId( GROUP_ID );
-        action.setRepositoryId( INTERNAL );
-
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.execute();
-        assertSuccessResult( result );
-
-        assertEquals( Collections.singleton( INTERNAL ), action.getRepositoriesMap().keySet() );
-        assertEquals( Arrays.asList( problem1, problem2 ), action.getRepositoriesMap().get( INTERNAL ) );
-
-        metadataRepositoryControl.verify();
-    }
-
-    public void testHealthReportSingleRepoByCorrectGroupIdAllRepositories()
-        throws Exception
-    {
-        RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
-        RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
-            Arrays.asList( problem1.getName() ) );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacets( SNAPSHOTS, RepositoryProblemFacet.FACET_ID ),
-            Arrays.asList( problem2.getName() ) );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ),
-            problem1 );
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacet( SNAPSHOTS, RepositoryProblemFacet.FACET_ID, problem2.getName() ),
-            problem2 );
-        metadataRepositoryControl.replay();
-
-        action.setGroupId( GROUP_ID );
-        action.setRepositoryId( GenerateReportAction.ALL_REPOSITORIES );
-
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.execute();
-        assertSuccessResult( result );
-
-        assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ),
-                      new ArrayList<String>( action.getRepositoriesMap().keySet() ) );
-        assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) );
-        assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) );
-
-        metadataRepositoryControl.verify();
-    }
-
-    public void testHealthReportSingleRepoByIncorrectGroupId()
-        throws Exception
-    {
-        metadataRepositoryControl.expectAndReturn(
-            metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ),
-            Collections.<MetadataFacet>emptyList() );
-        metadataRepositoryControl.replay();
-
-        action.setGroupId( "not.it" );
-        action.setRepositoryId( INTERNAL );
-
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.execute();
-        assertEquals( GenerateReportAction.BLANK, result );
-        assertFalse( action.hasActionErrors() );
-        assertFalse( action.hasFieldErrors() );
-
-        metadataRepositoryControl.verify();
-    }
-
-    private void assertMultiRepoCsvResult()
-        throws IOException
-    {
-        assertEquals(
-            "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n"
-                + "snapshots,0,0,0,0,0,0,0,0,0\n" + "internal,0,0,0,0,0,0,0,0,0\n",
-            IOUtils.toString( action.getInputStream() ) );
-    }
-
-    private RepositoryProblemFacet createProblem( String groupId, String artifactId, String repoId )
-    {
-        RepositoryProblemFacet problem = new RepositoryProblemFacet();
-        problem.setRepositoryId( repoId );
-        problem.setNamespace( groupId );
-        problem.setProject( artifactId );
-        problem.setProblem( PROBLEM );
-        return problem;
-    }
-
-    public void testHealthReportNoRepositoryId()
-        throws Exception
-    {
-        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
-
-        String result = action.execute();
-        assertEquals( Action.INPUT, result );
-        assertTrue( action.hasFieldErrors() );
-    }
-
-    private void assertSuccessResult( String result )
-    {
-        assertEquals( Action.SUCCESS, result );
-        assertFalse( action.hasActionErrors() );
-        assertFalse( action.hasFieldErrors() );
-    }
-
-    private RepositoryStatistics createDefaultStats()
-    {
-        return createStats( new Date() );
-    }
-
-    private RepositoryStatistics createStats( Date date )
-    {
-        RepositoryStatistics stats = new RepositoryStatistics();
-        stats.setScanStartTime( date );
-        return stats;
-    }
-}
index 01b2b30c3c55832e7db974dcdbb622873a19c771..7adf8c8c4a4827b2f07e0fc5e6c556214c66c265 100644 (file)
@@ -27,7 +27,7 @@
       <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
     </layout>
   </appender>
-  <logger name="org.apache.maven.archiva.web.action.SearchAction">
+  <logger name="org.apache.archiva.web.action.SearchAction">
     <level value="debug"/>
   </logger>
   <logger name="org.apache.archiva.indexer.search.NexusRepositorySearch">
index e8c1e7545b8807a0332d76cd454bc91d798cae9d..03f6171ffd3436305b01dc57055d51941df06f7e 100644 (file)
@@ -27,7 +27,7 @@
       <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
     </layout>
   </appender>
-  <logger name="org.apache.maven.archiva.web.action.SearchAction">
+  <logger name="org.apache.archiva.web.action.SearchAction">
     <level value="debug"/>
   </logger>
   <logger name="org.apache.archiva.indexer.search.NexusRepositorySearch">