RM-4619 - added the fileplan component check back but in different place

This commit is contained in:
Ana Bozianu
2017-01-30 12:54:37 +02:00
parent c52e2a7cf5
commit abfc606428
6 changed files with 48 additions and 25 deletions

View File

@@ -61,6 +61,7 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck;
@@ -277,6 +278,11 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
}
}
if(!filePlanService.isFilePlanComponent(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId)))
{
throw new InvalidParameterException("The provided node is not a fileplan component");
}
return super.validateNode(nodeId);
}

View File

@@ -36,6 +36,7 @@ import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.parameters.Parameters;
@@ -67,7 +68,8 @@ public class RecordsImpl implements Records, InitializingBean
protected FileFolderService fileFolderService;
protected DictionaryService dictionaryService;
protected AuthenticationUtil authenticationUtil;
protected RMNodes nodes;
protected RMNodes rmNodes;
protected Nodes nodes;
public void setRecordService(RecordService recordService)
{
@@ -99,7 +101,12 @@ public class RecordsImpl implements Records, InitializingBean
this.authenticationUtil = authenticationUtil;
}
public void setNodes(RMNodes nodes)
public void setRmNodes(RMNodes rmNodes)
{
this.rmNodes = rmNodes;
}
public void setNodes(Nodes nodes)
{
this.nodes = nodes;
}
@@ -108,6 +115,7 @@ public class RecordsImpl implements Records, InitializingBean
public Node declareFileAsRecord(String fileId, Parameters parameters)
{
// Get file to be declared
// Use nodes instead of rmNodes because the file is not a record yet
NodeRef fileNodeRef = nodes.validateNode(fileId) ;
// Get fileplan
@@ -127,7 +135,7 @@ public class RecordsImpl implements Records, InitializingBean
recordService.createRecord(filePlan, fileNodeRef, !hideRecord);
// Get information about the new record
return nodes.getFolderOrDocument(fileId, parameters);
return rmNodes.getFolderOrDocument(fileId, parameters);
}
@Override
@@ -139,7 +147,7 @@ public class RecordsImpl implements Records, InitializingBean
}
// Get record
NodeRef record = nodes.validateNode(recordId);
NodeRef record = rmNodes.validateNode(recordId);
// Get record folder to file/link the record to
String parentContainerId = target.getTargetParentId();
@@ -155,7 +163,7 @@ public class RecordsImpl implements Records, InitializingBean
}
});
}
NodeRef parentRecordFolder = nodes.getOrCreatePath(parentContainerId, target.getRelativePath(), ContentModel.TYPE_CONTENT);
NodeRef parentRecordFolder = rmNodes.getOrCreatePath(parentContainerId, target.getRelativePath(), ContentModel.TYPE_CONTENT);
// Check if the target is a record folder
if(!dictionaryService.isSubClass(nodeService.getType(parentRecordFolder), RecordsManagementModel.TYPE_RECORD_FOLDER))
@@ -186,7 +194,7 @@ public class RecordsImpl implements Records, InitializingBean
}
// Get the record info
return nodes.getFolderOrDocument(recordId, parameters);
return rmNodes.getFolderOrDocument(recordId, parameters);
}
@Override
@@ -194,7 +202,7 @@ public class RecordsImpl implements Records, InitializingBean
{
ParameterCheck.mandatory("recordService", recordService);
ParameterCheck.mandatory("filePlanService", filePlanService);
ParameterCheck.mandatory("nodes", nodes);
ParameterCheck.mandatory("nodes", rmNodes);
ParameterCheck.mandatory("nodeService", nodeService);
ParameterCheck.mandatory("fileFolderService", fileFolderService);
ParameterCheck.mandatory("dictionaryService", dictionaryService);