import java.io.Serializable;
import com.atlassian.xmlrpc.ServiceBean;
+import com.atlassian.xmlrpc.ServiceBeanField;
@ServiceBean
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;
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;
import java.io.Serializable;
import com.atlassian.xmlrpc.ServiceBean;
+import com.atlassian.xmlrpc.ServiceBeanField;
@ServiceBean
public class RemoteRepository
private String layout;
+ public RemoteRepository()
+ {
+
+ }
+
public RemoteRepository( String id, String name, String url, String layout )
{
this.id = id;
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
<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>
* under the License.
*/
+import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
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;
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() );
/* 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() );