From e54d726cd4249b095eb04ae4a56bd1cd2ed47cee Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Fri, 17 Oct 2008 07:46:09 +0000 Subject: [PATCH] - updated sample xmlrpc client - added @ServiceBeanField annotations to ManagedRepository and RemoteRepository git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@705500 13f79535-47bb-0310-9956-ffa450edef68 --- .../xmlrpc/api/beans/ManagedRepository.java | 12 ++++++ .../xmlrpc/api/beans/RemoteRepository.java | 20 +++++----- .../archiva-xmlrpc-client/pom.xml | 39 ++++++++++++++++++- .../web/xmlrpc/client/SampleClient.java | 35 +++++++++++++++-- 4 files changed, 92 insertions(+), 14 deletions(-) diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java index 266cb25f6..fd0f9ef4f 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java @@ -22,6 +22,7 @@ package org.apache.archiva.web.xmlrpc.api.beans; import java.io.Serializable; import com.atlassian.xmlrpc.ServiceBean; +import com.atlassian.xmlrpc.ServiceBeanField; @ServiceBean public class ManagedRepository @@ -39,6 +40,11 @@ public class ManagedRepository private boolean releases = false; + public ManagedRepository() + { + + } + public ManagedRepository( String id, String name, String url, String layout, boolean snapshots, boolean releases ) { this.id = id; @@ -108,31 +114,37 @@ public class ManagedRepository 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; diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java index 810f2ee5e..399b59e57 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java @@ -22,6 +22,7 @@ package org.apache.archiva.web.xmlrpc.api.beans; import java.io.Serializable; import com.atlassian.xmlrpc.ServiceBean; +import com.atlassian.xmlrpc.ServiceBeanField; @ServiceBean public class RemoteRepository @@ -35,6 +36,11 @@ public class RemoteRepository private String layout; + public RemoteRepository() + { + + } + public RemoteRepository( String id, String name, String url, String layout ) { this.id = id; @@ -89,31 +95,27 @@ public class RemoteRepository 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; - } - - public java.lang.String toString() - { - StringBuffer buf = new StringBuffer(); - buf.append( "id = '" ); - buf.append( getId() + "'" ); - return buf.toString(); - } + } } \ No newline at end of file diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml index d6f23d949..1e73dc933 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml @@ -35,6 +35,11 @@ xmlrpc-client 3.1 + + commons-beanutils + commons-beanutils + 1.8.0 + @@ -45,13 +50,45 @@ 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/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java index 34557aea0..e9dce7a9c 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java @@ -19,6 +19,7 @@ package org.apache.archiva.web.xmlrpc.client; * under the License. */ +import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; @@ -29,6 +30,7 @@ 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; @@ -75,7 +77,19 @@ public class SampleClient for( int i = 0; i < managedRepos.length; i++ ) { System.out.println( "=================================" ); - ManagedRepository managedRepo = (ManagedRepository) managedRepos[i]; + 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() ); @@ -86,14 +100,27 @@ public class SampleClient /* remote repositories */ params = new Object[]{}; - Object[] remoteReposObj = (Object[]) + Object[] remoteRepos = (Object[]) client.execute( "AdministrationService.getAllRemoteRepositories", params ); System.out.println( "\n******** Remote Repositories ********" ); - for( int i = 0; i < remoteReposObj.length; i++ ) + for( int i = 0; i < remoteRepos.length; i++ ) { System.out.println( "=================================" ); - RemoteRepository remoteRepo = (RemoteRepository) remoteReposObj[i]; + 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() ); -- 2.39.5