Search in sources :

Example 16 with Behaviour

use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.

the class RecordAspect method onMoveNode.

/**
 * Record move behaviour
 *
 * @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, notificationFrequency = NotificationFrequency.FIRST_EVENT)
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) {
    // check the records parent has actually changed
    if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef()) && isFilePlanComponent(oldChildAssocRef.getParentRef())) {
        final NodeRef record = newChildAssocRef.getChildRef();
        authenticationUtil.runAsSystem(new RunAsWork<Object>() {

            public Object doWork() {
                if (nodeService.exists(record) && recordService.isFiled(record)) {
                    // clean record
                    cleanDisposableItem(nodeService, record);
                    // re-file in the new folder
                    recordService.file(record);
                }
                return null;
            }
        });
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Behaviour(org.alfresco.repo.policy.annotation.Behaviour)

Example 17 with Behaviour

use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.

the class RecordCategoryType method onCreateChildAssociation.

/**
 * On every event
 *
 * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
 */
@Override
@Behaviour(kind = BehaviourKind.ASSOCIATION)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) {
    QName childType = nodeService.getType(childAssocRef.getChildRef());
    // Some modules use hidden folders to store information (see RM-3283).
    if (childType.equals(ContentModel.TYPE_FOLDER)) {
        nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_FOLDER);
    }
    validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
    if (bNew) {
        // setup the record folder
        recordFolderService.setupRecordFolder(childAssocRef.getChildRef());
    }
}
Also used : QName(org.alfresco.service.namespace.QName) Behaviour(org.alfresco.repo.policy.annotation.Behaviour)

Example 18 with Behaviour

use of org.alfresco.repo.policy.annotation.Behaviour in project records-management by Alfresco.

the class UnfiledRecordContainerType method onCreateChildAssociation.

@Override
@Behaviour(kind = BehaviourKind.ASSOCIATION)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) {
    // We need to automatically cast the created folder to record folder if it is a plain folder
    // This occurs if the RM folder has been created via IMap, WebDav, etc. Don't check subtypes.
    // Some modules use hidden folder subtypes to store information (see RM-3283).
    QName childType = nodeService.getType(childAssocRef.getChildRef());
    if (childType.equals(ContentModel.TYPE_FOLDER)) {
        nodeService.setType(childAssocRef.getChildRef(), TYPE_UNFILED_RECORD_FOLDER);
    }
    // check the created child is of an accepted type
    validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
}
Also used : QName(org.alfresco.service.namespace.QName) Behaviour(org.alfresco.repo.policy.annotation.Behaviour)

Aggregations

Behaviour (org.alfresco.repo.policy.annotation.Behaviour)18 NodeRef (org.alfresco.service.cmr.repository.NodeRef)10 QName (org.alfresco.service.namespace.QName)7 Serializable (java.io.Serializable)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)3 AuthenticationUtil (org.alfresco.repo.security.authentication.AuthenticationUtil)3 IntegrityException (org.alfresco.repo.node.integrity.IntegrityException)2 Calendar (java.util.Calendar)1 Map (java.util.Map)1 DispositionAction (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)1 ModelAccessDeniedException (org.alfresco.module.org_alfresco_module_rm.model.security.ModelAccessDeniedException)1 RunAsWork (org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 ContentData (org.alfresco.service.cmr.repository.ContentData)1 AccessStatus (org.alfresco.service.cmr.security.AccessStatus)1 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)1 PropertyMap (org.alfresco.util.PropertyMap)1