org.alfresco.repo.policy.JavaBehaviour Java Examples

The following examples show how to use org.alfresco.repo.policy.JavaBehaviour. 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: WorkflowDefinitionType.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * The initialise method     
 */
public void init()
{
    // Register interest in the onContentUpdate policy for the workflow definition type
    policyComponent.bindClassBehaviour(
            ContentServicePolicies.OnContentUpdatePolicy.QNAME, 
            WorkflowModel.TYPE_WORKFLOW_DEF, 
            new JavaBehaviour(this, "onContentUpdate"));
    
    // Register interest in the onPropertyUpdate policy for the workflow definition type
    policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), 
            WorkflowModel.TYPE_WORKFLOW_DEF, 
            new JavaBehaviour(this, "onUpdateProperties"));
    
    // Register interest in the node delete policy
    policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), 
            WorkflowModel.TYPE_WORKFLOW_DEF, 
            new JavaBehaviour(this, "beforeDeleteNode"));
}
 
Example #2
Source File: ImapContentPolicy.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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 #3
Source File: QuickShareServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * The initialise method. Register our policies.
 */
public void init()
{
    checkMandatoryProperties();

    // Register interest in the beforeDeleteNode policy - note: currently for content only !!
    policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
            ContentModel.TYPE_CONTENT,
            new JavaBehaviour(this, "beforeDeleteNode"));
    
    //Register interest in the onCopyNodePolicy to block copying of quick share metadta
    policyComponent.bindClassBehaviour(
                CopyServicePolicies.OnCopyNodePolicy.QNAME, 
                QuickShareModel.ASPECT_QSHARE, 
                new JavaBehaviour(this, "getCopyCallback"));

    this.policyComponent.bindClassBehaviour(
                NodeServicePolicies.OnRestoreNodePolicy.QNAME,
                QuickShareModel.ASPECT_QSHARE,
                new JavaBehaviour(this, "onRestoreNode"));
}
 
Example #4
Source File: OnCreateChildAssociationRuleTrigger.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger()
 */
public void registerRuleTrigger()
{
	if (isClassBehaviour == true)
	{
		this.policyComponent.bindClassBehaviour(
				QName.createQName(NamespaceService.ALFRESCO_URI, POLICY_NAME), 
				this, 
				new JavaBehaviour(this, POLICY_NAME));
	}
	else
	{		
		this.policyComponent.bindAssociationBehaviour(
				QName.createQName(NamespaceService.ALFRESCO_URI, POLICY_NAME), 
				this, 
				new JavaBehaviour(this, POLICY_NAME));
	}
}
 
Example #5
Source File: MultilingualDocumentAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Initialise the Multilingual Aspect
 *
 * Ensures that the {@link ContentModel#ASPECT_MULTILINGUAL_DOCUMENT ml document aspect}
 */
public void init()
{
    this.policyComponent.bindClassBehaviour(
            CopyServicePolicies.OnCopyNodePolicy.QNAME,
            ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
            new JavaBehaviour(this, "getCopyCallback"));

    this.policyComponent.bindAssociationBehaviour(
            NodeServicePolicies.BeforeDeleteChildAssociationPolicy.QNAME,
            ContentModel.TYPE_MULTILINGUAL_CONTAINER,
            ContentModel.ASSOC_MULTILINGUAL_CHILD,
            new JavaBehaviour(this, "beforeDeleteChildAssociation"));

    this.policyComponent.bindClassBehaviour(
            NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME,
            ContentModel.ASPECT_MULTILINGUAL_DOCUMENT,
            new JavaBehaviour(this, "onUpdateProperties"));

}
 
Example #6
Source File: DiscussableAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Initialise method
 */
public void init()
{
    // All forum-related copy behaviour uses the same copy callback
    this.policyComponent.bindClassBehaviour(
    QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
            ForumModel.ASPECT_DISCUSSABLE,
            new JavaBehaviour(this, "onAddAspect"));
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
            ForumModel.ASPECT_DISCUSSABLE,
            new JavaBehaviour(this, "getCopyCallback"));
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "onCopyComplete"),
            ForumModel.ASPECT_DISCUSSABLE,
            new JavaBehaviour(this, "onCopyComplete"));
    this.policyComponent.bindClassBehaviour(
            AfterVersionRevertPolicy.QNAME,
            ContentModel.ASPECT_VERSIONABLE,
            new JavaBehaviour(this, "afterVersionRevert"));           
}
 
Example #7
Source File: ForumPostBehaviours.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Initialise method
 */
public void init()
{
    this.policyComponent.bindClassBehaviour(
            OnUpdatePropertiesPolicy.QNAME,
            ForumModel.ASPECT_COMMENTS_ROLLUP,
            new JavaBehaviour(this, "onUpdateProperties"));
    this.policyComponent.bindClassBehaviour(
            OnCreateNodePolicy.QNAME,
            ForumModel.TYPE_POST,
            new JavaBehaviour(this, "onCreateNode"));
    this.policyComponent.bindClassBehaviour(
            BeforeDeleteNodePolicy.QNAME,
            ForumModel.TYPE_POST,
            new JavaBehaviour(this, "beforeDeleteNode"));
}
 
Example #8
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    this.policyComponent.bindClassBehaviour(
            BeforePurgeNodePolicy.QNAME,
            SiteModel.TYPE_SITE,
            new JavaBehaviour(this, "beforePurgeNode"));
    this.policyComponent.bindClassBehaviour(
            OnRestoreNodePolicy.QNAME,
            SiteModel.TYPE_SITE,
            new JavaBehaviour(this, "onRestoreNode"));
    this.policyComponent.bindClassBehaviour(
            BeforeRestoreArchivedNodePolicy.QNAME,
            SiteModel.TYPE_SITE,
            new JavaBehaviour(this, "beforeRestoreArchivedNode"));
    this.policyComponent.bindClassBehaviour(
            OnRestoreArchivedNodePolicy.QNAME,
            SiteModel.TYPE_SITE,
            new JavaBehaviour(this, "onRestoreArchivedNode"));
}
 
Example #9
Source File: SiteAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Initialise method
 */
public void init()
{
    this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME, 
            SiteModel.TYPE_SITE, 
            new JavaBehaviour(this, "onMoveNode", Behaviour.NotificationFrequency.EVERY_EVENT));
    
    this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME,
            SiteModel.ASPECT_SITE_CONTAINER,
            new JavaBehaviour(this, "onMoveNode", Behaviour.NotificationFrequency.EVERY_EVENT));
    
    this.policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, 
            SiteModel.TYPE_SITE, 
            new JavaBehaviour(this, "onUpdateProperties", Behaviour.NotificationFrequency.EVERY_EVENT));
    
    this.policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME,
            SiteModel.ASPECT_SITE_CONTAINER,
            new JavaBehaviour(this, "onUpdateProperties", Behaviour.NotificationFrequency.EVERY_EVENT));
}
 
Example #10
Source File: ThumbnailServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Registers to listen for events of interest.
 * @since 3.5.0
 */
public void init()
{
    policyComponent.bindClassBehaviour(
            NodeServicePolicies.OnCreateNodePolicy.QNAME,
            ContentModel.TYPE_THUMBNAIL,
            new JavaBehaviour(this, "onCreateNode", Behaviour.NotificationFrequency.EVERY_EVENT));
    policyComponent.bindClassBehaviour(
            NodeServicePolicies.BeforeCreateNodePolicy.QNAME,
            ContentModel.TYPE_FAILED_THUMBNAIL,
            new JavaBehaviour(this, "beforeCreateNode", Behaviour.NotificationFrequency.EVERY_EVENT));
    policyComponent.bindClassBehaviour(
            NodeServicePolicies.OnDeleteNodePolicy.QNAME,
            ContentModel.TYPE_THUMBNAIL,
            new JavaBehaviour(this, "onDeleteNode", Behaviour.NotificationFrequency.EVERY_EVENT));

    // Register copy class behaviour
    this.policyComponent.bindClassBehaviour(
            CopyServicePolicies.OnCopyNodePolicy.QNAME,
            ContentModel.ASPECT_THUMBNAIL_MODIFICATION,
            new JavaBehaviour(this, "getCopyCallback"));

    transactionListener = new ThumbnailTransactionListenerAdapter();
    thumbnailsToDeleteTransactionListener = new ThumbnailCleanupTransactionListenerAdapter();
}
 
Example #11
Source File: CascadeUpdateAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Initialise method
 */
public void init()
{
    // need to listen to:
    // invokeOnCreateChildAssociation(newParentAssocRef, false);
    // invokeOnDeleteChildAssociation(oldParentAssocRef);
    // invokeOnMoveNode(oldParentAssocRef, newParentAssocRef); 
    // categories affect paths via membership (not paths beneath nodes that are categories) 
    // - only changing category structure requires a cascade not changing a node's on a categories
    
    this.policyComponent.bindAssociationBehaviour(OnCreateChildAssociationPolicy.QNAME,
            ContentModel.TYPE_BASE,
            new JavaBehaviour(this, "onCreateChildAssociation", Behaviour.NotificationFrequency.EVERY_EVENT));
    this.policyComponent.bindAssociationBehaviour(OnDeleteChildAssociationPolicy.QNAME,
            ContentModel.TYPE_BASE,
            new JavaBehaviour(this, "onDeleteChildAssociation", Behaviour.NotificationFrequency.EVERY_EVENT));
    this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME,
            ContentModel.TYPE_BASE,
            new JavaBehaviour(this, "onMoveNode", Behaviour.NotificationFrequency.EVERY_EVENT));
}
 
Example #12
Source File: ContentServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Service initialise 
 */
public void init()
{
    // Set up a temporary store
    this.tempStore = new FileContentStore(this.applicationContext, TempFileProvider.getTempDir().getAbsolutePath());

    // Bind on update properties behaviour
    this.policyComponent.bindClassBehaviour(
            NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME,
            this,
            new JavaBehaviour(this, "onUpdateProperties"));
    
    // Register on content update policy
    this.onContentUpdateDelegate = this.policyComponent.registerClassPolicy(OnContentUpdatePolicy.class);
    this.onContentPropertyUpdateDelegate = this.policyComponent.registerClassPolicy(OnContentPropertyUpdatePolicy.class);
    this.onContentReadDelegate = this.policyComponent.registerClassPolicy(OnContentReadPolicy.class);
}
 
Example #13
Source File: AuthorityServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testMNT10533() throws Exception
{

    String GROUP_NAME = "testMNT10533";
    String GROUP_FULL_NAME = "GROUP_" + GROUP_NAME;

    policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(
            new GroupBehaviour(), "beforeDeleteNode"));

    UserTransaction transaction = null;

    transaction = transactionService.getUserTransaction();
    transaction.begin();
    try
    {
        authorityService.createAuthority(AuthorityType.GROUP, GROUP_NAME);

        assertNotNull(authorityService.getAuthorityNodeRef(GROUP_FULL_NAME));
        authorityService.deleteAuthority(GROUP_FULL_NAME);
        assertNull(authorityService.getAuthorityNodeRef(GROUP_FULL_NAME));
    }
    finally
    {
        transaction.commit();
    }
}
 
Example #14
Source File: RoutingContentServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testOnContentReadPolicy()
{
    // Register interest in the content read event for a versionable node
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "onContentRead"),
            ContentModel.ASPECT_VERSIONABLE,
            new JavaBehaviour(this, "onContentReadBehaviourTest"));
    
    // First check that the policy is not fired when the versionable aspect is not present
    this.contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
    assertFalse(this.readPolicyFired);
    
    // Write some content and check that the policy is still not fired
    ContentWriter contentWriter2 = this.contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
    contentWriter2.putContent("content update two");
    this.contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
    assertFalse(this.readPolicyFired);
    
    // Now check that the policy is fired when the versionable aspect is present
    this.nodeService.addAspect(this.contentNodeRef, ContentModel.ASPECT_VERSIONABLE, null);
    this.contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
    assertTrue(this.readPolicyFired);
}
 
Example #15
Source File: EventGenerator.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void bindBehaviours()
{
    policyComponent.bindClassBehaviour(OnCreateNodePolicy.QNAME, this,
                                       new JavaBehaviour(this, "onCreateNode"));
    policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, this,
                                       new JavaBehaviour(this, "beforeDeleteNode"));
    policyComponent.bindClassBehaviour(OnUpdatePropertiesPolicy.QNAME, this,
                                       new JavaBehaviour(this, "onUpdateProperties"));
    policyComponent.bindClassBehaviour(OnSetNodeTypePolicy.QNAME, this,
                                       new JavaBehaviour(this, "onSetNodeType"));
    policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, this,
                                       new JavaBehaviour(this, "onAddAspect"));
    policyComponent.bindClassBehaviour(OnRemoveAspectPolicy.QNAME, this,
                                       new JavaBehaviour(this, "onRemoveAspect"));
    policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME, this,
                                       new JavaBehaviour(this, "onMoveNode"));
    policyComponent.bindAssociationBehaviour(OnCreateChildAssociationPolicy.QNAME, this,
                                       new JavaBehaviour(this, "onCreateChildAssociation"));
    policyComponent.bindAssociationBehaviour(BeforeDeleteChildAssociationPolicy.QNAME, this,
                                       new JavaBehaviour(this, "beforeDeleteChildAssociation"));
    policyComponent.bindAssociationBehaviour(OnCreateAssociationPolicy.QNAME, this,
                                       new JavaBehaviour(this, "onCreateAssociation"));
    policyComponent.bindAssociationBehaviour(BeforeDeleteAssociationPolicy.QNAME, this,
                                       new JavaBehaviour(this, "beforeDeleteAssociation"));
}
 
Example #16
Source File: LockServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testLockServicePolicies()
{
    LockServicePoliciesImpl mockedLockServicePoliciesImpl = mock(LockServicePoliciesImpl.class);

    BehaviourDefinition<ClassBehaviourBinding> lockDef =
            this.policyComponent.bindClassBehaviour(LockServicePolicies.BeforeLock.QNAME, ContentModel.TYPE_BASE,
                    new JavaBehaviour(mockedLockServicePoliciesImpl, "beforeLock"));

    BehaviourDefinition<ClassBehaviourBinding> unlockDef =
            this.policyComponent.bindClassBehaviour(LockServicePolicies.BeforeUnlock.QNAME, ContentModel.TYPE_BASE,
                    new JavaBehaviour(mockedLockServicePoliciesImpl, "beforeUnlock"));

    this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);

    verify(mockedLockServicePoliciesImpl, times(1)).beforeLock(this.parentNode, LockType.WRITE_LOCK);

    this.lockService.unlock(this.parentNode);

    verify(mockedLockServicePoliciesImpl, times(1)).beforeUnlock(this.parentNode);

    // cleanup:
    this.policyComponent.removeClassDefinition(lockDef);
    this.policyComponent.removeClassDefinition(unlockDef);
}
 
Example #17
Source File: BufferedContentDiskDriver.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void init()
{
    PropertyCheck.mandatory(this, "diskInterface", diskInterface);
    PropertyCheck.mandatory(this, "diskSizeInterface", diskSizeInterface);
    PropertyCheck.mandatory(this, "ioctltInterface", ioctlInterface);
    PropertyCheck.mandatory(this, "fileInfoCache", fileInfoCache);
    PropertyCheck.mandatory(this, "fileLockingInterface", getFileLockingInterface());
    PropertyCheck.mandatory(this, "opLockInterface", getOpLockInterface());
    PropertyCheck.mandatory(this, "fileLockingInterface", fileLockingInterface);
    PropertyCheck.mandatory(this, "policyComponent", getPolicyComponent());
    
    getPolicyComponent().bindClassBehaviour( NodeServicePolicies.OnDeleteNodePolicy.QNAME,
            this, new JavaBehaviour(this, "onDeleteNode"));   
    getPolicyComponent().bindClassBehaviour( NodeServicePolicies.OnMoveNodePolicy.QNAME,
            this, new JavaBehaviour(this, "onMoveNode"));
}
 
Example #18
Source File: NodeAuditor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Checks that all necessary properties have been set and binds with the policy component.
 */
public void afterPropertiesSet()
{
    PropertyCheck.mandatory(this, "policyComponent", policyComponent);
    PropertyCheck.mandatory(this, "auditComponent", auditComponent);
    policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, this, new JavaBehaviour(this,
            "beforeDeleteNode"));
}
 
Example #19
Source File: UndeletableAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Initialise method
 */
public void init()
{
    this.policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME,
            ContentModel.ASPECT_UNDELETABLE,
            new JavaBehaviour(this, "beforeDeleteNode", Behaviour.NotificationFrequency.EVERY_EVENT));

    policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
            ContentModel.ASPECT_UNDELETABLE,
            new JavaBehaviour(this, "getCopyCallback"));
}
 
Example #20
Source File: TemporaryAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Initialise the Temporary Aspect
 * <p>
 * Ensures that the {@link ContentModel#ASPECT_TEMPORARY temporary aspect}
 * copy behaviour is disabled when update copies are performed.
 */
public void init()
{
    // disable copy for referencable aspect
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
            ContentModel.ASPECT_TEMPORARY,
            new JavaBehaviour(this, "getCopyCallback"));
}
 
Example #21
Source File: ActionsAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init()
{
    PropertyCheck.mandatory(this, "policyComponent", policyComponent);
    PropertyCheck.mandatory(this, "behaviourFilter", behaviourFilter);
    PropertyCheck.mandatory(this, "ruleService", ruleService);
    PropertyCheck.mandatory(this, "nodeService", nodeService);
    
    this.policyComponent.bindAssociationBehaviour(
            NodeServicePolicies.OnDeleteAssociationPolicy.QNAME,
            ActionModel.TYPE_ACTION_SCHEDULE,
            ActionModel.ASSOC_SCHEDULED_ACTION,
            new JavaBehaviour(this, "onDeleteAssociation"));
    
    this.policyComponent.bindClassBehaviour(
            CopyServicePolicies.OnCopyNodePolicy.QNAME,
            ActionModel.ASPECT_ACTIONS,
            new JavaBehaviour(this, "getCopyCallback"));
    this.policyComponent.bindClassBehaviour(
            CopyServicePolicies.OnCopyCompletePolicy.QNAME,
            ActionModel.ASPECT_ACTIONS,
            new JavaBehaviour(this, "onCopyComplete"));
    
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), 
            ActionModel.ASPECT_ACTIONS, 
            new JavaBehaviour(this, "onAddAspect"));
}
 
Example #22
Source File: ReferenceableAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Initialise the Referencable Aspect
 * <p>
 * Ensures that the {@link ContentModel#ASPECT_REFERENCEABLE referencable aspect}
 * copy behaviour is disabled.
 */
public void init()
{
    // disable copy for referencable aspect
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
            ContentModel.ASPECT_REFERENCEABLE,
            new JavaBehaviour(this, "getCopyCallback"));
}
 
Example #23
Source File: UserUsageTrackingComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Spring bean init method
 */
public void init()
{
    PropertyCheck.mandatory(this, "jobLockService", jobLockService);
    if (enabled)
    {
        this.policyComponent.bindClassBehaviour(OnCreateNodePolicy.QNAME, ContentModel.TYPE_PERSON, new JavaBehaviour(this, "onCreateNode"));
    }
}
 
Example #24
Source File: OnPropertyUpdateRuleTrigger.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void registerRuleTrigger()
{
    // Bind behaviour
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), 
            this, 
            new JavaBehaviour(this, "onUpdateProperties"));
}
 
Example #25
Source File: OnMoveNodeRuleTrigger.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger()
 */
public void registerRuleTrigger()
{
    if (isClassBehaviour == true)
    {
        this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, POLICY_NAME), this, new JavaBehaviour(this, POLICY_NAME));
    }
    else
    {
        this.policyComponent.bindAssociationBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, POLICY_NAME), this, new JavaBehaviour(this, POLICY_NAME));
    }
}
 
Example #26
Source File: SingleNodeRefPolicyRuleTrigger.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void registerRuleTrigger()
{
    if (policyName == null)
    {
        throw new RuleServiceException(ERR_POLICY_NAME_NOT_SET);
    }
    
    this.policyComponent.bindClassBehaviour(
            QName.createQName(this.policyNamespace, this.policyName), 
            this, 
            new JavaBehaviour(this, "policyBehaviour"));        
}
 
Example #27
Source File: SurfConfigCleaner.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init()
{
    this.policyComponent.bindClassBehaviour(
            BeforeDeleteNodePolicy.QNAME,
            ContentModel.TYPE_PERSON,
            new JavaBehaviour(this, BeforeDeleteNodePolicy.QNAME.getLocalName()));
}
 
Example #28
Source File: RulesAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init()
{
    PropertyCheck.mandatory(this, "policyComponent", policyComponent);
    PropertyCheck.mandatory(this, "behaviourFilter", behaviourFilter);
    PropertyCheck.mandatory(this, "ruleService", ruleService);
    PropertyCheck.mandatory(this, "nodeService", nodeService);

    this.policyComponent.bindClassBehaviour(
            CopyServicePolicies.OnCopyNodePolicy.QNAME,
            RuleModel.ASPECT_RULES,
            new JavaBehaviour(this, "getCopyCallback"));
    this.policyComponent.bindClassBehaviour(
            CopyServicePolicies.OnCopyCompletePolicy.QNAME,
            RuleModel.ASPECT_RULES,
            new JavaBehaviour(this, "onCopyComplete"));
    this.policyComponent.bindClassBehaviour(
            NodeServicePolicies.OnAddAspectPolicy.QNAME, 
            RuleModel.ASPECT_RULES, 
            new JavaBehaviour(this, "onAddAspect"));
    this.policyComponent.bindClassBehaviour(
            NodeServicePolicies.BeforeRemoveAspectPolicy.QNAME, 
            RuleModel.ASPECT_RULES, 
            new JavaBehaviour(this, "beforeRemoveAspect"));
    this.policyComponent.bindClassBehaviour(
            NodeServicePolicies.BeforeDeleteNodePolicy.QNAME, 
            RuleModel.ASPECT_RULES, 
            new JavaBehaviour(this, "beforeDeleteNode"));
}
 
Example #29
Source File: ContentUsageImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * The initialise method
 */
public void init()
{
    if (enabled)
    {
        // Register interest in the onUpdateProperties policy - for content
        policyComponent.bindClassBehaviour(
                QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"),
                ContentModel.TYPE_CONTENT,
                new JavaBehaviour(this, "onUpdateProperties"));
        
        // Register interest in the beforeDeleteNode policy - for content
        policyComponent.bindClassBehaviour(
                QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
                ContentModel.TYPE_CONTENT,
                new JavaBehaviour(this, "beforeDeleteNode"));
        
        // Register interest in the onCreateNode policy - for content
        policyComponent.bindClassBehaviour(
                QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),
                ContentModel.TYPE_CONTENT,
                new JavaBehaviour(this, "onCreateNode"));
        
        /*
        // Register interest in the onAddAspect policy - for ownable
        policyComponent.bindClassBehaviour(
                QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"),
                ContentModel.ASPECT_OWNABLE,
                new JavaBehaviour(this, "onAddAspect"));
        */
    }
}
 
Example #30
Source File: NodeServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private <T extends Policy> T createClassPolicy(Class<T> policyInterface, QName policyQName, QName triggerOnClass)
{
    T policy = mock(policyInterface);
    policyComponent.bindClassBehaviour(
                policyQName, 
                triggerOnClass, 
                new JavaBehaviour(policy, policyQName.getLocalName()));
    return policy;
}