diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index d8a1373c28..8b9378a91b 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -365,13 +365,8 @@ icon="/images/icons/save_search_large.gif" title-id="save_edit_search" description-id="save_search_description" /> - - - + callback = new RetryingTransactionCallback() - { - public Object execute() throws Throwable - { - // firstly retrieve all the properties for the current node - Map updateProps = nodeService.getProperties(getDocument().getNodeRef()); - - // create a node ref representation of the selected id and set the new properties - updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable) categories); - - // set the properties on the node - nodeService.setProperties(getDocument().getNodeRef(), updateProps); - return null; - } - }; - txnHelper.doInTransaction(callback); - - // reset the state of the current document so it reflects the changes just made - getDocument().reset(); - - } - catch (Throwable e) - { - Utils.addErrorMessage(MessageFormat.format(Application.getMessage( - FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_CATEGORY), e.getMessage()), e); - } - - return outcome; - } - /** * Applies the classifiable aspect to the current document */ @@ -1097,78 +982,4 @@ public class DocumentDetailsBean extends BaseDetailsBean implements IDialogBean { this.editionService = editionService; } - - // ------------------------------------------------------------------------------ - // IDialogBean implementation - - public String cancel() - { - return baseDialogBean.cancel(); - } - - public String finish() - { - return baseDialogBean.finish(); - } - - public List getAdditionalButtons() - { - return baseDialogBean.getAdditionalButtons(); - } - - public String getCancelButtonLabel() - { - return baseDialogBean.getCancelButtonLabel(); - } - - public String getContainerDescription() - { - return baseDialogBean.getContainerDescription(); - } - - public String getContainerTitle() - { - return Application.getMessage(FacesContext.getCurrentInstance(), MSG_MODIFY_CATEGORIES_OF) + - " '" + getDocument().getName() + "'"; - } - - public String getContainerSubTitle() - { - return baseDialogBean.getContainerSubTitle(); - } - - public boolean getFinishButtonDisabled() - { - return false; - } - - public String getFinishButtonLabel() - { - return baseDialogBean.getFinishButtonLabel(); - } - - public void init(Map parameters) - { - baseDialogBean.init(parameters); - } - - public void restored() - { - baseDialogBean.restored(); - } - - public Object getActionsContext() - { - return baseDialogBean.getActionsContext(); - } - - public String getActionsConfigId() - { - return baseDialogBean.getActionsConfigId(); - } - - public String getMoreActionsConfigId() - { - return baseDialogBean.getMoreActionsConfigId(); - } } diff --git a/source/java/org/alfresco/web/bean/SpaceDetailsBean.java b/source/java/org/alfresco/web/bean/SpaceDetailsBean.java index 62913cc660..82242c918b 100644 --- a/source/java/org/alfresco/web/bean/SpaceDetailsBean.java +++ b/source/java/org/alfresco/web/bean/SpaceDetailsBean.java @@ -24,7 +24,6 @@ */ package org.alfresco.web.bean; -import java.io.Serializable; import java.text.MessageFormat; import java.util.Collection; import java.util.HashMap; @@ -39,15 +38,11 @@ import org.alfresco.model.ApplicationModel; import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.TemplateService; -import org.alfresco.service.namespace.QName; import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.Application; import org.alfresco.web.app.servlet.GuestTemplateContentServlet; -import org.alfresco.web.bean.dialog.BaseDialogBean; -import org.alfresco.web.bean.dialog.IDialogBean; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils.URLMode; import org.alfresco.web.ui.common.component.UIActionLink; @@ -57,31 +52,15 @@ import org.alfresco.web.ui.common.component.UIActionLink; * * @author Kevin Roast */ -public class SpaceDetailsBean extends BaseDetailsBean implements IDialogBean +public class SpaceDetailsBean extends BaseDetailsBean { private static final String MSG_HAS_FOLLOWING_CATEGORIES = "has_following_categories_space"; private static final String MSG_NO_CATEGORIES_APPLIED = "no_categories_applied_space"; - private static final String MSG_ERROR_UPDATE_CATEGORY = "error_update_category"; private static final String MSG_ERROR_ASPECT_CLASSIFY = "error_aspect_classify_space"; - private static final String MSG_MODIFY_CATEGORIES_OF = "modify_categories_of"; - - /** Category details */ - private NodeRef addedCategory; - private List categories; - private BaseDialogBean baseDialogBean = new BaseDialogBeanImpl(); /** RSS Template ID */ private String rssTemplate; - private class BaseDialogBeanImpl extends BaseDialogBean - { - @Override - protected String finishImpl(FacesContext context, String outcome) throws Exception - { - return saveCategories(context, outcome); - } - } - // ------------------------------------------------------------------------------ // Construction @@ -352,99 +331,6 @@ public class SpaceDetailsBean extends BaseDetailsBean implements IDialogBean return html; } - - /** - * Event handler called to setup the categories for editing - * - * @param event The event - */ - public void setupCategoriesForEdit(ActionEvent event) - { - this.categories = (List)this.nodeService.getProperty(getSpace().getNodeRef(), - ContentModel.PROP_CATEGORIES); - } - - /** - * Returns a Map of the initial categories on the node keyed by the NodeRef - * - * @return Map of initial categories - */ - public List getCategories() - { - return this.categories; - } - - /** - * Sets the categories Map - * - * @param categories - */ - public void setCategories(List categories) - { - this.categories = categories; - } - - /** - * Returns the last category added from the multi value editor - * - * @return The last category added - */ - public NodeRef getAddedCategory() - { - return this.addedCategory; - } - - /** - * Sets the category added from the multi value editor - * - * @param addedCategory The added category - */ - public void setAddedCategory(NodeRef addedCategory) - { - this.addedCategory = addedCategory; - } - - /** - * Updates the categories for the current document - * - * @return The outcome - */ - public String saveCategories(FacesContext newContext, String newOutcome) - { - String outcome = newOutcome; - - UserTransaction tx = null; - - try - { - tx = Repository.getUserTransaction(FacesContext.getCurrentInstance()); - tx.begin(); - - // firstly retrieve all the properties for the current node - Map updateProps = this.nodeService.getProperties( - getSpace().getNodeRef()); - - // create a node ref representation of the selected id and set the new properties - updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable)this.categories); - - // set the properties on the node - this.nodeService.setProperties(getSpace().getNodeRef(), updateProps); - - // commit the transaction - tx.commit(); - - // reset the state of the current document so it reflects the changes just made - getSpace().reset(); - } - catch (Throwable e) - { - try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} - Utils.addErrorMessage(MessageFormat.format(Application.getMessage( - FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_CATEGORY), e.getMessage()), e); - } - - return outcome; - } /** * Applies the classifiable aspect to the current document @@ -598,78 +484,4 @@ public class SpaceDetailsBean extends BaseDetailsBean implements IDialogBean FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e); } } - - // ------------------------------------------------------------------------------ - // dialog implementation - - public String cancel() - { - return baseDialogBean.cancel(); - } - - public String finish() - { - return baseDialogBean.finish(); - } - - public List getAdditionalButtons() - { - return baseDialogBean.getAdditionalButtons(); - } - - public String getCancelButtonLabel() - { - return baseDialogBean.getCancelButtonLabel(); - } - - public String getContainerDescription() - { - return baseDialogBean.getContainerDescription(); - } - - public String getContainerTitle() - { - return Application.getMessage(FacesContext.getCurrentInstance(), MSG_MODIFY_CATEGORIES_OF) + - " '" + getSpace().getName() + "'"; - } - - public String getContainerSubTitle() - { - return baseDialogBean.getContainerSubTitle(); - } - - public boolean getFinishButtonDisabled() - { - return false; - } - - public String getFinishButtonLabel() - { - return baseDialogBean.getFinishButtonLabel(); - } - - public void init(Map parameters) - { - baseDialogBean.init(parameters); - } - - public void restored() - { - baseDialogBean.restored(); - } - - public Object getActionsContext() - { - return baseDialogBean.getActionsContext(); - } - - public String getActionsConfigId() - { - return baseDialogBean.getActionsConfigId(); - } - - public String getMoreActionsConfigId() - { - return baseDialogBean.getMoreActionsConfigId(); - } } diff --git a/source/java/org/alfresco/web/bean/categories/EditNodeCategoriesDialog.java b/source/java/org/alfresco/web/bean/categories/EditNodeCategoriesDialog.java new file mode 100644 index 0000000000..472ba9d105 --- /dev/null +++ b/source/java/org/alfresco/web/bean/categories/EditNodeCategoriesDialog.java @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.web.bean.categories; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import javax.faces.context.FacesContext; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.ParameterCheck; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.dialog.BaseDialogBean; +import org.alfresco.web.bean.repository.Node; +import org.alfresco.web.bean.repository.Repository; + +/** + * Implementation for the edit node categories dialog. + * + * @author gavinc + */ +public class EditNodeCategoriesDialog extends BaseDialogBean +{ + protected Node node; + protected NodeRef addedCategory; + protected List categories; + protected String description; + + private static final String MSG_ERROR_UPDATE_CATEGORY = "error_update_category"; + private static final String MSG_MODIFY_CATEGORIES_OF = "modify_categories_of"; + + // ------------------------------------------------------------------------------ + // Dialog implementation + + @Override + public void init(Map parameters) + { + super.init(parameters); + + // reset variables + this.categories = null; + this.addedCategory = null; + + // retrieve parameters + String id = parameters.get("id"); + + // make sure id was supplied + ParameterCheck.mandatoryString("id", id); + + // create the node + this.node = new Node(new NodeRef(Repository.getStoreRef(), id)); + + // determine description for dialog + FacesContext context = FacesContext.getCurrentInstance(); + if (this.dictionaryService.isSubClass(this.node.getType(), ContentModel.TYPE_FOLDER)) + { + this.description = Application.getMessage(context, "editcategory_space_description"); + } + else + { + this.description = Application.getMessage(context, "editcategory_description"); + } + } + + @Override + protected String finishImpl(FacesContext context, String outcome) throws Exception + { + // firstly retrieve all the properties for the current node + Map updateProps = this.nodeService.getProperties(this.node.getNodeRef()); + + // create a node ref representation of the selected id and set the new properties + updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable) categories); + + // set the properties on the node + this.nodeService.setProperties(this.node.getNodeRef(), updateProps); + + return outcome; + } + + @Override + public boolean getFinishButtonDisabled() + { + return false; + } + + @Override + public String getContainerTitle() + { + return Application.getMessage(FacesContext.getCurrentInstance(), MSG_MODIFY_CATEGORIES_OF) + + " '" + this.node.getName() + "'"; + } + + @Override + public String getContainerDescription() + { + return this.description; + } + + @Override + protected String getErrorMessageId() + { + return MSG_ERROR_UPDATE_CATEGORY; + } + + // ------------------------------------------------------------------------------ + // Bean property getters and setters + + /** + * Returns a Map of the initial categories on the node keyed by the NodeRef + * + * @return Map of initial categories + */ + public List getCategories() + { + if (this.categories == null) + { + // get the list of categories + this.categories = (List)this.nodeService.getProperty(this.node.getNodeRef(), + ContentModel.PROP_CATEGORIES); + } + + return this.categories; + } + + /** + * Sets the categories Map + * + * @param categories + */ + public void setCategories(List categories) + { + this.categories = categories; + } + + /** + * Returns the last category added from the multi value editor + * + * @return The last category added + */ + public NodeRef getAddedCategory() + { + return this.addedCategory; + } + + /** + * Sets the category added from the multi value editor + * + * @param addedCategory The added category + */ + public void setAddedCategory(NodeRef addedCategory) + { + this.addedCategory = addedCategory; + } +} diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 01ca94d044..d66e237e3c 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -4430,6 +4430,25 @@ session + + + The bean for the Edit Node Categories screen. + + EditNodeCategoriesDialog + + org.alfresco.web.bean.categories.EditNodeCategoriesDialog + + session + + nodeService + #{NodeService} + + + dictionaryService + #{DictionaryService} + + + The bean for the Edit Category screen. diff --git a/source/web/jsp/dialog/edit-category.jsp b/source/web/jsp/categories/edit-node-categories.jsp similarity index 90% rename from source/web/jsp/dialog/edit-category.jsp rename to source/web/jsp/categories/edit-node-categories.jsp index e271cde793..883f9baf90 100644 --- a/source/web/jsp/dialog/edit-category.jsp +++ b/source/web/jsp/categories/edit-node-categories.jsp @@ -37,15 +37,15 @@ + styleClass="selector" value="#{DialogManager.bean.addedCategory}" /> diff --git a/source/web/jsp/dialog/document-details.jsp b/source/web/jsp/dialog/document-details.jsp index fc9843bcf1..838a5aaf54 100644 --- a/source/web/jsp/dialog/document-details.jsp +++ b/source/web/jsp/dialog/document-details.jsp @@ -405,7 +405,9 @@ + action="dialog:editNodeCategories" actionListener="#{DialogManager.setupParameters}"> + + diff --git a/source/web/jsp/dialog/edit-space-category.jsp b/source/web/jsp/dialog/edit-space-category.jsp deleted file mode 100644 index aab2a9c295..0000000000 --- a/source/web/jsp/dialog/edit-space-category.jsp +++ /dev/null @@ -1,56 +0,0 @@ -<%-- -* Copyright (C) 2005-2007 Alfresco Software Limited. - -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -* As a special exception to the terms and conditions of version 2.0 of -* the GPL, you may redistribute this Program in connection with Free/Libre -* and Open Source Software ("FLOSS") applications as described in Alfresco's -* FLOSS exception. You should have recieved a copy of the text describing -* the FLOSS exception, and it is also available here: -* http://www.alfresco.com/legal/licensing" ---%> -<%@ 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" %> - - - - - - - - - -
: - - - - - - -
-
- diff --git a/source/web/jsp/dialog/space-details.jsp b/source/web/jsp/dialog/space-details.jsp index bb27606287..451fd38f34 100644 --- a/source/web/jsp/dialog/space-details.jsp +++ b/source/web/jsp/dialog/space-details.jsp @@ -253,7 +253,9 @@ + action="dialog:editNodeCategories" actionListener="#{DialogManager.setupParameters}"> + +