aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2008-10-20 05:59:47 +0000
committerMaria Odea B. Ching <oching@apache.org>2008-10-20 05:59:47 +0000
commitc303ba78c70a220c54b0501bf5239f5870d03ad9 (patch)
tree6d95b53c96b67ccf0ddba0054080440e49d2d42b /archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client
parentc64358cfd11f1c506afcc9cc2a4df5bc4f01b69a (diff)
downloadarchiva-c303ba78c70a220c54b0501bf5239f5870d03ad9.tar.gz
archiva-c303ba78c70a220c54b0501bf5239f5870d03ad9.zip
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
Diffstat (limited to 'archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client')
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml94
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java193
2 files changed, 287 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project>
+ <parent>
+ <artifactId>archiva-xmlrpc</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <version>1.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>archiva-xmlrpc-client</artifactId>
+ <name>Archiva Web :: XML-RPC Client</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-xmlrpc-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlrpc</groupId>
+ <artifactId>xmlrpc-client</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.8.0</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <configuration>
+ <executable>java</executable>
+ <mainClass>org.apache.archiva.web.xmlrpc.client.SampleClient</mainClass>
+ <arguments>
+ <!--
+ URL: ex. http://127.0.0.1:8080/archiva/xmlrpc
+ USERNAME & PASSWORD: Archiva credentials
+ -->
+ <argument>URL</argument>
+ <argument>USERNAME</argument>
+ <argument>PASSWORD</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ <!-- override parent config, commons-logging cannot be excluded from commons-beanutils - NoClassDef error occurs -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0-alpha-3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <bannedDependencies>
+ <excludes>
+ <exclude>org.codehaus.plexus:plexus-container-default</exclude>
+ <exclude>velocity:velocity-dep</exclude>
+ <exclude>classworlds:classworlds</exclude>
+ <exclude>javax.transaction:jta</exclude>
+ <exclude>javax.sql:jdbc-stdext</exclude>
+ <exclude>ant:ant-optional</exclude>
+ <!-- exclude>org.apache.maven.wagon:wagon-http-lightweight</exclude -->
+ <exclude>xom:xom</exclude>
+ </excludes>
+ </bannedDependencies>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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 <arguments> 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();
+ }
+ }
+}