------ Using REST Services ------ Olivier Lamy ------ 2011-09-16 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/guides/mini/guide-apt-format.html Using REST Services 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 Authentication headers for connect to your Archiva instance : %{snippet|id=authz-header|url=https://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} Get a Search Service Client : %{snippet|id=cxf-searchservice-creation|url=https://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=https://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=https://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=https://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=https://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} Copy Artifact from a repository to an other one : For some reasons you want to use a test repository before moving your artifacts to a repository used by final users. To achieve this, you can use a service which can copy an artifact from a repository to an other one %{snippet|id=copy-artifact|url=https://svn.apache.org/repos/asf/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java} To know all the possible options, you can refer to the javadoc of SearchRequest class. Dependencies to add in order to use those REST Services +------------------------- org.apache.archiva archiva-rest-api ${project.version} if you use CXF: org.apache.cxf cxf-bundle-jaxrs 2.4.2 org.eclipse.jetty jetty-server +------------------------- * Security Framework Services: You can use Redback Rest Services to control user creation/modification and add/remove roles. See {{http://redback.codehaus.org/integration/rest.html}}