gpt4 book ai didi

java - alfresco 4.2e 中自定义属性方面的空值

转载 作者:太空宇宙 更新时间:2023-11-04 06:18:45 38 4
gpt4 key购买 nike

我正在尝试使用Alfresco 4.2ejava中插入具有自定义属性的文档。现在插入值没有任何错误,但未设置自定义属性的值,它显示为 null。

这是我的代码:

    Map<String, String> props = new HashMap<String, String>();
props.put(PropertyIds.NAME, newDocName);
props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:kb:referencable");
props.put("kb:documentRef", "123");
props.put("kb:documentID", "1234");
String content = "sample=================";
byte[] buf = null;
try {
buf = content.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
ByteArrayInputStream input = new ByteArrayInputStream(buf);
ContentStream contentStream = session.getObjectFactory()
.createContentStream(newDocName, buf.length,
"text/plain; charset=UTF-8", input);
target.createDocument(props, contentStream, VersioningState.MAJOR);

搜索查询:

    String query = "SELECT * FROM kb:referencable ";
ItemIterable<QueryResult> queryResult = session.query(query, false);
for (QueryResult item : queryResult) {
System.out.println("item="+item.getProperties());

}

这是搜索输出:

item=[Property [id=kb:documentRef, display Name=KB Reference, local name=documentRef, query name=kb:documentRef, values=[]][extensions=null], Property [id=cmis:objectTypeId, display Name=Object Type Id, local name=objectTypeId, query name=cmis:objectTypeId, values=[cmis:document]][extensions=null], Property [id=cmis:lastModifiedBy, display Name=Last Modified By, local name=lastModifiedBy, query name=cmis:lastModifiedBy, values=[admin]][extensions=null], Property [id=cmis:name, display Name=Name, local name=name, query name=cmis:name, values=[chemistryTest1.txt]][extensions=null], Property [id=cmis:createdBy, display Name=Created by, local name=createdBy, query name=cmis:createdBy, values=[admin]][extensions=null], Property [id=kb:documentID, display Name=kb:documentID, local name=documentID, query name=kb:documentID, values=[]][extensions=null], Property [id=cmis:objectId, display Name=Object Id, local name=objectId, query name=cmis:objectId, values=[149666ab-5745-4365-b63e-c26cb6f4f6cc;1.0]][extensions=null], Property [id=cmis:creationDate, display Name=Creation Date, local name=creationDate, query name=cmis:creationDate, values=[java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2015,MONTH=0,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=1,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=9,MINUTE=32,SECOND=59,MILLISECOND=725,ZONE_OFFSET=?,DST_OFFSET=?]]][extensions=null], Property [id=cmis:changeToken, display Name=Change token, local name=changeToken, query name=cmis:changeToken, values=[]][extensions=null], Property [id=cmis:secondaryObjectTypeIds, display Name=Secondary Object Type Ids, local name=secondaryObjectTypeIds, query name=cmis:secondaryObjectTypeIds, values=[P:kb:referencable, P:cm:titled, P:cm:author, P:sys:localized]][extensions=null], Property [id=cmis:baseTypeId, display Name=Base Type Id, local name=baseTypeId, query name=cmis:baseTypeId, values=[cmis:document]][extensions=null], Property [id=alfcmis:nodeRef, display Name=Alfresco Node Ref, local name=nodeRef, query name=alfcmis:nodeRef, values=[workspace://SpacesStore/149666ab-5745-4365-b63e-c26cb6f4f6cc]][extensions=null], Property [id=cmis:description, display Name=Description, local name=description, query name=cmis:description, values=[]][extensions=null], Property [id=cmis:lastModificationDate, display Name=Last Modified Date, local name=lastModificationDate, query name=cmis:lastModificationDate, values=[java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2015,MONTH=0,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=1,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=9,MINUTE=32,SECOND=59,MILLISECOND=725,ZONE_OFFSET=?,DST_OFFSET=?]]][extensions=null]]

此处 kb:documentRef 和 kb:documentID(自定义属性)的值为 null。

最佳答案

好吧,老实说,我不知道 kb:documentRef 是否被解析为简写,但传递的 props 映射必须是这种类型:

Map<QName,Serializable> props = new Map<QName,Serializable>();

然后假设模型中的命名空间是 http://www.custommodel.com/kb/1.0 你应该这样做:

props.put(new QName("http://www.custommodel.com/kb/1.0","documentRef"), "123");
props.put(new QName("http://www.custommodel.com/kb/1.0","documentID"), "1234");

或者,更好的是,您可以编写方便的界面:

public interface MyModel {
KB_DOCUMENT_REF = new QName("http://www.custommodel.com/kb/1.0","documentRef");
}

那么,就更清楚了:

props.put(MyModel.KB_DOCUMENT_REF, "123");

关于java - alfresco 4.2e 中自定义属性方面的空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27718389/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com