RM-1444 (As a collaboration user I want to see the records details without leaving the collaboration site so that I never have to visit the file plan)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@67776 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-04-21 19:39:41 +00:00
parent 82a39c2563
commit ad4e7b616a

View File

@@ -21,15 +21,19 @@ package org.alfresco.module.org_alfresco_module_rm.jscript.app;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.PathUtil;
import org.apache.commons.lang.ArrayUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -119,6 +123,46 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
if (isFilePlanComponent)
{
rootJSONObject.put("rmNode", setRmNodeValues(nodeRef, useShortQNames));
// FIXME: Is this the right place to add the information?
addInfo(nodeInfo, rootJSONObject);
}
}
}
@SuppressWarnings("unchecked")
private void addInfo(FileInfo nodeInfo, JSONObject rootJSONObject)
{
String itemType = (String) rootJSONObject.get("type");
String typeContent = ContentModel.TYPE_CONTENT.toPrefixString(namespaceService);
if (itemType.equals(typeContent))
{
NodeRef nodeRef = nodeInfo.getNodeRef();
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
NodeRef originatingLocation = null;
for (ChildAssociationRef parent : parentAssocs)
{
// FIXME: What if there is more than a secondary parent?
if (!parent.isPrimary())
{
originatingLocation = parent.getParentRef();
break;
}
}
if (originatingLocation != null)
{
String pathSeparator = "/";
String displayPath = PathUtil.getDisplayPath(nodeService.getPath(originatingLocation), true);
String[] displayPathElements = displayPath.split(pathSeparator);
Object[] subPath = ArrayUtils.subarray(displayPathElements, 5, displayPathElements.length);
StringBuffer originatingLocationPath = new StringBuffer();
for (int i = 0; i < subPath.length; i++)
{
originatingLocationPath.append(pathSeparator).append(subPath[i]);
}
rootJSONObject.put("originatingLocationPath", originatingLocationPath.toString());
}
}
}