| 1 | |
package org.apache.archiva.web.xmlrpc.client; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
import java.net.URL; |
| 23 | |
import java.util.List; |
| 24 | |
|
| 25 | |
import org.apache.archiva.web.xmlrpc.api.AdministrationService; |
| 26 | |
import org.apache.archiva.web.xmlrpc.api.PingService; |
| 27 | |
import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; |
| 28 | |
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; |
| 29 | |
|
| 30 | |
import com.atlassian.xmlrpc.AuthenticationInfo; |
| 31 | |
import com.atlassian.xmlrpc.Binder; |
| 32 | |
import com.atlassian.xmlrpc.BindingException; |
| 33 | |
import com.atlassian.xmlrpc.DefaultBinder; |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | 0 | public class SampleClient |
| 50 | |
{ |
| 51 | |
public static void main( String[] args ) |
| 52 | |
{ |
| 53 | 0 | Binder binder = new DefaultBinder(); |
| 54 | |
|
| 55 | |
try |
| 56 | |
{ |
| 57 | 0 | AuthenticationInfo authnInfo = new AuthenticationInfo( args[1], args[2] ); |
| 58 | 0 | AdministrationService adminService = binder.bind( AdministrationService.class, new URL( args[0] ), authnInfo ); |
| 59 | 0 | PingService pingService = binder.bind( PingService.class, new URL( args[0] ), authnInfo ); |
| 60 | |
|
| 61 | 0 | System.out.println( "Ping : " + pingService.ping() ); |
| 62 | |
|
| 63 | 0 | List<ManagedRepository> managedRepos = adminService.getAllManagedRepositories(); |
| 64 | |
|
| 65 | 0 | System.out.println( "\n******** Managed Repositories ********" ); |
| 66 | 0 | for( ManagedRepository managedRepo : managedRepos ) |
| 67 | |
{ |
| 68 | 0 | System.out.println( "=================================" ); |
| 69 | 0 | System.out.println( "Id: " + managedRepo.getId() ); |
| 70 | 0 | System.out.println( "Name: " + managedRepo.getName() ); |
| 71 | 0 | System.out.println( "Layout: " + managedRepo.getLayout() ); |
| 72 | 0 | System.out.println( "URL: " + managedRepo.getUrl() ); |
| 73 | 0 | System.out.println( "Releases: " + managedRepo.isReleases() ); |
| 74 | 0 | System.out.println( "Snapshots: " + managedRepo.isSnapshots() ); |
| 75 | |
} |
| 76 | |
|
| 77 | 0 | System.out.println( "\n******** Remote Repositories ********" ); |
| 78 | 0 | List<RemoteRepository> remoteRepos = adminService.getAllRemoteRepositories(); |
| 79 | 0 | for( RemoteRepository remoteRepo : remoteRepos ) |
| 80 | |
{ |
| 81 | 0 | System.out.println( "=================================" ); |
| 82 | 0 | System.out.println( "Id: " + remoteRepo.getId() ); |
| 83 | 0 | System.out.println( "Name: " + remoteRepo.getName() ); |
| 84 | 0 | System.out.println( "Layout: " + remoteRepo.getLayout() ); |
| 85 | 0 | System.out.println( "URL: " + remoteRepo.getUrl() ); |
| 86 | |
} |
| 87 | |
|
| 88 | 0 | System.out.println( "\n******** Repository Consumers ********" ); |
| 89 | 0 | List<String> repoConsumers = adminService.getAllRepositoryConsumers(); |
| 90 | 0 | for( String consumer : repoConsumers ) |
| 91 | |
{ |
| 92 | 0 | System.out.println( consumer ); |
| 93 | |
} |
| 94 | |
|
| 95 | 0 | System.out.println( "\n******** Database Consumers ********" ); |
| 96 | 0 | List<String> dbConsumers = adminService.getAllDatabaseConsumers(); |
| 97 | 0 | for( String consumer : dbConsumers ) |
| 98 | |
{ |
| 99 | 0 | System.out.println( consumer ); |
| 100 | |
} |
| 101 | |
|
| 102 | 0 | Boolean success = adminService.configureRepositoryConsumer( "internal", "repository-purge", true ); |
| 103 | 0 | System.out.println( "\nConfigured repo consumer 'repository-purge' : " + |
| 104 | |
( (Boolean) success ).booleanValue() ); |
| 105 | |
|
| 106 | 0 | success = adminService.configureDatabaseConsumer( "update-db-bytecode-stats", false ); |
| 107 | 0 | System.out.println( "\nConfigured db consumer 'update-db-bytecode-stats' : " + |
| 108 | |
( (Boolean) success ).booleanValue() ); |
| 109 | |
|
| 110 | 0 | success = adminService.executeRepositoryScanner( "internal" ); |
| 111 | 0 | System.out.println( "\nExecuted repo scanner of repository 'internal' : " + |
| 112 | |
( (Boolean) success ).booleanValue() ); |
| 113 | |
|
| 114 | 0 | success = adminService.executeDatabaseScanner(); |
| 115 | 0 | System.out.println( "\nExecuted database scanner : " + ( (Boolean) success ).booleanValue() ); |
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
} |
| 143 | 0 | catch ( BindingException e ) |
| 144 | |
{ |
| 145 | 0 | e.printStackTrace(); |
| 146 | |
} |
| 147 | 0 | catch( Exception e ) |
| 148 | |
{ |
| 149 | 0 | e.printStackTrace(); |
| 150 | 0 | } |
| 151 | 0 | } |
| 152 | |
} |