From: Joakim Erdfelt Date: Mon, 5 Nov 2007 23:41:29 +0000 (+0000) Subject: Adding "You have access to no repositories" screen. X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e65732f69b34a56d5f2725de6da86e0a9cbbd1b4;p=archiva.git Adding "You have access to no repositories" screen. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-backend-security@592186 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java index 91993e67e..2bc042231 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.web.action; * under the License. */ +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.database.browsing.BrowsingResults; import org.apache.maven.archiva.database.browsing.RepositoryBrowsing; @@ -66,7 +67,13 @@ public class BrowseAction public String browse() { - this.results = repoBrowsing.getRoot( getPrincipal(), getObservableRepos() ); + List selectedRepos = getObservableRepos(); + if ( CollectionUtils.isEmpty( selectedRepos ) ) + { + return GlobalResults.ACCESS_TO_NO_REPOS; + } + + this.results = repoBrowsing.getRoot( getPrincipal(), selectedRepos ); return SUCCESS; } @@ -79,7 +86,14 @@ public class BrowseAction return ERROR; } - this.results = repoBrowsing.selectGroupId( getPrincipal(), getObservableRepos(), groupId ); + List selectedRepos = getObservableRepos(); + if ( CollectionUtils.isEmpty( selectedRepos ) ) + { + return GlobalResults.ACCESS_TO_NO_REPOS; + } + + + this.results = repoBrowsing.selectGroupId( getPrincipal(), selectedRepos, groupId ); return SUCCESS; } @@ -99,7 +113,14 @@ public class BrowseAction return ERROR; } - this.results = repoBrowsing.selectArtifactId( getPrincipal(), getObservableRepos(), groupId, artifactId ); + List selectedRepos = getObservableRepos(); + if ( CollectionUtils.isEmpty( selectedRepos ) ) + { + return GlobalResults.ACCESS_TO_NO_REPOS; + } + + + this.results = repoBrowsing.selectArtifactId( getPrincipal(), selectedRepos, groupId, artifactId ); return SUCCESS; } diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/GlobalResults.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/GlobalResults.java new file mode 100644 index 000000000..15b7ae5d8 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/GlobalResults.java @@ -0,0 +1,31 @@ +package org.apache.maven.archiva.web.action; + +/* + * 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. + */ + +/** + * GlobalResults - constants for global result definitions. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class GlobalResults +{ + public static final String ACCESS_TO_NO_REPOS = "access_to_no_repos"; +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java index d81d03e34..2785f7414 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.web.action; * under the License. */ +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.Constraint; @@ -95,8 +96,14 @@ public class SearchAction assert q != null && q.length() != 0; SearchResultLimits limits = new SearchResultLimits( 0 ); + + List selectedRepos = getObservableRepos(); + if ( CollectionUtils.isEmpty( selectedRepos ) ) + { + return GlobalResults.ACCESS_TO_NO_REPOS; + } - results = crossRepoSearch.searchForTerm( getPrincipal(), getObservableRepos(), q, limits ); + results = crossRepoSearch.searchForTerm( getPrincipal(), selectedRepos, q, limits ); if ( results.isEmpty() ) { diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index 4966cbde7..6727e5769 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -82,6 +82,7 @@ + index index @@ -126,6 +127,7 @@ /WEB-INF/jsp/generalError.jsp + /WEB-INF/jsp/accessToNoRepos.jsp diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp new file mode 100644 index 000000000..5ed04736f --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp @@ -0,0 +1,46 @@ +<%-- + ~ 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. + --%> + +<%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + You have access to no repositories + + + + + +
+ +
+ You have access to no repositories. + Ask your system administrator for access. +
+ +
+ +
+
+
+ + + +