我想在Alfresco中添加一个方面来添加我的自定义元数据,我只是想知道如何将这个方面添加到所有新创建的文件中。
自定义元数据文件添加在\ Alfresco \ tomcat \ shared \ classes \ alfresco \ extension中 。目录
答案 0 :(得分:3)
如果您需要为添加到Alfresco的所有内容添加一个方面而不管位置如何,您最好使用附加到JavaBehavior
的{{1}}。
您可以查看some Alfresco类,了解如何创建自定义行为的示例,大致如下(使用OnCreateNodePolicy
将行为附加到每个文档):< / p>
cm:content
然后,在一些Spring上下文文件中:
public class AddAspectBehavior implements NodeServicePolicies.OnCreateNodePolicy
{
/** Policy component */
private PolicyComponent policyComponent;
/** Node service */
private NodeService nodeService;
/** Dictionary service */
private DictionaryService dictionaryService;
// TODO: add setters for the services
public void init()
{
this.policyComponent.bindClassBehaviour(
NodeServicePolicies.OnCreateNodePolicy.QNAME,
ContentModel.TYPE_CONTENT,
new JavaBehaviour(this, "onCreateNode", NotificationFrequency.TRANSACTION_COMMIT));
}
@Override
public void onCreateNode(ChildAssociationRef childAssocRef)
{
Map<QName,Serializable> aspectValues = new HashMap<QName,Serializable>();
// TODO: add relevand properties
nodeService.addAspect(childAssocReg.getChildRef(), MyCustomModel.ASPECT_TO_ADD, props);
}
}
答案 1 :(得分:2)
例如,将规则添加到上传到的文件夹中,在创建新文件时使用“添加方面”操作进行配置。