From 86f31616ba8c45df4b10f0079a826c27ffb84205 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Fri, 22 Dec 2006 16:40:45 +0000 Subject: [PATCH] . Confirmation screens for Undo All and Undo Selected items for a sandbox - refactoring of revert functionality into Undo All and Undo Selected dialogs . Performance enhancement to Node class - to cache Path value from NodeService and changed appropriate class to use this . Fix to horribly broken values in AVMConstants git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4690 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 6 + config/alfresco/web-client-config-dialogs.xml | 8 + .../action/evaluator/CreateFormEvaluator.java | 5 +- .../org/alfresco/web/bean/BrowseBean.java | 4 +- .../org/alfresco/web/bean/NavigationBean.java | 2 +- .../alfresco/web/bean/repository/Node.java | 16 +- .../web/bean/repository/TransientNode.java | 2 +- .../alfresco/web/bean/wcm/AVMBrowseBean.java | 195 ++---------------- .../alfresco/web/bean/wcm/AVMConstants.java | 7 +- .../web/bean/wcm/RevertAllDialog.java | 136 ++++++++++++ .../web/bean/wcm/RevertSelectedDialog.java | 112 ++++++++++ .../alfresco/web/bean/wcm/SubmitDialog.java | 2 +- .../org/alfresco/web/ui/common/Utils.java | 3 +- .../web/ui/wcm/component/UIUserSandboxes.java | 6 +- source/web/WEB-INF/faces-config-beans.xml | 51 ++++- source/web/jsp/wcm/revert.jsp | 26 +++ 16 files changed, 368 insertions(+), 213 deletions(-) create mode 100644 source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java create mode 100644 source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java create mode 100644 source/web/jsp/wcm/revert.jsp diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 844a802d9f..8f8aac7533 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -988,6 +988,12 @@ create_webapp=Create Webapp Folder create_webapp_title=Create Webapp Folder create_webapp_desc=Create a new root Webapp folder for this web project submit_workflow_config_error=Workflow parameters have not been fully configured, cannot submit items. +revert_selected_title=Undo Selected Items +revert_selected_desc=To undo the changes to the selected files in the sandbox, click OK. +revert_selected_confirm=Are you sure you want to undo the changes to the selected files in from the sandbox? +revert_all_title=Undo All Items +revert_all_desc=To undo the changes to all the files in the sandbox, click OK. +revert_all_confirm=Are you sure you want to undo the changes to all files in the sandbox? # New User Wizard messages new_user_title=New User Wizard diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index c6047e0a93..2721e2723e 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -189,6 +189,14 @@ + + + + diff --git a/source/java/org/alfresco/web/action/evaluator/CreateFormEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CreateFormEvaluator.java index 669b15c6c5..f5f469f133 100644 --- a/source/java/org/alfresco/web/action/evaluator/CreateFormEvaluator.java +++ b/source/java/org/alfresco/web/action/evaluator/CreateFormEvaluator.java @@ -20,7 +20,6 @@ import javax.faces.context.FacesContext; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.web.action.ActionEvaluator; import org.alfresco.web.app.Application; @@ -44,10 +43,12 @@ public class CreateFormEvaluator implements ActionEvaluator final FacesContext fc = FacesContext.getCurrentInstance(); final ServiceRegistry services = Repository.getServiceRegistry(fc); final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); + // get the path to the current name - compare last element with the Website folder assoc name - final Path path = services.getNodeService().getPath(navigator.getCurrentNode().getNodeRef()); + final Path path = navigator.getCurrentNode().getNodePath(); final Path.Element element = path.get(path.size() - 1); final String endPath = element.getPrefixedString(services.getNamespaceService()); + // check we have the permission to create nodes in that Website folder return (Application.getContentFormsFolderName(fc).equals(endPath) && navigator.getCurrentNode().hasPermission(PermissionService.ADD_CHILDREN)); diff --git a/source/java/org/alfresco/web/bean/BrowseBean.java b/source/java/org/alfresco/web/bean/BrowseBean.java index 74b26c1b7c..da813a369b 100644 --- a/source/java/org/alfresco/web/bean/BrowseBean.java +++ b/source/java/org/alfresco/web/bean/BrowseBean.java @@ -990,14 +990,14 @@ public class BrowseBean implements IContextListener public NodePropertyResolver resolverPath = new NodePropertyResolver() { public Object get(Node node) { - return nodeService.getPath(node.getNodeRef()); + return node.getNodePath(); } }; public NodePropertyResolver resolverDisplayPath = new NodePropertyResolver() { public Object get(Node node) { // TODO: replace this with a method that shows the full display name - not QNames? - return Repository.getDisplayPath( (Path)node.getProperties().get("path") ); + return Repository.getDisplayPath(node.getNodePath()); } }; diff --git a/source/java/org/alfresco/web/bean/NavigationBean.java b/source/java/org/alfresco/web/bean/NavigationBean.java index 5f85d6f6dd..d6729e13d0 100644 --- a/source/java/org/alfresco/web/bean/NavigationBean.java +++ b/source/java/org/alfresco/web/bean/NavigationBean.java @@ -523,7 +523,7 @@ public class NavigationBean } String icon = (String)props.get("app:icon"); props.put("icon", icon != null ? icon : CreateSpaceWizard.DEFAULT_SPACE_ICON_NAME); - Path path = this.nodeService.getPath(nodeRef); + Path path = node.getNodePath(); // resolve CIFS network folder location for this node DiskSharedDevice diskShare = cifsServer.getConfiguration().getPrimaryFilesystem(); diff --git a/source/java/org/alfresco/web/bean/repository/Node.java b/source/java/org/alfresco/web/bean/repository/Node.java index 036537666f..fcd7802bfb 100644 --- a/source/java/org/alfresco/web/bean/repository/Node.java +++ b/source/java/org/alfresco/web/bean/repository/Node.java @@ -31,6 +31,7 @@ import org.alfresco.service.cmr.lock.LockStatus; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.Path; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; @@ -49,7 +50,7 @@ public class Node implements Serializable protected NodeRef nodeRef; protected String name; protected QName type; - protected String path; + protected Path path; protected String id; protected Set aspects = null; protected Map permissions; @@ -367,15 +368,22 @@ public class Node implements Serializable } /** - * @return The path for the node + * @return The simple display path for the node */ public String getPath() + { + return getNodePath().toString(); + } + + /** + * @return the repo Path to the node + */ + public Path getNodePath() { if (this.path == null) { - this.path = getServiceRegistry().getNodeService().getPath(this.nodeRef).toString(); + this.path = getServiceRegistry().getNodeService().getPath(this.nodeRef); } - return this.path; } diff --git a/source/java/org/alfresco/web/bean/repository/TransientNode.java b/source/java/org/alfresco/web/bean/repository/TransientNode.java index 0588c4e6af..0ef8245fed 100644 --- a/source/java/org/alfresco/web/bean/repository/TransientNode.java +++ b/source/java/org/alfresco/web/bean/repository/TransientNode.java @@ -261,7 +261,7 @@ public class TransientNode extends Node } // setup remaining variables - this.path = ""; + this.path = null; this.locked = Boolean.FALSE; this.workingCopyOwner = Boolean.FALSE; } diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 947c5d3332..354ca3d2ac 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -41,18 +41,12 @@ import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMStoreDescriptor; -import org.alfresco.service.cmr.avmsync.AVMDifference; -import org.alfresco.service.cmr.avmsync.AVMSyncService; -import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.NameMatcher; import org.alfresco.util.Pair; import org.alfresco.web.app.Application; import org.alfresco.web.app.context.IContextListener; @@ -88,8 +82,6 @@ public class AVMBrowseBean implements IContextListener private static Log logger = LogFactory.getLog(AVMBrowseBean.class); private static final String MSG_REVERT_SUCCESS = "revert_success"; - private static final String MSG_REVERTALL_SUCCESS = "revertall_success"; - private static final String MSG_REVERTSELECTED_SUCCESS = "revertselected_success"; private static final String MSG_REVERT_SANDBOX = "revert_sandbox_success"; private static final String MSG_SANDBOXTITLE = "sandbox_title"; private static final String MSG_SANDBOXSTAGING = "sandbox_staging"; @@ -101,10 +93,10 @@ public class AVMBrowseBean implements IContextListener private static final String MSG_SUBMITSELECTED_SUCCESS = "submitselected_success"; /** Component id the status messages are tied too */ - private static final String COMPONENT_SANDBOXESPANEL = "sandboxes-panel"; + static final String COMPONENT_SANDBOXESPANEL = "sandboxes-panel"; /** Top-level JSF form ID */ - private static final String FORM_ID = "browse-website"; + static final String FORM_ID = "browse-website"; /** Content Manager role name */ private static final String ROLE_CONTENT_MANAGER = "ContentManager"; @@ -128,7 +120,8 @@ public class AVMBrowseBean implements IContextListener private String currentPath = null; private AVMNode currentPathNode = null; - private boolean submitAll = false; + /** flag to indicate that all items in the sandbox are involved in the current action */ + private boolean allItemsAction = false; /* component references */ private UIRichList foldersRichList; @@ -151,36 +144,18 @@ public class AVMBrowseBean implements IContextListener /** The NodeService to be used by the bean */ protected NodeService nodeService; - /** The DictionaryService bean reference */ - protected DictionaryService dictionaryService; - - /** The SearchService bean reference. */ - protected SearchService searchService; - - /** The NamespaceService bean reference. */ - protected NamespaceService namespaceService; - /** The WorkflowService bean reference. */ protected WorkflowService workflowService; - /** The browse bean */ - protected BrowseBean browseBean; - /** The NavigationBean bean reference */ protected NavigationBean navigator; /** AVM service bean reference */ protected AVMService avmService; - /** AVM Sync service bean reference */ - protected AVMSyncService avmSyncService; - /** Action service bean reference */ protected ActionService actionService; - /** Global exclude name matcher */ - protected NameMatcher nameMatcher; - /** * Default Constructor @@ -202,14 +177,6 @@ public class AVMBrowseBean implements IContextListener this.avmService = avmService; } - /** - * @param avmSyncService The AVMSyncService to set. - */ - public void setAvmSyncService(AVMSyncService avmSyncService) - { - this.avmSyncService = avmSyncService; - } - /** * @param nodeService The NodeService to set. */ @@ -237,40 +204,6 @@ public class AVMBrowseBean implements IContextListener return this.nodeService; } - /** - * @param dictionaryService The DictionaryService to set. - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param searchService The SearchService to set. - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * @param namespaceService The NamespaceService to set. - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Sets the BrowseBean instance to use to retrieve the current document - * - * @param browseBean BrowseBean instance - */ - public void setBrowseBean(BrowseBean browseBean) - { - this.browseBean = browseBean; - } - /** * @param navigator The NavigationBean to set. */ @@ -287,14 +220,6 @@ public class AVMBrowseBean implements IContextListener this.actionService = actionService; } - /** - * @param nameMatcher The nameMatcher to set. - */ - public void setNameMatcher(NameMatcher nameMatcher) - { - this.nameMatcher = nameMatcher; - } - /** * Summary text for the staging store: * Created On: xx/yy/zz @@ -758,11 +683,11 @@ public class AVMBrowseBean implements IContextListener } /** - * @return true if the special Submit All action has been initialised + * @return true if a special All Items action has been initialised */ - public boolean getSubmitAll() + public boolean getAllItemsAction() { - return this.submitAll; + return this.allItemsAction; } @@ -833,7 +758,7 @@ public class AVMBrowseBean implements IContextListener this.location = null; setCurrentPath(null); setAvmActionNode(null); - this.submitAll = false; + this.allItemsAction = false; } } @@ -862,7 +787,7 @@ public class AVMBrowseBean implements IContextListener // calculate username and store name from specified path String[] parts = path.split("[-:]"); String storename = parts[0]; - String username = parts[1]; + String username = parts[2]; if (username.equals(AVMConstants.STORE_STAGING.substring(1))) { setupSandboxActionImpl(null, null, false); @@ -889,12 +814,12 @@ public class AVMBrowseBean implements IContextListener } /** - * Submit all nodes from user sandbox into the staging area sandbox via workflow + * Action handler for all nodes from user sandbox */ - public void setupSubmitAllAction(ActionEvent event) + public void setupAllItemsAction(ActionEvent event) { setupSandboxAction(event); - this.submitAll = true; + this.allItemsAction = true; } /** @@ -939,102 +864,6 @@ public class AVMBrowseBean implements IContextListener } } - /** - * Undo changes to the entire sandbox - */ - public void revertAll(ActionEvent event) - { - UIActionLink link = (UIActionLink)event.getComponent(); - Map params = link.getParameterMap(); - String store = params.get("store"); - String username = params.get("username"); - - UserTransaction tx = null; - try - { - FacesContext context = FacesContext.getCurrentInstance(); - tx = Repository.getUserTransaction(context, true); - tx.begin(); - - // calcluate the list of differences between the user store and the staging area - List diffs = this.avmSyncService.compare( - -1, store + ":/", -1, getStagingStore() + ":/", this.nameMatcher); - List> versionPaths = new ArrayList>(); - for (AVMDifference diff : diffs) - { - versionPaths.add(new Pair(-1, diff.getSourcePath())); - } - Map args = new HashMap(1, 1.0f); - args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths); - Action action = this.actionService.createAction(AVMUndoSandboxListAction.NAME, args); - this.actionService.executeAction(action, null); // dummy action ref - - // commit the transaction - tx.commit(); - - // if we get here, all was well - output friendly status message to the user - String msg = MessageFormat.format(Application.getMessage( - context, MSG_REVERTALL_SUCCESS), username); - displayStatusMessage(context, msg); - } - catch (Throwable err) - { - Utils.addErrorMessage(MessageFormat.format(Application.getMessage( - FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); - try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} - } - } - - /** - * Undo changes to items selected using multi-select - */ - public void revertSelected(ActionEvent event) - { - UIActionLink link = (UIActionLink)event.getComponent(); - Map params = link.getParameterMap(); - String username = params.get("username"); - - List selected = this.userSandboxes.getSelectedNodes(username); - if (selected != null) - { - UserTransaction tx = null; - try - { - FacesContext context = FacesContext.getCurrentInstance(); - tx = Repository.getUserTransaction(context, false); - tx.begin(); - - List> versionPaths = new ArrayList>(); - for (AVMNodeDescriptor node : selected) - { - versionPaths.add(new Pair(-1, node.getPath())); - } - Map args = new HashMap(1, 1.0f); - args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths); - for (AVMNodeDescriptor node : selected) - { - Action action = this.actionService.createAction(AVMUndoSandboxListAction.NAME, args); - this.actionService.executeAction(action, AVMNodeConverter.ToNodeRef(-1, node.getPath())); - } - - // commit the transaction - tx.commit(); - - // if we get here, all was well - output friendly status message to the user - String msg = MessageFormat.format(Application.getMessage( - context, MSG_REVERTSELECTED_SUCCESS), username); - displayStatusMessage(context, msg); - } - catch (Throwable err) - { - err.printStackTrace(System.err); - Utils.addErrorMessage(MessageFormat.format(Application.getMessage( - FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); - try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} - } - } - } - /** * Revert a sandbox to a specific snapshot version ID */ diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java index 4b9914fc76..ceccd7e045 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java @@ -404,8 +404,8 @@ public final class AVMConstants private static final String STORE_SEPARATOR = "--"; // names of the stores representing the layers for an AVM website - public final static String STORE_STAGING = ""; - public final static String STORE_MAIN = ""; + public final static String STORE_STAGING = STORE_SEPARATOR + "staging"; + public final static String STORE_MAIN = STORE_SEPARATOR + "main"; public final static String STORE_PREVIEW = STORE_SEPARATOR + "preview"; // system directories at the top level of an AVM website @@ -416,11 +416,8 @@ public final class AVMConstants public final static String DIR_APPBASE = "appBase"; public final static String DIR_WEBAPPS = "avm_webapps"; - - // servlet default webapp // Note: this webapp is mapped to the URL path "" - // public final static String DIR_ROOT = "ROOT"; // system property keys for sandbox identification and DNS virtualisation mapping diff --git a/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java b/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java new file mode 100644 index 0000000000..7c40a1f685 --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java @@ -0,0 +1,136 @@ +/* + * 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.bean.wcm; + +import java.io.Serializable; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ActionService; +import org.alfresco.service.cmr.avm.AVMNodeDescriptor; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.avmsync.AVMDifference; +import org.alfresco.service.cmr.avmsync.AVMSyncService; +import org.alfresco.util.NameMatcher; +import org.alfresco.util.Pair; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.dialog.BaseDialogBean; + +/** + * Revert (undo) all files in the current user sandbox. + * + * @author Kevin Roast + */ +public class RevertAllDialog extends BaseDialogBean +{ + private static final String MSG_REVERTALL_SUCCESS = "revertall_success"; + + protected AVMBrowseBean avmBrowseBean; + protected AVMSyncService avmSyncService; + protected ActionService actionService; + protected NameMatcher nameMatcher; + + /** + * @param avmBrowseBean The AVM BrowseBean to set + */ + public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) + { + this.avmBrowseBean = avmBrowseBean; + } + + /** + * @param avmSyncService The AVMSyncService to set. + */ + public void setAvmSyncService(AVMSyncService avmSyncService) + { + this.avmSyncService = avmSyncService; + } + + /** + * @param actionService The actionService to set. + */ + public void setActionService(ActionService actionService) + { + this.actionService = actionService; + } + + /** + * @param nameMatcher The nameMatcher to set. + */ + public void setNameMatcher(NameMatcher nameMatcher) + { + this.nameMatcher = nameMatcher; + } + + + /** + * @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String) + */ + @Override + protected String finishImpl(FacesContext context, String outcome) throws Exception + { + String webapp = this.avmBrowseBean.getWebapp(); + String userStore = AVMConstants.buildAVMStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp); + String stagingStore = AVMConstants.buildAVMStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp); + + // calcluate the list of differences between the user store and the staging area + List diffs = this.avmSyncService.compare( + -1, userStore, -1, stagingStore, this.nameMatcher); + List> versionPaths = new ArrayList>(); + for (AVMDifference diff : diffs) + { + versionPaths.add(new Pair(-1, diff.getSourcePath())); + } + Map args = new HashMap(1, 1.0f); + args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths); + Action action = this.actionService.createAction(AVMUndoSandboxListAction.NAME, args); + this.actionService.executeAction(action, null); // dummy action ref + + String msg = MessageFormat.format(Application.getMessage( + context, MSG_REVERTALL_SUCCESS), this.avmBrowseBean.getUsername()); + FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg); + context.addMessage(AVMBrowseBean.FORM_ID + ':' + AVMBrowseBean.COMPONENT_SANDBOXESPANEL, facesMsg); + + return outcome; + } + + /** + * @return the confirmation to display to the user + */ + public String getConfirmMessage() + { + return Application.getMessage(FacesContext.getCurrentInstance(), "revert_all_confirm"); + } + + /** + * @see org.alfresco.web.bean.dialog.BaseDialogBean#getFinishButtonDisabled() + */ + @Override + public boolean getFinishButtonDisabled() + { + return false; + } +} diff --git a/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java b/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java new file mode 100644 index 0000000000..95f479fef1 --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java @@ -0,0 +1,112 @@ +/* + * 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.bean.wcm; + +import java.io.Serializable; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction; +import org.alfresco.service.cmr.action.Action; +import org.alfresco.service.cmr.action.ActionService; +import org.alfresco.service.cmr.avm.AVMNodeDescriptor; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.util.Pair; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.dialog.BaseDialogBean; + +/** + * Revert (undo) the selected files in the current user sandbox. + * + * @author Kevin Roast + */ +public class RevertSelectedDialog extends BaseDialogBean +{ + private static final String MSG_REVERTSELECTED_SUCCESS = "revertselected_success"; + + protected AVMBrowseBean avmBrowseBean; + protected ActionService actionService; + + /** + * @param avmBrowseBean The AVM BrowseBean to set + */ + public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) + { + this.avmBrowseBean = avmBrowseBean; + } + + /** + * @param actionService The actionService to set. + */ + public void setActionService(ActionService actionService) + { + this.actionService = actionService; + } + + + /** + * @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String) + */ + @Override + protected String finishImpl(FacesContext context, String outcome) throws Exception + { + List selected = this.avmBrowseBean.getSelectedSandboxItems(); + List> versionPaths = new ArrayList>(); + for (AVMNodeDescriptor node : selected) + { + versionPaths.add(new Pair(-1, node.getPath())); + } + Map args = new HashMap(1, 1.0f); + args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths); + for (AVMNodeDescriptor node : selected) + { + Action action = this.actionService.createAction(AVMUndoSandboxListAction.NAME, args); + this.actionService.executeAction(action, AVMNodeConverter.ToNodeRef(-1, node.getPath())); + } + + String msg = MessageFormat.format(Application.getMessage( + context, MSG_REVERTSELECTED_SUCCESS), this.avmBrowseBean.getUsername()); + FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg); + context.addMessage(AVMBrowseBean.FORM_ID + ':' + AVMBrowseBean.COMPONENT_SANDBOXESPANEL, facesMsg); + + return outcome; + } + + /** + * @return the confirmation to display to the user + */ + public String getConfirmMessage() + { + return Application.getMessage(FacesContext.getCurrentInstance(), "revert_selected_confirm"); + } + + /** + * @see org.alfresco.web.bean.dialog.BaseDialogBean#getFinishButtonDisabled() + */ + @Override + public boolean getFinishButtonDisabled() + { + return false; + } +} diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index 09463b2d91..2e7532d0d8 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -454,7 +454,7 @@ public class SubmitDialog extends BaseDialogBean { // TODO: start txn here? List selected; - if (this.avmBrowseBean.getSubmitAll()) + if (this.avmBrowseBean.getAllItemsAction()) { String webapp = this.avmBrowseBean.getWebapp(); String userStore = AVMConstants.buildAVMStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp); diff --git a/source/java/org/alfresco/web/ui/common/Utils.java b/source/java/org/alfresco/web/ui/common/Utils.java index 34d4c58580..e7045a3119 100644 --- a/source/java/org/alfresco/web/ui/common/Utils.java +++ b/source/java/org/alfresco/web/ui/common/Utils.java @@ -633,8 +633,7 @@ public final class Utils NodeRef rootNode = contentCtx.getRootNode(); try { - Path path = nodeService.getPath(node.getNodeRef()); - url = Repository.getNamePath(nodeService, path, rootNode, "\\", + url = Repository.getNamePath(nodeService, node.getNodePath(), rootNode, "\\", "file:///" + navBean.getCIFSServerPath(diskShare)); } catch (AccessDeniedException e) diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java index 2fc17bb43b..f430358e5c 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -345,12 +345,12 @@ public class UIUserSandboxes extends SelfRenderingComponent Utils.encodeRecursive(context, aquireAction( context, mainStore, username, ACT_SANDBOX_SUBMITALL, "/images/icons/submit_all.gif", - "#{AVMBrowseBean.setupSubmitAllAction}", "dialog:submitSandboxItems")); + "#{AVMBrowseBean.setupAllItemsAction}", "dialog:submitSandboxItems")); out.write(" "); Utils.encodeRecursive(context, aquireAction( context, mainStore, username, ACT_SANDBOX_REVERTALL, "/images/icons/revert_all.gif", - "#{AVMBrowseBean.revertAll}", null)); + "#{AVMBrowseBean.setupAllItemsAction}", "dialog:revertAllItems")); out.write(" "); if (isManager) @@ -678,7 +678,7 @@ public class UIUserSandboxes extends SelfRenderingComponent out.write(" "); Utils.encodeRecursive(fc, aquireAction( fc, userStore, username, ACT_SANDBOX_REVERTSELECTED, "/images/icons/revert_all.gif", - "#{AVMBrowseBean.revertSelected}", null)); + "#{AVMBrowseBean.setupSandboxAction}", "dialog:revertSelectedItems")); out.write(""); // end table diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index bb1cde5951..24cab98cbf 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -1790,7 +1790,6 @@ avmSyncService #{AVMSyncService} - @@ -2363,10 +2362,6 @@ avmService #{AVMService} - - avmSyncService - #{AVMSyncService} - navigationBean #{NavigationBean} @@ -2383,10 +2378,6 @@ workflowService #{WorkflowService} - - nameMatcher - #{globalPathExcluder} - @@ -2888,6 +2879,48 @@ + + + The bean that backs up the Revert selected items Dialog + + RevertSelectedDialog + org.alfresco.web.bean.wcm.RevertSelectedDialog + session + + avmBrowseBean + #{AVMBrowseBean} + + + actionService + #{ActionService} + + + + + + The bean that backs up the Revert all items Dialog + + RevertAllDialog + org.alfresco.web.bean.wcm.RevertAllDialog + session + + avmBrowseBean + #{AVMBrowseBean} + + + actionService + #{ActionService} + + + avmSyncService + #{AVMSyncService} + + + nameMatcher + #{globalPathExcluder} + + + diff --git a/source/web/jsp/wcm/revert.jsp b/source/web/jsp/wcm/revert.jsp new file mode 100644 index 0000000000..8fc81f84c3 --- /dev/null +++ b/source/web/jsp/wcm/revert.jsp @@ -0,0 +1,26 @@ +<%-- + 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. +--%> +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> +<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> + +<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %> +<%@ page isELIgnored="false" %> + +