(8);
+ CategoriesDialog categoriesDialog = new CategoriesDialog();
+ loc.add(categoriesDialog.new CategoryBreadcrumbHandler(null, Application.getMessage(FacesContext.getCurrentInstance(), MSG_CATEGORIES)));
+
+ setLocation(loc);
+ }
+ return this.location;
+ }
+
+ @Override
+ public boolean getFinishButtonDisabled()
+ {
+ return false;
+ }
+
+ @Override
+ protected String finishImpl(FacesContext context, String outcome) throws Exception
+ {
+ finishDelete();
+ return outcome;
+ }
+
+ @Override
+ public String getContainerTitle()
+ {
+
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_DELETE_CATEGORY) + " '" + getActionCategory().getName() + "'";
+ }
+
+ @Override
+ public String getFinishButtonLabel()
+ {
+
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_DELETE);
+ }
+
+ public UIRichList getCategoriesRichList()
+ {
+ return categoriesRichList;
+ }
+
+ public void setCategoriesRichList(UIRichList categoriesRichList)
+ {
+ this.categoriesRichList = categoriesRichList;
+ }
+
+ /**
+ * @see org.alfresco.web.app.context.IContextListener#contextUpdated()
+ */
+ public void contextUpdated()
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Invalidating Category Management Components...");
+
+ // force a requery of the current category ref properties
+ setCategory(null);
+
+ // force a requery of the richlist dataset
+ if (this.categoriesRichList != null)
+ {
+ this.categoriesRichList.setValue(null);
+ }
+
+ }
+
+ /**
+ * @return The ID of the currently displayed category or null if at the root.
+ */
+ public String getCurrentCategoryId()
+ {
+ if (getCategoryRef() != null)
+ {
+ return getCategoryRef().getId();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Set the current category node.
+ *
+ * Setting this value causes the UI to update and display the specified node as current.
+ *
+ * @param ref The current category node.
+ */
+ public void setCurrentCategory(NodeRef ref)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Setting current category: " + ref);
+
+ // set the current NodeRef for our UI context operations
+ setCategoryRef(ref);
+
+ // clear current node context
+ setCategory(null);
+
+ // inform that the UI needs updating after this change
+ contextUpdated();
+ }
+
+
+ public String finishDelete()
+ {
+ String outcome = DEFAULT_OUTCOME;
+
+ if (getActionCategory() != null)
+ {
+ try
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
+ RetryingTransactionCallback callback = new RetryingTransactionCallback()
+ {
+ @SuppressWarnings("unchecked")
+ public NodeRef execute() throws Throwable
+ {
+ // delete the category node using the nodeservice
+ NodeRef categoryNodeRef = getActionCategory().getNodeRef();
+ getCategoryService().deleteCategory(categoryNodeRef);
+
+ // if there are other items in the repository using this category
+ // all the associations to the category should be removed too
+ if (getMembers() != null && getMembers().size() > 0)
+ {
+ for (ChildAssociationRef childRef : getMembers())
+ {
+ List list = new ArrayList(getMembers().size());
+
+ NodeRef member = childRef.getChildRef();
+ Collection categories = (Collection) nodeService.getProperty(member, ContentModel.PROP_CATEGORIES);
+
+ for (NodeRef category : categories)
+ {
+ if (category.equals(categoryNodeRef) == false)
+ {
+ list.add(category);
+ }
+ }
+
+ // persist the list back to the repository
+ nodeService.setProperty(member, ContentModel.PROP_CATEGORIES, (Serializable) list);
+ }
+ }
+ return categoryNodeRef;
+ }
+ };
+ NodeRef categoryNodeRef = txnHelper.doInTransaction(callback);
+
+ // remove this node from the breadcrumb if required
+ List location = getLocation();
+ IBreadcrumbHandler handler = location.get(location.size() - 1);
+
+ // see if the current breadcrumb location is our node
+ if (categoryNodeRef.equals(((IRepoBreadcrumbHandler) handler).getNodeRef()))
+ {
+ location.remove(location.size() - 1);
+
+ // now work out which node to set the list to refresh against
+ if (location.size() != 0)
+ {
+ handler = location.get(location.size() - 1);
+ this.setCurrentCategory(((IRepoBreadcrumbHandler) handler).getNodeRef());
+ }
+ }
+
+ // clear action context
+ setActionCategory(null);
+ }
+ catch (Throwable err)
+ {
+ Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
+ outcome = null;
+ }
+ }
+
+ return outcome;
+ }
+
+}
diff --git a/source/java/org/alfresco/web/bean/categories/EditCategoryDialog.java b/source/java/org/alfresco/web/bean/categories/EditCategoryDialog.java
new file mode 100644
index 0000000000..c7ebd7aa15
--- /dev/null
+++ b/source/java/org/alfresco/web/bean/categories/EditCategoryDialog.java
@@ -0,0 +1,281 @@
+/*
+ * 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.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.search.CategoryService;
+import org.alfresco.service.cmr.search.CategoryService.Depth;
+import org.alfresco.service.cmr.search.CategoryService.Mode;
+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;
+import org.alfresco.web.ui.common.Utils;
+import org.alfresco.web.ui.common.component.IBreadcrumbHandler;
+import org.alfresco.web.ui.common.component.data.UIRichList;
+import org.alfresco.web.ui.repo.component.IRepoBreadcrumbHandler;
+
+public class EditCategoryDialog extends BaseDialogBean
+{
+ private static final String DEFAULT_OUTCOME = "finish";
+ private final static String MSG_EDIT_CATEGORY = "edit_category";
+ private final static String MSG_FINISH = "finish_button";
+ private static final String MSG_CATEGORIES = "categories";
+
+ protected CategoryService categoryService;
+
+ /** Action category node */
+ private Node actionCategory = null;
+
+ /** Currently visible category Node */
+ private Node category = null;
+
+ String categoryRef = null;
+
+ /** Category path breadcrumb location */
+ private List location = null;
+
+ /** Members of the linked items of a category */
+ private Collection members = null;
+
+ /** Component references */
+ protected UIRichList categoriesRichList;
+
+ /** Dialog properties */
+ private String name = null;
+ private String description = null;
+
+ @Override
+ public void init(Map parameters)
+ {
+ this.isFinished = false;
+
+ // retrieve parameters
+ categoryRef = parameters.get(CategoriesDialog.PARAM_CATEGORY_REF);
+
+ // make sure nodeRef was supplied
+ ParameterCheck.mandatoryString(CategoriesDialog.PARAM_CATEGORY_REF, categoryRef);
+
+ // create the node
+ this.category = new Node(new NodeRef(categoryRef));
+
+ setActionCategory(category);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public UIRichList getCategoriesRichList()
+ {
+ return categoriesRichList;
+ }
+
+ public void setCategoriesRichList(UIRichList categoriesRichList)
+ {
+ this.categoriesRichList = categoriesRichList;
+ }
+
+ public CategoryService getCategoryService()
+ {
+ return categoryService;
+ }
+
+ public void setCategoryService(CategoryService categoryService)
+ {
+ this.categoryService = categoryService;
+ }
+
+ public Node getCategory()
+ {
+ return category;
+ }
+
+ public void setCategory(Node category)
+ {
+ this.category = category;
+ }
+
+ public Collection getMembers()
+ {
+ return members;
+ }
+
+ public void setMembers(Collection members)
+ {
+ this.members = members;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setActionCategory(Node node)
+ {
+ this.actionCategory = node;
+
+ if (node != null)
+ {
+ // setup form properties
+ setName(node.getName());
+ setDescription((String) node.getProperties().get(ContentModel.PROP_DESCRIPTION));
+ setMembers(getCategoryService().getChildren(node.getNodeRef(), Mode.MEMBERS, Depth.ANY));
+ }
+ else
+ {
+ setName(null);
+ setDescription(null);
+ Object emptyCollection = Collections.emptyList();
+ setMembers((Collection) emptyCollection);
+ }
+ }
+
+ public Node getActionCategory()
+ {
+ return actionCategory;
+ }
+
+ @Override
+ public boolean getFinishButtonDisabled()
+ {
+ return false;
+ }
+
+ @Override
+ protected String finishImpl(FacesContext context, String outcome) throws Exception
+ {
+
+ finishEdit();
+ return outcome;
+ }
+
+ @Override
+ public String getContainerTitle()
+ {
+
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_EDIT_CATEGORY) + " '" + getActionCategory().getName() + "'";
+ }
+
+ @Override
+ public String getFinishButtonLabel()
+ {
+
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_FINISH);
+ }
+
+ public void setLocation(List location)
+ {
+ this.location = location;
+ }
+
+ /**
+ * @return Breadcrumb location list
+ */
+ public List getLocation()
+ {
+ if (this.location == null)
+ {
+ List loc = new ArrayList(8);
+ CategoriesDialog categoriesDialog = new CategoriesDialog();
+ loc.add(categoriesDialog.new CategoryBreadcrumbHandler(null, Application.getMessage(FacesContext.getCurrentInstance(), MSG_CATEGORIES)));
+
+ setLocation(loc);
+ }
+ return this.location;
+ }
+
+ public String finishEdit()
+ {
+ String outcome = DEFAULT_OUTCOME;
+
+ try
+ {
+
+ // update the category node
+ NodeRef nodeRef = getActionCategory().getNodeRef();
+ nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, getName());
+
+ // apply the titled aspect - for description
+ if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
+ {
+ Map titledProps = new HashMap(1, 1.0f);
+ titledProps.put(ContentModel.PROP_DESCRIPTION, getDescription());
+ nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, titledProps);
+ }
+ else
+ {
+ nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, getDescription());
+ }
+
+ // edit the node in the breadcrumb if required
+ List location = getLocation();
+ IBreadcrumbHandler handler = location.get(location.size() - 1);
+
+ // see if the current breadcrumb location is our node
+ if (nodeRef.equals(((IRepoBreadcrumbHandler) handler).getNodeRef()))
+ {
+ // and update with the modified node details
+ CategoriesDialog categoriesDialog = new CategoriesDialog();
+ IBreadcrumbHandler newHandler = categoriesDialog.new CategoryBreadcrumbHandler(nodeRef, Repository.getNameForNode(nodeService, nodeRef));
+ location.set(location.size() - 1, newHandler);
+ }
+ }
+ catch (Throwable err)
+ {
+ Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
+ outcome = null;
+ }
+
+ return outcome;
+ }
+}
diff --git a/source/java/org/alfresco/web/bean/coci/CCCheckinFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCCheckinFileDialog.java
new file mode 100644
index 0000000000..046a15e78b
--- /dev/null
+++ b/source/java/org/alfresco/web/bean/coci/CCCheckinFileDialog.java
@@ -0,0 +1,36 @@
+package org.alfresco.web.bean.coci;
+
+import javax.faces.context.FacesContext;
+
+import org.alfresco.web.app.Application;
+
+public class CCCheckinFileDialog extends CheckinCheckoutDialog
+{
+
+ private static final String MSG_CHECK_IN = "check_in";
+
+ @Override
+ protected String finishImpl(FacesContext context, String outcome) throws Exception
+ {
+ return checkinFileOK(context, outcome);
+ }
+
+ @Override
+ public String getFinishButtonLabel()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CHECK_IN);
+ }
+
+ @Override
+ public String getContainerTitle()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CHECK_IN) + " '" + property.getDocument().getName() + "'";
+ }
+
+ @Override
+ public boolean getFinishButtonDisabled()
+ {
+ return false;
+ }
+
+}
diff --git a/source/java/org/alfresco/web/bean/CCCheckoutFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java
similarity index 99%
rename from source/java/org/alfresco/web/bean/CCCheckoutFileDialog.java
rename to source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java
index 316c29fa2e..ed80e9ca56 100644
--- a/source/java/org/alfresco/web/bean/CCCheckoutFileDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
diff --git a/source/java/org/alfresco/web/bean/CCCheckoutFileLinkDialog.java b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileLinkDialog.java
similarity index 95%
rename from source/java/org/alfresco/web/bean/CCCheckoutFileLinkDialog.java
rename to source/java/org/alfresco/web/bean/coci/CCCheckoutFileLinkDialog.java
index 3054392311..c2d7d7674f 100644
--- a/source/java/org/alfresco/web/bean/CCCheckoutFileLinkDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileLinkDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
@@ -62,6 +62,11 @@ public class CCCheckoutFileLinkDialog extends CheckinCheckoutDialog
{
return Application.getMessage(FacesContext.getCurrentInstance(), LBL_UNDO_CHECKOUT);
}
+
+ public String getFinishButtonLabel()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), "ok");
+ }
@Override
public String cancel()
diff --git a/source/java/org/alfresco/web/bean/CCEditFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCEditFileDialog.java
similarity index 98%
rename from source/java/org/alfresco/web/bean/CCEditFileDialog.java
rename to source/java/org/alfresco/web/bean/coci/CCEditFileDialog.java
index e4c41987a5..f2d96b1fcb 100644
--- a/source/java/org/alfresco/web/bean/CCEditFileDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCEditFileDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
diff --git a/source/java/org/alfresco/web/bean/CCEditHtmlInlineDialog.java b/source/java/org/alfresco/web/bean/coci/CCEditHtmlInlineDialog.java
similarity index 98%
rename from source/java/org/alfresco/web/bean/CCEditHtmlInlineDialog.java
rename to source/java/org/alfresco/web/bean/coci/CCEditHtmlInlineDialog.java
index 7865b4778a..d7765a604a 100644
--- a/source/java/org/alfresco/web/bean/CCEditHtmlInlineDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCEditHtmlInlineDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
diff --git a/source/java/org/alfresco/web/bean/CCEditTextInlineDialog.java b/source/java/org/alfresco/web/bean/coci/CCEditTextInlineDialog.java
similarity index 98%
rename from source/java/org/alfresco/web/bean/CCEditTextInlineDialog.java
rename to source/java/org/alfresco/web/bean/coci/CCEditTextInlineDialog.java
index 40bfffc03b..536dc9f9e7 100644
--- a/source/java/org/alfresco/web/bean/CCEditTextInlineDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCEditTextInlineDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
diff --git a/source/java/org/alfresco/web/bean/CCProperties.java b/source/java/org/alfresco/web/bean/coci/CCProperties.java
similarity index 98%
rename from source/java/org/alfresco/web/bean/CCProperties.java
rename to source/java/org/alfresco/web/bean/coci/CCProperties.java
index b1073622a9..e9dd0e63ca 100644
--- a/source/java/org/alfresco/web/bean/CCProperties.java
+++ b/source/java/org/alfresco/web/bean/coci/CCProperties.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import java.io.File;
@@ -328,13 +328,13 @@ public class CCProperties
*/
public String getCopyLocation()
{
- if (this.getFileName() != null)
+ if (this.getFileName() == null || this.getFileName().length() == 0)
{
- return CCProperties.COPYLOCATION_OTHER;
+ return this.copyLocation;
}
else
{
- return this.copyLocation;
+ return CCProperties.COPYLOCATION_OTHER;
}
}
diff --git a/source/java/org/alfresco/web/bean/CCUndoCheckoutFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCUndoCheckoutFileDialog.java
similarity index 99%
rename from source/java/org/alfresco/web/bean/CCUndoCheckoutFileDialog.java
rename to source/java/org/alfresco/web/bean/coci/CCUndoCheckoutFileDialog.java
index 34bd9917ae..74664ec0e1 100644
--- a/source/java/org/alfresco/web/bean/CCUndoCheckoutFileDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCUndoCheckoutFileDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
diff --git a/source/java/org/alfresco/web/bean/coci/CCUpdateFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCUpdateFileDialog.java
new file mode 100644
index 0000000000..76d1f60cf0
--- /dev/null
+++ b/source/java/org/alfresco/web/bean/coci/CCUpdateFileDialog.java
@@ -0,0 +1,34 @@
+package org.alfresco.web.bean.coci;
+
+import javax.faces.context.FacesContext;
+
+import org.alfresco.web.app.Application;
+
+public class CCUpdateFileDialog extends CheckinCheckoutDialog
+{
+ private final static String MSG_UPDATE = "update";
+
+ @Override
+ protected String finishImpl(FacesContext context, String outcome) throws Exception
+ {
+ return updateFileOK(context, outcome);
+ }
+
+ @Override
+ public String getContainerTitle()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_UPDATE) + " '" + property.getDocument().getName() + "'";
+ }
+
+ @Override
+ public boolean getFinishButtonDisabled()
+ {
+ return getFileName() == null;
+ }
+
+ @Override
+ public String getFinishButtonLabel()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), MSG_UPDATE);
+ }
+}
diff --git a/source/java/org/alfresco/web/bean/CCWorkingCopyMissingDialog.java b/source/java/org/alfresco/web/bean/coci/CCWorkingCopyMissingDialog.java
similarity index 98%
rename from source/java/org/alfresco/web/bean/CCWorkingCopyMissingDialog.java
rename to source/java/org/alfresco/web/bean/coci/CCWorkingCopyMissingDialog.java
index 318cde3bcf..5c5ac27a40 100644
--- a/source/java/org/alfresco/web/bean/CCWorkingCopyMissingDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCWorkingCopyMissingDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
diff --git a/source/java/org/alfresco/web/bean/CheckinCheckoutDialog.java b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java
similarity index 90%
rename from source/java/org/alfresco/web/bean/CheckinCheckoutDialog.java
rename to source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java
index 16b8ef211d..4429310ba7 100644
--- a/source/java/org/alfresco/web/bean/CheckinCheckoutDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.web.bean;
+package org.alfresco.web.bean.coci;
import java.io.Serializable;
import java.text.MessageFormat;
@@ -51,10 +51,12 @@ import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.app.servlet.DownloadContentServlet;
+import org.alfresco.web.bean.BrowseBean;
+import org.alfresco.web.bean.FileUploadBean;
+import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
-import org.alfresco.web.forms.FormNotFoundException;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink;
import org.apache.commons.logging.Log;
@@ -76,6 +78,8 @@ public class CheckinCheckoutDialog extends BaseDialogBean
public static final String MSG_ERROR_UPDATE = "error_update";
public static final String MSG_ERROR_CHECKOUT = "error_checkout";
+ public static final String FILE = "file";
+
protected CCProperties property;
// ------------------------------------------------------------------------------
@@ -129,6 +133,21 @@ public class CheckinCheckoutDialog extends BaseDialogBean
this.nodeService = nodeService;
}
+ public boolean getFinishButtonDisabled()
+ {
+ return false;
+ }
+
+ public String getFinishButtonLabel()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), "check_in");
+ }
+
+ public String getContainerTitle()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), "check_in") + " '" + this.property.getDocument().getName() + "'";
+ }
+
/**
* Determines whether the document being checked in has
* the versionable aspect applied
@@ -185,6 +204,33 @@ public class CheckinCheckoutDialog extends BaseDialogBean
}
}
+ /**
+ * Clear the uploaded form, clearing the specific Upload component by Id
+ */
+ protected void clearUpload(final String id)
+ {
+ // remove the file upload bean from the session
+ final FacesContext ctx = FacesContext.getCurrentInstance();
+ FileUploadBean fileBean = (FileUploadBean)
+ ctx.getExternalContext().getSessionMap().get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
+ if (fileBean != null)
+ {
+ fileBean.setFile(null);
+ fileBean.setFileName(null);
+ }
+ }
+
+ /**
+ * Action handler called when the user wishes to remove an uploaded file
+ */
+ public String removeUploadedFile()
+ {
+ this.clearUpload(CheckinCheckoutDialog.FILE);
+ property.setFileName(null) ;
+ property.setFile(null);
+ return null;
+ }
+
// ------------------------------------------------------------------------------
// Navigation action event handlers
@@ -419,17 +465,15 @@ public class CheckinCheckoutDialog extends BaseDialogBean
/**
* Action called upon completion of the Check In file page
*/
- public String checkinFileOK()
+ public String checkinFileOK(final FacesContext context, String outcome)
{
- String outcome = null;
// NOTE: for checkin the document node _is_ the working document!
final Node node = property.getDocument();
- if (node != null && (property.getCopyLocation().equals(CCProperties.COPYLOCATION_CURRENT) || this.getFileName() != null))
+ if (node != null && (property.getCopyLocation().equals(CCProperties.COPYLOCATION_CURRENT) || (this.getFileName() != null && !this.getFileName().equals(""))))
{
try
{
- final FacesContext context = FacesContext.getCurrentInstance();
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
RetryingTransactionCallback