RM-777: Record name duplication within the in-place container is not allowed.

* records are now renamed when they are created to incorporate the record identifier
  * rejecting a record resotres the origional name



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@53630 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-08-06 03:36:54 +00:00
parent 254cec038c
commit c9c3812fe5
5 changed files with 90 additions and 25 deletions

View File

@@ -7,10 +7,11 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurit
# #
# Module patches # Module patches
# #
log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=debug log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info
# #
# RM Permission Debug Information # RM Permission Debug Information
# #
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter=debug #log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter=debug
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.declarative=debug #log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.declarative=debug
log4j.logger.org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl=debug

View File

@@ -715,6 +715,12 @@
<type>d:date</type> <type>d:date</type>
</property> </property>
<property name="rma:origionalName">
<title>Origional Name</title>
<type>d:text</type>
<protected>true</protected>
</property>
<property name="rma:publicationDate"> <property name="rma:publicationDate">
<title>Publication Date</title> <title>Publication Date</title>
<type>d:date</type> <type>d:date</type>

View File

@@ -93,6 +93,7 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
// Record aspect // Record aspect
public static final QName ASPECT_RECORD = QName.createQName(RM_URI, "record"); public static final QName ASPECT_RECORD = QName.createQName(RM_URI, "record");
public static final QName PROP_DATE_FILED = QName.createQName(RM_URI, "dateFiled"); public static final QName PROP_DATE_FILED = QName.createQName(RM_URI, "dateFiled");
public static final QName PROP_ORIGIONAL_NAME = QName.createQName(RM_URI, "origionalName");
public static final QName PROP_ORIGINATOR = QName.createQName(RM_URI, "originator"); public static final QName PROP_ORIGINATOR = QName.createQName(RM_URI, "originator");
public static final QName PROP_ORIGINATING_ORGANIZATION = QName.createQName(RM_URI, "originatingOrganization"); public static final QName PROP_ORIGINATING_ORGANIZATION = QName.createQName(RM_URI, "originatingOrganization");
public static final QName PROP_PUBLICATION_DATE = QName.createQName(RM_URI, "publicationDate"); public static final QName PROP_PUBLICATION_DATE = QName.createQName(RM_URI, "publicationDate");

View File

@@ -60,6 +60,7 @@ import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
@@ -539,15 +540,24 @@ public class RecordServiceImpl implements RecordService,
if (isLinked == true) if (isLinked == true)
{ {
// maintain the original primary location // turn off rules
nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName()); ruleService.disableRules();
try
{
// maintain the original primary location
nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName());
// set the extended security // set the extended security
Set<String> combinedWriters = new HashSet<String>(writers); Set<String> combinedWriters = new HashSet<String>(writers);
combinedWriters.add(owner); combinedWriters.add(owner);
combinedWriters.add(AuthenticationUtil.getFullyAuthenticatedUser()); combinedWriters.add(AuthenticationUtil.getFullyAuthenticatedUser());
extendedSecurityService.addExtendedSecurity(nodeRef, readers, combinedWriters); extendedSecurityService.addExtendedSecurity(nodeRef, readers, combinedWriters);
}
finally
{
ruleService.enableRules();
}
} }
return null; return null;
@@ -610,11 +620,43 @@ public class RecordServiceImpl implements RecordService,
*/ */
private void makeRecord(NodeRef document) private void makeRecord(NodeRef document)
{ {
nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, null); try
{
// get the record id
String recordId = identifierService.generateIdentifier(ASPECT_RECORD,
nodeService.getPrimaryParent(document).getParentRef());
// get the record name
String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME);
// rename the record
int dotIndex = name.lastIndexOf(".");
String prefix = name;
String postfix = "";
if (dotIndex != -1)
{
prefix = name.substring(0, dotIndex);
postfix = name.substring(dotIndex);
}
String recordName = prefix + " (" + recordId + ")" + postfix;
fileFolderService.rename(document, recordName);
if (logger.isDebugEnabled() == true)
{
logger.debug("Rename " + name + " to " + recordName);
}
// add the record aspect
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
props.put(PROP_IDENTIFIER, recordId);
props.put(PROP_ORIGIONAL_NAME, name);
nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props);
}
catch (FileNotFoundException e)
{
throw new AlfrescoRuntimeException("Unable to make record, because rename failed.", e);
}
String recordId = identifierService.generateIdentifier(ASPECT_RECORD, nodeService.getPrimaryParent(document)
.getParentRef());
nodeService.setProperty(document, PROP_IDENTIFIER, recordId);
} }
/** /**
@@ -749,14 +791,14 @@ public class RecordServiceImpl implements RecordService,
ruleService.disableRules(); ruleService.disableRules();
try try
{ {
// take note of the record id // get record property values
String recordId = (String)nodeService.getProperty(nodeRef, PROP_IDENTIFIER); Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
String recordId = (String)properties.get(PROP_IDENTIFIER);
// take node of the original document owner String documentOwner = (String)properties.get(PROP_RECORD_ORIGINATING_USER_ID);
String documentOwner = (String) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_USER_ID); String origionalName = (String)properties.get(PROP_ORIGIONAL_NAME);
NodeRef originatingLocation = (NodeRef)properties.get(PROP_RECORD_ORIGINATING_LOCATION);
// first remove the secondary link association // first remove the secondary link association
NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef); List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs) for (ChildAssociationRef childAssociationRef : parentAssocs)
{ {
@@ -784,6 +826,18 @@ public class RecordServiceImpl implements RecordService,
// move the record into the collaboration site // move the record into the collaboration site
nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// rename to the origional name
if (origionalName != null)
{
fileFolderService.rename(nodeRef, origionalName);
if (logger.isDebugEnabled() == true)
{
String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
logger.debug("Rename " + name + " to " + origionalName);
}
}
// save the information about the rejection details // save the information about the rejection details
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(3); Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(3);
aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId); aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId);

View File

@@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability; import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
@@ -47,7 +48,7 @@ public class FileToActionTest extends BaseRMTestCase
private static final String PATH_BAD = "monkey/rmfolder"; private static final String PATH_BAD = "monkey/rmfolder";
private static final String PATH_CREATE = "rmcontainer/newrmfolder"; private static final String PATH_CREATE = "rmcontainer/newrmfolder";
private static final String PATH_SUB1 = "rmcontainer/${node.cm:name}"; private static final String PATH_SUB1 = "rmcontainer/${node.cm:title}";
protected ActionService dmActionService; protected ActionService dmActionService;
@@ -112,6 +113,8 @@ public class FileToActionTest extends BaseRMTestCase
{ {
public Void run() public Void run()
{ {
nodeService.setProperty(dmDocument, ContentModel.PROP_TITLE, "mytestvalue");
// create record from document // create record from document
recordService.createRecord(filePlan, dmDocument); recordService.createRecord(filePlan, dmDocument);
@@ -193,7 +196,7 @@ public class FileToActionTest extends BaseRMTestCase
public void testCreateSub() throws Exception public void testCreateSub() throws Exception
{ {
initRecord(); initRecord();
createRecord(PATH_SUB1, "collabDocument.txt", "rmcontainer/collabDocument.txt"); createRecord(PATH_SUB1, "mytestvalue", "rmcontainer/mytestvalue");
} }
private void createRecord(String path, String name) private void createRecord(String path, String name)