]> source.dussan.org Git - archiva.git/commitdiff
- updated sample xmlrpc client
authorMaria Odea B. Ching <oching@apache.org>
Fri, 17 Oct 2008 07:46:09 +0000 (07:46 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Fri, 17 Oct 2008 07:46:09 +0000 (07:46 +0000)
- added @ServiceBeanField annotations to ManagedRepository and RemoteRepository

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@705500 13f79535-47bb-0310-9956-ffa450edef68

MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java
MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java
MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java

index 266cb25f6cf8d5064a3da3d9174901a26927d545..fd0f9ef4fd3c07557cd3f92dfb2f645ab508127f 100644 (file)
@@ -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;
index 810f2ee5e92308204564428eaa3e83dbe9c5ef7a..399b59e574c531d6b64ebc10ed87ab288b052c01 100644 (file)
@@ -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
index d6f23d9493d609499391f7f2deb16107ee9ca445..1e73dc9332612a19dfa4ce46d8895cb6de3ca605 100644 (file)
       <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>
           <executable>java</executable>
           <mainClass>org.apache.archiva.web.xmlrpc.client.SampleClient</mainClass>
           <arguments>
-            <!-- URL ex. http://127.0.0.1:8080/archiva/xmlrpc --> 
+            <!-- 
+                 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>
index 34557aea02d8b27511eaa918d73b6046ef0aed73..e9dce7a9c4a8168e16168ff91df0dfac28e4cfe8 100644 (file)
@@ -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() );