mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-5012 - make record on first event and add identifier on commit or on record complete
This commit is contained in:
@@ -140,6 +140,7 @@
|
||||
<property name="modelSecurityService" ref="modelSecurityService" />
|
||||
<property name="recordFolderService" ref="RecordFolderService" />
|
||||
<property name="holdService" ref="HoldService" />
|
||||
<property name="identifierService" ref="recordsManagementIdentifierService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="rmProxyAction"
|
||||
|
@@ -65,7 +65,6 @@
|
||||
<property name="identifierService" ref="recordsManagementIdentifierService"/>
|
||||
<property name="recordService" ref="RecordService" />
|
||||
<property name="recordFolderService" ref="recordFolderService" />
|
||||
<property name="dispositionService" ref="dispositionService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="rma.nonElectronicRecord" class="org.alfresco.module.org_alfresco_module_rm.model.rma.type.NonElectronicRecordType" parent="rm.baseBehaviour">
|
||||
@@ -106,6 +105,7 @@
|
||||
<property name="recordFolderService" ref="RecordFolderService" />
|
||||
<property name="dispositionService" ref="DispositionService" />
|
||||
<property name="vitalRecordService" ref="VitalRecordService" />
|
||||
<property name="identifierService" ref="recordsManagementIdentifierService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="rma.dispositionActionDefinition" class="org.alfresco.module.org_alfresco_module_rm.model.rma.type.DispositionActionDefinitionType" parent="rm.baseBehaviour">
|
||||
|
@@ -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;
|
||||
@@ -128,6 +129,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<FilePlanComponentKind> applicableKinds = new HashSet<FilePlanComponentKind>();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
@@ -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<String> missingProperties = new ArrayList<String>(5);
|
||||
// Aspect not already defined - check mandatory properties then add
|
||||
if (!checkMandatoryPropertiesEnabled ||
|
||||
|
@@ -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,10 +274,7 @@ 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
|
||||
|
@@ -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;
|
||||
@@ -72,8 +73,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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<Void>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Void doWork() throws Exception {
|
||||
Map<QName, Serializable> props = new HashMap<>();
|
||||
|
||||
if(!nodeService.hasAspect(document, ASPECT_RECORD_COMPONENT_ID))
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// 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);
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
@@ -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<QName, Serializable> 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
|
||||
*
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user