use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class RecordServiceImpl method onRemoveAspect.
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, type = "sys:noContent")
public void onRemoveAspect(NodeRef nodeRef, QName aspect) {
if (nodeService.hasAspect(nodeRef, ASPECT_RECORD)) {
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
if (ContentData.hasContent(contentData) && contentData.getSize() > 0) {
appendIdentifierToName(nodeService, nodeRef);
reevaluateIncompleteTag(nodeRef);
}
}
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class RecordFolderType method onCreateChildAssociationOnCommit.
/**
* On transaction commit
*
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
*/
@Behaviour(kind = BehaviourKind.ASSOCIATION, policy = "alf:onCreateChildAssociation", notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT)
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew) {
final NodeRef child = childAssocRef.getChildRef();
if (!nodeService.exists(child)) {
return;
}
// only records can be added in a record folder or hidden folders(is the case of e-mail attachments)
if (instanceOf(child, ContentModel.TYPE_FOLDER) && !nodeService.hasAspect(child, ContentModel.ASPECT_HIDDEN)) {
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD, nodeService.getType(child)), null);
}
behaviourFilter.disableBehaviour();
try {
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
@Override
public Void doWork() {
// setup vital record definition
vitalRecordService.setupVitalRecordDefinition(child);
return null;
}
});
} finally {
behaviourFilter.enableBehaviour();
}
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class RmSiteType method beforeDeleteNode.
/**
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
*/
@Behaviour(kind = BehaviourKind.CLASS, notificationFrequency = NotificationFrequency.FIRST_EVENT)
public void beforeDeleteNode(NodeRef nodeRef) {
final SiteInfo siteInfo = siteService.getSite(nodeRef);
if (siteInfo != null) {
// grab the file plan for the RM site
NodeRef filePlan = AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>() {
@Override
public NodeRef doWork() {
return siteService.getContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY);
}
});
if (filePlan != null) {
// determine whether the current user has delete capability on the file plan node
AccessStatus accessStatus = capabilityService.getCapabilityAccessState(filePlan, "Delete");
if (AccessStatus.DENIED.equals(accessStatus)) {
throw new AlfrescoRuntimeException("The records management site can not be deleted, because the user doesn't have sufficient privillages to delete the file plan.");
}
// work around for MNT-11038 .. we want to ensure that the RM site can be created once it's been deleted since we only
// allow one short name for the RM site
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
@Override
public Void doWork() {
// delete the authority
String siteGroup = siteService.getSiteGroup(siteInfo.getShortName());
authorityService.deleteAuthority(siteGroup, true);
return null;
}
});
filePlanType.disable();
}
}
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class RecordCategoryType method onCreateChildAssociationOnCommit.
/**
* On transaction commit
*
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
*/
@Behaviour(kind = BehaviourKind.ASSOCIATION, policy = "alf:onCreateChildAssociation", notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT)
public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, final boolean bNew) {
final NodeRef child = childAssocRef.getChildRef();
behaviourFilter.disableBehaviour();
try {
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
@Override
public Void doWork() {
// setup vital record definition
if (nodeService.exists(child)) {
vitalRecordService.setupVitalRecordDefinition(child);
}
return null;
}
});
} finally {
behaviourFilter.enableBehaviour();
}
}
use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.
the class CmObjectType method beforeCopy.
/**
* @see org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy#beforeCopy(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, name = COPY_BEHAVIOUR_NAME)
public void beforeCopy(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef) {
mandatory("sourceNodeRef", sourceNodeRef);
mandatory("targetNodeRef", targetNodeRef);
NodeRef sourceParentNodeRef = nodeService.getPrimaryParent(sourceNodeRef).getParentRef();
boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParentNodeRef);
NodeRef targetParentNodeRef = nodeService.getPrimaryParent(targetNodeRef).getParentRef();
boolean isTargetNodeParentFilePlanComponent = isFilePlanComponent(targetParentNodeRef);
// The method should just check copy operations from outside of RM into the RM site
if (isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) {
return;
}
// Do not allow to copy anything outside of RM site into the RM site
if (!isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) {
throw new AlfrescoRuntimeException("Nothing can be copied from a collaboration site into a RM site.");
}
}
Aggregations