Starting version 1.4, you can use some REST Services to manage your Apache Archiva instance and Search artifacts.
All samples here will use Apache CXF REST client API. By the way you can use some others REST client frameworks.
+ NOTE: a wadl is available in your Archiva instance : http(s)://ip:port/..//restServices/application.wadl
* Search Service
Get a Search Service Client :
%{snippet|id=cxf-searchservice-creation|url=http://svn.apache.org/repos/asf/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java}
+
+ Quick Search
+
+%{snippet|id=quick-search|url=http://svn.apache.org/repos/asf/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java}
+
+ Search Artifacts Version : to search all availables version with a groupId and artifactId and packaging (if empty jar is used)
+
+%{snippet|id=searchservice-artifact-versions|url=http://svn.apache.org/repos/asf/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java}
+
+ Search Service with a classifier :
+
+%{snippet|id=searchservice-with-classifier|url=http://svn.apache.org/repos/asf/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java}
+
+ Search Service with a classifier :
+
+%{snippet|id=searchservice-with-classifier|url=http://svn.apache.org/repos/asf/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java}
+
+ To know all the possible options, you can refer to the javadoc of SearchRequest class.
+
+
+
// START SNIPPET: quick-search
List<Artifact> artifacts = searchService.quickSearch( "commons-logging" );
- // return all artifacts with groupId OR artifactId
+ // return all artifacts with groupId OR artifactId OR version OR packaging OR className
+ // NOTE : only artifacts with classifier empty are returned
// START SNIPPET: quick-search
assertNotNull( artifacts );
SearchService searchService = getSearchService( authorizationHeader );
+ // START SNIPPET: searchservice-with-classifier
SearchRequest searchRequest = new SearchRequest();
searchRequest.setGroupId( "commons-logging" );
searchRequest.setArtifactId( "commons-logging" );
searchRequest.setClassifier( "sources" );
List<Artifact> artifacts = searchService.searchArtifacts( searchRequest );
+ // END SNIPPET: searchservice-with-classifier
assertNotNull( artifacts );
assertTrue( " not 2 results for commons-logging search but " + artifacts.size() + ":" + artifacts,
SearchService searchService = getSearchService( authorizationHeader );
+ // START SNIPPET: searchservice-with-osgi
SearchRequest searchRequest = new SearchRequest();
searchRequest.setBundleSymbolicName( "org.apache.karaf.features.command" );
+ // END SNIPPET: searchservice-with-osgi
List<Artifact> artifacts = searchService.searchArtifacts( searchRequest );