1 package org.apache.archiva.web.xmlrpc.client;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
23 import java.util.List;
25 import org.apache.archiva.web.xmlrpc.api.AdministrationService;
26 import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
27 import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
29 import com.atlassian.xmlrpc.AuthenticationInfo;
30 import com.atlassian.xmlrpc.Binder;
31 import com.atlassian.xmlrpc.BindingException;
32 import com.atlassian.xmlrpc.DefaultBinder;
37 * Test client for Archiva Web Services.
40 * 1. set the <arguments> in the exec-maven-plugin config in the pom.xml in the following order:
44 * 2. execute 'mvn exec:java' from the command-line
48 public class SampleClient
50 public static void main( String[] args )
52 Binder binder = new DefaultBinder();
56 AuthenticationInfo authnInfo = new AuthenticationInfo( args[1], args[2] );
57 AdministrationService adminService = binder.bind( AdministrationService.class, new URL( args[0] ), authnInfo );
58 List<ManagedRepository> managedRepos = adminService.getAllManagedRepositories();
60 System.out.println( "\n******** Managed Repositories ********" );
61 for( ManagedRepository managedRepo : managedRepos )
63 System.out.println( "=================================" );
64 System.out.println( "Id: " + managedRepo.getId() );
65 System.out.println( "Name: " + managedRepo.getName() );
66 System.out.println( "Layout: " + managedRepo.getLayout() );
67 System.out.println( "URL: " + managedRepo.getUrl() );
68 System.out.println( "Releases: " + managedRepo.isReleases() );
69 System.out.println( "Snapshots: " + managedRepo.isSnapshots() );
72 System.out.println( "\n******** Remote Repositories ********" );
73 List<RemoteRepository> remoteRepos = adminService.getAllRemoteRepositories();
74 for( RemoteRepository remoteRepo : remoteRepos )
76 System.out.println( "=================================" );
77 System.out.println( "Id: " + remoteRepo.getId() );
78 System.out.println( "Name: " + remoteRepo.getName() );
79 System.out.println( "Layout: " + remoteRepo.getLayout() );
80 System.out.println( "URL: " + remoteRepo.getUrl() );
83 System.out.println( "\n******** Repository Consumers ********" );
84 List<String> repoConsumers = adminService.getAllRepositoryConsumers();
85 for( String consumer : repoConsumers )
87 System.out.println( consumer );
90 System.out.println( "\n******** Database Consumers ********" );
91 List<String> dbConsumers = adminService.getAllDatabaseConsumers();
92 for( String consumer : dbConsumers )
94 System.out.println( consumer );
97 Boolean success = adminService.configureRepositoryConsumer( "internal", "repository-purge", true );
98 System.out.println( "\nConfigured repo consumer 'repository-purge' : " +
99 ( (Boolean) success ).booleanValue() );
101 success = adminService.configureDatabaseConsumer( "update-db-bytecode-stats", false );
102 System.out.println( "\nConfigured db consumer 'update-db-bytecode-stats' : " +
103 ( (Boolean) success ).booleanValue() );
105 success = adminService.executeRepositoryScanner( "internal" );
106 System.out.println( "\nExecuted repo scanner of repository 'internal' : " +
107 ( (Boolean) success ).booleanValue() );
109 success = adminService.executeDatabaseScanner();
110 System.out.println( "\nExecuted database scanner : " + ( (Boolean) success ).booleanValue() );
112 /* delete artifact */
114 * NOTE: before enabling & invoking deleteArtifact, make sure that the repository and artifact exists first!
116 success = adminService.deleteArtifact( "internal", "javax.activation", "activation", "1.1" );
117 System.out.println( "\nDeleted artifact 'javax.activation:activation:1.1' from repository 'internal' : " +
118 ( (Boolean) success ).booleanValue() );
121 catch ( BindingException e )