2014-02-18 66 views
1

我試圖添加一個行爲組中的所有用戶(即添加一個方面給用戶,如果添加和刪除時不在組中),但我在init方法內的綁定點上得到一個異常:是否可以在室外將策略綁定到組?

public void init() { 
    this.policyComponent.bindClassBehaviour(OnUpdateNodePolicy.QNAME, ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(this, "onUpdateNode")); 
    this.policyComponent.bindClassBehaviour(BeforeUpdateNodePolicy.QNAME, ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(this, "beforeUpdateNode")); 
} 

任何其他方式,如果這是不可能的,我可以解決這個問題?

+0

你得到的錯誤是什麼? –

+0

第一個策略組件綁定行中的空指針異常。 –

+0

因此,如果您將其更改爲contentModel.Type_content或它的作品? –

回答

3

如果您希望在用戶添加和從組中刪除時採取行動,則應該使用ChildAssociation策略。看看http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/repo/policy/AssociationPolicy.html挑選適合你的那些。

這就是說,它可能是更聰明,只是延長AuthorityService,敷調用

public void addAuthority(String parentName, String childName); 
public void removeAuthority(String parentName, String childName); 

加入您的定製邏輯。

+0

起初我雖然政策組件被忽略,但我意識到我沒有改變綁定到正確的協會。但在我做之後。我得到一個異常,「java.lang.IllegalArgumentException:Class {http://www.alfresco.org/model/content/1.0}member尚未在數據字典中定義」 –

+0

Aahh從不知道,我應該綁定到關聯行爲。 –

+0

這很可能是因爲在您的init方法啓動時該字典沒有被引導。在我的應用程序中,由於某種原因,我不需要它,但是您可能想要在bean上嘗試depends-on =「dictionaryBootstrap」 。如果事情仍然出錯,請顯示bean以及上下文文件的路徑。 –

相關問題