Class DocumentHelper
java.lang.Object
org.nuxeo.ecm.automation.core.util.DocumentHelper
- Author:
- Bogdan Stefanescu
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
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
setListProperty
(Type type, String behavior, boolean decodeStringListAsJSON, String value, Property p) 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
setProperties
(CoreSession session, DocumentModel doc, Properties properties, Properties propertiesBehaviors) static void
setProperty
(CoreSession session, DocumentModel doc, String key, String value) static void
setProperty
(CoreSession session, DocumentModel doc, String key, String value, boolean decodeStringListAsJSON) static void
setProperty
(CoreSession session, DocumentModel doc, String key, String value, String behavior) static void
setProperty
(CoreSession session, DocumentModel doc, String key, String value, String behavior, boolean decodeStringListAsJSON)
-
Field Details
-
SET_PROPERTY_BEHAVIOR_APPEND_INCLUDING_DUPLICATES
- Since:
- 2021.12
- See Also:
-
SET_PROPERTY_BEHAVIOR_APPEND_EXCLUDING_DUPLICATES
- Since:
- 2021.12
- See Also:
-
SET_PROPERTY_BEHAVIOR_REPLACE
- Since:
- 2021.12
- See Also:
-
-
Method Details
-
saveDocument
Saves the document and clear context data to avoid incrementing version in next operations if not needed. -
removeProperty
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
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
-
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, Properties properties, Properties propertiesBehaviors) throws IOException - Throws:
IOException
- Since:
- 2021.12
-
setProperties
public static void setProperties(CoreSession session, DocumentModel doc, Map<String, String> values) throws IOExceptionSets 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
-
setProperty
public static void setProperty(CoreSession session, DocumentModel doc, String key, String value, String behavior) throws IOException - Throws:
IOException
- Since:
- 2021.12
-
setLocalAcl
-
readStringList
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
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
-
setProperty
public static void setProperty(CoreSession session, DocumentModel doc, String key, String value, String behavior, boolean decodeStringListAsJSON) throws IOException - Throws:
IOException
- Since:
- 2021.12
-
setListProperty
protected static void setListProperty(Type type, String behavior, boolean decodeStringListAsJSON, String value, Property p) throws IOException - Throws:
IOException
- Since:
- 2021.12
-