Class DocumentHelper
- java.lang.Object
-
- org.nuxeo.ecm.automation.core.util.DocumentHelper
-
public class DocumentHelper extends Object
- Author:
- Bogdan Stefanescu
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addBlob(Property p, Blob blob)
Given a document property, updates its value with the given blob.static HashMap<String,Serializable>
createBlobHolderMap(Blob blob)
static String[]
readStringList(String value)
Read an encoded string list as a comma separated list.static Object
readStringList(String value, SimpleType type)
Read an encoded string list as a comma separated list.static void
removeProperty(DocumentModel doc, String xpath)
Removes a property from a document given the xpath.static DocumentModel
saveDocument(CoreSession session, DocumentModel doc)
Saves the document and clear context data to avoid incrementing version in next operations if not needed.static void
setJSONProperties(CoreSession session, DocumentModel doc, Properties properties)
Sets the properties of a document based on their JSON representation (especially for scalar lists).protected static void
setLocalAcl(CoreSession session, DocumentModel doc, String value)
static void
setProperties(CoreSession session, DocumentModel doc, Map<String,String> values)
Sets the properties given as a map of xpath:value to the given document.static void
setProperties(CoreSession session, DocumentModel doc, Properties properties)
static void
setProperty(CoreSession session, DocumentModel doc, String key, String value)
static void
setProperty(CoreSession session, DocumentModel doc, String key, String value, boolean decodeStringListAsJSON)
-
-
-
Method Detail
-
saveDocument
public static DocumentModel saveDocument(CoreSession session, DocumentModel doc)
Saves the document and clear context data to avoid incrementing version in next operations if not needed.
-
removeProperty
public static void removeProperty(DocumentModel doc, String xpath)
Removes a property from a document given the xpath. If the xpath points to a list property the list will be cleared. If the path points to a blob in a list the property is removed from the list. Otherwise the xpath should point to a non list property that will be removed.
-
addBlob
public static void addBlob(Property p, Blob blob) throws PropertyException
Given a document property, updates its value with the given blob. The property can be a blob list or a blob. If a blob list the blob is appended to the list, if a blob then it will be set as the property value. Both blob list formats are supported: the file list (blob holder list) and simple blob list.- Throws:
PropertyException
-
createBlobHolderMap
public static HashMap<String,Serializable> createBlobHolderMap(Blob blob)
-
setProperties
public static void setProperties(CoreSession session, DocumentModel doc, Properties properties) throws IOException, PropertyException
- Throws:
IOException
PropertyException
-
setProperties
public static void setProperties(CoreSession session, DocumentModel doc, Map<String,String> values) throws IOException
Sets the properties given as a map of xpath:value to the given document. There is one special property: ecm:acl that can be used to set the local acl. The format of this property value is: [string username]:[string permission]:[boolean grant], [string username]:[string permission]:[boolean grant], ... TODO list properties are not yet supported- Throws:
IOException
-
setProperty
public static void setProperty(CoreSession session, DocumentModel doc, String key, String value) throws IOException
- Throws:
IOException
-
setLocalAcl
protected static void setLocalAcl(CoreSession session, DocumentModel doc, String value)
-
readStringList
public static Object readStringList(String value, SimpleType type)
Read an encoded string list as a comma separated list. To use comma inside list element values you need to escape them using '\'. If the given type is different fromStringType.ID
then array elements will be converted to the actual type.
-
readStringList
public static String[] readStringList(String value)
Read an encoded string list as a comma separated list. To use comma inside list element values you need to escape them using '\'.
-
setJSONProperties
public static void setJSONProperties(CoreSession session, DocumentModel doc, Properties properties) throws IOException
Sets the properties of a document based on their JSON representation (especially for scalar lists).- Throws:
IOException
- Since:
- 5.9.2
-
setProperty
public static void setProperty(CoreSession session, DocumentModel doc, String key, String value, boolean decodeStringListAsJSON) throws IOException
- Throws:
IOException
- Since:
- 5.9.2
-
-