org.alfresco.repo.policy.Behaviour.NotificationFrequency Java Examples
The following examples show how to use
org.alfresco.repo.policy.Behaviour.NotificationFrequency.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImapContentPolicy.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Init method. Registered behaviours. */ public void init() { PropertyCheck.mandatory(this, "actionService", getActionService()); PropertyCheck.mandatory(this, "policyComponent", getPolicyComponent()); /** * Bind policies */ this.getPolicyComponent().bindClassBehaviour(OnAddAspectPolicy.QNAME, ImapModel.ASPECT_IMAP_CONTENT, new JavaBehaviour(this, "onAddAspect", NotificationFrequency.TRANSACTION_COMMIT)); /** * Bind policies */ this.getPolicyComponent().bindClassBehaviour(OnCopyNodePolicy.QNAME , ImapModel.ASPECT_IMAP_CONTENT, new JavaBehaviour(this, "getCopyCallback", NotificationFrequency.EVERY_EVENT)); }
Example #2
Source File: TypeRoutingContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 6 votes |
private void afterPropertiesSet_setupChangePolicies() { if (this.moveStoresOnChangeOptionPropertyName != null) { this.moveStoresOnChangeOptionPropertyQName = QName.resolveToQName(this.namespaceService, this.moveStoresOnChangeOptionPropertyName); PropertyCheck.mandatory(this, "moveStoresOnChangeOptionPropertyQName", this.moveStoresOnChangeOptionPropertyQName); final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService .getProperty(this.moveStoresOnChangeOptionPropertyQName); if (moveStoresOnChangeOptionPropertyDefinition == null || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName()) || moveStoresOnChangeOptionPropertyDefinition.isMultiValued()) { throw new IllegalStateException(this.moveStoresOnChangeOptionPropertyName + " is not a valid content model property of type single-valued d:boolean"); } } if (this.moveStoresOnChange || this.moveStoresOnChangeOptionPropertyQName != null) { this.policyComponent.bindClassBehaviour(OnSetNodeTypePolicy.QNAME, ContentModel.TYPE_BASE, new JavaBehaviour(this, "onSetNodeType", NotificationFrequency.EVERY_EVENT)); } }
Example #3
Source File: PolicyFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Construct a collection of Policy implementations for the specified binding * * @param binding the binding * @return the collection of policy implementations */ @SuppressWarnings("unchecked") public Collection<P> createList(B binding) { Collection<BehaviourDefinition> behaviourDefs = index.find(binding); List<P> policyInterfaces = new ArrayList<P>(behaviourDefs.size()); for (BehaviourDefinition behaviourDef : behaviourDefs) { Behaviour behaviour = behaviourDef.getBehaviour(); P policyIF = behaviour.getInterface(policyClass); if (!(behaviour.getNotificationFrequency().equals(NotificationFrequency.EVERY_EVENT))) { // wrap behaviour in transaction proxy which deals with delaying invocation until necessary if (transactionHandlerFactory == null) { throw new PolicyException("Transaction-level policies not supported as transaction support for the Policy Component has not been initialised."); } InvocationHandler trxHandler = transactionHandlerFactory.createHandler(behaviour, behaviourDef.getPolicyDefinition(), policyIF); policyIF = (P)Proxy.newProxyInstance(policyClass.getClassLoader(), new Class[]{policyClass}, trxHandler); } policyInterfaces.add(policyIF); } return policyInterfaces; }
Example #4
Source File: AliasableAspect.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Spring initilaise method used to register the policy behaviours */ public void init() { PropertyCheck.mandatory(this, "policyComponent", policyComponent); PropertyCheck.mandatory(this, "nodeService", nodeService); PropertyCheck.mandatory(this, "attributeService", attributeService); // Register the policy behaviours policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, EmailServerModel.ASPECT_ALIASABLE, new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT)); policyComponent.bindClassBehaviour(BeforeRemoveAspectPolicy.QNAME, EmailServerModel.ASPECT_ALIASABLE, new JavaBehaviour(this, "beforeRemoveAspect", NotificationFrequency.FIRST_EVENT)); policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, EmailServerModel.ASPECT_ALIASABLE, new JavaBehaviour(this, "onUpdateProperties")); policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, EmailServerModel.ASPECT_ALIASABLE, new JavaBehaviour(this, "beforeDeleteNode")); policyComponent.bindClassBehaviour(CopyServicePolicies.OnCopyNodePolicy.QNAME, EmailServerModel.ASPECT_ALIASABLE, new JavaBehaviour(this, "getCopyCallback")); }
Example #5
Source File: ImapServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected void bindBehaviour() { if (logger.isDebugEnabled()) { logger.debug("[bindBeahaviour] Binding behaviours"); } PolicyComponent policyComponent = (PolicyComponent) serviceRegistry.getService(QName.createQName(NamespaceService.ALFRESCO_URI, "policyComponent")); // Only listen to folders we've tagged with imap properties - not all folders or we'll really slow down the repository! policyComponent.bindAssociationBehaviour( OnCreateChildAssociationPolicy.QNAME, ImapModel.ASPECT_IMAP_FOLDER, ContentModel.ASSOC_CONTAINS, new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT)); policyComponent.bindAssociationBehaviour( OnDeleteChildAssociationPolicy.QNAME, ImapModel.ASPECT_IMAP_FOLDER, ContentModel.ASSOC_CONTAINS, new JavaBehaviour(this, "onDeleteChildAssociation", NotificationFrequency.EVERY_EVENT)); policyComponent.bindClassBehaviour( OnUpdatePropertiesPolicy.QNAME, ContentModel.TYPE_CONTENT, new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.EVERY_EVENT)); policyComponent.bindClassBehaviour( BeforeDeleteNodePolicy.QNAME, ContentModel.TYPE_CONTENT, new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.EVERY_EVENT)); policyComponent.bindClassBehaviour( OnRestoreNodePolicy.QNAME, ContentModel.TYPE_CONTENT, new JavaBehaviour(this, "onRestoreNode", NotificationFrequency.EVERY_EVENT)); }
Example #6
Source File: ArchiveFileContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
/** * * {@inheritDoc} */ @Override public void afterPropertiesSet() { super.afterPropertiesSet(); // if we ever support more variants, OR this if (this.retentionViaAccessTime) { PropertyCheck.mandatory(this, "namespaceService", this.namespaceService); PropertyCheck.mandatory(this, "dictionaryService", this.dictionaryService); PropertyCheck.mandatory(this, "nodeService", this.nodeService); PropertyCheck.mandatory(this, "retentionDatePropertyName", this.retentionDatePropertyName); this.retentionDatePropertyQName = QName.resolveToQName(this.namespaceService, this.retentionDatePropertyName); if (this.retentionDatePropertyQName == null) { throw new IllegalStateException(this.retentionDatePropertyName + " cannot be resolved to a qualified name"); } final PropertyDefinition property = this.dictionaryService.getProperty(this.retentionDatePropertyQName); if (property == null || !(DataTypeDefinition.DATE.equals(property.getDataType().getName()) || DataTypeDefinition.DATETIME.equals(property.getDataType().getName()))) { throw new IllegalStateException( this.retentionDatePropertyName + " is not a date/datetime property defined in the data model"); } if (this.prolongRetentionOnPropertyChange) { PropertyCheck.mandatory(this, "policyComponent", this.policyComponent); this.policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, property.getContainerClass().getName(), new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.EVERY_EVENT)); } } PropertyCheck.mandatory(this, "digestAlgorithm", this.digestAlgorithm); }
Example #7
Source File: SiteRoutingFileContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
protected void afterPropertiesSet_setupChangePolicies() { if (this.moveStoresOnNodeMoveOrCopyOverridePropertyName != null) { this.moveStoresOnNodeMoveOrCopyOverridePropertyQName = QName.resolveToQName(this.namespaceService, this.moveStoresOnNodeMoveOrCopyOverridePropertyName); PropertyCheck.mandatory(this, "moveStoresOnNodeMoveOrCopyOverridePropertyQName", this.moveStoresOnNodeMoveOrCopyOverridePropertyQName); final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService .getProperty(this.moveStoresOnNodeMoveOrCopyOverridePropertyQName); if (moveStoresOnChangeOptionPropertyDefinition == null || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName()) || moveStoresOnChangeOptionPropertyDefinition.isMultiValued()) { throw new IllegalStateException(this.moveStoresOnNodeMoveOrCopyOverridePropertyName + " is not a valid content model property of type single-valued d:boolean"); } } if (this.moveStoresOnNodeMoveOrCopy || this.moveStoresOnNodeMoveOrCopyOverridePropertyQName != null) { this.policyComponent.bindClassBehaviour(OnCopyCompletePolicy.QNAME, ContentModel.TYPE_BASE, new JavaBehaviour(this, "onCopyComplete", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME, ContentModel.TYPE_BASE, new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT)); } }
Example #8
Source File: SiteRoutingContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
protected void afterPropertiesSet_setupChangePolicies() { if (this.moveStoresOnNodeMoveOrCopyOverridePropertyName != null) { this.moveStoresOnNodeMoveOrCopyOverridePropertyQName = QName.resolveToQName(this.namespaceService, this.moveStoresOnNodeMoveOrCopyOverridePropertyName); PropertyCheck.mandatory(this, "moveStoresOnNodeMoveOrCopyOverridePropertyQName", this.moveStoresOnNodeMoveOrCopyOverridePropertyQName); final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService .getProperty(this.moveStoresOnNodeMoveOrCopyOverridePropertyQName); if (moveStoresOnChangeOptionPropertyDefinition == null || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName()) || moveStoresOnChangeOptionPropertyDefinition.isMultiValued()) { throw new IllegalStateException(this.moveStoresOnNodeMoveOrCopyOverridePropertyName + " is not a valid content model property of type single-valued d:boolean"); } } if (this.moveStoresOnNodeMoveOrCopy || this.moveStoresOnNodeMoveOrCopyOverridePropertyQName != null) { PropertyCheck.mandatory(this, "policyComponent", this.policyComponent); PropertyCheck.mandatory(this, "dictionaryService", this.dictionaryService); PropertyCheck.mandatory(this, "nodeService", this.nodeService); this.policyComponent.bindClassBehaviour(OnCopyCompletePolicy.QNAME, ContentModel.TYPE_BASE, new JavaBehaviour(this, "onCopyComplete", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME, ContentModel.TYPE_BASE, new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT)); } }
Example #9
Source File: SelectorPropertyContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
private void afterPropertiesSet_setupChangePolicies() { if (this.moveStoresOnChangeOptionPropertyName != null) { this.moveStoresOnChangeOptionPropertyQName = QName.resolveToQName(this.namespaceService, this.moveStoresOnChangeOptionPropertyName); PropertyCheck.mandatory(this, "moveStoresOnChangeOptionPropertyQName", this.moveStoresOnChangeOptionPropertyQName); final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService .getProperty(this.moveStoresOnChangeOptionPropertyQName); if (moveStoresOnChangeOptionPropertyDefinition == null || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName()) || moveStoresOnChangeOptionPropertyDefinition.isMultiValued()) { throw new IllegalStateException(this.moveStoresOnChangeOptionPropertyName + " is not a valid content model property of type single-valued d:boolean"); } } if (this.moveStoresOnChange || this.moveStoresOnChangeOptionPropertyQName != null) { this.policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, this.selectorClassQName, new JavaBehaviour(this, "onUpdateProperties", NotificationFrequency.EVERY_EVENT)); final ClassDefinition classDefinition = this.dictionaryService.getClass(this.selectorClassQName); if (classDefinition.isAspect()) { this.policyComponent.bindClassBehaviour(BeforeRemoveAspectPolicy.QNAME, this.selectorClassQName, new JavaBehaviour(this, "beforeRemoveAspect", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, this.selectorClassQName, new JavaBehaviour(this, "onAddAspect", NotificationFrequency.EVERY_EVENT)); } } }
Example #10
Source File: CreateNodeRuleTrigger.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public void registerRuleTrigger() { if (isClassBehaviour == true) { this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, POLICY), this, new JavaBehaviour(this, POLICY)); } else { this.policyComponent.bindAssociationBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, POLICY), this, new JavaBehaviour(this, POLICY)); } for (QName ignoreAspect : getIgnoredAspects()) { // Register interest in the addition and removal of the sys:noContent aspect this.policyComponent.bindClassBehaviour( NodeServicePolicies.OnAddAspectPolicy.QNAME, ignoreAspect, new JavaBehaviour(this, "onAddAspect", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour( NodeServicePolicies.OnRemoveAspectPolicy.QNAME, ignoreAspect, new JavaBehaviour(this, "onRemoveAspect", NotificationFrequency.EVERY_EVENT)); } }
Example #11
Source File: PolicyComponentTransactionTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { applicationContext = ApplicationContextHelper.getApplicationContext(); // initialise policy test model DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List<String> bootstrapModels = new ArrayList<String>(); bootstrapModels.add(TEST_MODEL); bootstrap.setModels(bootstrapModels); bootstrap.setDictionaryDAO((DictionaryDAO)applicationContext.getBean("dictionaryDAO")); bootstrap.setTenantService((TenantService)applicationContext.getBean("tenantService")); bootstrap.bootstrap(); // retrieve policy component this.policyComponent = (PolicyComponent)applicationContext.getBean("policyComponent"); this.behaviourFilter = (BehaviourFilter) applicationContext.getBean("policyBehaviourFilter"); this.trxService = (TransactionService) applicationContext.getBean("transactionComponent"); this.nodeService = (NodeService) applicationContext.getBean("nodeService"); this.nodeLocatorService = (NodeLocatorService) applicationContext.getBean("nodeLocatorService"); this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent"); this.authenticationComponent.setSystemUserAsCurrentUser(); // Register Policy if (sideEffectDelegate == null) { sideEffectDelegate = policyComponent.registerClassPolicy(SideEffectTestPolicy.class); // Bind Behaviour to side effect policy QName policyName = QName.createQName(TEST_NAMESPACE, "sideEffect"); Behaviour baseBehaviour = new JavaBehaviour(this, "sideEffectTest", NotificationFrequency.TRANSACTION_COMMIT); this.policyComponent.bindClassBehaviour(policyName, BASE_TYPE, baseBehaviour); } this.companyHome = nodeLocatorService.getNode(CompanyHomeNodeLocator.NAME, null, null); createAndEnableBehaviours(); }
Example #12
Source File: MaxVersionPolicy.java From alfresco-maxversion-policy with Apache License 2.0 | 4 votes |
public void init() { logger.debug("MaxVersions is set to: " + maxVersions); Behaviour afterCreateVersionBehaviour = new JavaBehaviour(this, "afterCreateVersion", NotificationFrequency.TRANSACTION_COMMIT); this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "afterCreateVersion"), MaxVersionPolicy.class, afterCreateVersionBehaviour); }
Example #13
Source File: ContentMetadataExtracterTagMappingTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void setUp() throws Exception { // Detect any dangling transactions as there is a lot of direct UserTransaction manipulation if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE) { throw new IllegalStateException( "There should not be any transactions when starting test: " + AlfrescoTransactionSupport.getTransactionId() + " started at " + new Date(AlfrescoTransactionSupport.getTransactionStartTime())); } // Get services this.taggingService = (TaggingService)ctx.getBean("TaggingService"); this.nodeService = (NodeService) ctx.getBean("NodeService"); this.contentService = (ContentService) ctx.getBean("ContentService"); this.transactionService = (TransactionService)ctx.getBean("transactionComponent"); this.auditService = (AuditService)ctx.getBean("auditService"); this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent"); this.executer = (ContentMetadataExtracter) ctx.getBean("extract-metadata"); executer.setEnableStringTagging(true); executer.setTaggingService(taggingService); if (init == false) { this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){ @Override public Void execute() throws Throwable { // Authenticate as the system user authenticationComponent.setSystemUserAsCurrentUser(); // Create the store and get the root node ContentMetadataExtracterTagMappingTest.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); ContentMetadataExtracterTagMappingTest.rootNode = nodeService.getRootNode(ContentMetadataExtracterTagMappingTest.storeRef); // Create the required tagging category NodeRef catContainer = nodeService.createNode(ContentMetadataExtracterTagMappingTest.rootNode, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categoryContainer"), ContentModel.TYPE_CONTAINER).getChildRef(); NodeRef catRoot = nodeService.createNode( catContainer, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categoryRoot"), ContentModel.TYPE_CATEGORYROOT).getChildRef(); nodeService.createNode( catRoot, ContentModel.ASSOC_CATEGORIES, ContentModel.ASPECT_TAGGABLE, ContentModel.TYPE_CATEGORY).getChildRef(); MetadataExtracterRegistry registry = (MetadataExtracterRegistry) ctx.getBean("metadataExtracterRegistry"); extractor = new TagMappingMetadataExtracter(); extractor.setRegistry(registry); extractor.register(); init = true; return null; }}); } // We want to know when tagging actions have finished running asyncOccurs = (new TaggingServiceImplTest()).new AsyncOccurs(); ((PolicyComponent)ctx.getBean("policyComponent")).bindClassBehaviour( AsynchronousActionExecutionQueuePolicies.OnAsyncActionExecute.QNAME, ActionModel.TYPE_ACTION, new JavaBehaviour(asyncOccurs, "onAsyncActionExecute", NotificationFrequency.EVERY_EVENT) ); // We do want action tracking whenever the tag scope updater runs UpdateTagScopesActionExecuter updateTagsAction = (UpdateTagScopesActionExecuter)ctx.getBean("update-tagscope"); updateTagsAction.setTrackStatus(true); }
Example #14
Source File: ActionTrackingServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override @SuppressWarnings("unchecked") protected void setUp() throws Exception { // Detect any dangling transactions as there is a lot of direct UserTransaction manipulation if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE) { throw new IllegalStateException( "There should not be any transactions when starting test: " + AlfrescoTransactionSupport.getTransactionId() + " started at " + new Date(AlfrescoTransactionSupport.getTransactionStartTime())); } // Grab our beans this.nodeService = (NodeService)ctx.getBean("nodeService"); this.scriptService = (ScriptService)ctx.getBean("scriptService"); this.actionService = (ActionService)ctx.getBean("actionService"); this.runtimeActionService = (RuntimeActionService)ctx.getBean("actionService"); this.actionTrackingService = (ActionTrackingService)ctx.getBean("actionTrackingService"); this.transactionService = (TransactionService)ctx.getBean("transactionService"); this.executingActionsCache = (SimpleCache<String, ExecutionDetails>)ctx.getBean("executingActionsCache"); AuthenticationUtil.setRunAsUserSystem(); UserTransaction txn = transactionService.getUserTransaction(); txn.begin(); // Where to put things this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = this.nodeService.getRootNode(this.storeRef); // Create the node used for tests this.nodeRef = this.nodeService.createNode( this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testnode"), ContentModel.TYPE_CONTENT).getChildRef(); this.nodeService.setProperty( this.nodeRef, ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null)); this.folder = this.nodeService.createNode( this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testFolder"), ContentModel.TYPE_FOLDER).getChildRef(); txn.commit(); // Cache should start empty each time executingActionsCache.clear(); // Reset the execution instance IDs, so we // can predict what they'll be ((ActionTrackingServiceImpl)actionTrackingService).resetNextExecutionId(); // Register the test executor, if needed SleepActionExecuter.registerIfNeeded(ctx); // We want to know when async actions occur asyncOccurs = new AsyncOccurs(); ((PolicyComponent)ctx.getBean("policyComponent")).bindClassBehaviour( AsynchronousActionExecutionQueuePolicies.OnAsyncActionExecute.QNAME, ActionModel.TYPE_ACTION, new JavaBehaviour(asyncOccurs, "onAsyncActionExecute", NotificationFrequency.EVERY_EVENT) ); }
Example #15
Source File: TaggingServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Before public void setUp() throws Exception { // Detect any dangling transactions as there is a lot of direct UserTransaction manipulation if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE) { throw new IllegalStateException( "There should not be any transactions when starting test: " + AlfrescoTransactionSupport.getTransactionId() + " started at " + new Date(AlfrescoTransactionSupport.getTransactionStartTime())); } // Get services this.taggingService = (TaggingServiceImpl)applicationContext.getBean("taggingService"); this.nodeService = (NodeService) applicationContext.getBean("NodeService"); this.fileFolderService = (FileFolderService) applicationContext.getBean("FileFolderService"); this.copyService = (CopyService) applicationContext.getBean("CopyService"); this.checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("CheckoutCheckinService"); this.actionService = (ActionService)applicationContext.getBean("ActionService"); this.transactionService = (TransactionService)applicationContext.getBean("transactionComponent"); this.siteService = applicationContext.getBean("SiteService", SiteService.class); //MNT-10807 : Auditing does not take into account audit.filter.alfresco-access.transaction.user UserAuditFilter userAuditFilter = new UserAuditFilter(); userAuditFilter.setUserFilterPattern("System;.*"); userAuditFilter.afterPropertiesSet(); AuditComponent auditComponent = (AuditComponent) applicationContext.getBean("auditComponent"); auditComponent.setUserAuditFilter(userAuditFilter); AuditServiceImpl auditServiceImpl = (AuditServiceImpl) applicationContext.getBean("auditService"); auditServiceImpl.setAuditComponent(auditComponent); this.auditService = (AuditService)applicationContext.getBean("auditService"); this.scriptService = (ScriptService)applicationContext.getBean("scriptService"); this.actionTrackingService = (ActionTrackingService)applicationContext.getBean("actionTrackingService"); this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent"); this.personService = (PersonService)applicationContext.getBean("PersonService"); this.permissionService = (PermissionService)applicationContext.getBean("PermissionService"); this.authenticationService = (MutableAuthenticationService)applicationContext.getBean("authenticationService"); this.nodeRefPropInterceptor = (NodeRefPropertyMethodInterceptor)applicationContext.getBean("nodeRefPropertyInterceptor"); if (init == false) { this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>(){ @Override public Void execute() throws Throwable { // Authenticate as the system user authenticationComponent.setSystemUserAsCurrentUser(); // Create the store and get the root node TaggingServiceImplTest.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); TaggingServiceImplTest.rootNode = nodeService.getRootNode(TaggingServiceImplTest.storeRef); // Create the required tagging category NodeRef catContainer = nodeService.createNode(TaggingServiceImplTest.rootNode, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categoryContainer"), ContentModel.TYPE_CONTAINER).getChildRef(); NodeRef catRoot = nodeService.createNode( catContainer, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "categoryRoot"), ContentModel.TYPE_CATEGORYROOT).getChildRef(); nodeService.createNode( catRoot, ContentModel.ASSOC_CATEGORIES, ContentModel.ASPECT_TAGGABLE, ContentModel.TYPE_CATEGORY).getChildRef(); init = true; return null; }}); } // We want to know when tagging actions have finished running asyncOccurs = new AsyncOccurs(); ((PolicyComponent)applicationContext.getBean("policyComponent")).bindClassBehaviour( AsynchronousActionExecutionQueuePolicies.OnAsyncActionExecute.QNAME, ActionModel.TYPE_ACTION, new JavaBehaviour(asyncOccurs, "onAsyncActionExecute", NotificationFrequency.EVERY_EVENT) ); // We do want action tracking whenever the tag scope updater runs UpdateTagScopesActionExecuter updateTagsAction = (UpdateTagScopesActionExecuter)applicationContext.getBean("update-tagscope"); updateTagsAction.setTrackStatus(true); // Create the folders and documents to be tagged createTestDocumentsAndFolders(); }
Example #16
Source File: TaggingServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Init method */ public void init() { // Register policy behaviours this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), ContentModel.ASPECT_TAGGABLE, new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.EVERY_EVENT)); // Create tag behaviour createTagBehaviour = new JavaBehaviour(this, "createTags", NotificationFrequency.FIRST_EVENT); this.policyComponent.bindClassBehaviour( OnCreateNodePolicy.QNAME, ContentModel.ASPECT_TAGGABLE, createTagBehaviour); // We need to register on content and folders, rather than // tagable, so we can pick up when things start and // stop being tagged updateTagBehaviour = new JavaBehaviour(this, "updateTags", NotificationFrequency.EVERY_EVENT); this.policyComponent.bindClassBehaviour( OnUpdatePropertiesPolicy.QNAME, ContentModel.TYPE_CONTENT, updateTagBehaviour); this.policyComponent.bindClassBehaviour( OnUpdatePropertiesPolicy.QNAME, ContentModel.TYPE_FOLDER, updateTagBehaviour); // We need to know when you move or copy nodes this.policyComponent.bindClassBehaviour( OnMoveNodePolicy.QNAME, ContentModel.ASPECT_TAGGABLE, new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour( BeforeCopyPolicy.QNAME, ContentModel.ASPECT_TAGGABLE, new JavaBehaviour(this, "beforeCopy", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour( OnCopyCompletePolicy.QNAME, ContentModel.ASPECT_TAGGABLE, new JavaBehaviour(this, "onCopyComplete", NotificationFrequency.EVERY_EVENT)); this.policyComponent.bindClassBehaviour( CheckOutCheckInServicePolicies.OnCheckOut.QNAME, ContentModel.ASPECT_TAGGABLE, new JavaBehaviour(this, "afterCheckOut", NotificationFrequency.EVERY_EVENT)); }
Example #17
Source File: OwnableServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void init() { policyComponent.bindClassBehaviour( NodeServicePolicies.OnAddAspectPolicy.QNAME, ContentModel.ASPECT_OWNABLE, new JavaBehaviour(this, "onAddAspect")); policyComponent.bindClassBehaviour( NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, ContentModel.ASPECT_OWNABLE, new JavaBehaviour(this, "onUpdateProperties")); policyComponent.bindClassBehaviour( NodeServicePolicies.OnRemoveAspectPolicy.QNAME, ContentModel.ASPECT_OWNABLE, new JavaBehaviour(this, "onRemoveAspect")); policyComponent.bindClassBehaviour( NodeServicePolicies.OnDeleteNodePolicy.QNAME, ContentModel.ASPECT_OWNABLE, new JavaBehaviour(this, "onDeleteNode")); policyComponent.bindClassBehaviour( NodeServicePolicies.OnAddAspectPolicy.QNAME, ContentModel.ASPECT_AUDITABLE, new JavaBehaviour(this, "onAddAspect")); policyComponent.bindClassBehaviour( NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, ContentModel.ASPECT_AUDITABLE, new JavaBehaviour(this, "onUpdateProperties")); policyComponent.bindClassBehaviour( NodeServicePolicies.OnRemoveAspectPolicy.QNAME, ContentModel.ASPECT_AUDITABLE, new JavaBehaviour(this, "onRemoveAspect")); policyComponent.bindClassBehaviour( NodeServicePolicies.OnDeleteNodePolicy.QNAME, ContentModel.ASPECT_AUDITABLE, new JavaBehaviour(this, "onDeleteNode")); policyComponent.bindClassBehaviour( CopyServicePolicies.OnCopyNodePolicy.QNAME, ContentModel.ASPECT_OWNABLE, new JavaBehaviour(this, "onCopyNode", NotificationFrequency.EVERY_EVENT)); policyComponent.bindClassBehaviour( CopyServicePolicies.OnCopyNodePolicy.QNAME, ContentModel.ASPECT_AUDITABLE, new JavaBehaviour(this, "onCopyNode", NotificationFrequency.EVERY_EVENT)); }
Example #18
Source File: BaseBehaviour.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void setNotificationFrequency(NotificationFrequency frequency) { this.frequency = frequency; }
Example #19
Source File: BaseBehaviour.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Constructor * * @param frequency the notification frequency */ public BaseBehaviour(NotificationFrequency frequency) { ParameterCheck.mandatory("Frequency", frequency); this.frequency = frequency; }
Example #20
Source File: TransactionInvocationHandlerFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // Handle Object level methods if (method.getName().equals("toString")) { return policyInterface.toString(); } else if (method.getName().equals("hashCode")) { return policyInterface.hashCode(); } else if (method.getName().equals("equals")) { return policyInterface.equals(args[0]); } // Invoke policy based on its notification frequency Object result = null; if (behaviour.getNotificationFrequency().equals(NotificationFrequency.FIRST_EVENT)) { Map<ExecutionInstanceKey, Object> executedBehaviours = (Map<ExecutionInstanceKey, Object>)AlfrescoTransactionSupport.getResource(EXECUTED_KEY); if (executedBehaviours == null) { executedBehaviours = new HashMap<ExecutionInstanceKey, Object>(); AlfrescoTransactionSupport.bindResource(EXECUTED_KEY, executedBehaviours); } ExecutionInstanceKey key = new ExecutionInstanceKey(behaviour, definition.getArguments(), args); if (executedBehaviours.containsKey(key) == false) { // Invoke behavior for first time and mark as executed try { result = method.invoke(policyInterface, args); executedBehaviours.put(key, result); } catch (InvocationTargetException e) { throw e.getTargetException(); } } else { // Return result of previous execution result = executedBehaviours.get(key); } } else if (behaviour.getNotificationFrequency().equals(NotificationFrequency.TRANSACTION_COMMIT)) { // queue policy invocation for end of transaction queue.queue(behaviour, definition, policyInterface, method, args); } else { // Note: shouldn't get here throw new PolicyException("Invalid Notification frequency " + behaviour.getNotificationFrequency()); } return result; }
Example #21
Source File: RepoTransferReceiverImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void init() { PropertyCheck.mandatory(this, "nodeService", nodeService); PropertyCheck.mandatory(this, "searchService", searchService); PropertyCheck.mandatory(this, "ruleService", ruleService); PropertyCheck.mandatory(this, "actionService", actionService); PropertyCheck.mandatory(this, "behaviourFilter", behaviourFilter); PropertyCheck.mandatory(this, "tennantService", tenantService); PropertyCheck.mandatory(this, "transactionService", transactionService); PropertyCheck.mandatory(this, "transferLockFolderPath", transferLockFolderPath); PropertyCheck.mandatory(this, "inboundTransferRecordsPath", inboundTransferRecordsPath); PropertyCheck.mandatory(this, "rootStagingDirectory", rootStagingDirectory); PropertyCheck.mandatory(this, "policyComponent", policyComponent); PropertyCheck.mandatory(this, "descriptorService", descriptorService); PropertyCheck.mandatory(this, "alienProcessor", alienProcessor); PropertyCheck.mandatory(this, "jobLockService", getJobLockService()); PropertyCheck.mandatory(this, "transferVersionChecker", getTransferVersionChecker()); PropertyCheck.mandatory(this, "namespaceService", namespaceService); beforeStartInboundTransferDelegate = policyComponent.registerClassPolicy(TransferServicePolicies.BeforeStartInboundTransferPolicy.class); onStartInboundTransferDelegate = policyComponent.registerClassPolicy(TransferServicePolicies.OnStartInboundTransferPolicy.class); onEndInboundTransferDelegate = policyComponent.registerClassPolicy(TransferServicePolicies.OnEndInboundTransferPolicy.class); /** * For every new child of a node with the trx:transferred aspect run this.onCreateChildAssociation */ this.getPolicyComponent().bindAssociationBehaviour( NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, TransferModel.ASPECT_TRANSFERRED, new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT)); /** * For every update of a transferred node */ this.getPolicyComponent().bindClassBehaviour( ContentServicePolicies.OnContentUpdatePolicy.QNAME, TransferModel.ASPECT_TRANSFERRED, new JavaBehaviour(this, "onContentUpdate", NotificationFrequency.EVERY_EVENT)); /** * For every copy of a transferred node run onCopyTransferred */ this.getPolicyComponent().bindClassBehaviour( CopyServicePolicies.OnCopyNodePolicy.QNAME, TransferModel.ASPECT_TRANSFERRED, new JavaBehaviour(this, "onCopyTransferred", NotificationFrequency.EVERY_EVENT)); /** * For every new child of a node with the trx:alien aspect run this.onCreateChildAssociation */ this.getPolicyComponent().bindAssociationBehaviour( NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, TransferModel.ASPECT_ALIEN, new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT)); /** * For every node with the trx:alien aspect run this.beforeDeleteNode */ this.getPolicyComponent().bindClassBehaviour( NodeServicePolicies.BeforeDeleteNodePolicy.QNAME, TransferModel.ASPECT_ALIEN, new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.EVERY_EVENT)); /** * For every restore of a node with the trx:alien aspect */ this.getPolicyComponent().bindClassBehaviour( NodeServicePolicies.OnRestoreNodePolicy.QNAME, TransferModel.ASPECT_ALIEN, new JavaBehaviour(this, "onRestoreNode", NotificationFrequency.EVERY_EVENT)); /** * For every move of a node with the trx:alien aspect. */ this.getPolicyComponent().bindClassBehaviour( NodeServicePolicies.OnMoveNodePolicy.QNAME, TransferModel.ASPECT_ALIEN, new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT)); /** * For every copy of an alien node remove the alien aspect */ this.getPolicyComponent().bindClassBehaviour( CopyServicePolicies.OnCopyNodePolicy.QNAME, TransferModel.ASPECT_ALIEN, new JavaBehaviour(this, "onCopyAlien", NotificationFrequency.EVERY_EVENT)); }
Example #22
Source File: BaseBehaviour.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * Get the notification frequency * * @return the notification frequency */ public NotificationFrequency getNotificationFrequency() { return frequency; }