From 48da9ae955cbe403012f5622ad92d0cb7f82d39c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 27 Feb 2012 16:57:14 +0000 Subject: [PATCH] add rest method to getObservableRepoIds git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1294221 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/rest/api/model/StringList.java | 55 +++++++++++++++++++ .../rest/api/services/SearchService.java | 8 +++ .../rest/services/DefaultSearchService.java | 21 ++++--- 3 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/StringList.java diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/StringList.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/StringList.java new file mode 100644 index 000000000..7381141ea --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/StringList.java @@ -0,0 +1,55 @@ +package org.apache.archiva.rest.api.model; +/* + * 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. + */ + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +/** + * jaxrs fail to return List so use this contains for rest services returning that + * + * @author Olivier Lamy + * @since 1.4-M3 + */ +@XmlRootElement( name = "stringList" ) +public class StringList +{ + private List strings; + + public StringList() + { + // no op + } + + public StringList( List strings ) + { + this.strings = strings; + } + + public List getStrings() + { + return strings == null ? new ArrayList( 0 ) : strings; + } + + public void setStrings( List strings ) + { + this.strings = strings; + } +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java index 4f6f06e95..96565bfd6 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java @@ -23,6 +23,7 @@ package org.apache.archiva.rest.api.services; import org.apache.archiva.rest.api.model.Artifact; import org.apache.archiva.rest.api.model.GroupIdList; import org.apache.archiva.rest.api.model.SearchRequest; +import org.apache.archiva.rest.api.model.StringList; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; import javax.ws.rs.GET; @@ -88,6 +89,13 @@ public interface SearchService GroupIdList getAllGroupIds( @QueryParam( "selectedRepos" ) List selectedRepos ) throws ArchivaRestServiceException; + @Path( "observablesRepoIds" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( noPermission = true, noRestriction = true ) + StringList getObservablesRepoIds() + throws ArchivaRestServiceException; + /* @Path( "getDependencies" ) @GET diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java index c3b5f154e..41d5d2181 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java @@ -30,24 +30,14 @@ import org.apache.archiva.rest.api.model.Artifact; import org.apache.archiva.rest.api.model.Dependency; import org.apache.archiva.rest.api.model.GroupIdList; import org.apache.archiva.rest.api.model.SearchRequest; +import org.apache.archiva.rest.api.model.StringList; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.SearchService; -import org.apache.archiva.security.AccessDeniedException; -import org.apache.archiva.security.ArchivaSecurityException; -import org.apache.archiva.security.PrincipalNotFoundException; -import org.apache.archiva.security.UserRepositories; import org.apache.commons.collections.ListUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.plexus.redback.users.UserManager; -import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal; -import org.codehaus.redback.rest.services.RedbackRequestInformation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Context; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -174,6 +164,15 @@ public class DefaultSearchService return null; //To change body of implemented methods use File | Settings | File Templates. } + public StringList getObservablesRepoIds() + throws ArchivaRestServiceException + { + return new StringList( getObservableRepos() ); + } + + //------------------------------------- + // internal + //------------------------------------- protected List getArtifacts( SearchResults searchResults ) { -- 2.39.5