diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties
index 9ad5369915..78868eda95 100644
--- a/config/alfresco/messages/webclient.properties
+++ b/config/alfresco/messages/webclient.properties
@@ -302,7 +302,8 @@ label=Label
edit_doc_offline=Edit offline
edit_doc_online=Edit online
upload_new_version=Upload new version
-checkin_this_file=Check in this file
+checkin_this_file=Check in this file
+cannot_delete_node_has_working_copy=Cannot delete file \"{0}\" as it has an associated working copy.
# Properties
username=User Name
diff --git a/config/alfresco/web-client-config-actions.xml b/config/alfresco/web-client-config-actions.xml
index 44d033683c..9f847fca68 100644
--- a/config/alfresco/web-client-config-actions.xml
+++ b/config/alfresco/web-client-config-actions.xml
@@ -258,10 +258,10 @@
org.alfresco.web.action.evaluator.DeleteDocEvaluator
delete
/images/icons/delete.gif
- #{BrowseBean.setupContentAction}
- dialog:deleteFile
+ #{BrowseBean.deleteFile}
#{actionContext.id}
+ #{actionContext.nodeRef}
diff --git a/source/java/org/alfresco/web/bean/BrowseBean.java b/source/java/org/alfresco/web/bean/BrowseBean.java
index a74e495c16..907b6d0cff 100644
--- a/source/java/org/alfresco/web/bean/BrowseBean.java
+++ b/source/java/org/alfresco/web/bean/BrowseBean.java
@@ -35,6 +35,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import javax.faces.application.NavigationHandler;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction;
@@ -43,7 +44,7 @@ import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService;
import org.alfresco.model.ApplicationModel;
-import org.alfresco.model.ContentModel;
+import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.SearcherException;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
@@ -2055,7 +2056,65 @@ public class BrowseBean implements IContextListener, Serializable
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, outcome);
}
+ /**
+ * Event handler used when a file is being deleted, checks that the node
+ * does not have an associated working copy.
+ *
+ * @param event The event
+ */
+
+ public void deleteFile(ActionEvent event)
+ {
+ setupContentAction(event);
+
+ UIActionLink link = (UIActionLink)event.getComponent();
+ Map params = link.getParameterMap();
+ String ref = params.get("ref");
+ if (ref != null && ref.length() > 0)
+ {
+ NodeRef nodeRef = new NodeRef(ref);
+
+ boolean hasWorkingCopy = false;
+ ResultSet resultSet = null;
+
+ try
+ {
+ // query for a working copy
+ resultSet = getSearchService().query(nodeRef.getStoreRef(), SearchService.LANGUAGE_LUCENE,
+ "ASPECT:\"" + ContentModel.ASPECT_WORKING_COPY.toString() +
+ "\" AND +@\\{http\\://www.alfresco.org/model/content/1.0\\}" +
+ ContentModel.PROP_COPY_REFERENCE.getLocalName() + ":\"" + nodeRef.toString() + "\"");
+
+ if (resultSet.getNodeRefs().size() != 0)
+ {
+ hasWorkingCopy = true;
+ }
+ }
+ finally
+ {
+ if (resultSet != null)
+ {
+ resultSet.close();
+ }
+ }
+
+ if (hasWorkingCopy)
+ {
+ // if node has a working copy setup error message and return
+ Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
+ FacesContext.getCurrentInstance(), MSG_CANNOT_DELETE_NODE_HAS_WORKING_COPY),
+ new Object[] {getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME)}));
+ return;
+ }
+
+ // if there isn't a working copy go to normal delete dialog
+ FacesContext fc = FacesContext.getCurrentInstance();
+ NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
+ navigationHandler.handleNavigation(fc, null, "dialog:deleteFile");
+ }
+ }
+
// ------------------------------------------------------------------------------
// Inner classes
@@ -2135,6 +2194,7 @@ public class BrowseBean implements IContextListener, Serializable
/** I18N messages */
private static final String MSG_DELETE_COMPANYROOT = "delete_companyroot_confirm";
public static final String MSG_SEARCH_MINIMUM = "search_minimum";
+ private static final String MSG_CANNOT_DELETE_NODE_HAS_WORKING_COPY = "cannot_delete_node_has_working_copy";
/** The NodeService to be used by the bean */
private transient NodeService nodeService;
diff --git a/source/web/jsp/wcm/import-content-dialog.jsp b/source/web/jsp/wcm/import-content-dialog.jsp
index b9650b4f05..f3fe038f86 100644
--- a/source/web/jsp/wcm/import-content-dialog.jsp
+++ b/source/web/jsp/wcm/import-content-dialog.jsp
@@ -37,6 +37,26 @@
+
+