如何使用Apache Chemistry在对象上创建自定义属性 [英] How to create custom property on object using Apache Chemistry
问题描述
我正在使用Alfresco CMS的本地实例,并且正在使用Apache Chemistry Java CMIS. 一切都可以很好地浏览和创建对象,但是我很难在文档上添加元数据.
I'm working with a local instance of Alfresco CMS and I'm using the Apache Chemistry Java CMIS. Everything works well for browsing and creating objects, however I'm having a hard time adding metadata on documents.
在他们的源页面代码上有一个示例,说明您需要在CmisObject
上调用updateProperties
.不幸的是,这是行不通的,我已经声明了一个例外:Property 'my:property' is not valid for this type or one of the secondary types
There is an example on their source page code saying that you need to call updateProperties
on the CmisObject
. Unfortunately, this doesn't work, the exception I got stating: Property 'my:property' is not valid for this type or one of the secondary types
您知道如何添加自定义属性吗?我是否必须增强现有的方面集合,如果是的话,我该如何做?
Do you know how can I add a custom property? Do I have to enhance the existing aspects collection and if so, how can I do it?
谢谢.
推荐答案
属性'my:property'对此类型或其中一种辅助类型无效
Property 'my:property' is not valid for this type or one of the secondary types
my:property似乎是一个自定义属性,然后应使用自定义Alfresco方面进行处理.
my:property seems to be a custom property, and should then be handled with a custom Alfresco aspect.
If you want to use Alfresco aspects, you will need the Alfresco OpenCMIS Extension
以下代码片段允许在OpenCMIS中使用Alfresco扩展:
The following code fragment allows to use the Alfresco Extension with OpenCMIS:
Map<String, String> parameter = new HashMap<String, String>();
// user credentials
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
// connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// set the alfresco object factory
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// create session
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
以下代码允许创建一个新文档,其中填充了一个自定义属性:
The following code allows to create a new document with a custom property filled :
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, "doc1");
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,my:docProps");
properties.put("my:property", "My document");
Document doc = session.getRootFolder().createDocument(properties, null, null);
这篇关于如何使用Apache Chemistry在对象上创建自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!