diff --git a/source/java/org/alfresco/web/bean/TrashcanBean.java b/source/java/org/alfresco/web/bean/TrashcanBean.java index 13bc4cc332..a209c99a74 100644 --- a/source/java/org/alfresco/web/bean/TrashcanBean.java +++ b/source/java/org/alfresco/web/bean/TrashcanBean.java @@ -35,10 +35,10 @@ import org.alfresco.repo.node.archive.RestoreNodeReport; import org.alfresco.repo.node.archive.RestoreNodeReport.RestoreStatus; import org.alfresco.repo.search.impl.lucene.QueryParser; import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Path; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSetRow; import org.alfresco.service.cmr.search.SearchParameters; @@ -479,13 +479,31 @@ public class TrashcanBean implements IContextListener private NodePropertyResolver resolverLocationPath = new NodePropertyResolver() { public Object get(Node node) { - return (Path)node.getProperties().get(ContentModel.PROP_ARCHIVED_ORIGINAL_PATH); + ChildAssociationRef childRef = + (ChildAssociationRef)node.getProperties().get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); + if (nodeService.exists(childRef.getParentRef())) + { + return nodeService.getPath(childRef.getParentRef()); + } + else + { + return null; + } } }; private NodePropertyResolver resolverDisplayPath = new NodePropertyResolver() { public Object get(Node node) { - return Repository.getDisplayPath((Path)node.getProperties().get(ContentModel.PROP_ARCHIVED_ORIGINAL_PATH)); + ChildAssociationRef childRef = + (ChildAssociationRef)node.getProperties().get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); + if (nodeService.exists(childRef.getParentRef())) + { + return Repository.getDisplayPath(nodeService.getPath(childRef.getParentRef()), true); + } + else + { + return ""; + } } }; @@ -623,6 +641,16 @@ public class TrashcanBean implements IContextListener contextUpdated(); } + /** + * Action handler to setup actions that act on lists + */ + public void setupListAction(ActionEvent event) + { + // clear the UI state in preparation for finishing the next action + setDestination(null); + contextUpdated(); + } + /** * Delete single item OK button handler */ @@ -739,28 +767,28 @@ public class TrashcanBean implements IContextListener { FacesContext fc = FacesContext.getCurrentInstance(); + // restore the nodes - the user may have requested a restore to a different parent + List nodeRefs = new ArrayList(this.listedItems.size()); + for (Node node : this.listedItems) + { + nodeRefs.add(node.getNodeRef()); + } + List reports; + if (this.destination == null) + { + reports = this.nodeArchiveService.restoreArchivedNodes(nodeRefs); + } + else + { + reports = this.nodeArchiveService.restoreArchivedNodes(nodeRefs, this.destination, null, null); + } + UserTransaction tx = null; try { tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true); tx.begin(); - // restore the nodes - the user may have requested a restore to a different parent - List nodeRefs = new ArrayList(this.listedItems.size()); - for (Node node : this.listedItems) - { - nodeRefs.add(node.getNodeRef()); - } - List reports; - if (this.destination == null) - { - reports = this.nodeArchiveService.restoreArchivedNodes(nodeRefs); - } - else - { - reports = this.nodeArchiveService.restoreArchivedNodes(nodeRefs, this.destination, null, null); - } - saveReportDetail(reports); tx.commit(); @@ -776,9 +804,6 @@ public class TrashcanBean implements IContextListener fc.addMessage(null, facesMsg); } - // clear the UI state in preparation for finishing the action - contextUpdated(); - return OUTCOME_RECOVERY_REPORT; } @@ -789,24 +814,23 @@ public class TrashcanBean implements IContextListener { FacesContext fc = FacesContext.getCurrentInstance(); + // restore all nodes - the user may have requested a restore to a different parent + List reports; + if (this.destination == null) + { + reports = this.nodeArchiveService.restoreAllArchivedNodes(Repository.getStoreRef()); + } + else + { + reports = this.nodeArchiveService.restoreAllArchivedNodes(Repository.getStoreRef(), this.destination, null, null); + } + UserTransaction tx = null; try { tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true); tx.begin(); - // restore all nodes - the user may have requested a restore to a different parent - List reports; - if (this.destination == null) - { - reports = this.nodeArchiveService.restoreAllArchivedNodes(Repository.getStoreRef()); - } - else - { - reports = this.nodeArchiveService.restoreAllArchivedNodes(Repository.getStoreRef(), this.destination, null, null); - } - - // TODO: wrap all this in a UserTransaction - it performs a lot of getProperties()! saveReportDetail(reports); tx.commit(); @@ -822,9 +846,6 @@ public class TrashcanBean implements IContextListener fc.addMessage(null, facesMsg); } - // clear the UI state in preparation for finishing the action - contextUpdated(); - return OUTCOME_RECOVERY_REPORT; } @@ -858,9 +879,6 @@ public class TrashcanBean implements IContextListener FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); } - // clear the UI state in preparation for finishing the action - contextUpdated(); - return OUTCOME_DIALOGCLOSE; } @@ -879,9 +897,6 @@ public class TrashcanBean implements IContextListener FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); } - // clear the UI state in preparation for finishing the action - contextUpdated(); - return OUTCOME_DIALOGCLOSE; } @@ -1100,10 +1115,11 @@ public class TrashcanBean implements IContextListener buf.append(""); buf.append(node.getName()); buf.append(""); - Path path = (Path)node.getProperties().get(ContentModel.PROP_ARCHIVED_ORIGINAL_PATH); - if (path != null) + ChildAssociationRef childRef = + (ChildAssociationRef)node.getProperties().get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); + if (nodeService.exists(childRef.getParentRef())) { - buf.append(Repository.getDisplayPath(path)); + buf.append(Repository.getNamePath(nodeService, nodeService.getPath(childRef.getParentRef()), null, "/", null)); } buf.append(""); if (report) diff --git a/source/java/org/alfresco/web/bean/repository/Repository.java b/source/java/org/alfresco/web/bean/repository/Repository.java index 3f3b4b0ea0..3860ac21ee 100644 --- a/source/java/org/alfresco/web/bean/repository/Repository.java +++ b/source/java/org/alfresco/web/bean/repository/Repository.java @@ -223,10 +223,25 @@ public final class Repository * @return human readable form of the Path excluding the final element */ public static String getDisplayPath(Path path) + { + return getDisplayPath(path, false); + } + + /** + * Return the human readable form of the specified node Path. Fast version of the method that + * simply converts QName localname components to Strings. + * + * @param path Path to extract readable form from + * @param showLeaf Whether to process the final leaf element of the path + * + * @return human readable form of the Path excluding the final element + */ + public static String getDisplayPath(Path path, boolean showLeaf) { StringBuilder buf = new StringBuilder(64); - for (int i=0; i <%-- Admin only global actions --%> -   - +   + @@ -210,8 +210,8 @@
<%-- Recover Listed Items actions --%> -   - +   +
- + <%-- Deleted Date column --%>