use of org.alfresco.repo.policy.JavaBehaviour in project records-management by Alfresco.
the class RecordsManagementSearchBehaviour method init.
/**
* Initialisation method
*/
public void init() {
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), TYPE_DISPOSITION_ACTION, jbDispositionActionCreate);
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), TYPE_DISPOSITION_ACTION, jbDispositionActionPropertiesUpdate);
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), TYPE_DISPOSITION_SCHEDULE, jbDispositionSchedulePropertiesUpdate);
this.policyComponent.bindAssociationBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), TYPE_DISPOSITION_ACTION, ASSOC_EVENT_EXECUTIONS, jbEventExecutionUpdate);
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), TYPE_EVENT_EXECUTION, jbEventExecutionDelete);
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), ASPECT_RM_SEARCH, onAddSearchAspect);
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), ASPECT_DISPOSITION_LIFECYCLE, jbDispositionLifeCycleAspect);
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), ASPECT_RECORD, new JavaBehaviour(this, "onAddRecordAspect", NotificationFrequency.TRANSACTION_COMMIT));
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), TYPE_RECORD_FOLDER, new JavaBehaviour(this, "recordFolderCreate", NotificationFrequency.TRANSACTION_COMMIT));
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onSetNodeType"), TYPE_RECORD_FOLDER, new JavaBehaviour(this, "convertedToOrFromRecordFolder", NotificationFrequency.TRANSACTION_COMMIT));
// Vital Records Review Details Rollup
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), ASPECT_VITAL_RECORD_DEFINITION, new JavaBehaviour(this, "vitalRecordDefintionAddAspect", NotificationFrequency.TRANSACTION_COMMIT));
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), ASPECT_VITAL_RECORD_DEFINITION, new JavaBehaviour(this, "vitalRecordDefintionUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT));
}
use of org.alfresco.repo.policy.JavaBehaviour in project records-management by Alfresco.
the class ProtectedAspects method init.
/**
* Initialise method
*/
public void init() {
// Watch removal of the aspect rma:record
this.policyComponent.bindClassBehaviour(NodeServicePolicies.OnRemoveAspectPolicy.QNAME, RecordsManagementModel.ASPECT_RECORD, new JavaBehaviour(this, "onRemoveAspect"));
// Watch removal of the aspect rma:filePlanComponent
this.policyComponent.bindClassBehaviour(NodeServicePolicies.OnRemoveAspectPolicy.QNAME, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, new JavaBehaviour(this, "onRemoveAspect"));
// Watch removal of the aspect rma:recordComponentIdentifier
this.policyComponent.bindClassBehaviour(NodeServicePolicies.OnRemoveAspectPolicy.QNAME, RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID, new JavaBehaviour(this, "onRemoveAspect"));
// Watch removal of the aspect rma:commonRecordDetails
this.policyComponent.bindClassBehaviour(NodeServicePolicies.OnRemoveAspectPolicy.QNAME, RecordsManagementModel.ASPECT_COMMON_RECORD_DETAILS, new JavaBehaviour(this, "onRemoveAspect"));
}
use of org.alfresco.repo.policy.JavaBehaviour in project records-management by Alfresco.
the class FilePlanPermissionServiceImpl method init.
/**
* Initialisation method
*/
public void init() {
getPolicyComponent().bindClassBehaviour(NodeServicePolicies.OnAddAspectPolicy.QNAME, ASPECT_RECORD, new JavaBehaviour(this, "onAddRecord", TRANSACTION_COMMIT));
getPolicyComponent().bindClassBehaviour(NodeServicePolicies.OnMoveNodePolicy.QNAME, ASPECT_RECORD, new JavaBehaviour(this, "onMoveRecord", TRANSACTION_COMMIT));
getPolicyComponent().bindClassBehaviour(NodeServicePolicies.OnMoveNodePolicy.QNAME, TYPE_RECORD_CATEGORY, new JavaBehaviour(this, "onMoveNode", TRANSACTION_COMMIT));
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
recordsManagementAuditService.registerAuditEvent(new AuditEvent(AUDIT_SET_PERMISSION, "rm.audit.set-permission"));
return null;
}
});
}
use of org.alfresco.repo.policy.JavaBehaviour in project alfresco-remote-api by Alfresco.
the class WebDAVonContentUpdateTest method testUploadNewContentFiresContentUpdatePolicies.
/**
* Put a content file and check that onContentUpdate fired
* <p>
* Lock the file
* <p>
* Put the contents
* <p>
* Unlock the node
*/
@Test
public void testUploadNewContentFiresContentUpdatePolicies() throws Exception {
flag = false;
counter = 0;
policyComponent.bindClassBehaviour(OnContentUpdatePolicy.QNAME, ContentModel.TYPE_CONTENT, new JavaBehaviour(this, "doOnContentUpdate"));
String fileName = "file-" + GUID.generate();
NodeRef fileNoderef = null;
try {
executeMethod(WebDAV.METHOD_LOCK, fileName, davLockInfoFile, null);
List<NodeRef> refs = searchService.selectNodes(nodeService.getRootNode(storeRef), "/app:company_home/cm:" + fileName, null, namespaceService, false);
fileNoderef = refs.get(0);
assertEquals("File should be locked", LockStatus.LOCK_OWNER, lockService.getLockStatus(fileNoderef));
} catch (Exception e) {
fail("Failed to lock a file: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
}
txn.commit();
txn = transactionService.getUserTransaction();
txn.begin();
// Construct IF HEADER
String lockToken = fileNoderef.getId() + WebDAV.LOCK_TOKEN_SEPERATOR + AuthenticationUtil.getAdminUserName();
String lockHeaderValue = "(<" + WebDAV.OPAQUE_LOCK_TOKEN + lockToken + ">)";
HashMap<String, String> headers = new HashMap<String, String>();
headers.put(WebDAV.HEADER_IF, lockHeaderValue);
try {
executeMethod(WebDAV.METHOD_PUT, fileName, testDataFile, headers);
assertTrue("File does not exist.", nodeService.exists(fileNoderef));
assertEquals("Filename is not correct", fileName, nodeService.getProperty(fileNoderef, ContentModel.PROP_NAME));
assertTrue("Expected return status is " + HttpServletResponse.SC_NO_CONTENT + ", but returned is " + response.getStatus(), HttpServletResponse.SC_NO_CONTENT == response.getStatus());
assertTrue("File should have NO_CONTENT aspect", nodeService.hasAspect(fileNoderef, ContentModel.ASPECT_NO_CONTENT));
InputStream updatedFileIS = fileFolderService.getReader(fileNoderef).getContentInputStream();
byte[] updatedFile = IOUtils.toByteArray(updatedFileIS);
updatedFileIS.close();
assertTrue("The content has to be equal", ArrayUtils.isEquals(testDataFile, updatedFile));
} catch (Exception e) {
fail("Failed to upload a file: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
}
txn.commit();
txn = transactionService.getUserTransaction();
txn.begin();
headers = new HashMap<String, String>();
headers.put(WebDAV.HEADER_LOCK_TOKEN, "<" + WebDAV.OPAQUE_LOCK_TOKEN + lockToken + ">");
try {
executeMethod(WebDAV.METHOD_UNLOCK, fileName, null, headers);
assertTrue("Expected return status is " + HttpServletResponse.SC_NO_CONTENT + ", but returned is " + response.getStatus(), HttpServletResponse.SC_NO_CONTENT == response.getStatus());
assertFalse("File should not have NO_CONTENT aspect", nodeService.hasAspect(fileNoderef, ContentModel.ASPECT_NO_CONTENT));
assertEquals("File should be unlocked", LockStatus.NO_LOCK, lockService.getLockStatus(fileNoderef));
} catch (Exception e) {
fail("Failed to unlock a file: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
}
assertTrue("onContentUpdate policies were not triggered", flag);
assertEquals("onContentUpdate policies should be triggered only once", counter, 1);
if (fileNoderef != null) {
nodeService.deleteNode(fileNoderef);
}
}
use of org.alfresco.repo.policy.JavaBehaviour in project records-management by Alfresco.
the class JSONConversionComponent method init.
/**
* The initialise method
*/
public void init() {
policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), RecordsManagementModel.TYPE_RM_SITE, new JavaBehaviour(this, "onDeleteNode"));
policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), RecordsManagementModel.TYPE_RM_SITE, new JavaBehaviour(this, "onCreateNode"));
}
Aggregations