RM-5012 - fixed custom identifier issue

This commit is contained in:
Ana Bozianu
2017-05-12 18:54:31 +03:00
parent 1d50299bd2
commit f971c80a37
5 changed files with 76 additions and 26 deletions

View File

@@ -486,6 +486,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
}
}
// recalculate disposition schedule for the record when linking it
dispositionService.recalculateNextDispositionStep(nodeRef);
}
}
catch (RecordLinkRuntimeException e)
@@ -1206,29 +1208,43 @@ public class RecordServiceImpl extends BaseBehaviourBean
disablePropertyEditableCheck();
try
{
// get the record id
String recordId = identifierService.generateIdentifier(ASPECT_RECORD,
nodeService.getPrimaryParent(document).getParentRef());
authenticationUtil.runAsSystem(new RunAsWork<Void>()
{
// get the record name
String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME);
@Override
public Void doWork() throws Exception {
Map<QName, Serializable> props = new HashMap<>();
// 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);
if(!nodeService.hasAspect(document, ASPECT_RECORD_COMPONENT_ID))
{
// get the record id
String recordId = identifierService.generateIdentifier(ASPECT_RECORD,
nodeService.getPrimaryParent(document).getParentRef());
// remove versionable aspect(s)
nodeService.removeAspect(document, RecordableVersionModel.ASPECT_VERSIONABLE);
// get the record name
String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME);
// remove the owner
ownableService.setOwner(document, OwnableService.NO_OWNER);
// add the record aspect
if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
{
appendIdentifierToName(nodeService, document);
}
props.put(PROP_IDENTIFIER, recordId);
props.put(PROP_ORIGIONAL_NAME, name);
}
nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props);
// remove versionable aspect(s)
nodeService.removeAspect(document, RecordableVersionModel.ASPECT_VERSIONABLE);
// remove the owner
ownableService.setOwner(document, OwnableService.NO_OWNER);
if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
{
appendIdentifierToName(nodeService, document);
}
return null;
}
});
}
finally
{

View File

@@ -617,13 +617,6 @@ public class FilePlanComponentsApiUtils
QName typeQName = nodes.createQName(type);
newNodeRef = fileFolderService.create(parentNodeRef, name, typeQName).getNodeRef();
// Set the provided properties if any
Map<QName, Serializable> qnameProperties = mapToNodeProperties(properties);
if (qnameProperties != null)
{
nodeService.addProperties(newNodeRef, qnameProperties);
}
// If electronic record create empty content
if (!typeQName.equals(RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT)
&& dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT))
@@ -631,6 +624,13 @@ public class FilePlanComponentsApiUtils
writeContent(newNodeRef, name, new ByteArrayInputStream("".getBytes()), false);
}
// Set the provided properties if any
Map<QName, Serializable> qnameProperties = mapToNodeProperties(properties);
if (qnameProperties != null)
{
nodeService.addProperties(newNodeRef, qnameProperties);
}
// Add the provided aspects if any
if (aspects != null)
{

View File

@@ -192,7 +192,7 @@ public class UnfiledContainerChildrenRelation implements RelationshipResourceAct
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get the nodes info
List<UnfiledContainerChild> result = new LinkedList<>();