]> source.dussan.org Git - archiva.git/commitdiff
add rest method to getObservableRepoIds
authorOlivier Lamy <olamy@apache.org>
Mon, 27 Feb 2012 16:57:14 +0000 (16:57 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 27 Feb 2012 16:57:14 +0000 (16:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1294221 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/StringList.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.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 (file)
index 0000000..7381141
--- /dev/null
@@ -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<String> so use this contains for rest services returning that
+ *
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+@XmlRootElement( name = "stringList" )
+public class StringList
+{
+    private List<String> strings;
+
+    public StringList()
+    {
+        // no op
+    }
+
+    public StringList( List<String> strings )
+    {
+        this.strings = strings;
+    }
+
+    public List<String> getStrings()
+    {
+        return strings == null ? new ArrayList<String>( 0 ) : strings;
+    }
+
+    public void setStrings( List<String> strings )
+    {
+        this.strings = strings;
+    }
+}
index 4f6f06e95325fe3fab76d4dc0ab9f7563ff0022e..96565bfd63898995e1e117a6ad39a55c6fa080da 100644 (file)
@@ -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<String> 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
index c3b5f154e26b1355bb356f8b336fec8be9593d9c..41d5d2181f5da16a7f291a31575ee3dfd3f5cecc 100644 (file)
@@ -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<Artifact> getArtifacts( SearchResults searchResults )
     {