001 package org.apache.archiva.rest.api.services; 002 /* 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 021 import org.apache.archiva.admin.model.beans.ManagedRepository; 022 import org.apache.archiva.maven2.model.Artifact; 023 import org.apache.archiva.maven2.model.TreeEntry; 024 import org.apache.archiva.metadata.model.ProjectVersionMetadata; 025 import org.apache.archiva.redback.authorization.RedbackAuthorization; 026 import org.apache.archiva.rest.api.model.ArtifactContent; 027 import org.apache.archiva.rest.api.model.ArtifactContentEntry; 028 import org.apache.archiva.rest.api.model.BrowseResult; 029 import org.apache.archiva.rest.api.model.Entry; 030 import org.apache.archiva.rest.api.model.MetadataAddRequest; 031 import org.apache.archiva.rest.api.model.VersionsList; 032 033 import javax.ws.rs.DELETE; 034 import javax.ws.rs.GET; 035 import javax.ws.rs.POST; 036 import javax.ws.rs.PUT; 037 import javax.ws.rs.Path; 038 import javax.ws.rs.PathParam; 039 import javax.ws.rs.Produces; 040 import javax.ws.rs.QueryParam; 041 import javax.ws.rs.core.MediaType; 042 import java.util.List; 043 044 /** 045 * @author Olivier Lamy 046 * @since 1.4-M3 047 */ 048 @Path("/browseService/") 049 public interface BrowseService 050 { 051 @Path("rootGroups") 052 @GET 053 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 054 @RedbackAuthorization(noPermission = true, noRestriction = true) 055 BrowseResult getRootGroups( @QueryParam("repositoryId") String repositoryId ) 056 throws ArchivaRestServiceException; 057 058 /** 059 * @param groupId groupId to browse 060 * @param repositoryId optionnal (repository to browse if <code>null</code> all available user repositories are used) 061 */ 062 @Path("browseGroupId/{groupId}") 063 @GET 064 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 065 @RedbackAuthorization(noPermission = true, noRestriction = true) 066 BrowseResult browseGroupId( @PathParam("groupId") String groupId, @QueryParam("repositoryId") String repositoryId ) 067 throws ArchivaRestServiceException; 068 069 @Path("versionsList/{g}/{a}") 070 @GET 071 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 072 @RedbackAuthorization(noPermission = true, noRestriction = true) 073 VersionsList getVersionsList( @PathParam("g") String groupId, @PathParam("a") String artifactId, 074 @QueryParam("repositoryId") String repositoryId ) 075 throws ArchivaRestServiceException; 076 077 @Path("projectVersionMetadata/{g}/{a}") 078 @GET 079 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 080 @RedbackAuthorization(noPermission = true, noRestriction = true) 081 ProjectVersionMetadata getProjectVersionMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, 082 @QueryParam("repositoryId") String repositoryId ) 083 throws ArchivaRestServiceException; 084 085 @Path("projectVersionMetadata/{g}/{a}/{v}") 086 @GET 087 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 088 @RedbackAuthorization(noPermission = true, noRestriction = true) 089 ProjectVersionMetadata getProjectMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, 090 @PathParam("v") String version, 091 @QueryParam("repositoryId") String repositoryId ) 092 throws ArchivaRestServiceException; 093 094 /** 095 * @return List of managed repositories current user can read 096 */ 097 @Path("userRepositories") 098 @GET 099 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 100 @RedbackAuthorization(noPermission = true, noRestriction = true) 101 List<ManagedRepository> getUserRepositories() 102 throws ArchivaRestServiceException; 103 104 /** 105 * return the dependency Tree for an artifacts 106 * <b>the List result has only one entry</b> 107 */ 108 @Path("treeEntries/{g}/{a}/{v}") 109 @GET 110 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 111 @RedbackAuthorization(noPermission = true, noRestriction = true) 112 List<TreeEntry> getTreeEntries( @PathParam("g") String groupId, @PathParam("a") String artifactId, 113 @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId ) 114 throws ArchivaRestServiceException; 115 116 /** 117 * List of artifacts using the artifact passed in parameter. 118 */ 119 @Path("dependees/{g}/{a}/{v}") 120 @GET 121 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 122 @RedbackAuthorization(noPermission = true, noRestriction = true) 123 List<Artifact> getDependees( @PathParam("g") String groupId, @PathParam("a") String artifactId, 124 @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId ) 125 throws ArchivaRestServiceException; 126 127 @Path("metadatas/{g}/{a}/{v}") 128 @GET 129 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 130 @RedbackAuthorization(noPermission = true, noRestriction = true) 131 List<Entry> getMetadatas( @PathParam("g") String groupId, @PathParam("a") String artifactId, 132 @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId ) 133 throws ArchivaRestServiceException; 134 135 @Path("metadata/{g}/{a}/{v}/{key}/{value}") 136 @PUT 137 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 138 @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata") 139 Boolean addMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, 140 @PathParam("v") String version, @PathParam("key") String key, @PathParam("value") String value, 141 @QueryParam("repositoryId") String repositoryId ) 142 throws ArchivaRestServiceException; 143 144 @Path("metadata/{g}/{a}/{v}/{key}") 145 @DELETE 146 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 147 @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata") 148 Boolean deleteMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, 149 @PathParam("v") String version, @PathParam("key") String key, 150 @QueryParam("repositoryId") String repositoryId ) 151 throws ArchivaRestServiceException; 152 153 @Path("importMetadata") 154 @POST 155 @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata") 156 Boolean importMetadata( MetadataAddRequest metadataAddRequest, @QueryParam("repository") String repository ) 157 throws ArchivaRestServiceException; 158 159 @Path("artifactContentEntries/{g}/{a}/{v}") 160 @GET 161 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 162 @RedbackAuthorization(noPermission = true, noRestriction = true) 163 List<ArtifactContentEntry> getArtifactContentEntries( @PathParam("g") String groupId, 164 @PathParam("a") String artifactId, 165 @PathParam("v") String version, 166 @QueryParam("c") String classifier, 167 @QueryParam("t") String type, @QueryParam("p") String path, 168 @QueryParam("repositoryId") String repositoryId ) 169 throws ArchivaRestServiceException; 170 171 @Path("artifactDownloadInfos/{g}/{a}/{v}") 172 @GET 173 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 174 @RedbackAuthorization(noPermission = true, noRestriction = true) 175 List<Artifact> getArtifactDownloadInfos( @PathParam("g") String groupId, @PathParam("a") String artifactId, 176 @PathParam("v") String version, 177 @QueryParam("repositoryId") String repositoryId ) 178 throws ArchivaRestServiceException; 179 180 /** 181 * if path is empty content of the file is returned (for pom view) 182 */ 183 @Path("artifactContentText/{g}/{a}/{v}") 184 @GET 185 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 186 @RedbackAuthorization(noPermission = true, noRestriction = true) 187 ArtifactContent getArtifactContentText( @PathParam("g") String groupId, @PathParam("a") String artifactId, 188 @PathParam("v") String version, @QueryParam("c") String classifier, 189 @QueryParam("t") String type, @QueryParam("p") String path, 190 @QueryParam("repositoryId") String repositoryId ) 191 throws ArchivaRestServiceException; 192 193 /** 194 * verify if an artifact is available locally if not download from proxies will be try 195 * 196 * @since 1.4-M3 197 */ 198 @Path("artifactAvailable/{g}/{a}/{v}") 199 @GET 200 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 201 @RedbackAuthorization(noPermission = true, noRestriction = true) 202 Boolean artifactAvailable( @PathParam("g") String groupId, @PathParam("a") String artifactId, 203 @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId ) 204 throws ArchivaRestServiceException; 205 206 /** 207 * verify if an artifact is available locally if not download from proxies will be try 208 * 209 * @since 1.4-M4 210 */ 211 @Path( "artifactAvailable/{g}/{a}/{v}/{c}" ) 212 @GET 213 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) 214 @RedbackAuthorization( noPermission = true, noRestriction = true ) 215 Boolean artifactAvailable( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, 216 @PathParam( "v" ) String version, @PathParam( "c" ) String classifier, 217 @QueryParam( "repositoryId" ) String repositoryId ) 218 throws ArchivaRestServiceException; 219 220 /** 221 * return List of all artifacts from this repository 222 * 223 * @param repositoryId 224 * @return 225 * @throws ArchivaRestServiceException 226 * @since 1.4-M3 227 */ 228 @Path("artifacts/{r}") 229 @GET 230 @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) 231 @RedbackAuthorization(noPermission = true, noRestriction = true) 232 List<Artifact> getArtifacts( @PathParam("r") String repositoryId ) 233 throws ArchivaRestServiceException; 234 }