From c303ba78c70a220c54b0501bf5239f5870d03ad9 Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Mon, 20 Oct 2008 05:59:47 +0000 Subject: [PATCH] merged MRM-124 branch (-r706118) - archiva web services git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@706126 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractLegacyRepositoryContent.java | 5 + .../ManagedDefaultRepositoryContent.java | 4 + .../ManagedLegacyRepositoryContent.java | 5 + .../xml/AbstractArchivaXmlTestCase.java | 5 +- .../ArtifactVersionsConstraint.java | 12 +- .../ArtifactVersionsConstraintTest.java | 4 +- .../archiva-web/archiva-webapp/pom.xml | 17 + .../webapp/WEB-INF/applicationContext.xml | 23 + .../src/main/webapp/WEB-INF/web.xml | 241 +++-- .../archiva-xmlrpc/archiva-xmlrpc-api/pom.xml | 40 + .../web/xmlrpc/api/AdministrationService.java | 115 +++ .../archiva/web/xmlrpc/api/SearchService.java | 28 + .../archiva/web/xmlrpc/api/TestService.java | 28 + .../xmlrpc/api/beans/ManagedRepository.java | 152 +++ .../xmlrpc/api/beans/RemoteRepository.java | 121 +++ .../archiva-xmlrpc-client/pom.xml | 94 ++ .../web/xmlrpc/client/SampleClient.java | 193 ++++ .../archiva-xmlrpc-security/pom.xml | 83 ++ .../ServiceMethodsPermissionsMapping.java | 69 ++ .../xmlrpc/security/XmlRpcAuthenticator.java | 117 +++ .../security/XmlRpcAuthenticatorTest.java | 220 ++++ .../META-INF/redback/redback-core.xml | 210 ++++ .../security/XmlRpcAuthenticatorTest.xml | 192 ++++ .../archiva-xmlrpc-services/pom.xml | 60 ++ .../services/AdministrationServiceImpl.java | 440 ++++++++ .../web/xmlrpc/services/PingServiceImpl.java | 30 + .../AdministrationServiceImplTest.java | 954 ++++++++++++++++++ .../archiva-test/1.0/archiva-test-1.0.jar | 0 .../archiva-test/1.0/archiva-test-1.0.jar.md5 | 0 .../1.0/archiva-test-1.0.jar.sha1 | 0 .../archiva-test/1.0/archiva-test-1.0.pom | 0 .../archiva-test/1.0/archiva-test-1.0.pom.md5 | 0 .../1.0/archiva-test-1.0.pom.sha1 | 0 .../archiva-test/1.0/maven-metadata.xml | 0 .../archiva-test/1.0/maven-metadata.xml.md5 | 0 .../archiva-test/1.0/maven-metadata.xml.sha1 | 0 .../archiva-test/1.1/archiva-test-1.1.jar | 0 .../archiva-test/1.1/archiva-test-1.1.pom | 0 .../jars/archiva-diff-1.0.jar | 0 .../jars/archiva-test-1.0.jar | 0 .../jars/archiva-test-1.1.jar | 0 .../poms/archiva-diff-1.0.pom | 0 .../poms/archiva-test-1.0.pom | 0 .../poms/archiva-test-1.1.pom | 0 .../AdministrationServiceImplTest.xml | 27 + .../archiva-web/archiva-xmlrpc/pom.xml | 37 + archiva-modules/archiva-web/pom.xml | 5 +- pom.xml | 64 ++ 48 files changed, 3484 insertions(+), 111 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/META-INF/redback/redback-core.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.xml create mode 100644 archiva-modules/archiva-web/archiva-xmlrpc/pom.xml diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractLegacyRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractLegacyRepositoryContent.java index f135d5aad..5ff3c783b 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractLegacyRepositoryContent.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractLegacyRepositoryContent.java @@ -117,4 +117,9 @@ public abstract class AbstractLegacyRepositoryContent // Default process. return type + "s"; } + + public void setLegacyPathParser( PathParser parser ) + { + this.legacyPathParser = parser; + } } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java index 53bfc1bcb..93545f3dd 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java @@ -78,6 +78,10 @@ public class ManagedDefaultRepositoryContent // TODO: log this somewhere? } } + else + { + throw new ContentNotFoundException( "Unable to delete non-existing project directory." ); + } } public String getId() diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java index 6b59d86f3..03216fd8a 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java @@ -454,4 +454,9 @@ public class ManagedLegacyRepositoryContent } } } + + public void setFileTypes( FileTypes fileTypes ) + { + this.filetypes = fileTypes; + } } diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java index 7fd49274a..c26889d55 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java @@ -33,10 +33,13 @@ public abstract class AbstractArchivaXmlTestCase extends TestCase { protected static final String OSLASH = "\u00f8"; + protected static final String TRYGVIS = "Trygve Laugst" + OSLASH + "l"; + protected static final String INFIN = "\u221e"; + protected static final String INFINITE_ARCHIVA = "The " + INFIN + " Archiva"; - + protected File getExampleXml( String filename ) { File examplesDir = new File( "src/test/examples" ); diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java index c7eee23a5..4307022ba 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraint.java @@ -35,18 +35,20 @@ public class ArtifactVersionsConstraint private String sortColumn = "repositoryId"; - public ArtifactVersionsConstraint( String repoId, String groupId, String artifactId ) + public ArtifactVersionsConstraint( String repoId, String groupId, String artifactId, boolean includeWhenGathered ) { if( repoId != null ) { - whereClause = "repositoryId.equals(selectedRepoId) && groupId.equals(selectedGroupId) && artifactId.equals(selectedArtifactId) " + - "&& whenGathered != null"; + whereClause = "repositoryId.equals(selectedRepoId) && groupId.equals(selectedGroupId) && artifactId.equals(selectedArtifactId) " + + ( includeWhenGathered ? "&& whenGathered != null" : "" ); declParams = new String[] { "String selectedRepoId", "String selectedGroupId", "String selectedArtifactId" }; params = new Object[] { repoId, groupId, artifactId }; } else { - whereClause = "groupId.equals(selectedGroupId) && artifactId.equals(selectedArtifactId) && this.whenGathered != null"; + whereClause = + "groupId.equals(selectedGroupId) && artifactId.equals(selectedArtifactId) " + + ( includeWhenGathered ? "&& whenGathered != null" : "" ); declParams = new String[] { "String selectedGroupId", "String selectedArtifactId" }; params = new Object[] { groupId, artifactId }; } @@ -54,7 +56,7 @@ public class ArtifactVersionsConstraint public ArtifactVersionsConstraint( String repoId, String groupId, String artifactId, String sortColumn ) { - this( repoId, groupId, artifactId ); + this( repoId, groupId, artifactId, true ); this.sortColumn = sortColumn; } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraintTest.java index f7fa5b4ff..d00c6dcf5 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraintTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactVersionsConstraintTest.java @@ -87,14 +87,14 @@ public class ArtifactVersionsConstraintTest { populateDb(); assertConstraint( "Artifacts By Repository", 3, - new ArtifactVersionsConstraint( null, "org.apache.archiva", "artifact-one" ) ); + new ArtifactVersionsConstraint( null, "org.apache.archiva", "artifact-one", true ) ); } public void testQueryAllVersionsOfArtifactInARepo() throws Exception { populateDb(); assertConstraint( "Artifacts By Repository", 2, - new ArtifactVersionsConstraint( TEST_REPO, "org.apache.archiva", "artifact-one" ) ); + new ArtifactVersionsConstraint( TEST_REPO, "org.apache.archiva", "artifact-one", true ) ); } private void assertConstraint( String msg, int count, ArtifactVersionsConstraint constraint ) diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 5c6a5a8f7..127d08b25 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -84,6 +84,18 @@ org.apache.archiva archiva-rss + + org.apache.archiva + archiva-xmlrpc-api + + + org.apache.archiva + archiva-xmlrpc-services + + + org.apache.archiva + archiva-xmlrpc-security + javax.servlet servlet-api @@ -221,6 +233,11 @@ commons-logging-api 1.1 + + com.atlassian.xmlrpc + atlassian-xmlrpc-binder-server-spring + runtime + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 93bd4a30b..d8604065c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -30,4 +30,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml index d002c0fb5..a8c61356e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml @@ -1,4 +1,4 @@ - + - - - Apache Archiva - - - webwork-cleanup - org.apache.struts2.dispatcher.ActionContextCleanUp - - - - sitemesh - com.opensymphony.module.sitemesh.filter.PageFilter - - - - webwork - org.apache.struts2.dispatcher.FilterDispatcher - - - - - webwork-cleanup - /* - - - - sitemesh - /* - - - - webwork - /* - - - - org.springframework.web.context.ContextLoaderListener - - - - org.apache.maven.archiva.web.startup.ArchivaStartup - - - - contextClass - org.codehaus.plexus.spring.PlexusWebApplicationContext - - - - contextConfigLocation - - classpath*:META-INF/plexus/components.xml - classpath*:META-INF/spring-context.xml - /WEB-INF/classes/META-INF/plexus/application.xml - /WEB-INF/classes/META-INF/plexus/components.xml - /WEB-INF/applicationContext.xml - - - - - RepositoryServlet - org.apache.maven.archiva.webdav.RepositoryServlet - - 1 - - - - RssFeedServlet - org.apache.maven.archiva.web.rss.RssFeedServlet - - - - RssFeedServlet - /feeds/* - - - - RepositoryServlet - /repository/* - - - - jdbc/users - javax.sql.DataSource - Container - Shareable - - - jdbc/archiva - javax.sql.DataSource - Container - Shareable - - - mail/Session - javax.mail.Session - Container - Shareable - + + + Apache Archiva + + + webwork-cleanup + org.apache.struts2.dispatcher.ActionContextCleanUp + + + + sitemesh + + com.opensymphony.module.sitemesh.filter.PageFilter + + + + + webwork + org.apache.struts2.dispatcher.FilterDispatcher + + + + + webwork-cleanup + /* + + + + sitemesh + /* + + + + webwork + /* + + + + + org.springframework.web.context.ContextLoaderListener + + + + + + org.apache.maven.archiva.web.startup.ArchivaStartup + + + + + contextClass + + org.codehaus.plexus.spring.PlexusWebApplicationContext + + + + + contextConfigLocation + + classpath*:META-INF/plexus/components.xml + classpath*:META-INF/spring-context.xml + /WEB-INF/classes/META-INF/plexus/application.xml + /WEB-INF/classes/META-INF/plexus/components.xml + /WEB-INF/applicationContext.xml + + + + + RepositoryServlet + + org.apache.maven.archiva.webdav.RepositoryServlet + + + 1 + + + + XmlRpcServlet + + com.atlassian.xmlrpc.spring.BinderSpringXmlRpcServlet + + + serviceListBeanName + xmlrpcServicesList + + + authHandlerBeanName + xmlRpcAuthenticator + + + enabledForExtensions + true + + 1 + + + + RssFeedServlet + + org.apache.maven.archiva.web.rss.RssFeedServlet + + + + + RssFeedServlet + /feeds/* + + + + RepositoryServlet + /repository/* + + + + XmlRpcServlet + /xmlrpc + + + + jdbc/users + javax.sql.DataSource + Container + Shareable + + + jdbc/archiva + javax.sql.DataSource + Container + Shareable + + + mail/Session + javax.mail.Session + Container + Shareable + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml new file mode 100644 index 000000000..ac145568f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + org.apache.archiva + archiva-xmlrpc + 1.2-SNAPSHOT + ../pom.xml + + archiva-xmlrpc-api + Archiva Web :: XML-RPC API + + + com.atlassian.xmlrpc + atlassian-xmlrpc-binder-annotations + + + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java new file mode 100644 index 000000000..814933446 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java @@ -0,0 +1,115 @@ +package org.apache.archiva.web.xmlrpc.api; + +/* + * 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.List; + +import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; +import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; + +import com.atlassian.xmlrpc.ServiceObject; + +@ServiceObject( "AdministrationService" ) +public interface AdministrationService +{ + /** + * Executes repository scanner on the given repository. + * + * @param repoId id of the repository to be scanned + * @return + * @throws Exception + */ + public Boolean executeRepositoryScanner( String repoId ) throws Exception; + + /** + * Executes the database scanner. + * + * @return + * @throws Exception + */ + public Boolean executeDatabaseScanner() throws Exception; + + /** + * Gets all available database consumers. + * @return + */ + public List getAllDatabaseConsumers(); + + /** + * Configures (enable or disable) database consumer. + * + * @param consumerId id of the database consumer + * @param enable flag whether to enable or disable the specified consumer + * @return + * @throws Exception + */ + public Boolean configureDatabaseConsumer( String consumerId, boolean enable ) throws Exception; + + /** + * Gets all available repository consumers. + * + * @return + */ + public List getAllRepositoryConsumers(); + + // TODO should we already implement config of consumers per repository? + /** + * Configures (enable or disable) repository consumer. + * + * @param repoId + * @param consumerId + * @param enable + * @return + * @throws Exception + */ + public Boolean configureRepositoryConsumer( String repoId, String consumerId, boolean enable ) throws Exception; + + /** + * Gets all managed repositories. + * + * @return + */ + public List getAllManagedRepositories(); + + /** + * Gets all remote repositories. + * + * @return + */ + public List getAllRemoteRepositories(); + + /** + * Deletes given artifact from the specified repository. + * + * @param repoId id of the repository where the artifact to be deleted resides + * @param groupId groupId of the artifact to be deleted + * @param artifactId artifactId of the artifact to be deleted + * @param version version of the artifact to be deleted + * @return + * @throws Exception + */ + public Boolean deleteArtifact( String repoId, String groupId, String artifactId, String version ) + throws Exception; + + //TODO + // consider the following as additional services: + // - getAllConfiguredRepositoryConsumers( String repoId ) - list all enabled consumers for the repo + // - getAllConfiguredDatabaseConsumers() - list all enabled db consumers +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java new file mode 100644 index 000000000..cbc47547f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java @@ -0,0 +1,28 @@ +package org.apache.archiva.web.xmlrpc.api; + +/* + * 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.atlassian.xmlrpc.ServiceObject; + +@ServiceObject("Search") +public interface SearchService +{ + +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java new file mode 100644 index 000000000..5eba5144d --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java @@ -0,0 +1,28 @@ +package org.apache.archiva.web.xmlrpc.api; + +/* + * 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.atlassian.xmlrpc.ServiceObject; + +@ServiceObject("Test") +public interface TestService +{ + public String ping(); +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java new file mode 100644 index 000000000..fd0f9ef4f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java @@ -0,0 +1,152 @@ +package org.apache.archiva.web.xmlrpc.api.beans; + +/* + * 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.io.Serializable; + +import com.atlassian.xmlrpc.ServiceBean; +import com.atlassian.xmlrpc.ServiceBeanField; + +@ServiceBean +public class ManagedRepository + implements Serializable +{ + private String id; + + private String name; + + private String url; + + private String layout; + + private boolean snapshots = false; + + private boolean releases = false; + + public ManagedRepository() + { + + } + + public ManagedRepository( String id, String name, String url, String layout, boolean snapshots, boolean releases ) + { + this.id = id; + this.name = name; + this.url = url; + this.layout = layout; + this.snapshots = snapshots; + this.releases = releases; + } + + public boolean equals(Object other) + { + if ( this == other) + { + return true; + } + + if ( !(other instanceof ManagedRepository) ) + { + return false; + } + + ManagedRepository that = (ManagedRepository) other; + boolean result = true; + result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) ); + return result; + } + + public String getId() + { + return this.id; + } + + public String getLayout() + { + return this.layout; + } + + public String getName() + { + return this.name; + } + + public String getUrl() + { + return this.url; + } + + public int hashCode() + { + int result = 17; + long tmp; + result = 37 * result + ( id != null ? id.hashCode() : 0 ); + return result; + } + + public boolean isReleases() + { + return this.releases; + } + + /** + * Get null + */ + public boolean isSnapshots() + { + return this.snapshots; + } + + @ServiceBeanField( "id" ) + public void setId(String id) + { + this.id = id; + } + + @ServiceBeanField( "layout" ) + public void setLayout(String layout) + { + this.layout = layout; + } + + @ServiceBeanField( "name" ) + public void setName(String name) + { + this.name = name; + } + + @ServiceBeanField( "releases" ) + public void setReleases(boolean releases) + { + this.releases = releases; + } + + @ServiceBeanField( "snapshots" ) + public void setSnapshots(boolean snapshots) + { + this.snapshots = snapshots; + } + + @ServiceBeanField( "url" ) + public void setUrl(String url) + { + this.url = url; + } +} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java new file mode 100644 index 000000000..399b59e57 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java @@ -0,0 +1,121 @@ +package org.apache.archiva.web.xmlrpc.api.beans; + +/* + * 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.io.Serializable; + +import com.atlassian.xmlrpc.ServiceBean; +import com.atlassian.xmlrpc.ServiceBeanField; + +@ServiceBean +public class RemoteRepository + implements Serializable +{ + private String id; + + private String name; + + private String url; + + private String layout; + + public RemoteRepository() + { + + } + + public RemoteRepository( String id, String name, String url, String layout ) + { + this.id = id; + this.name = name; + this.url = url; + this.layout = layout; + } + + public boolean equals(Object other) + { + if ( this == other) + { + return true; + } + + if ( !(other instanceof RemoteRepository) ) + { + return false; + } + + RemoteRepository that = (RemoteRepository) other; + boolean result = true; + result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) ); + return result; + } + + public String getId() + { + return this.id; + } + + public String getLayout() + { + return this.layout; + } + + public String getName() + { + return this.name; + } + + public String getUrl() + { + return this.url; + } + + public int hashCode() + { + int result = 17; + long tmp; + result = 37 * result + ( id != null ? id.hashCode() : 0 ); + return result; + } + + @ServiceBeanField( "id" ) + public void setId(String id) + { + this.id = id; + } + + @ServiceBeanField( "layout" ) + public void setLayout(String layout) + { + this.layout = layout; + } + + @ServiceBeanField( "name" ) + public void setName(String name) + { + this.name = name; + } + + @ServiceBeanField( "url" ) + public void setUrl(String url) + { + this.url = url; + } +} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml new file mode 100644 index 000000000..1e73dc933 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml @@ -0,0 +1,94 @@ + + + + + + archiva-xmlrpc + org.apache.archiva + 1.2-SNAPSHOT + + 4.0.0 + archiva-xmlrpc-client + Archiva Web :: XML-RPC Client + + + org.apache.archiva + archiva-xmlrpc-api + ${project.version} + + + org.apache.xmlrpc + xmlrpc-client + 3.1 + + + commons-beanutils + commons-beanutils + 1.8.0 + + + + + + org.codehaus.mojo + exec-maven-plugin + + java + org.apache.archiva.web.xmlrpc.client.SampleClient + + + URL + USERNAME + PASSWORD + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0-alpha-3 + + + + enforce + + + + + + org.codehaus.plexus:plexus-container-default + velocity:velocity-dep + classworlds:classworlds + javax.transaction:jta + javax.sql:jdbc-stdext + ant:ant-optional + + xom:xom + + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java new file mode 100644 index 000000000..7f94734a1 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java @@ -0,0 +1,193 @@ +package org.apache.archiva.web.xmlrpc.client; + +/* + * 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.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.archiva.web.xmlrpc.api.AdministrationService; +import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; +import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.apache.xmlrpc.client.XmlRpcClientRequestImpl; +import org.apache.xmlrpc.client.util.ClientFactory; + +/** + * TestClient + * + * Test client for Archiva Web Services. + * To execute: + * + * 1. set the in the exec-maven-plugin config in the pom.xml in the following order: + * - url + * - username + * - password + * 2. execute 'mvn exec:java' from the command-line + * + * @author + * @version $Id$ + */ +public class SampleClient +{ + public static void main( String[] args ) + { + try + { + XmlRpcClient client = new XmlRpcClient(); + + XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setServerURL( new URL( args[0] ) ); + config.setBasicUserName( args[1] ); + config.setBasicPassword( args[2] ); + config.setEnabledForExtensions( true ); + + client.setConfig( config ); + + /* managed repositories */ + Object[] params = new Object[]{}; + Object[] managedRepos = (Object[]) + client.execute( "AdministrationService.getAllManagedRepositories", params ); + + System.out.println( "\n******** Managed Repositories ********" ); + for( int i = 0; i < managedRepos.length; i++ ) + { + System.out.println( "=================================" ); + ManagedRepository managedRepo = new ManagedRepository(); + try + { + BeanUtils.populate( managedRepo, (Map)managedRepos[i] ); + } + catch ( IllegalAccessException e ) + { + e.printStackTrace(); + } + catch ( InvocationTargetException e ) + { + e.printStackTrace(); + } + System.out.println( "Id: " + managedRepo.getId() ); + System.out.println( "Name: " + managedRepo.getName() ); + System.out.println( "Layout: " + managedRepo.getLayout() ); + System.out.println( "URL: " + managedRepo.getUrl() ); + System.out.println( "Releases: " + managedRepo.isReleases() ); + System.out.println( "Snapshots: " + managedRepo.isSnapshots() ); + } + + /* remote repositories */ + params = new Object[]{}; + Object[] remoteRepos = (Object[]) + client.execute( "AdministrationService.getAllRemoteRepositories", params ); + + System.out.println( "\n******** Remote Repositories ********" ); + for( int i = 0; i < remoteRepos.length; i++ ) + { + System.out.println( "=================================" ); + RemoteRepository remoteRepo = new RemoteRepository(); + + try + { + BeanUtils.populate( remoteRepo, (Map) remoteRepos[i] ); + } + catch ( IllegalAccessException e ) + { + e.printStackTrace(); + } + catch ( InvocationTargetException e ) + { + e.printStackTrace(); + } + System.out.println( "Id: " + remoteRepo.getId() ); + System.out.println( "Name: " + remoteRepo.getName() ); + System.out.println( "Layout: " + remoteRepo.getLayout() ); + System.out.println( "URL: " + remoteRepo.getUrl() ); + } + + /* repo consumers */ + params = new Object[]{}; + Object[] repoConsumers = (Object[]) + client.execute( "AdministrationService.getAllRepositoryConsumers", params ); + + System.out.println( "\n******** Repository Consumers ********" ); + for( int i = 0; i < repoConsumers.length; i++ ) + { + System.out.println( repoConsumers[i] ); + } + + /* db consumers */ + params = new Object[]{}; + Object[] dbConsumers = (Object[]) + client.execute( "AdministrationService.getAllDatabaseConsumers", params ); + + System.out.println( "\n******** Database Consumers ********" ); + for( int i = 0; i < dbConsumers.length; i++ ) + { + System.out.println( dbConsumers[i] ); + } + + /* configure repo consumer */ + Object[] configureRepoConsumerParams = new Object[] { "internal", "repository-purge", true }; + Object configured = client.execute( "AdministrationService.configureRepositoryConsumer", configureRepoConsumerParams ); + System.out.println( "\nConfigured repo consumer 'repository-purge' : " + ( ( Boolean ) configured ).booleanValue() ); + + + /* configure db consumer */ + Object[] configureDbConsumerParams = new Object[] { "update-db-bytecode-stats", false }; + configured = client.execute( "AdministrationService.configureDatabaseConsumer", configureDbConsumerParams ); + System.out.println( "\nConfigured db consumer 'update-db-bytecode-stats' : " + ( ( Boolean ) configured ).booleanValue() ); + + + /* execute repo scanner */ + Object[] executeRepoScanParams = new Object[] { "internal" }; + configured = client.execute( "AdministrationService.executeRepositoryScanner", executeRepoScanParams ); + System.out.println( "\nExecuted repo scanner of repository 'internal' : " + ( ( Boolean ) configured ).booleanValue() ); + + + /* execute db scanner */ + Object[] executeDbScanParams = new Object[] {}; + configured = client.execute( "AdministrationService.executeDatabaseScanner", executeDbScanParams ); + System.out.println( "\nExecuted database scanner : " + ( ( Boolean ) configured ).booleanValue() ); + + /* delete artifact */ + /* + * NOTE: before enabling & invoking deleteArtifact, make sure that the repository and artifact exists first! + Object[] deleteArtifactParams = new Object[] { "internal", "javax.activation", "activation", "1.1" }; + Object artifactDeleted = client.execute( "AdministrationService.deleteArtifact", deleteArtifactParams ); + System.out.println( "\nDeleted artifact 'javax.activation:activation:1.1' from repository 'internal' : " + + ( (Boolean) artifactDeleted ).booleanValue() ); + */ + } + catch ( MalformedURLException e ) + { + e.printStackTrace(); + } + catch ( XmlRpcException e ) + { + e.printStackTrace(); + } + } +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml new file mode 100644 index 000000000..8736f8071 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml @@ -0,0 +1,83 @@ + + + + + + 4.0.0 + + org.apache.archiva + archiva-xmlrpc + 1.2-SNAPSHOT + ../pom.xml + + archiva-xmlrpc-security + Archiva Web :: XML-RPC Security + + + org.apache.xmlrpc + xmlrpc-server + + + commons-logging + commons-logging + + + + + org.codehaus.redback + redback-system + + + org.apache.archiva + archiva-security + + + org.codehaus.plexus + plexus-spring + test + + + + org.codehaus.redback + redback-authorization-rbac + test + + + org.codehaus.redback + redback-keys-memory + test + + + org.codehaus.redback + redback-users-memory + test + + + org.codehaus.redback + redback-rbac-memory + test + + + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java new file mode 100644 index 000000000..333b4218e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java @@ -0,0 +1,69 @@ +package org.apache.archiva.web.xmlrpc.security; + + +/* + * 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.ArrayList; +import java.util.List; + +/** + * ServiceMethodsPermissionsMapping + * + * Used by the XmlRpcAuthenticationHandler to check the permissions specific to the requested service method. + * New methods in exposed services must be registered in the appropriate operation below. + * + * @version $Id: ServiceMethodsPermissionsMapping.java + */ +public class ServiceMethodsPermissionsMapping +{ + public static final List SERVICE_METHODS_FOR_OPERATION_MANAGE_CONFIGURATION = new ArrayList() + { + { + add( "AdministrationService.configureRepositoryConsumer" ); + add( "AdministrationService.configureDatabaseConsumer" ); + add( "AdministrationService.executeDatabaseScanner" ); + add( "AdministrationService.getAllManagedRepositories" ); + add( "AdministrationService.getAllRemoteRepositories" ); + add( "AdministrationService.getAllDatabaseConsumers" ); + add( "AdministrationService.getAllRepositoryConsumers" ); + add( "AdministrationService.deleteArtifact" ); + } + }; + + public static final List SERVICE_METHODS_FOR_OPERATION_RUN_INDEXER = new ArrayList() + { + { + add( "AdministrationService.executeRepositoryScanner"); + } + }; + + public static final List SERVICE_METHODS_FOR_OPERATION_ACCESS_REPORT = new ArrayList(); + + public static final List SERVICE_METHODS_FOR_OPERATION_REPOSITORY_ACCESS = new ArrayList(); + + public static final List SERVICE_METHODS_FOR_OPERATION_ADD_REPOSITORY = new ArrayList(); + + public static final List SERVICE_METHODS_FOR_OPERATION_DELETE_REPOSITORY = new ArrayList(); + + public static final List SERVICE_METHODS_FOR_OPERATION_EDIT_REPOSITORY = new ArrayList(); + + public static final List SERVICE_METHODS_FOR_OPERATION_REPOSITORY_UPLOAD = new ArrayList(); + +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java new file mode 100644 index 000000000..40ee2fd6f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java @@ -0,0 +1,117 @@ +package org.apache.archiva.web.xmlrpc.security; + +/* + * 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.maven.archiva.security.ArchivaRoleConstants; +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcRequest; +import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; +import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.AuthenticationHandler; +import org.codehaus.plexus.redback.authentication.AuthenticationException; +import org.codehaus.plexus.redback.authentication.PasswordBasedAuthenticationDataSource; +import org.codehaus.plexus.redback.authorization.AuthorizationException; +import org.codehaus.plexus.redback.authorization.AuthorizationResult; +import org.codehaus.plexus.redback.policy.AccountLockedException; +import org.codehaus.plexus.redback.system.SecuritySession; +import org.codehaus.plexus.redback.system.SecuritySystem; +import org.codehaus.plexus.redback.users.UserNotFoundException; + +/** + * XmlRpcAuthenticator + * + * Custom authentication and authorization handler for xmlrpc requests. + * + * @version $Id + */ +public class XmlRpcAuthenticator + implements AuthenticationHandler +{ + private final SecuritySystem securitySystem; + + public XmlRpcAuthenticator( SecuritySystem securitySystem ) + { + this.securitySystem = securitySystem; + } + + public boolean isAuthorized( XmlRpcRequest pRequest ) + throws XmlRpcException + { + if ( pRequest.getConfig() instanceof XmlRpcHttpRequestConfigImpl ) + { + XmlRpcHttpRequestConfigImpl config = (XmlRpcHttpRequestConfigImpl) pRequest.getConfig(); + SecuritySession session = + authenticate( new PasswordBasedAuthenticationDataSource( config.getBasicUserName(), + config.getBasicPassword() ) ); + String method = pRequest.getMethodName(); + AuthorizationResult result = authorize( session, method ); + + return result.isAuthorized(); + } + + throw new XmlRpcException( "Unsupported transport (must be http)" ); + } + + private SecuritySession authenticate( PasswordBasedAuthenticationDataSource authenticationDataSource ) + throws XmlRpcException + { + try + { + return securitySystem.authenticate( authenticationDataSource ); + } + catch ( AccountLockedException e ) + { + throw new XmlRpcException( 401, e.getMessage(), e ); + } + catch ( AuthenticationException e ) + { + throw new XmlRpcException( 401, e.getMessage(), e ); + } + catch ( UserNotFoundException e ) + { + throw new XmlRpcException( 401, e.getMessage(), e ); + } + } + + private AuthorizationResult authorize( SecuritySession session, String methodName ) + throws XmlRpcException + { + try + { + // sample attempt at simplifying authorization checking of requested service method + // TODO test with a sample client to see if this would work! + if ( ServiceMethodsPermissionsMapping.SERVICE_METHODS_FOR_OPERATION_MANAGE_CONFIGURATION.contains( methodName ) ) + { + return securitySystem.authorize( session, ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ); + } + else if ( ServiceMethodsPermissionsMapping.SERVICE_METHODS_FOR_OPERATION_RUN_INDEXER.contains( methodName ) ) + { + return securitySystem.authorize( session, ArchivaRoleConstants.OPERATION_RUN_INDEXER ); + } + else + { + return securitySystem.authorize( session, ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE ); + } + } + catch ( AuthorizationException e ) + { + throw new XmlRpcException( 401, e.getMessage(), e ); + } + } +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java new file mode 100644 index 000000000..721aa828d --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java @@ -0,0 +1,220 @@ +package org.apache.archiva.xmlrpc.security; + +/* + * 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.web.xmlrpc.security.XmlRpcAuthenticator; +import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.xmlrpc.XmlRpcRequest; +import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; +import org.codehaus.plexus.redback.role.RoleManager; +import org.codehaus.plexus.redback.system.SecuritySystem; +import org.codehaus.plexus.redback.users.User; +import org.codehaus.plexus.redback.users.UserManager; +import org.codehaus.plexus.redback.users.UserNotFoundException; +import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.easymock.MockControl; +import org.easymock.classextension.MockClassControl; + +/** + * XmlRpcAuthenticatorTest + * + * @version $Id XmlRpcAuthenticatorTest.java + */ +public class XmlRpcAuthenticatorTest +//extends AbstractDependencyInjectionSpringContextTests + extends PlexusInSpringTestCase +{ + protected static final String USER_GUEST = "guest"; + + protected static final String USER_ADMIN = "admin"; + + protected static final String USER_ALPACA = "alpaca"; + + private static final String PASSWORD = "password123"; + + protected SecuritySystem securitySystem; + + protected RoleManager roleManager; + + private MockControl xmlRpcRequestControl; + + private XmlRpcRequest xmlRpcRequest; + + private XmlRpcAuthenticator authenticator; + + private MockControl configControl; + + private XmlRpcHttpRequestConfigImpl config; + + public void setUp() + throws Exception + { + super.setUp(); + + securitySystem = (SecuritySystem) lookup( SecuritySystem.class, "testable" ); + roleManager = (RoleManager) lookup( RoleManager.class, "default" ); + + // Some basic asserts. + assertNotNull( securitySystem ); + assertNotNull( roleManager ); + + // Setup Admin User. + User adminUser = createUser( USER_ADMIN, "Admin User", null ); + roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN, adminUser.getPrincipal().toString() ); + + // Setup Guest User. + User guestUser = createUser( USER_GUEST, "Guest User", null ); + roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, guestUser.getPrincipal().toString() ); + + configControl = MockClassControl.createControl( XmlRpcHttpRequestConfigImpl.class ); + config = ( XmlRpcHttpRequestConfigImpl ) configControl.getMock(); + + xmlRpcRequestControl = MockControl.createControl( XmlRpcRequest.class ); + xmlRpcRequest = ( XmlRpcRequest ) xmlRpcRequestControl.getMock(); + + authenticator = new XmlRpcAuthenticator( securitySystem ); + } + + private User createUser( String principal, String fullname, String password ) + throws UserNotFoundException + { + UserManager userManager = securitySystem.getUserManager(); + + User user = userManager.createUser( principal, fullname, principal + "@testable.archiva.apache.org" ); + securitySystem.getPolicy().setEnabled( false ); + userManager.addUser( user ); + securitySystem.getPolicy().setEnabled( true ); + + user.setPassword( password ); + userManager.updateUser( user ); + + return user; + } + + public void testIsAuthorizedUserExistsButNotAuthorized() + throws Exception + { + createUser( USER_ALPACA, "Al 'Archiva' Paca", PASSWORD ); + + UserManager userManager = securitySystem.getUserManager(); + try + { + User user = userManager.findUser( USER_ALPACA ); + assertEquals( USER_ALPACA, user.getPrincipal() ); + } + catch ( UserNotFoundException e ) + { + fail( "User should exist in the database." ); + } + + xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getConfig(), config, 2 ); + + configControl.expectAndReturn( config.getBasicUserName(), USER_ALPACA ); + + configControl.expectAndReturn( config.getBasicPassword(), PASSWORD ); + + xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getMethodName(), + "AdministrationService.getAllManagedRepositories" ); + + xmlRpcRequestControl.replay(); + configControl.replay(); + + boolean isAuthorized = authenticator.isAuthorized( xmlRpcRequest ); + + xmlRpcRequestControl.verify(); + configControl.verify(); + + assertFalse( isAuthorized ); + } + + public void testIsAuthorizedUserExistsAndAuthorized() + throws Exception + { + createUser( USER_ALPACA, "Al 'Archiva' Paca", PASSWORD ); + + UserManager userManager = securitySystem.getUserManager(); + try + { + User user = userManager.findUser( USER_ALPACA ); + assertEquals( USER_ALPACA, user.getPrincipal() ); + } + catch ( UserNotFoundException e ) + { + fail( "User should exist in the database." ); + } + + //TODO cannot assign global repo manager role - it says role does not exist :| + + //roleManager.assignRole( ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE, USER_ALPACA ); + + xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getConfig(), config, 2 ); + + configControl.expectAndReturn( config.getBasicUserName(), USER_ALPACA ); + + configControl.expectAndReturn( config.getBasicPassword(), PASSWORD ); + + xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getMethodName(), + "AdministrationService.getAllManagedRepositories" ); + + xmlRpcRequestControl.replay(); + configControl.replay(); + + boolean isAuthorized = authenticator.isAuthorized( xmlRpcRequest ); + + xmlRpcRequestControl.verify(); + configControl.verify(); + + //assertTrue( isAuthorized ); + } + + public void testIsAuthorizedUserDoesNotExist() + throws Exception + { + UserManager userManager = securitySystem.getUserManager(); + try + { + userManager.findUser( USER_ALPACA ); + fail( "User should not exist in the database." ); + } + catch ( UserNotFoundException e ) + { + assertEquals( "Unable to find user 'alpaca'", e.getMessage() ); + } + + xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getConfig(), config, 2 ); + + configControl.expectAndReturn( config.getBasicUserName(), USER_ALPACA ); + + configControl.expectAndReturn( config.getBasicPassword(), PASSWORD ); + + xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getMethodName(), + "AdministrationService.getAllManagedRepositories" ); + + xmlRpcRequestControl.replay(); + configControl.replay(); + + boolean isAuthorized = authenticator.isAuthorized( xmlRpcRequest ); + + xmlRpcRequestControl.verify(); + configControl.verify(); + + assertFalse( isAuthorized ); + } +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/META-INF/redback/redback-core.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/META-INF/redback/redback-core.xml new file mode 100644 index 000000000..289043991 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/META-INF/redback/redback-core.xml @@ -0,0 +1,210 @@ + + 1.0.0 + + + Redback XWork Integration Security Core + 1.0 + + + global + * + true + + global resource implies full access for authorization + + + + username + ${username} + true + + replaced with the username of the principal at authorization + check time + + + + + + configuration-edit + configuration-edit + edit configuration + true + + + user-management-user-create + user-management-user-create + create user + true + + + user-management-user-edit + user-management-user-edit + edit user + true + + + user-management-user-role + user-management-user-role + user roles + true + + + user-management-user-delete + user-management-user-delete + delete user + true + + + user-management-user-list + user-management-user-list + list users + true + + + user-management-role-grant + user-management-role-grant + grant role + true + + + user-management-role-drop + user-management-role-drop + drop role + true + + + user-management-rbac-admin + user-management-rbac-admin + administer rbac + true + + + guest-access + guest-access + access guest + true + + + add-repository + add-repository + add repository + true + + + + + system-administrator + System Administrator + true + true + + + edit-redback-configuration + Edit Redback Configuration + configuration-edit + global + true + + + manage-rbac-setup + User RBAC Management + user-management-rbac-admin + global + true + + + + user-administrator + + + + user-administrator + User Administrator + true + true + + + drop-roles-for-anyone + Drop Roles for Anyone + user-management-role-drop + global + true + + + grant-roles-for-anyone + Grant Roles for Anyone + user-management-role-grant + global + true + + + user-create + Create Users + user-management-user-create + global + true + + + user-delete + Delete Users + user-management-user-delete + global + true + + + user-edit + Edit Users + user-management-user-edit + global + true + + + access-users-roles + Access Users Roles + user-management-user-role + global + true + + + access-user-list + Access User List + user-management-user-list + global + true + + + + + registered-user + Registered User + true + true + + + edit-user-by-username + Edit User Data by Username + user-management-user-edit + username + true + + + + + guest + Guest + true + true + + + guest-permission + Guest Permission + guest-access + global + true + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml new file mode 100644 index 000000000..9c7b9344f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml @@ -0,0 +1,192 @@ + + + + + + + + org.codehaus.plexus.redback.system.SecuritySystem + testable + org.codehaus.plexus.redback.system.DefaultSecuritySystem + DefaultSecuritySystem: + + + org.codehaus.plexus.redback.authentication.AuthenticationManager + authnManager + + + org.codehaus.plexus.redback.authorization.Authorizer + rbac + authorizer + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + org.codehaus.plexus.redback.keys.KeyManager + memory + keyManager + + + org.codehaus.plexus.redback.policy.UserSecurityPolicy + policy + + + + + + org.codehaus.plexus.redback.authorization.Authorizer + rbac + org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer + RbacAuthorizer: + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + manager + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator + default + evaluator + + + org.codehaus.plexus.redback.configuration.UserConfiguration + default + config + + + + + + org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator + default + org.codehaus.plexus.redback.authorization.rbac.evaluator.DefaultPermissionEvaluator + + + org.codehaus.plexus.redback.users.UserManager + memory + userManager + + + + + + org.codehaus.plexus.redback.role.RoleManager + default + org.codehaus.plexus.redback.role.DefaultRoleManager + RoleProfileManager: + + + org.codehaus.plexus.redback.role.validator.RoleModelValidator + default + modelValidator + + + org.codehaus.plexus.redback.role.processor.RoleModelProcessor + default + modelProcessor + + + org.codehaus.plexus.redback.role.template.RoleTemplateProcessor + default + templateProcessor + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + rbacManager + + + + + + org.codehaus.plexus.redback.role.processor.RoleModelProcessor + default + org.codehaus.plexus.redback.role.processor.DefaultRoleModelProcessor + DefaultRoleModelProcessor: inserts the components of the model that can be populated into the rbac manager + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + rbacManager + + + + + + org.codehaus.plexus.redback.role.template.RoleTemplateProcessor + default + org.codehaus.plexus.redback.role.template.DefaultRoleTemplateProcessor + DefaultRoleTemplateProcessor: inserts the components of a template into the rbac manager + + + org.codehaus.plexus.redback.rbac.RBACManager + memory + rbacManager + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml new file mode 100644 index 000000000..8d68c8df3 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml @@ -0,0 +1,60 @@ + + + + + + 4.0.0 + + org.apache.archiva + archiva-xmlrpc + 1.2-SNAPSHOT + ../pom.xml + + archiva-xmlrpc-services + Archiva Web :: XML-RPC Services + + + org.apache.archiva + archiva-xmlrpc-api + + + org.apache.archiva + archiva-configuration + + + org.apache.archiva + archiva-scheduled + + + javax.servlet + servlet-api + + + org.springframework + spring-web + + + org.codehaus.plexus + plexus-spring + + + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java new file mode 100644 index 000000000..7bb2882b2 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -0,0 +1,440 @@ +package org.apache.archiva.web.xmlrpc.services; + +/* + * 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.ArrayList; +import java.util.List; + +import org.apache.archiva.web.xmlrpc.api.AdministrationService; +import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; +import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; +import org.apache.maven.archiva.consumers.ConsumerException; +import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer; +import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer; +import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; +import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; +import org.apache.maven.archiva.database.ArchivaDatabaseException; +import org.apache.maven.archiva.database.ArtifactDAO; +import org.apache.maven.archiva.database.constraints.ArtifactVersionsConstraint; +import org.apache.maven.archiva.database.updater.DatabaseConsumers; +import org.apache.maven.archiva.model.ArchivaArtifact; +import org.apache.maven.archiva.model.VersionedReference; +import org.apache.maven.archiva.repository.ContentNotFoundException; +import org.apache.maven.archiva.repository.ManagedRepositoryContent; +import org.apache.maven.archiva.repository.RepositoryContentFactory; +import org.apache.maven.archiva.repository.RepositoryException; +import org.apache.maven.archiva.repository.RepositoryNotFoundException; +import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers; +import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; +import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler; +import org.apache.maven.archiva.scheduled.tasks.ArchivaTask; +import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; +import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; +import org.codehaus.plexus.registry.RegistryException; + +/** + * AdministrationServiceImpl + * + * @version $Id: AdministrationServiceImpl.java + */ +public class AdministrationServiceImpl + implements AdministrationService +{ + private ArchivaConfiguration archivaConfiguration; + + private RepositoryContentConsumers repoConsumersUtil; + + private DatabaseConsumers dbConsumersUtil; + + private RepositoryContentFactory repoFactory; + + private ArtifactDAO artifactDAO; + + private DatabaseCleanupConsumer cleanupArtifacts; + + private DatabaseCleanupConsumer cleanupProjects; + + private ArchivaTaskScheduler taskScheduler; + + public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, + DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory, + ArtifactDAO artifactDAO, DatabaseCleanupConsumer cleanupArtifacts, + DatabaseCleanupConsumer cleanupProjects, ArchivaTaskScheduler taskScheduler ) + { + this.archivaConfiguration = archivaConfig; + this.repoConsumersUtil = repoConsumersUtil; + this.dbConsumersUtil = dbConsumersUtil; + this.repoFactory = repoFactory; + this.artifactDAO = artifactDAO; + this.cleanupArtifacts = cleanupArtifacts; + this.cleanupProjects = cleanupProjects; + this.taskScheduler = taskScheduler; + } + + /** + * @see AdministrationService#configureDatabaseConsumer(String, boolean) + */ + public Boolean configureDatabaseConsumer( String consumerId, boolean enable ) throws Exception + { + List cleanupConsumers = dbConsumersUtil.getAvailableCleanupConsumers(); + List unprocessedConsumers = + dbConsumersUtil.getAvailableUnprocessedConsumers(); + + boolean found = false; + boolean isCleanupConsumer = false; + for( DatabaseCleanupConsumer consumer : cleanupConsumers ) + { + if( consumer.getId().equals( consumerId ) ) + { + found = true; + isCleanupConsumer = true; + break; + } + } + + if( !found ) + { + for( DatabaseUnprocessedArtifactConsumer consumer : unprocessedConsumers ) + { + if( consumer.getId().equals( consumerId ) ) + { + found = true; + break; + } + } + } + + if( !found ) + { + throw new Exception( "Invalid database consumer." ); + } + + Configuration config = archivaConfiguration.getConfiguration(); + DatabaseScanningConfiguration dbScanningConfig = config.getDatabaseScanning(); + + if( isCleanupConsumer ) + { + dbScanningConfig.addCleanupConsumer( consumerId ); + } + else + { + dbScanningConfig.addUnprocessedConsumer( consumerId ); + } + + config.setDatabaseScanning( dbScanningConfig ); + saveConfiguration( config ); + + return new Boolean( true ); + } + + /** + * @see AdministrationService#configureRepositoryConsumer(String, String, boolean) + */ + public Boolean configureRepositoryConsumer( String repoId, String consumerId, boolean enable ) + throws Exception + { + // TODO use repoId once consumers are configured per repository! (MRM-930) + + List knownConsumers = repoConsumersUtil.getAvailableKnownConsumers(); + List invalidConsumers = repoConsumersUtil.getAvailableInvalidConsumers(); + + boolean found = false; + boolean isKnownContentConsumer = false; + for( KnownRepositoryContentConsumer consumer : knownConsumers ) + { + if( consumer.getId().equals( consumerId ) ) + { + found = true; + isKnownContentConsumer = true; + break; + } + } + + if( !found ) + { + for( InvalidRepositoryContentConsumer consumer : invalidConsumers ) + { + if( consumer.getId().equals( consumerId ) ) + { + found = true; + break; + } + } + } + + if( !found ) + { + throw new Exception( "Invalid repository consumer." ); + } + + Configuration config = archivaConfiguration.getConfiguration(); + RepositoryScanningConfiguration repoScanningConfig = config.getRepositoryScanning(); + + if( isKnownContentConsumer ) + { + repoScanningConfig.addKnownContentConsumer( consumerId ); + } + else + { + repoScanningConfig.addInvalidContentConsumer( consumerId ); + } + + config.setRepositoryScanning( repoScanningConfig ); + saveConfiguration( config ); + + return new Boolean( true ); + } + + /** + * @see AdministrationService#deleteArtifact(String, String, String, String) + */ + public Boolean deleteArtifact( String repoId, String groupId, String artifactId, String version ) + throws Exception + { + Configuration config = archivaConfiguration.getConfiguration(); + ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repoId ); + + if( repoConfig == null ) + { + throw new Exception( "Repository does not exist." ); + } + + try + { + ManagedRepositoryContent repoContent = repoFactory.getManagedRepositoryContent( repoId ); + VersionedReference ref = new VersionedReference(); + ref.setGroupId( groupId ); + ref.setArtifactId( artifactId ); + ref.setVersion( version ); + + // delete from file system + repoContent.deleteVersion( ref ); + + ArtifactVersionsConstraint constraint = new ArtifactVersionsConstraint( repoId, groupId, artifactId, false ); + List artifacts = null; + + try + { + artifacts = artifactDAO.queryArtifacts( constraint ); + if( artifacts == null ) + { + return true; + } + } + catch ( ArchivaDatabaseException e ) + { + throw new Exception( "Error occurred while cleaning up database." ); + } + + // cleanup db manually? or use the cleanup consumers as what is done now? + for( ArchivaArtifact artifact : artifacts ) + { + if( artifact.getVersion().equals( version ) ) + { + try + { + cleanupArtifacts.processArchivaArtifact( artifact ); + cleanupProjects.processArchivaArtifact( artifact ); + } + catch ( ConsumerException ce ) + { + // log error + continue; + } + } + } + } + catch ( ContentNotFoundException e ) + { + throw new Exception( "Artifact does not exist." ); + } + catch ( RepositoryNotFoundException e ) + { + throw new Exception( "Repository does not exist." ); + } + catch ( RepositoryException e ) + { + throw new Exception( "Repository exception occurred." ); + } + + return new Boolean( true ); + } + + /** + * @see AdministrationService#executeDatabaseScanner() + */ + public Boolean executeDatabaseScanner() throws Exception + { + if ( taskScheduler.isProcessingDatabaseTask() ) + { + return false; + } + + DatabaseTask task = new DatabaseTask(); + task.setName( DefaultArchivaTaskScheduler.DATABASE_JOB + ":user-requested-via-web-service" ); + task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT ); + + taskScheduler.queueDatabaseTask( task ); + + return new Boolean( true ); + } + + /** + * @see AdministrationService#executeRepositoryScanner(String) + */ + public Boolean executeRepositoryScanner( String repoId ) throws Exception + { + Configuration config = archivaConfiguration.getConfiguration(); + if( config.findManagedRepositoryById( repoId ) == null ) + { + throw new Exception( "Repository does not exist." ); + } + + if ( taskScheduler.isProcessingAnyRepositoryTask() ) + { + if ( taskScheduler.isProcessingRepositoryTask( repoId ) ) + { + return false; + } + } + + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repoId ); + task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repoId ); + task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT ); + + taskScheduler.queueRepositoryTask( task ); + + return new Boolean( true ); + } + + /** + * @see AdministrationService#getAllDatabaseConsumers() + */ + public List getAllDatabaseConsumers() + { + List consumers = new ArrayList(); + + List cleanupConsumers = dbConsumersUtil.getAvailableCleanupConsumers(); + List unprocessedConsumers = dbConsumersUtil.getAvailableUnprocessedConsumers(); + + for( DatabaseCleanupConsumer consumer : cleanupConsumers ) + { + consumers.add( consumer.getId() ); + } + + for( DatabaseUnprocessedArtifactConsumer consumer : unprocessedConsumers ) + { + consumers.add( consumer.getId() ); + } + + return consumers; + } + + /** + * @see AdministrationService#getAllRepositoryConsumers() + */ + public List getAllRepositoryConsumers() + { + List consumers = new ArrayList(); + + List knownConsumers = repoConsumersUtil.getAvailableKnownConsumers(); + List invalidConsumers = repoConsumersUtil.getAvailableInvalidConsumers(); + + for( KnownRepositoryContentConsumer consumer : knownConsumers ) + { + consumers.add( consumer.getId() ); + } + + for( InvalidRepositoryContentConsumer consumer : invalidConsumers ) + { + consumers.add( consumer.getId() ); + } + + return consumers; + } + + /** + * @see AdministrationService#getAllManagedRepositories() + */ + public List getAllManagedRepositories() + { + List managedRepos = new ArrayList(); + + Configuration config = archivaConfiguration.getConfiguration(); + List managedRepoConfigs = config.getManagedRepositories(); + + for( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs ) + { + // TODO fix resolution of repo url! + ManagedRepository repo = + new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL", repoConfig.getLayout(), + repoConfig.isSnapshots(), repoConfig.isReleases() ); + managedRepos.add( repo ); + } + + return managedRepos; + } + + /** + * @see AdministrationService#getAllRemoteRepositories() + */ + public List getAllRemoteRepositories() + { + List remoteRepos = new ArrayList(); + + Configuration config = archivaConfiguration.getConfiguration(); + List remoteRepoConfigs = config.getRemoteRepositories(); + + for( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs ) + { + RemoteRepository repo = + new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(), + repoConfig.getLayout() ); + remoteRepos.add( repo ); + } + + return remoteRepos; + } + + private void saveConfiguration( Configuration config ) + throws Exception + { + try + { + archivaConfiguration.save( config ); + } + catch( RegistryException e ) + { + throw new Exception( "Error occurred in the registry." ); + } + catch ( IndeterminateConfigurationException e ) + { + throw new Exception( "Error occurred while saving the configuration." ); + } + } +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java new file mode 100644 index 000000000..aa47f5f0e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java @@ -0,0 +1,30 @@ +package org.apache.archiva.web.xmlrpc.services; + +/* + * 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.web.xmlrpc.api.TestService; + +public class PingServiceImpl implements TestService +{ + public String ping() + { + return "pong"; + } +} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java new file mode 100644 index 000000000..a7f85f7e1 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -0,0 +1,954 @@ +package org.apache.archiva.web.xmlrpc.services; + +/* + * 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.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; +import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; +import org.apache.maven.archiva.configuration.FileTypes; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; +import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer; +import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer; +import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; +import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; +import org.apache.maven.archiva.database.ArtifactDAO; +import org.apache.maven.archiva.database.updater.DatabaseConsumers; +import org.apache.maven.archiva.model.ArchivaArtifact; +import org.apache.maven.archiva.model.ArchivaArtifactModel; +import org.apache.maven.archiva.model.ArtifactReference; +import org.apache.maven.archiva.repository.RepositoryContentFactory; +import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; +import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent; +import org.apache.maven.archiva.repository.content.PathParser; +import org.apache.maven.archiva.repository.layout.LayoutException; +import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers; +import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; +import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; +import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; +import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.easymock.MockControl; +import org.easymock.classextension.MockClassControl; + +/** + * AdministrationServiceImplTest + * + * @version $Id: AdministrationServiceImplTest.java + */ +public class AdministrationServiceImplTest + extends PlexusInSpringTestCase +{ + private MockControl archivaConfigControl; + + private ArchivaConfiguration archivaConfig; + + private MockControl configControl; + + private Configuration config; + + private AdministrationServiceImpl service; + + private MockControl taskSchedulerControl; + + private ArchivaTaskScheduler taskScheduler; + + // repository consumers + private MockControl repoConsumerUtilsControl; + + private RepositoryContentConsumers repoConsumersUtil; + + private MockControl knownContentConsumerControl; + + private MockControl invalidContentConsumerControl; + + private KnownRepositoryContentConsumer indexArtifactConsumer; + + private KnownRepositoryContentConsumer indexPomConsumer; + + private InvalidRepositoryContentConsumer checkPomConsumer; + + private InvalidRepositoryContentConsumer checkMetadataConsumer; + + // database consumers + private MockControl dbConsumersUtilControl; + + private DatabaseConsumers dbConsumersUtil; + + private MockControl unprocessedConsumersControl; + + private MockControl cleanupConsumersControl; + + private DatabaseUnprocessedArtifactConsumer processArtifactConsumer; + + private DatabaseUnprocessedArtifactConsumer processPomConsumer; + + private DatabaseCleanupConsumer cleanupIndexConsumer; + + private DatabaseCleanupConsumer cleanupDbConsumer; + + // delete artifact + private MockControl repoFactoryControl; + + private RepositoryContentFactory repositoryFactory; + + private MockControl artifactDaoControl; + + private ArtifactDAO artifactDao; + + private MockControl cleanupControl; + + private DatabaseCleanupConsumer cleanupConsumer; + + protected void setUp() + throws Exception + { + super.setUp(); + + archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class ); + archivaConfig = ( ArchivaConfiguration ) archivaConfigControl.getMock(); + + configControl = MockClassControl.createControl( Configuration.class ); + config = ( Configuration ) configControl.getMock(); + + taskSchedulerControl = MockControl.createControl( ArchivaTaskScheduler.class ); + taskScheduler = ( ArchivaTaskScheduler ) taskSchedulerControl.getMock(); + + // repo consumers + repoConsumerUtilsControl = MockClassControl.createControl( RepositoryContentConsumers.class ); + repoConsumersUtil = ( RepositoryContentConsumers ) repoConsumerUtilsControl.getMock(); + + knownContentConsumerControl = MockControl.createControl( KnownRepositoryContentConsumer.class ); + indexArtifactConsumer = ( KnownRepositoryContentConsumer ) knownContentConsumerControl.getMock(); + indexPomConsumer = ( KnownRepositoryContentConsumer ) knownContentConsumerControl.getMock(); + + invalidContentConsumerControl = MockControl.createControl( InvalidRepositoryContentConsumer.class ); + checkPomConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock(); + checkMetadataConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock(); + + // db consumers + dbConsumersUtilControl = MockClassControl.createControl( DatabaseConsumers.class ); + dbConsumersUtil = ( DatabaseConsumers ) dbConsumersUtilControl.getMock(); + + cleanupConsumersControl = MockControl.createControl( DatabaseCleanupConsumer.class ); + cleanupIndexConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock(); + cleanupDbConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock(); + + unprocessedConsumersControl = MockControl.createControl( DatabaseUnprocessedArtifactConsumer.class ); + processArtifactConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock(); + processPomConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock(); + + // delete artifact + repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class ); + repositoryFactory = ( RepositoryContentFactory ) repoFactoryControl.getMock(); + + artifactDaoControl = MockControl.createControl( ArtifactDAO.class ); + artifactDao = ( ArtifactDAO ) artifactDaoControl.getMock(); + + cleanupControl = MockClassControl.createControl( DatabaseCleanupConsumer.class ); + cleanupConsumer = ( DatabaseCleanupConsumer ) cleanupControl.getMock(); + + service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil, + repositoryFactory, artifactDao, cleanupConsumer, cleanupConsumer, taskScheduler ); + } + +/* Tests for database consumers */ + + public void testGetAllDbConsumers() + throws Exception + { + recordDbConsumers(); + + dbConsumersUtilControl.replay(); + cleanupConsumersControl.replay(); + unprocessedConsumersControl.replay(); + + List dbConsumers = service.getAllDatabaseConsumers(); + + dbConsumersUtilControl.verify(); + cleanupConsumersControl.verify(); + unprocessedConsumersControl.verify(); + + assertNotNull( dbConsumers ); + assertEquals( 4, dbConsumers.size() ); + assertTrue( dbConsumers.contains( "cleanup-index" ) ); + assertTrue( dbConsumers.contains( "cleanup-database" ) ); + assertTrue( dbConsumers.contains( "process-artifact" ) ); + assertTrue( dbConsumers.contains( "process-pom" ) ); + } + + public void testConfigureValidDatabaseConsumer() + throws Exception + { + DatabaseScanningConfiguration dbScanning = new DatabaseScanningConfiguration(); + dbScanning.addCleanupConsumer( "cleanup-index" ); + dbScanning.addCleanupConsumer( "cleanup-database" ); + dbScanning.addUnprocessedConsumer( "process-artifact" ); + + recordDbConsumers(); + + // test enable "process-pom" db consumer + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning ); + + config.setDatabaseScanning( dbScanning ); + configControl.setMatcher( MockControl.ALWAYS_MATCHER ); + configControl.setVoidCallable(); + + archivaConfig.save( config ); + archivaConfigControl.setVoidCallable(); + + dbConsumersUtilControl.replay(); + cleanupConsumersControl.replay(); + unprocessedConsumersControl.replay(); + archivaConfigControl.replay(); + configControl.replay(); + + try + { + boolean success = service.configureDatabaseConsumer( "process-pom", true ); + assertTrue( success ); + } + catch ( Exception e ) + { + fail( "An exception should not have been thrown." ); + } + + dbConsumersUtilControl.verify(); + cleanupConsumersControl.verify(); + unprocessedConsumersControl.verify(); + archivaConfigControl.verify(); + configControl.verify(); + + // test disable "process-pom" db consumer + dbConsumersUtilControl.reset(); + cleanupConsumersControl.reset(); + unprocessedConsumersControl.reset(); + archivaConfigControl.reset(); + configControl.reset(); + + dbScanning.addUnprocessedConsumer( "process-pom" ); + + recordDbConsumers(); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning ); + + config.setDatabaseScanning( dbScanning ); + configControl.setMatcher( MockControl.ALWAYS_MATCHER ); + configControl.setVoidCallable(); + + archivaConfig.save( config ); + archivaConfigControl.setVoidCallable(); + + dbConsumersUtilControl.replay(); + cleanupConsumersControl.replay(); + unprocessedConsumersControl.replay(); + archivaConfigControl.replay(); + configControl.replay(); + + try + { + boolean success = service.configureDatabaseConsumer( "process-pom", false ); + assertTrue( success ); + } + catch ( Exception e ) + { + fail( "An exception should not have been thrown." ); + } + + dbConsumersUtilControl.verify(); + cleanupConsumersControl.verify(); + unprocessedConsumersControl.verify(); + archivaConfigControl.verify(); + configControl.verify(); + } + + public void testConfigureInvalidDatabaseConsumer() + throws Exception + { + recordDbConsumers(); + + dbConsumersUtilControl.replay(); + cleanupConsumersControl.replay(); + unprocessedConsumersControl.replay(); + + try + { + service.configureDatabaseConsumer( "invalid-consumer", true ); + fail( "An exception should have been thrown." ); + } + catch ( Exception e ) + { + assertEquals( "Invalid database consumer.", e.getMessage() ); + } + + dbConsumersUtilControl.verify(); + cleanupConsumersControl.verify(); + unprocessedConsumersControl.verify(); + } + +/* Tests for repository consumers */ + + public void testGetAllRepoConsumers() + throws Exception + { + recordRepoConsumers(); + + repoConsumerUtilsControl.replay(); + knownContentConsumerControl.replay(); + invalidContentConsumerControl.replay(); + + List repoConsumers = service.getAllRepositoryConsumers(); + + repoConsumerUtilsControl.verify(); + knownContentConsumerControl.verify(); + invalidContentConsumerControl.verify(); + + assertNotNull( repoConsumers ); + assertEquals( 4, repoConsumers.size() ); + assertTrue( repoConsumers.contains( "index-artifact" ) ); + assertTrue( repoConsumers.contains( "index-pom" ) ); + assertTrue( repoConsumers.contains( "check-pom" ) ); + assertTrue( repoConsumers.contains( "check-metadata" ) ); + } + + public void testConfigureValidRepositoryConsumer() + throws Exception + { + RepositoryScanningConfiguration repoScanning = new RepositoryScanningConfiguration(); + repoScanning.addKnownContentConsumer( "index-artifact" ); + repoScanning.addKnownContentConsumer( "index-pom" ); + repoScanning.addInvalidContentConsumer( "check-pom" ); + + // test enable "check-metadata" consumer + recordRepoConsumers(); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning ); + + config.setRepositoryScanning( repoScanning ); + configControl.setMatcher( MockControl.ALWAYS_MATCHER ); + configControl.setVoidCallable(); + + archivaConfig.save( config ); + archivaConfigControl.setVoidCallable(); + + repoConsumerUtilsControl.replay(); + knownContentConsumerControl.replay(); + invalidContentConsumerControl.replay(); + archivaConfigControl.replay(); + configControl.replay(); + + try + { + boolean success = service.configureRepositoryConsumer( null, "check-metadata", true ); + assertTrue( success ); + } + catch ( Exception e ) + { + fail( "An exception should not have been thrown." ); + } + + repoConsumerUtilsControl.verify(); + knownContentConsumerControl.verify(); + invalidContentConsumerControl.verify(); + archivaConfigControl.verify(); + configControl.verify(); + + // test disable "check-metadata" consumer + repoConsumerUtilsControl.reset(); + knownContentConsumerControl.reset(); + invalidContentConsumerControl.reset(); + archivaConfigControl.reset(); + configControl.reset(); + + repoScanning.addInvalidContentConsumer( "check-metadata" ); + + recordRepoConsumers(); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning ); + + config.setRepositoryScanning( repoScanning ); + configControl.setMatcher( MockControl.ALWAYS_MATCHER ); + configControl.setVoidCallable(); + + archivaConfig.save( config ); + archivaConfigControl.setVoidCallable(); + + repoConsumerUtilsControl.replay(); + knownContentConsumerControl.replay(); + invalidContentConsumerControl.replay(); + archivaConfigControl.replay(); + configControl.replay(); + + try + { + boolean success = service.configureRepositoryConsumer( null, "check-metadata", false ); + + repoConsumerUtilsControl.verify(); + knownContentConsumerControl.verify(); + invalidContentConsumerControl.verify(); + archivaConfigControl.verify(); + configControl.verify(); + + assertTrue( success ); + } + catch ( Exception e ) + { + fail( "An excecption should not have been thrown." ); + } + } + + + public void testConfigureInvalidRepositoryConsumer() + throws Exception + { + recordRepoConsumers(); + + repoConsumerUtilsControl.replay(); + knownContentConsumerControl.replay(); + invalidContentConsumerControl.replay(); + + try + { + service.configureRepositoryConsumer( null, "invalid-consumer", true ); + fail( "An exception should have been thrown." ); + } + catch ( Exception e ) + { + assertEquals( "Invalid repository consumer.", e.getMessage() ); + } + + repoConsumerUtilsControl.verify(); + knownContentConsumerControl.verify(); + invalidContentConsumerControl.verify(); + } + +/* Tests for delete artifact */ + + public void testDeleteM2ArtifactArtifactExists() + throws Exception + { + File file = new File( getBasedir(), "/target/test-classes/default-repo/" ); + assertTrue( file.exists() ); + + ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "default", "Internal Repository", true, false ); + managedRepo.setLocation( file.getAbsolutePath() ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); + + ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(); + repoContent.setRepository( managedRepo ); + + repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent ); + + List artifacts = getArtifacts(); + + artifactDao.queryArtifacts( null ); + artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER ); + artifactDaoControl.setReturnValue( artifacts ); + + cleanupConsumer.processArchivaArtifact( artifacts.get( 0 ) ); + cleanupControl.setVoidCallable( 2 ); + + archivaConfigControl.replay(); + configControl.replay(); + repoFactoryControl.replay(); + artifactDaoControl.replay(); + cleanupControl.replay(); + + try + { + boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" ); + assertTrue( success ); + } + catch ( Exception e ) + { + fail( "An exception should not have been thrown." ); + } + + archivaConfigControl.verify(); + configControl.verify(); + repoFactoryControl.verify(); + artifactDaoControl.verify(); + cleanupControl.verify(); + + assertFalse( new File( getBasedir(), "/target/test-classes/default-repo/org/apache/archiva/archiva-test/1.0" ).exists() ); + assertTrue( new File( getBasedir(), "/target/test-classes/default-repo/org/apache/archiva/archiva-test/1.1" ).exists() ); + } + + public void testDeleteM1ArtifactArtifactExists() + throws Exception + { + MockControl fileTypesControl = MockClassControl.createControl( FileTypes.class ); + FileTypes fileTypes = ( FileTypes ) fileTypesControl.getMock(); + + MockControl pathParserControl = MockClassControl.createControl( PathParser.class ); + PathParser parser = ( PathParser ) pathParserControl.getMock(); + + File file = new File( getBasedir(), "/target/test-classes/legacy-repo/" ); + assertTrue( file.exists() ); + + ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "legacy", "Internal Repository", true, false ); + managedRepo.setLocation( file.getAbsolutePath() ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); + + ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent(); + repoContent.setRepository( managedRepo ); + repoContent.setFileTypes( fileTypes ); + repoContent.setLegacyPathParser( parser ); + + repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent ); + + recordInManagedLegacyRepoContent( fileTypesControl, fileTypes, pathParserControl, parser ); + + List artifacts = getArtifacts(); + + artifactDao.queryArtifacts( null ); + artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER ); + artifactDaoControl.setReturnValue( artifacts ); + + cleanupConsumer.processArchivaArtifact( artifacts.get( 0 ) ); + cleanupControl.setVoidCallable( 2 ); + + archivaConfigControl.replay(); + configControl.replay(); + repoFactoryControl.replay(); + artifactDaoControl.replay(); + cleanupControl.replay(); + fileTypesControl.replay(); + pathParserControl.replay(); + + try + { + boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" ); + assertTrue( success ); + } + catch ( Exception e ) + { + fail( "An exception should not have been thrown." ); + } + + archivaConfigControl.verify(); + configControl.verify(); + repoFactoryControl.verify(); + artifactDaoControl.verify(); + cleanupControl.verify(); + fileTypesControl.verify(); + pathParserControl.verify(); + + assertFalse( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar" ).exists() ); + assertFalse( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom" ).exists() ); + + assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar" ).exists() ); + assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar" ).exists() ); + assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom" ).exists() ); + assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom" ).exists() ); + } + + public void testDeleteArtifactArtifactDoesNotExist() + throws Exception + { + File file = new File( getBasedir(), "/target/test-classes/default-repo/" ); + assertTrue( file.exists() ); + + ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "default", "Internal Repository", true, false ); + managedRepo.setLocation( file.getAbsolutePath() ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); + + ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(); + repoContent.setRepository( managedRepo ); + + repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent ); + + archivaConfigControl.replay(); + configControl.replay(); + repoFactoryControl.replay(); + + try + { + service.deleteArtifact( "internal", "org.apache.archiva", "archiva-non-existing", "1.0" ); + fail( "An exception should have been thrown." ); + } + catch ( Exception e ) + { + assertEquals( "Artifact does not exist.", e.getMessage() ); + } + + archivaConfigControl.verify(); + configControl.verify(); + repoFactoryControl.verify(); + } + + public void testDeleteArtifacRepositoryDoesNotExist() + throws Exception + { + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.findManagedRepositoryById( "non-existing-repo" ), null ); + + archivaConfigControl.replay(); + configControl.replay(); + + try + { + service.deleteArtifact( "non-existing-repo", "org.apache.archiva", "archiva-test", "1.0" ); + fail( "An exception should have been thrown." ); + } + catch ( Exception e ) + { + assertEquals( "Repository does not exist.", e.getMessage() ); + } + + archivaConfigControl.verify(); + configControl.verify(); + } + +/* Tests for repository scanning */ + + public void testExecuteRepoScannerRepoExistsAndNotBeingScanned() + throws Exception + { + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), + createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); + + RepositoryTask task = new RepositoryTask(); + + taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingAnyRepositoryTask(), true ); + taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), false ); + + taskScheduler.queueRepositoryTask( task ); + taskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); + taskSchedulerControl.setVoidCallable(); + + archivaConfigControl.replay(); + configControl.replay(); + taskSchedulerControl.replay(); + + try + { + boolean success = service.executeRepositoryScanner( "internal" ); + assertTrue( success ); + } + catch ( Exception e ) + { + fail( "An exception should not have been thrown." ); + } + + archivaConfigControl.verify(); + configControl.verify(); + taskSchedulerControl.verify(); + } + + public void testExecuteRepoScannerRepoExistsButBeingScanned() + throws Exception + { + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), + createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); + + taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingAnyRepositoryTask(), true ); + taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), true); + + archivaConfigControl.replay(); + configControl.replay(); + taskSchedulerControl.replay(); + + try + { + boolean success = service.executeRepositoryScanner( "internal" ); + assertFalse( success ); + } + catch ( Exception e ) + { + fail( "An exception should not have been thrown." ); + } + + archivaConfigControl.verify(); + configControl.verify(); + taskSchedulerControl.verify(); + } + + public void testExecuteRepoScannerRepoDoesNotExist() + throws Exception + { + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), null ); + + archivaConfigControl.replay(); + configControl.replay(); + + try + { + service.executeRepositoryScanner( "internal" ); + fail( "An exception should have been thrown." ); + } + catch ( Exception e ) + { + assertEquals( "Repository does not exist.", e.getMessage() ); + } + + archivaConfigControl.verify(); + configControl.verify(); + } + +/* Tests for db scanning */ + + public void testExecuteDbScannerDbNotBeingScanned() + throws Exception + { + DatabaseTask task = new DatabaseTask(); + + taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingDatabaseTask(), false ); + + taskScheduler.queueDatabaseTask( task ); + taskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); + taskSchedulerControl.setVoidCallable(); + + taskSchedulerControl.replay(); + + boolean success = service.executeDatabaseScanner(); + + taskSchedulerControl.verify(); + + assertTrue( success ); + } + + public void testExecuteDbScannerDbIsBeingScanned() + throws Exception + { + taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingDatabaseTask(), true ); + + taskSchedulerControl.replay(); + + boolean success = service.executeDatabaseScanner(); + + taskSchedulerControl.verify(); + + assertFalse( success ); + } + +/* Tests for querying repositories */ + + public void testGetAllManagedRepositories() + throws Exception + { + List managedRepos = new ArrayList(); + managedRepos.add( createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); + managedRepos.add( createManagedRepo( "snapshots", "default", "Snapshots Repository", false, true ) ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.getManagedRepositories(), managedRepos ); + + archivaConfigControl.replay(); + configControl.replay(); + + List repos = service.getAllManagedRepositories(); + + archivaConfigControl.verify(); + configControl.verify(); + + assertNotNull( repos ); + assertEquals( 2, repos.size() ); + + assertManagedRepo( ( ManagedRepository ) repos.get( 0 ), managedRepos.get( 0 ) ); + assertManagedRepo( ( ManagedRepository ) repos.get( 1 ), managedRepos.get( 1 ) ); + } + + public void testGetAllRemoteRepositories() + throws Exception + { + List remoteRepos = new ArrayList(); + remoteRepos.add( createRemoteRepository( "central", "Central Repository", "default", "http://repo1.maven.org/maven2") ); + remoteRepos.add( createRemoteRepository( "dummy", "Dummy Remote Repository", "legacy", "http://dummy.com/dummy") ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + configControl.expectAndReturn( config.getRemoteRepositories(), remoteRepos ); + + archivaConfigControl.replay(); + configControl.replay(); + + List repos = service.getAllRemoteRepositories(); + + archivaConfigControl.verify(); + configControl.verify(); + + assertNotNull( repos ); + assertEquals( 2, repos.size() ); + + assertRemoteRepo( (RemoteRepository) repos.get( 0 ), remoteRepos.get( 0 ) ); + assertRemoteRepo( (RemoteRepository) repos.get( 1 ), remoteRepos.get( 1 ) ); + } + +/* private methods */ + + private void assertRemoteRepo( RemoteRepository remoteRepo, RemoteRepositoryConfiguration expectedRepoConfig ) + { + assertEquals( expectedRepoConfig.getId(), remoteRepo.getId() ); + assertEquals( expectedRepoConfig.getLayout(), remoteRepo.getLayout() ); + assertEquals( expectedRepoConfig.getName(), remoteRepo.getName() ); + assertEquals( expectedRepoConfig.getUrl(), remoteRepo.getUrl() ); + } + + private RemoteRepositoryConfiguration createRemoteRepository(String id, String name, String layout, String url) + { + RemoteRepositoryConfiguration remoteConfig = new RemoteRepositoryConfiguration(); + remoteConfig.setId( id ); + remoteConfig.setName( name ); + remoteConfig.setLayout( layout ); + remoteConfig.setUrl( url ); + + return remoteConfig; + } + + private void assertManagedRepo( ManagedRepository managedRepo, ManagedRepositoryConfiguration expectedRepoConfig ) + { + assertEquals( expectedRepoConfig.getId(), managedRepo.getId() ); + assertEquals( expectedRepoConfig.getLayout(), managedRepo.getLayout() ); + assertEquals( expectedRepoConfig.getName(), managedRepo.getName() ); + + //TODO enable assert once fixed in AdministrationServiceImpl! + //assertEquals( "http://localhost:8080/archiva/repository/" + expectedRepoConfig.getId(), managedRepo.getUrl() ); + assertEquals( expectedRepoConfig.isReleases(), managedRepo.isReleases() ); + assertEquals( expectedRepoConfig.isSnapshots(), managedRepo.isSnapshots() ); + } + + private ManagedRepositoryConfiguration createManagedRepo( String id, String layout, String name, + boolean hasReleases, boolean hasSnapshots ) + { + ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration(); + repoConfig.setId( id ); + repoConfig.setLayout( layout ); + repoConfig.setName( name ); + repoConfig.setReleases( hasReleases ); + repoConfig.setSnapshots( hasSnapshots ); + + return repoConfig; + } + + private void recordRepoConsumers() + { + List availableKnownConsumers = new ArrayList(); + availableKnownConsumers.add( indexArtifactConsumer ); + availableKnownConsumers.add( indexPomConsumer ); + + List availableInvalidConsumers = new ArrayList(); + availableInvalidConsumers.add( checkPomConsumer ); + availableInvalidConsumers.add( checkMetadataConsumer ); + + repoConsumerUtilsControl.expectAndReturn( repoConsumersUtil.getAvailableKnownConsumers(), availableKnownConsumers ); + knownContentConsumerControl.expectAndReturn( indexArtifactConsumer.getId(), "index-artifact" ); + knownContentConsumerControl.expectAndReturn( indexPomConsumer.getId(), "index-pom" ); + + repoConsumerUtilsControl.expectAndReturn( repoConsumersUtil.getAvailableInvalidConsumers(), availableInvalidConsumers ); + invalidContentConsumerControl.expectAndReturn( checkPomConsumer.getId(), "check-pom" ); + invalidContentConsumerControl.expectAndReturn( checkMetadataConsumer.getId(), "check-metadata" ); + } + + private void recordDbConsumers() + { + List cleanupConsumers = new ArrayList(); + cleanupConsumers.add( cleanupIndexConsumer ); + cleanupConsumers.add( cleanupDbConsumer ); + + List unprocessedConsumers = + new ArrayList(); + unprocessedConsumers.add( processArtifactConsumer ); + unprocessedConsumers.add( processPomConsumer ); + + dbConsumersUtilControl.expectAndReturn( dbConsumersUtil.getAvailableCleanupConsumers(), cleanupConsumers ); + cleanupConsumersControl.expectAndReturn( cleanupIndexConsumer.getId(), "cleanup-index" ); + cleanupConsumersControl.expectAndReturn( cleanupDbConsumer.getId(), "cleanup-database" ); + + dbConsumersUtilControl.expectAndReturn( dbConsumersUtil.getAvailableUnprocessedConsumers(), unprocessedConsumers ); + unprocessedConsumersControl.expectAndReturn( processArtifactConsumer.getId(), "process-artifact" ); + unprocessedConsumersControl.expectAndReturn( processPomConsumer.getId(), "process-pom" ); + } + + private void recordInManagedLegacyRepoContent( MockControl fileTypesControl, FileTypes fileTypes, + MockControl pathParserControl, PathParser parser ) + throws LayoutException + { + fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( "org.apache.archiva/poms/archiva-test-1.0.pom" ), true ); + fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( "org.apache.archiva/poms/archiva-test-1.1.pom" ), true ); + fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( "org.apache.archiva/poms/archiva-diff-1.0.pom" ), true ); + fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( "org.apache.archiva/jars/archiva-diff-1.0.jar" ), true ); + fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( "org.apache.archiva/jars/archiva-test-1.0.jar" ), true ); + fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( "org.apache.archiva/jars/archiva-test-1.1.jar" ), true ); + + ArtifactReference aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.1", "pom"); + pathParserControl.expectAndReturn( parser.toArtifactReference( "org.apache.archiva/poms/archiva-test-1.1.pom" ), aRef ); + + aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.0", "pom"); + pathParserControl.expectAndReturn( parser.toArtifactReference( "org.apache.archiva/poms/archiva-test-1.0.pom" ), aRef ); + + aRef = createArtifactReference("archiva-diff", "org.apache.archiva", "1.0", "pom"); + pathParserControl.expectAndReturn( parser.toArtifactReference( "org.apache.archiva/poms/archiva-diff-1.0.pom" ), aRef ); + + aRef = createArtifactReference("archiva-diff", "org.apache.archiva", "1.0", "jar"); + pathParserControl.expectAndReturn( parser.toArtifactReference( "org.apache.archiva/jars/archiva-diff-1.0.jar" ), aRef ); + + aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.0", "jar"); + pathParserControl.expectAndReturn( parser.toArtifactReference( "org.apache.archiva/jars/archiva-test-1.0.jar" ), aRef ); + + aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.1", "jar"); + pathParserControl.expectAndReturn( parser.toArtifactReference( "org.apache.archiva/jars/archiva-test-1.1.jar" ), aRef ); + } + + private List getArtifacts() + { + List artifacts = new ArrayList(); + + ArchivaArtifactModel model = new ArchivaArtifactModel(); + model.setRepositoryId( "internal" ); + model.setGroupId( "org.apache.archiva" ); + model.setArtifactId( "archiva-test" ); + model.setVersion( "1.0" ); + model.setType( "jar" ); + + ArchivaArtifact artifact = new ArchivaArtifact( model ); + artifacts.add( artifact ); + return artifacts; + } + + private ArtifactReference createArtifactReference( String artifactId, String groupId, String version, String type ) + { + ArtifactReference aRef = new ArtifactReference(); + aRef.setArtifactId( artifactId ); + aRef.setGroupId( groupId ); + aRef.setType( type ); + aRef.setVersion( version ); + + return aRef; + } +} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.xml new file mode 100644 index 000000000..fc0308c69 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.xml @@ -0,0 +1,27 @@ + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + configured + + + + + org.codehaus.plexus.registry.Registry + configured + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/pom.xml new file mode 100644 index 000000000..df9b70aed --- /dev/null +++ b/archiva-modules/archiva-web/archiva-xmlrpc/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + org.apache.archiva + archiva-web + 1.2-SNAPSHOT + ../pom.xml + + archiva-xmlrpc + Archiva Web :: XML-RPC + pom + + archiva-xmlrpc-api + archiva-xmlrpc-services + archiva-xmlrpc-security + archiva-xmlrpc-client + + diff --git a/archiva-modules/archiva-web/pom.xml b/archiva-modules/archiva-web/pom.xml index a46196010..e3421d23e 100644 --- a/archiva-modules/archiva-web/pom.xml +++ b/archiva-modules/archiva-web/pom.xml @@ -13,7 +13,9 @@ ~ 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. - --> + --> + + 4.0.0 org.apache.archiva @@ -32,6 +34,7 @@ archiva-webapp archiva-webdav archiva-rss + archiva-xmlrpc diff --git a/pom.xml b/pom.xml index 0dcf1418e..1d3daa95b 100644 --- a/pom.xml +++ b/pom.xml @@ -393,6 +393,21 @@ archiva-rss 1.2-SNAPSHOT + + org.apache.archiva + archiva-xmlrpc-api + 1.2-SNAPSHOT + + + org.apache.archiva + archiva-xmlrpc-services + 1.2-SNAPSHOT + + + org.apache.archiva + archiva-xmlrpc-security + 1.2-SNAPSHOT + org.codehaus.plexus plexus-spring @@ -508,6 +523,11 @@ mail 1.4 + + org.apache.xmlrpc + xmlrpc-server + 3.1 + org.apache.maven maven-artifact-manager @@ -894,6 +914,36 @@ ${jetty.version} + + + com.atlassian.xmlrpc + atlassian-xmlrpc-binder-annotations + ${binder.version} + + + com.atlassian.xmlrpc + atlassian-xmlrpc-binder-server-spring + ${binder.version} + + + commons-logging + commons-logging + + + + + com.atlassian.xmlrpc + atlassian-xmlrpc-binder + ${binder.version} + test + + + com.atlassian.xmlrpc + atlassian-xmlrpc-binder-testing + ${binder.version} + test + + org.springframework @@ -928,6 +978,19 @@ + org.apache.maven maven-artifact @@ -978,6 +1041,7 @@ 1.0-beta-4 1.2-SNAPSHOT 6.1.6 + 0.8.1 -- 2.39.5