Issues found during demo prep.

* a couple of checks for type wheren't doing sub-type of cm:content checks
 * could not view a held record in-place



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@69667 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2014-05-06 11:49:27 +00:00
parent b2b268c74d
commit dd58a35e17
4 changed files with 83 additions and 38 deletions

View File

@@ -19,6 +19,7 @@
package org.alfresco.module.org_alfresco_module_rm.action.constraint;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -27,6 +28,8 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
import org.alfresco.repo.i18n.StaticMessageLookup;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -81,24 +84,35 @@ public class RecordTypeParameterConstraint extends BaseParameterConstraint
*/
protected Map<String, String> getAllowableValuesImpl()
{
// get the file plan
// TODO we will likely have to re-implement as a custom control so that context of the file
// plan can be correctly determined when setting the rule up
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
Set<QName> recordTypes = recordService.getRecordMetadataAspects(filePlan);
Map<String, String> result = new HashMap<String, String>(recordTypes.size());
for (QName recordType : recordTypes)
return AuthenticationUtil.runAsSystem(new RunAsWork<Map<String, String>>()
{
AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType);
if (aspectDefinition != null)
@SuppressWarnings("unchecked")
public Map<String, String> doWork() throws Exception
{
result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle(new StaticMessageLookup()));
Map<String, String> result = Collections.EMPTY_MAP;
// get the file plan
// TODO we will likely have to re-implement as a custom control so that context of the file
// plan can be correctly determined when setting the rule up
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan != null)
{
Set<QName> recordTypes = recordService.getRecordMetadataAspects(filePlan);
result = new HashMap<String, String>(recordTypes.size());
for (QName recordType : recordTypes)
{
AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType);
if (aspectDefinition != null)
{
result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle(new StaticMessageLookup()));
}
}
}
return result;
}
}
return result;
}
});
}
}

View File

@@ -279,7 +279,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr
if(create)
{
creating = true;
boolean lastAsFolder = lastPathElement && (ContentModel.TYPE_CONTENT.equals(nodeService.getType(actionedUponNodeRef)) || RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(actionedUponNodeRef)));
boolean lastAsFolder = lastPathElement && (dictionaryService.isSubClass(nodeService.getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT) || RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(actionedUponNodeRef)));
nodeRef = createChild(action, parent, childName, targetisUnfiledRecords, lastAsFolder);
}
else

View File

@@ -26,7 +26,9 @@ 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.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -52,6 +54,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
/** Capability service */
private CapabilityService capabilityService;
/** dictionary service */
private DictionaryService dictionaryService;
/** Indicators */
private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>();
@@ -82,6 +87,14 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
{
this.capabilityService = capabilityService;
}
/**
* @param dictionaryService dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* @param indicator registered indicator
@@ -107,35 +120,44 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
@Override
protected void setRootValues(FileInfo nodeInfo, JSONObject rootJSONObject, boolean useShortQNames)
{
// Set the base root values
super.setRootValues(nodeInfo, rootJSONObject, useShortQNames);
// Get the node reference for convenience
NodeRef nodeRef = nodeInfo.getNodeRef();
if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef,
RMPermissionModel.VIEW_RECORDS)))
if (nodeInfo != null)
{
// Indicate whether the node is a RM object or not
boolean isFilePlanComponent = filePlanService.isFilePlanComponent(nodeInfo.getNodeRef());
rootJSONObject.put("isRmNode", isFilePlanComponent);
if (isFilePlanComponent)
// Set the base root values
super.setRootValues(nodeInfo, rootJSONObject, useShortQNames);
// Get the node reference for convenience
NodeRef nodeRef = nodeInfo.getNodeRef();
if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef,
RMPermissionModel.VIEW_RECORDS)))
{
rootJSONObject.put("rmNode", setRmNodeValues(nodeRef, useShortQNames));
// FIXME: Is this the right place to add the information?
addInfo(nodeInfo, rootJSONObject);
// Indicate whether the node is a RM object or not
boolean isFilePlanComponent = filePlanService.isFilePlanComponent(nodeInfo.getNodeRef());
rootJSONObject.put("isRmNode", isFilePlanComponent);
if (isFilePlanComponent)
{
rootJSONObject.put("rmNode", setRmNodeValues(nodeRef, useShortQNames));
// FIXME: Is this the right place to add the information?
addInfo(nodeInfo, rootJSONObject);
}
}
}
}
/**
* Helper method to add information about node
*
* @param nodeInfo node information
* @param rootJSONObject root JSON object
*/
@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))
QName itemTypeQName = QName.createQName(itemType, namespaceService);
if (dictionaryService.isSubClass(itemTypeQName, ContentModel.TYPE_CONTENT))
{
NodeRef nodeRef = nodeInfo.getNodeRef();
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
@@ -147,7 +169,15 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
if (!parent.isPrimary())
{
originatingLocation = parent.getParentRef();
break;
// only consider the non-RM parent otherwise we can
// run into issues with frozen or transferring records
if (!nodeService.hasAspect(originatingLocation, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
{
// assume we have found the correct in-place location
// FIXME when we support multiple in-place locations
break;
}
}
}