Hi,
I am trying to create a document in alfresco with metadata. taking the file and metadata info from a json file.
while creating noderef for that in webscript getting the below error,
org.alfresco.service.cmr.repository.datatype.TypeConversionException: There is no conversion registered for the value:
value class: com.fasterxml.jackson.databind.node.TextNode
to class: java.lang.String
can anyone help please.
Thanks,
Could you please paste your code here ?
Hi kaynezhang,
//getting the filename, docType and metadata as a jsonString
props.put(ContentModel.PROP_NAME, fileName);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonnode = objectMapper.readTree(metadata);
Iterator<String> fieldNames=jsonnode.fieldNames();
while(fieldNames.hasNext()) {
String paramName = fieldNames.next();
QName reqDocPropQName = QName.resolveToQName(serviceRegistry.getNamespaceService(), paramName);
props.put(reqDocPropQName, (Serializable) jsonnode.get(paramName));
}
// use the node service to create a new node
QName reqDocContentQName = QName.resolveToQName(serviceRegistry.getNamespaceService(), docType);
docNodeRef = serviceRegistry.getNodeService().createNode(descFolderNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
fileName), reqDocContentQName, props) .getChildRef();
Alfresco property class only support some common class ,for example
String、Boolean、Character、Number、Byte、Short、Long、Float、BigDecimal、InputStream and so on.
And some alfresco specified class ,for exmple
QName、NodeRef、ChildAssociationRef、MLText and so on.
It dose not support JsonNode,so you should change it to class as mentioned above before you set it to property map
If your reqDocPropQName is long ,you can change it to long like this jsonnode.get(paramName).asLong()
If it is String you can change it to String like this jsonnode.get(paramName).toString()
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.