001    package org.apache.archiva.rest.api.services;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import org.apache.archiva.admin.model.beans.ManagedRepository;
023    import org.apache.archiva.rest.api.model.ArchivaRepositoryStatistics;
024    import org.apache.archiva.security.common.ArchivaRoleConstants;
025    import org.apache.archiva.redback.authorization.RedbackAuthorization;
026    
027    import javax.ws.rs.Consumes;
028    import javax.ws.rs.GET;
029    import javax.ws.rs.POST;
030    import javax.ws.rs.Path;
031    import javax.ws.rs.PathParam;
032    import javax.ws.rs.Produces;
033    import javax.ws.rs.QueryParam;
034    import javax.ws.rs.core.MediaType;
035    import java.util.List;
036    
037    /**
038     * @author Olivier Lamy
039     * @since 1.4-M1
040     */
041    @Path( "/managedRepositoriesService/" )
042    public interface ManagedRepositoriesService
043    {
044        @Path( "getManagedRepositories" )
045        @GET
046        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
047        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
048        List<ManagedRepository> getManagedRepositories()
049            throws ArchivaRestServiceException;
050    
051        @Path( "getManagedRepository/{repositoryId}" )
052        @GET
053        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
054        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
055        ManagedRepository getManagedRepository( @PathParam( "repositoryId" ) String repositoryId )
056            throws ArchivaRestServiceException;
057    
058        @Path( "deleteManagedRepository" )
059        @GET
060        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
061        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
062        Boolean deleteManagedRepository( @QueryParam( "repositoryId" ) String repositoryId,
063                                         @QueryParam( "deleteContent" ) boolean deleteContent )
064            throws ArchivaRestServiceException;
065    
066    
067        @Path( "addManagedRepository" )
068        @POST
069        @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
070        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
071        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
072        ManagedRepository addManagedRepository( ManagedRepository managedRepository )
073            throws ArchivaRestServiceException;
074    
075    
076        @Path( "updateManagedRepository" )
077        @POST
078        @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
079        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
080        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
081        Boolean updateManagedRepository( ManagedRepository managedRepository )
082            throws ArchivaRestServiceException;
083    
084        /**
085         * @since 1.4-M3
086         */
087        @Path( "fileLocationExists" )
088        @GET
089        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
090        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
091        Boolean fileLocationExists( @QueryParam( "fileLocation" ) String fileLocation )
092            throws ArchivaRestServiceException;
093    
094        /**
095         * @since 1.4-M3
096         */
097        @Path( "getManagedRepositoryStatistics/{repositoryId}/{lang}" )
098        @GET
099        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
100        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
101        ArchivaRepositoryStatistics getManagedRepositoryStatistics( @PathParam( "repositoryId" ) String repositoryId,
102                                                                    @PathParam( "lang" ) String lang )
103            throws ArchivaRestServiceException;
104    
105        /**
106         * return a pom snippet to use this repository with entities escaped (< > )
107         * @since 1.4-M3
108         */
109        @Path( "getPomSnippet/{repositoryId}" )
110        @GET
111        @Produces( { MediaType.TEXT_PLAIN } )
112        @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
113        String getPomSnippet( @PathParam( "repositoryId" ) String repositoryId )
114            throws ArchivaRestServiceException;
115    
116    
117    }