diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml
index 3cac624ada..3b05142894 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml
@@ -140,6 +140,7 @@
+
-
@@ -106,6 +105,7 @@
+
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java
index a45f7967e4..3ea22ba684 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java
@@ -42,6 +42,7 @@ import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventSe
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
+import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
@@ -127,6 +128,9 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
/** Hold service */
private HoldService holdService;
+
+ /** Identifier service */
+ private IdentifierService identifierService;
/** List of kinds for which this action is applicable */
protected Set applicableKinds = new HashSet();
@@ -491,6 +495,26 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
this.holdService = holdService;
}
+ /**
+ * Gets the identifier service
+ *
+ * @return the identifier service
+ */
+ public IdentifierService getIdentifierService()
+ {
+ return identifierService;
+ }
+
+ /**
+ * Sets the identifier service
+ *
+ * @param identifierService the identifier service
+ */
+ public void setIdentifierService(IdentifierService identifierService)
+ {
+ this.identifierService = identifierService;
+ }
+
/**
* Sets the applicable kinds
*
@@ -550,6 +574,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
PropertyCheck.mandatory(this, "recordsManagementActionService", recordsManagementActionService);
PropertyCheck.mandatory(this, "recordsManagementAdminService", recordsManagementAdminService);
PropertyCheck.mandatory(this, "recordsManagementEventService", recordsManagementEventService);
+ PropertyCheck.mandatory(this, "identifierService", identifierService);
super.init();
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java
index 40698f75e4..f0be02b99a 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DeclareRecordAction.java
@@ -35,6 +35,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.generateRecordIdentifier;
+
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -90,6 +92,9 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
{
if (!getRecordService().isDeclared(actionedUponNodeRef))
{
+ // make sure the record identifier is set
+ generateRecordIdentifier(getNodeService(), getIdentifierService(), actionedUponNodeRef);
+
List missingProperties = new ArrayList(5);
// Aspect not already defined - check mandatory properties then add
if (!checkMandatoryPropertiesEnabled ||
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java
index ac631d2998..80fb8b2a0b 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java
@@ -27,11 +27,14 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
+import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.generateRecordIdentifier;
+
import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
@@ -77,6 +80,9 @@ public class RecordFolderType extends AbstractDisposableItem
/** vital record service */
protected VitalRecordService vitalRecordService;
+ /** identifier service */
+ protected IdentifierService identifierService;
+
/** I18N */
private static final String MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD = "rm.action.create.record.folder.child-error-message";
@@ -106,6 +112,11 @@ public class RecordFolderType extends AbstractDisposableItem
this.vitalRecordService = vitalRecordService;
}
+ public void setIdentifierService(IdentifierService identifierService)
+ {
+ this.identifierService = identifierService;
+ }
+
/**
* Record folder move behaviour
*
@@ -263,11 +274,8 @@ public class RecordFolderType extends AbstractDisposableItem
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD, nodeService.getType(child)), null);
}
- // file the record
- recordService.file(child);
- // recalculate disposition schedule
- dispositionService.recalculateNextDispositionStep(child);
-
+ generateRecordIdentifier(nodeService, identifierService, child);
+
behaviourFilter.disableBehaviour();
try
{
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java
index b400dff8cc..c2b89e405d 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java
@@ -28,6 +28,7 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.appendIdentifierToName;
+import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.generateRecordIdentifier;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
@@ -71,8 +72,6 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
/** record folder service */
protected RecordFolderService recordFolderService;
-
- protected DispositionService dispositionService;
/** I18N */
private static final String MSG_CANNOT_CAST_TO_RM_TYPE = "rm.action.cast-to-rm-type";
@@ -101,14 +100,6 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
this.recordFolderService = recordFolderService;
}
- /**
- * @param dispositionService disposition service
- */
- public void setDispositionService(DispositionService dispositionService)
- {
- this.dispositionService = dispositionService;
- }
-
/**
* Disable the behaviours for this transaction
*
@@ -184,6 +175,7 @@ public class RecordsManagementContainerType extends BaseBehaviourBean
{
recordService.makeRecord(child);
}
+ generateRecordIdentifier(nodeService, identifierService, child);
}
}
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java
index 7add39936d..db9e25f98d 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java
@@ -28,6 +28,7 @@
package org.alfresco.module.org_alfresco_module_rm.record;
import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.appendIdentifierToName;
+import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.generateRecordIdentifier;
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.FIRST_EVENT;
import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.TRANSACTION_COMMIT;
import static org.alfresco.repo.policy.annotation.BehaviourKind.ASSOCIATION;
@@ -79,6 +80,7 @@ import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent;
+import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
@@ -485,7 +487,11 @@ public class RecordServiceImpl extends BaseBehaviourBean
validateLinkConditions(nodeRef, parentNodeRef);
}
}
- nodeService.addAspect(nodeRef, RecordsManagementModel.ASPECT_RECORD, null);
+
+ //create and file the content as a record
+ file(nodeRef);
+ // recalculate disposition schedule for the record when linking it
+ dispositionService.recalculateNextDispositionStep(nodeRef);
}
}
catch (RecordLinkRuntimeException e)
@@ -504,6 +510,22 @@ public class RecordServiceImpl extends BaseBehaviourBean
}, AuthenticationUtil.getSystemUserName());
}
+ @Behaviour
+ (
+ kind = BehaviourKind.ASSOCIATION,
+ policy = "alf:onCreateChildAssociation",
+ type = "rma:recordFolder",
+ notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
+ )
+ public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew)
+ {
+ NodeRef record = childAssocRef.getChildRef();
+ if(nodeService.exists(record) && dictionaryService.isSubClass(nodeService.getType(record), ContentModel.TYPE_CONTENT))
+ {
+ generateRecordIdentifier(nodeService, identifierService, record);
+ }
+ }
+
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck()
*/
@@ -1208,35 +1230,21 @@ public class RecordServiceImpl extends BaseBehaviourBean
{
authenticationUtil.runAsSystem(new RunAsWork()
{
-
@Override
- public Void doWork() throws Exception {
- Map props = new HashMap<>();
-
- if(!nodeService.hasAspect(document, ASPECT_RECORD_COMPONENT_ID))
- {
- // 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);
-
- // add the record aspect
-
- props.put(PROP_IDENTIFIER, recordId);
- props.put(PROP_ORIGIONAL_NAME, name);
- }
- nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props);
+ public Void doWork() throws Exception
+ {
+ nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, null);
// remove versionable aspect(s)
nodeService.removeAspect(document, RecordableVersionModel.ASPECT_VERSIONABLE);
// remove the owner
-
ownableService.setOwner(document, OwnableService.NO_OWNER);
- appendIdentifierToName(nodeService, document);
+ if (TYPE_NON_ELECTRONIC_DOCUMENT.equals(nodeService.getType(document)))
+ {
+ generateRecordIdentifier(nodeService, identifierService, document);
+ }
return null;
}
});
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java
index 81c14e4048..c4dd92129a 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordUtils.java
@@ -26,13 +26,23 @@
*/
package org.alfresco.module.org_alfresco_module_rm.record;
+import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_RECORD;
+import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.PROP_IDENTIFIER;
+import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.PROP_ORIGIONAL_NAME;
+import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.appendIdentifierToName;
import static org.alfresco.util.ParameterCheck.mandatory;
import static org.apache.commons.lang.StringUtils.isNotBlank;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.namespace.QName;
/**
* Util class for records
@@ -47,6 +57,33 @@ public class RecordUtils
// Will not be called
}
+ /**
+ * Utility method that generates a record identifier and adds the new identifier to the record's name
+ *
+ * @param record the record to generate the identifier for
+ */
+ public static void generateRecordIdentifier(NodeService nodeService, IdentifierService identifierService, NodeRef record)
+ {
+ if(nodeService.getProperty(record, PROP_IDENTIFIER) == null)
+ {
+ // get the record id
+ String recordId = identifierService.generateIdentifier(ASPECT_RECORD,
+ nodeService.getPrimaryParent(record).getParentRef());
+
+ // get the record name
+ String name = (String)nodeService.getProperty(record, ContentModel.PROP_NAME);
+
+ // add the properties to the record
+ Map props = new HashMap<>();
+ props.put(PROP_IDENTIFIER, recordId);
+ props.put(PROP_ORIGIONAL_NAME, name);
+ nodeService.addProperties(record, props);
+ }
+
+ // append the identifier to the name even if it's been randomly generated or it was already set
+ appendIdentifierToName(nodeService, record);
+ }
+
/**
* Appends the record identifier to the name of the record
*
@@ -56,10 +93,10 @@ public class RecordUtils
{
mandatory("nodeService", nodeService);
mandatory("nodeRef", nodeRef);
-
+
if(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT))
{
- return;
+ return;
}
// get the record id
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java
index 865be37d74..456a4637fe 100644
--- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java
@@ -253,9 +253,6 @@ public class CommonRMTestUtils implements RecordsManagementModel
writer.setEncoding("UTF-8");
writer.putContent(content);
- // file the record
- recordService.file(record);
-
return record;
}
@@ -279,9 +276,6 @@ public class CommonRMTestUtils implements RecordsManagementModel
writer.setEncoding("UTF-8");
writer.putContent(content);
- // file the record
- recordService.file(record);
-
return record;
}