我正在使用Alfresco CMS的一个本地实例,并且我正在使用Apache Chemistry CMIS。对于浏览和创建对象来说,一切都很好,但是我很难在文档上添加元数据。
在它们的源代码页面上有一个示例,说明您需要在CmisObject上调用updateProperties。不幸的是,这不起作用,我得到的异常是:Property 'my:property' is not valid for this type or one of the secondary types
您知道如何添加自定义属性吗?我必须增强现有的aspects集合吗?如果需要,我该如何做?
谢谢。
发布于 2013-06-21 16:23:01
属性“my: Property”对此类型或其中一个辅助类型无效
my:property似乎是一个自定义属性,然后应该用一个自定义的Alfresco方面来处理。
如果你想使用Alfresco aspects,你将需要Alfresco OpenCMIS Extension
下面的代码片段允许在OpenCMIS中使用Alfresco扩展:
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();下面的代码允许创建一个填充了自定义属性的新文档:
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);发布于 2017-01-06 05:43:37
自定义属性应该在存储库中定义,然后您可以尝试在CMIS属性中设置它们。
https://stackoverflow.com/questions/17217036
复制相似问题