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

@@ -9,6 +9,7 @@
<property name="recordService" ref="RecordService"/> <property name="recordService" ref="RecordService"/>
<property name="filePlanService" ref="FilePlanService"/> <property name="filePlanService" ref="FilePlanService"/>
<property name="capabilityService" ref="CapabilityService"/> <property name="capabilityService" ref="CapabilityService"/>
<property name="dictionaryService" ref="DictionaryService" />
</bean> </bean>
<!-- extends core bean with RM extensions --> <!-- extends core bean with RM extensions -->

View File

@@ -19,6 +19,7 @@
package org.alfresco.module.org_alfresco_module_rm.action.constraint; package org.alfresco.module.org_alfresco_module_rm.action.constraint;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.repo.action.constraint.BaseParameterConstraint; import org.alfresco.repo.action.constraint.BaseParameterConstraint;
import org.alfresco.repo.i18n.StaticMessageLookup; 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.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -81,14 +84,23 @@ public class RecordTypeParameterConstraint extends BaseParameterConstraint
*/ */
protected Map<String, String> getAllowableValuesImpl() protected Map<String, String> getAllowableValuesImpl()
{ {
return AuthenticationUtil.runAsSystem(new RunAsWork<Map<String, String>>()
{
@SuppressWarnings("unchecked")
public Map<String, String> doWork() throws Exception
{
Map<String, String> result = Collections.EMPTY_MAP;
// get the file plan // get the file plan
// TODO we will likely have to re-implement as a custom control so that context of the file // 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 // plan can be correctly determined when setting the rule up
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if (filePlan != null)
{
Set<QName> recordTypes = recordService.getRecordMetadataAspects(filePlan); Set<QName> recordTypes = recordService.getRecordMetadataAspects(filePlan);
Map<String, String> result = new HashMap<String, String>(recordTypes.size()); result = new HashMap<String, String>(recordTypes.size());
for (QName recordType : recordTypes) for (QName recordType : recordTypes)
{ {
AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType); AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType);
@@ -97,8 +109,10 @@ public class RecordTypeParameterConstraint extends BaseParameterConstraint
result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle(new StaticMessageLookup())); 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) if(create)
{ {
creating = true; 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); nodeRef = createChild(action, parent, childName, targetisUnfiledRecords, lastAsFolder);
} }
else 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.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; 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.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.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.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -53,6 +55,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
/** Capability service */ /** Capability service */
private CapabilityService capabilityService; private CapabilityService capabilityService;
/** dictionary service */
private DictionaryService dictionaryService;
/** Indicators */ /** Indicators */
private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>(); private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>();
@@ -83,6 +88,14 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
this.capabilityService = capabilityService; this.capabilityService = capabilityService;
} }
/**
* @param dictionaryService dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/** /**
* @param indicator registered indicator * @param indicator registered indicator
*/ */
@@ -106,6 +119,8 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected void setRootValues(FileInfo nodeInfo, JSONObject rootJSONObject, boolean useShortQNames) protected void setRootValues(FileInfo nodeInfo, JSONObject rootJSONObject, boolean useShortQNames)
{
if (nodeInfo != null)
{ {
// Set the base root values // Set the base root values
super.setRootValues(nodeInfo, rootJSONObject, useShortQNames); super.setRootValues(nodeInfo, rootJSONObject, useShortQNames);
@@ -129,13 +144,20 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
} }
} }
} }
}
/**
* Helper method to add information about node
*
* @param nodeInfo node information
* @param rootJSONObject root JSON object
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void addInfo(FileInfo nodeInfo, JSONObject rootJSONObject) private void addInfo(FileInfo nodeInfo, JSONObject rootJSONObject)
{ {
String itemType = (String) rootJSONObject.get("type"); String itemType = (String) rootJSONObject.get("type");
String typeContent = ContentModel.TYPE_CONTENT.toPrefixString(namespaceService); QName itemTypeQName = QName.createQName(itemType, namespaceService);
if (itemType.equals(typeContent)) if (dictionaryService.isSubClass(itemTypeQName, ContentModel.TYPE_CONTENT))
{ {
NodeRef nodeRef = nodeInfo.getNodeRef(); NodeRef nodeRef = nodeInfo.getNodeRef();
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef); List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
@@ -147,9 +169,17 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
if (!parent.isPrimary()) if (!parent.isPrimary())
{ {
originatingLocation = parent.getParentRef(); originatingLocation = parent.getParentRef();
// 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; break;
} }
} }
}
if (originatingLocation != null) if (originatingLocation != null)
{ {