use of org.alfresco.repo.node.archive.RestoreNodeReport.RestoreStatus in project acs-community-packaging by Alfresco.
the class TrashcanDialog method buildItemsTable.
/**
* Build an HTML table of the items that are to be or have been recovered.
*
* @param items List of Node objects to display in the table
* @param cssClass CSS style to apply to the table
* @param report Set true to report the reason for any failure. This flag requires that the Node
* object has a pseudo property "recoverstatus" containing the RestoreStatus.
* @param archivedPath Set true to show the path from the 'sys:archivedOriginalParentAssoc' property,
* else the current Node Path will be used.
*
* @return HTML table of node info
*/
private String buildItemsTable(List<Node> items, String cssClass, boolean report, boolean archivedPath) {
FacesContext fc = FacesContext.getCurrentInstance();
String contextPath = fc.getExternalContext().getRequestContextPath();
StringBuilder buf = new StringBuilder(1024);
// outer table
buf.append("<table width=100% cellspacing=1 cellpadding=1 border=0 class='");
buf.append(cssClass);
buf.append("'>");
// title row
buf.append("<tr style='border-bottom:1px'><th></th><th align=left><b>");
buf.append(Application.getMessage(fc, MSG_NAME));
buf.append("</b></th>");
if (report == true) {
buf.append("<th align=left>");
buf.append(Application.getMessage(fc, MSG_RECOVERY_REASON));
buf.append("</th>");
} else {
buf.append("<th align=left><b>");
buf.append(Application.getMessage(fc, MSG_LOCATION));
buf.append("</b></th>");
}
buf.append("</tr>");
for (Node node : items) {
// listed item rows
buf.append("<tr><td width=16>");
String img;
if (getDictionaryService().isSubClass(node.getType(), ContentModel.TYPE_FOLDER)) {
String icon = (String) node.getProperties().get("app:icon");
img = "/images/icons/" + (icon != null ? icon + "-16.gif" : BrowseBean.SPACE_SMALL_DEFAULT + ".gif");
} else {
img = FileTypeImageUtils.getFileTypeImage(node.getName(), true);
}
buf.append("<img width=16 height=16 alt='' src='").append(contextPath).append(img).append("'>");
buf.append("</td><td>");
buf.append(Utils.encode(node.getName()));
buf.append("</td>");
if (report) {
buf.append("<td>");
String msg;
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;
break;
case FAILURE_PERMISSION:
msg = MSG_RECOVERED_ITEM_PERMISSION_S;
break;
case FAILURE_INTEGRITY:
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("</td>");
} else {
buf.append("<td>");
if (archivedPath) {
ChildAssociationRef childRef = (ChildAssociationRef) node.getProperties().get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
if (getNodeService().exists(childRef.getParentRef())) {
buf.append(Utils.encode(Repository.getNamePath(getNodeService(), getNodeService().getPath(childRef.getParentRef()), null, "/", null)));
}
} else {
buf.append(Utils.encode(Repository.getNamePath(getNodeService(), getNodeService().getPath(node.getNodeRef()), null, "/", null)));
}
buf.append("</td>");
}
buf.append("</tr>");
}
// end table
buf.append("</table>");
return buf.toString();
}
Aggregations