use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class CmObjectType method onMoveNode.
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, name = MOVE_BEHAVIOUR_NAME)
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) {
mandatory("oldChildAssocRef", oldChildAssocRef);
mandatory("newChildAssocRef", newChildAssocRef);
NodeRef sourceParent = oldChildAssocRef.getParentRef();
boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParent);
NodeRef targetParent = newChildAssocRef.getParentRef();
boolean isTargetParentFilePlanComponent = isFilePlanComponent(targetParent);
// The method should just check move operations from outside of RM into the RM site
if (isSourceParentFilePlanComponent && isTargetParentFilePlanComponent) {
return;
}
NodeRef object = oldChildAssocRef.getChildRef();
QName objectType = nodeService.getType(object);
// Only documents can be moved into the RM site
if (!objectType.equals(ContentModel.TYPE_CONTENT) && isTargetParentFilePlanComponent) {
throw new AlfrescoRuntimeException("Only documents can be moved from a collaboration site into a RM site.");
}
// Documents can be moved only into a RM folder
if (isTargetParentFilePlanComponent && !isRecordFolder(targetParent)) {
throw new AlfrescoRuntimeException("A document can only be moved into a folder in RM site.");
}
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class OnReferenceCreateEventType method onCreateReference.
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, type = "rma:record", notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT)
public void onCreateReference(final NodeRef fromNodeRef, final NodeRef toNodeRef, final QName reference) {
AuthenticationUtil.RunAsWork<Object> work = new AuthenticationUtil.RunAsWork<Object>() {
public Object doWork() {
// Check whether it is the reference type we care about
if (reference.equals(OnReferenceCreateEventType.this.reference)) {
DispositionAction da = dispositionService.getNextDispositionAction(toNodeRef);
if (da != null) {
List<EventCompletionDetails> events = da.getEventCompletionDetails();
for (EventCompletionDetails event : events) {
RecordsManagementEvent rmEvent = getRecordsManagementEventService().getEvent(event.getEventName());
if (!event.isEventComplete() && rmEvent.getType().equals(getName())) {
// Complete the event
Map<String, Serializable> params = new HashMap<String, Serializable>(3);
params.put(CompleteEventAction.PARAM_EVENT_NAME, event.getEventName());
params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date());
recordsManagementActionService.executeRecordsManagementAction(toNodeRef, "completeEvent", params);
break;
}
}
}
}
return null;
}
};
AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName());
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class HoldServiceImpl method beforeDeleteNode.
/**
* Behaviour unfreezes node's that will no longer he held after delete.
*
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
*/
@Behaviour(kind = BehaviourKind.CLASS, type = "rma:hold", notificationFrequency = NotificationFrequency.EVERY_EVENT)
@Override
public void beforeDeleteNode(final NodeRef hold) {
if (nodeService.exists(hold) && isHold(hold)) {
RunAsWork<Void> work = new RunAsWork<Void>() {
@Override
public Void doWork() {
List<NodeRef> frozenNodes = getHeld(hold);
for (NodeRef frozenNode : frozenNodes) {
removeFreezeAspect(frozenNode, 1);
}
return null;
}
};
// run as system user
authenticationUtil.runAsSystem(work);
}
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class OnReferencedRecordActionedUpon method beforeRMActionExecution.
/**
* Before action exeuction behaviour.
*
* @param nodeRef
* @param name
* @param parameters
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, type = "rma:filePlanComponent", notificationFrequency = NotificationFrequency.FIRST_EVENT)
public void beforeRMActionExecution(final NodeRef nodeRef, final String name, final Map<String, Serializable> parameters) {
AuthenticationUtil.RunAsWork<Object> work = new AuthenticationUtil.RunAsWork<Object>() {
public Object doWork() {
if (nodeService.exists(nodeRef) && name.equals(actionName)) {
QName type = nodeService.getType(nodeRef);
if (TYPE_TRANSFER.equals(type)) {
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs) {
processRecordFolder(assoc.getChildRef());
}
} else {
processRecordFolder(nodeRef);
}
}
return null;
}
};
AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName());
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class VitalRecordServiceImpl method onFileRecord.
/**
* Behavior to initialize vital record.
*
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord#onFileRecord(org.alfresco.service.cmr.repository.NodeRef)
* @since 2.2
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, type = "rma:record")
public void onFileRecord(NodeRef nodeRef) {
// Calculate the review schedule
VitalRecordDefinition viDef = getVitalRecordDefinition(nodeRef);
if (viDef != null && viDef.isEnabled()) {
Date reviewAsOf = viDef.getNextReviewDate();
if (reviewAsOf != null) {
Map<QName, Serializable> reviewProps = new HashMap<QName, Serializable>(1);
reviewProps.put(RecordsManagementModel.PROP_REVIEW_AS_OF, reviewAsOf);
if (!nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)) {
nodeService.addAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD, reviewProps);
} else {
Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
props.putAll(reviewProps);
nodeService.setProperties(nodeRef, props);
}
}
} else {
// if we are re-filling then remove the vital aspect if it is not longer a vital record
if (nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)) {
nodeService.removeAspect(nodeRef, ASPECT_VITAL_RECORD);
}
}
}
Aggregations