diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index d42c3b8e5c..3751f2ccbb 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -1524,6 +1524,8 @@ recovered_item_integrity=Failed to recover the item \"{0}\" as there is now an i recovered_item_integrity_short=Item with same name exists recovered_item_failure=Failed to recover the item \"{0}\" due to error: {1} recovered_item_failure_short=Failed +recovered_item_duplicate=Failed to recover the item \"{0}\", duplicate name not allowed. +recovered_item_duplicate_short=Duplicate name not allowed delete_item_success=The item \"{0}\" has been permanently deleted. title_deleted_item_details=Deleted Item Details deleteditem_details_description=Details of the deleted item diff --git a/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java b/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java index 4a44bd8e26..524ba96c94 100644 --- a/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java +++ b/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java @@ -76,6 +76,7 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener private static final String MSG_DELETED_ITEMS_FOR = "deleted_items_for"; private static final String MSG_DELETED_ITEMS = "deleted_items"; + private static final String MSG_RECOVERED_ITEM_DUPLICATE_S = "recovered_item_duplicate_short"; private static final String MSG_RECOVERED_ITEM_INTEGRITY_S = "recovered_item_integrity_short"; private static final String MSG_RECOVERED_ITEM_PERMISSION_S = "recovered_item_permission_short"; private static final String MSG_RECOVERED_ITEM_PARENT_S = "recovered_item_parent_short"; @@ -86,6 +87,7 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener private final static String MSG_CLOSE = "close"; private static final String PROP_RECOVERSTATUS = "recoverstatus"; + private static final String PROP_RECOVERERRORMESSAGE = "recovererrormessage"; private static final String FILTER_DATE_ALL = "all"; private static final String FILTER_DATE_TODAY = "today"; @@ -106,6 +108,9 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener private final static String SEARCH_TEXT_QUOTED = "PARENT:\"%s\" AND ASPECT:\"%s\" AND TEXT:\"%s\""; private final static String SEARCH_USERPREFIX = "@" + USER_ATTR + ":%s AND "; + /** maximum number of failed items to report to the user */ + private static final int MAX_FAILURE_REPORTS = 25; + /** The PermissionService reference */ transient protected PermissionService permissionService; @@ -697,6 +702,7 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener protected void saveReportDetail(List reports) { // store the results ready for the next dialog page + int failureItemsCount = 0; property.setSuccessItems(new ArrayList(reports.size())); property.setFailureItems(new ArrayList(reports.size())); for (RestoreNodeReport report : reports) @@ -709,9 +715,14 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener } else { - Node node = new Node(report.getArchivedNodeRef()); - node.getProperties().put(PROP_RECOVERSTATUS, report.getStatus()); - property.getFailureItems().add(node); + if (failureItemsCount < MAX_FAILURE_REPORTS) + { + Node node = new Node(report.getArchivedNodeRef()); + node.getProperties().put(PROP_RECOVERSTATUS, report.getStatus()); + node.getProperties().put(PROP_RECOVERERRORMESSAGE, report.getCause().getMessage()); + property.getFailureItems().add(node); + failureItemsCount++; + } } } } @@ -780,7 +791,9 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener { buf.append(""); String msg; - switch ((RestoreStatus)node.getProperties().get(PROP_RECOVERSTATUS)) + RestoreStatus status = (RestoreStatus) node.getProperties().get(PROP_RECOVERSTATUS); + String message = (String) node.getProperties().get(PROP_RECOVERERRORMESSAGE); + switch (status) { case FAILURE_INVALID_PARENT: msg = MSG_RECOVERED_ITEM_PARENT_S; @@ -794,11 +807,17 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener msg = MSG_RECOVERED_ITEM_INTEGRITY_S; break; + case FAILURE_DUPLICATE_CHILD_NODE_NAME: + msg = MSG_RECOVERED_ITEM_DUPLICATE_S; + break; + default: msg = MSG_RECOVERED_ITEM_FAILURE_S; break; } buf.append(Application.getMessage(fc, msg)); + buf.append(": "); + buf.append(message); buf.append(""); } else diff --git a/source/java/org/alfresco/web/bean/trashcan/TrashcanRecoverItemDialog.java b/source/java/org/alfresco/web/bean/trashcan/TrashcanRecoverItemDialog.java index a901d87d07..fc4b2b21f3 100644 --- a/source/java/org/alfresco/web/bean/trashcan/TrashcanRecoverItemDialog.java +++ b/source/java/org/alfresco/web/bean/trashcan/TrashcanRecoverItemDialog.java @@ -35,6 +35,7 @@ public class TrashcanRecoverItemDialog extends TrashcanDialog private static final String RICHLIST_ID = "trashcan-list"; private static final String RICHLIST_MSG_ID = "trashcan" + ':' + RICHLIST_ID; private static final String MSG_RECOVERED_ITEM_SUCCESS = "recovered_item_success"; + private static final String MSG_RECOVERED_ITEM_DUPLICATE = "recovered_item_duplicate"; private static final String MSG_RECOVERED_ITEM_INTEGRITY = "recovered_item_integrity"; private static final String MSG_RECOVERED_ITEM_PERMISSION = "recovered_item_permission"; private static final String MSG_RECOVERED_ITEM_PARENT = "recovered_item_parent"; @@ -92,6 +93,11 @@ public class TrashcanRecoverItemDialog extends TrashcanDialog errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg); break; + case FAILURE_DUPLICATE_CHILD_NODE_NAME: + msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_DUPLICATE), item.getName()); + errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg); + break; + default: String reason = report.getCause().getMessage(); msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_FAILURE), item.getName(), reason);