From 8bb97be974c3e137a7929c0e3bc50b1825d76e4e Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Wed, 17 May 2006 16:15:49 +0000 Subject: [PATCH] . Added unlock action to doc details list of actions. - fixes AWC-566 and AWC-195 and AWC-221 . Fix for unreported issue where an error would occur when showing the details of a locked doc where it's associated working-copy had been deleted. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2912 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 3 ++ config/alfresco/web-client-config-actions.xml | 12 ++++++ .../action/evaluator/UnlockDocEvaluator.java | 36 +++++++++++++++++ .../alfresco/web/bean/BaseDetailsBean.java | 2 + .../web/bean/DocumentDetailsBean.java | 37 ++++++++++++++++++ source/web/images/icons/unlock.gif | Bin 886 -> 989 bytes source/web/jsp/dialog/document-details.jsp | 20 +++++----- 7 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 source/java/org/alfresco/web/action/evaluator/UnlockDocEvaluator.java diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index afea77b454..1956d9b31a 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -173,6 +173,8 @@ working_copy_document=Working Copy copy_of=Copy of link_to=Link to icon=Icon +lock=Lock +unlock=Unlock # Properties username=User Name @@ -526,6 +528,7 @@ select_category=Select a category selected_categories=Selected categories no_selected_categories=No categories selected. success_ownership=Successfully took ownership of the object. +success_unlock=Successfully unlocked the document. inherit_permissions=Inherit Parent Space Permissions success_inherit_permissions=Successfully changed Inherit Parent Permissions to 'Yes' success_not_inherit_permissions=Successfully changed Inherit Parent Permissions to 'No' diff --git a/config/alfresco/web-client-config-actions.xml b/config/alfresco/web-client-config-actions.xml index 6aa20cc859..406f207f15 100644 --- a/config/alfresco/web-client-config-actions.xml +++ b/config/alfresco/web-client-config-actions.xml @@ -396,6 +396,17 @@ #{SpaceDetailsBean.takeOwnership} + + + + Unlock + + org.alfresco.web.action.evaluator.UnlockDocEvaluator + unlock + /images/icons/unlock.gif + #{DocumentDetailsBean.unlock} + + @@ -560,6 +571,7 @@ + diff --git a/source/java/org/alfresco/web/action/evaluator/UnlockDocEvaluator.java b/source/java/org/alfresco/web/action/evaluator/UnlockDocEvaluator.java new file mode 100644 index 0000000000..11020467c2 --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/UnlockDocEvaluator.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 - Unlock a locked document. + * + * @author Kevin Roast + */ +public final class UnlockDocEvaluator implements ActionEvaluator +{ + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + return (node.isLocked() == true); + } +} diff --git a/source/java/org/alfresco/web/bean/BaseDetailsBean.java b/source/java/org/alfresco/web/bean/BaseDetailsBean.java index 9c464bab11..65795a5cce 100644 --- a/source/java/org/alfresco/web/bean/BaseDetailsBean.java +++ b/source/java/org/alfresco/web/bean/BaseDetailsBean.java @@ -334,6 +334,8 @@ public abstract class BaseDetailsBean String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc); fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg); + getNode().reset(); + // commit the transaction tx.commit(); } diff --git a/source/java/org/alfresco/web/bean/DocumentDetailsBean.java b/source/java/org/alfresco/web/bean/DocumentDetailsBean.java index ca259212fd..1a6065b437 100644 --- a/source/java/org/alfresco/web/bean/DocumentDetailsBean.java +++ b/source/java/org/alfresco/web/bean/DocumentDetailsBean.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; import javax.transaction.UserTransaction; @@ -64,6 +65,7 @@ public class DocumentDetailsBean extends BaseDetailsBean private static final String MSG_HAS_FOLLOWING_CATEGORIES = "has_following_categories"; private static final String MSG_NO_CATEGORIES_APPLIED = "no_categories_applied"; + private static final String MSG_SUCCESS_UNLOCK = "success_unlock"; private static final String MSG_ERROR_ASPECT_INLINEEDITABLE = "error_aspect_inlineeditable"; private static final String MSG_ERROR_ASPECT_VERSIONING = "error_aspect_versioning"; private static final String MSG_ERROR_ASPECT_CLASSIFY = "error_aspect_classify"; @@ -820,6 +822,41 @@ public class DocumentDetailsBean extends BaseDetailsBean } } + /** + * Action Handler to unlock a locked document + */ + public void unlock(ActionEvent event) + { + FacesContext fc = FacesContext.getCurrentInstance(); + + UserTransaction tx = null; + + try + { + tx = Repository.getUserTransaction(fc); + tx.begin(); + + this.lockService.unlock(getNode().getNodeRef()); + + String msg = Application.getMessage(fc, MSG_SUCCESS_UNLOCK); + FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg); + String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc); + fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg); + + getNode().reset(); + + // commit the transaction + tx.commit(); + } + catch (Throwable e) + { + // rollback the transaction + try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} + Utils.addErrorMessage(MessageFormat.format(Application.getMessage( + fc, Repository.ERROR_GENERIC), e.getMessage()), e); + } + } + /** * Applies the inlineeditable aspect to the current document */ diff --git a/source/web/images/icons/unlock.gif b/source/web/images/icons/unlock.gif index d8c2e48a7c22e084d0a05b15d2c143494d8f6413..70c331a788634115d7d1a035d8a1fa175bc5fbfb 100644 GIT binary patch delta 607 zcmV-l0-*i&2HgjLM@dFFIbje05CHc803Hi{Dj9?=D~&ESl2vG}Q+Tv)VytR=w|#uH ze}A?nlfEaEz9^KxDwV$~mB1^Oz$}))FqpwInZh!f!ZVt}HJigXoWnks!8o17I-SHj zp2a<%#Xq3NK%mA!p~ga?$3mjVL!!q?rO8aD%1x)rPpHa&P^rsNsmoKU%vP(-SFFui ztr_Pb8(4?cv zrlZKMs?4u{tj)c=*@3~@gTmT{!`q9++>6HCjKXA>bl+Qzu)Y_!P~>Z+sMY<)6wJK-s{8R?ZxBn$mH(P z=<(9&^403{*6Z`w?DOX3@8sn0=JWXI^!WDn`v3m~|NsC0u|bRhe?U4lL*NJ5n>%8Q7T$2f<|M)I!Dxa95}}Y z4=Y!s^r+E-1dBNcW1Nw52M?V#V6*_C!2#inF>c_*c|*nv79TJ)AawCXOc^svlx&%T zV}%8TDY9_sasWVpQ5-yAl$d~U#1AS}2mmmkLk0>D5DML_@n literal 886 zcmZ?wbhEHb*15 z*v8AMHp9d4U^6SXNXC_p1rEp9_+(518W
- : - + : +
-
+
<%-- Navigation --%> - + - + @@ -116,8 +116,6 @@
- - <%-- wrapper comment used by the panel to add additional component facets --%> @@ -222,7 +220,8 @@ action="#{DocumentDetailsBean.applyInlineEditable}" rendered="#{DocumentDetailsBean.inlineEditable == false}" /> - + +
@@ -253,7 +252,8 @@ columns="1" mode="view" labelStyleClass="propertiesLabel" externalConfig="true" /> - + + @@ -383,7 +383,7 @@
- +