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 d8c2e48a7c..70c331a788 100644 Binary files a/source/web/images/icons/unlock.gif and b/source/web/images/icons/unlock.gif differ diff --git a/source/web/jsp/dialog/document-details.jsp b/source/web/jsp/dialog/document-details.jsp index 2586e7d60c..4436c21d32 100644 --- a/source/web/jsp/dialog/document-details.jsp +++ b/source/web/jsp/dialog/document-details.jsp @@ -77,22 +77,22 @@ - : - + : + - + <%-- 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 @@ - +