From 8abc4a6e95acfd88bb2e4f9b5717adf7c9783bff Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 23 May 2006 16:02:24 +0000 Subject: [PATCH] . Fix for AWC-693 - Added evaluator so the user cannot try to Take Ownership of a locked item . Fixes for AWC-640 and AWC-457 - Company Home, Guest Home and My Home links now disable/enable depending on the user permissions on the respective locations - Guest can now longer see Company Home link if they do not have access (which is the default) . Company/Home/Guest link toolbar no longer highlights the selected item (as it is not the only way to navigate to it) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2958 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 1 + config/alfresco/web-client-config-actions.xml | 1 + .../evaluator/TakeOwnershipDocEvaluator.java | 36 ++++++++ .../org/alfresco/web/app/Application.java | 36 +++++++- .../org/alfresco/web/bean/NavigationBean.java | 85 +++++++++++++++++-- source/web/jsp/parts/titlebar.jsp | 5 +- 6 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 source/java/org/alfresco/web/action/evaluator/TakeOwnershipDocEvaluator.java diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 3f73c06744..4129e64e67 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -94,6 +94,7 @@ recent_spaces=Recent Spaces shortcuts=Shortcuts company_home=Company Home my_home=My Home +guest_home=Guest Home new_search=New Search search_results=Search Results search_detail=Search for \"{0}\" results shown below diff --git a/config/alfresco/web-client-config-actions.xml b/config/alfresco/web-client-config-actions.xml index 844fe3410f..40243aa8eb 100644 --- a/config/alfresco/web-client-config-actions.xml +++ b/config/alfresco/web-client-config-actions.xml @@ -381,6 +381,7 @@ TakeOwnership + org.alfresco.web.action.evaluator.TakeOwnershipDocEvaluator take_ownership /images/icons/take_ownership.gif #{DocumentDetailsBean.takeOwnership} diff --git a/source/java/org/alfresco/web/action/evaluator/TakeOwnershipDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/TakeOwnershipDocEvaluator.java new file mode 100644 index 0000000000..091302ebe5 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/TakeOwnershipDocEvaluator.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * 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. + */ +package org.alfresco.web.action.evaluator; + +import org.alfresco.web.action.ActionEvaluator; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Take ownership of a document. + * + * @author Kevin Roast + */ +public final class TakeOwnershipDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.isLocked() == false); + } +} diff --git a/source/java/org/alfresco/web/app/Application.java b/source/java/org/alfresco/web/app/Application.java index f7502318de..04552ed611 100644 --- a/source/java/org/alfresco/web/app/Application.java +++ b/source/java/org/alfresco/web/app/Application.java @@ -72,6 +72,7 @@ public class Application private static String emailTemplatesFolderName; private static String savedSearchesFolderName; private static String scriptsFolderName; + private static String guestHomeFolderName; /** * Private constructor to prevent instantiation of this class @@ -380,7 +381,6 @@ public class Application return getSavedSearchesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); } - /** * @return Return the JavaScript scripts folder name */ @@ -397,6 +397,22 @@ public class Application return getScriptsFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); } + /** + * @return Return the Guest Home folder name + */ + public static String getGuestHomeFolderName(ServletContext context) + { + return getGuestHomeFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); + } + + /** + * @return Return the Guest Home folder name + */ + public static String getGuestHomeFolderName(FacesContext context) + { + return getGuestHomeFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); + } + /** * Set the language locale for the current user context * @@ -764,6 +780,24 @@ public class Application return scriptsFolderName; } + /** + * Returns the Guest Home folder name name + * + * @param context The spring context + * @return The Guest Home folder name + */ + private static String getGuestHomeFolderName(WebApplicationContext context) + { + if (guestHomeFolderName == null) + { + ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP); + Properties configuration = bootstrap.getConfiguration(); + guestHomeFolderName = configuration.getProperty("spaces.guest_home.childname"); + } + + return guestHomeFolderName; + } + /** * Retrieves the configured error page for the application * diff --git a/source/java/org/alfresco/web/bean/NavigationBean.java b/source/java/org/alfresco/web/bean/NavigationBean.java index f8ee991f28..0cc97b2301 100644 --- a/source/java/org/alfresco/web/bean/NavigationBean.java +++ b/source/java/org/alfresco/web/bean/NavigationBean.java @@ -105,7 +105,7 @@ public class NavigationBean { this.ruleService = ruleService; } - + /** * @param cifsServer The cifsServer to set. */ @@ -484,6 +484,67 @@ public class NavigationBean return this.dispatchContext; } + /** + * @return Node representing the Company Home folder + */ + public Node getCompanyHomeNode() + { + if (this.companyHomeNode == null) + { + NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()); + this.companyHomeNode = new Node(companyRootRef); + } + return this.companyHomeNode; + } + + /** + * @return Node representing the Guest Home Space folder + */ + public Node getGuestHomeNode() + { + if (this.guestHomeNode == null) + { + try + { + FacesContext fc = FacesContext.getCurrentInstance(); + String xpath = Application.getRootPath(fc) + "/" + Application.getGuestHomeFolderName(fc); + List guestHomeRefs = this.searchService.selectNodes( + this.nodeService.getRootNode(Repository.getStoreRef()), + xpath, null, this.namespaceService, false); + if (guestHomeRefs.size() == 1) + { + this.guestHomeNode = new Node(guestHomeRefs.get(0)); + } + } + catch (InvalidNodeRefException err1) + { + // cannot continue if this occurs + } + catch (AccessDeniedException err2) + { + // cannot see node if this occurs + } + } + return this.guestHomeNode; + } + + /** + * @return true if the Company home node is accessable to the current user + */ + public boolean getCompanyHomeVisible() + { + return getCompanyHomeNode().hasPermission(PermissionService.READ); + } + + /** + * @return true if the Guest home node is accessable to the current user + */ + public boolean getGuestHomeVisible() + { + Node guestHome = getGuestHomeNode(); + return guestHome != null && guestHome.hasPermission(PermissionService.READ); + } + // ------------------------------------------------------------------------------ // Navigation action event handlers @@ -522,11 +583,10 @@ public class NavigationBean if (LOCATION_COMPANY.equals(location)) { List elements = new ArrayList(1); - NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId()); - String companySpaceName = Repository.getNameForNode(this.nodeService, companyRootRef); - elements.add(new NavigationBreadcrumbHandler(companyRootRef, companySpaceName)); + Node companyHome = getCompanyHomeNode(); + elements.add(new NavigationBreadcrumbHandler(companyHome.getNodeRef(), companyHome.getName())); setLocation(elements); - setCurrentNodeId(companyRootRef.getId()); + setCurrentNodeId(companyHome.getId()); } else if (LOCATION_HOME.equals(location)) { @@ -538,6 +598,14 @@ public class NavigationBean setLocation(elements); setCurrentNodeId(homeSpaceRef.getId()); } + else if (LOCATION_GUEST.equals(location)) + { + List elements = new ArrayList(1); + Node guestHome = getGuestHomeNode(); + elements.add(new NavigationBreadcrumbHandler(guestHome.getNodeRef(), guestHome.getName())); + setLocation(elements); + setCurrentNodeId(guestHome.getId()); + } // we need to force a navigation to refresh the browse screen breadcrumb context.getApplication().getNavigationHandler().handleNavigation(context, null, "browse"); @@ -665,6 +733,7 @@ public class NavigationBean /** constant values used by the toolbar location modelist control */ private static final String LOCATION_COMPANY = "company"; private static final String LOCATION_HOME = "home"; + private static final String LOCATION_GUEST = "guest"; private static final String ERROR_DELETED_FOLDER = "error_deleted_folder"; @@ -701,6 +770,12 @@ public class NavigationBean /** Node we are using for dispatching */ private Node dispatchContext = null; + /** Node representing the guest home */ + private Node guestHomeNode = null; + + /** Node representing the company home */ + private Node companyHomeNode = null; + /** Current toolbar location */ private String toolbarLocation = LOCATION_HOME; diff --git a/source/web/jsp/parts/titlebar.jsp b/source/web/jsp/parts/titlebar.jsp index d5629917ee..3c6d812cba 100644 --- a/source/web/jsp/parts/titlebar.jsp +++ b/source/web/jsp/parts/titlebar.jsp @@ -26,10 +26,11 @@ <%-- Toolbar --%> - + +