Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.automation.core.util
Class DocumentHelper

java.lang.Object
  extended by org.nuxeo.ecm.automation.core.util.DocumentHelper

public class DocumentHelper
extends java.lang.Object

Author:
Bogdan Stefanescu

Constructor Summary
DocumentHelper()
           
 
Method Summary
static void addBlob(Property p, Blob blob)
          Given a document property, updates its value with the given blob.
static java.util.HashMap<java.lang.String,java.io.Serializable> createBlobHolderMap(Blob blob)
           
static void removeProperty(DocumentModel doc, java.lang.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 setProperties(CoreSession session, DocumentModel doc, java.util.Map<java.lang.String,java.lang.String> values)
          Sets the properties given as a map of xpath:value to the given document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentHelper

public DocumentHelper()
Method Detail

saveDocument

public static DocumentModel saveDocument(CoreSession session,
                                         DocumentModel doc)
                                  throws ClientException
Saves the document and clear context data to avoid incrementing version in next operations if not needed.

Throws:
ClientException

removeProperty

public static void removeProperty(DocumentModel doc,
                                  java.lang.String xpath)
                           throws ClientException
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.

Throws:
ClientException

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 java.util.HashMap<java.lang.String,java.io.Serializable> createBlobHolderMap(Blob blob)

setProperties

public static void setProperties(CoreSession session,
                                 DocumentModel doc,
                                 java.util.Map<java.lang.String,java.lang.String> values)
                          throws java.lang.Exception
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:
java.lang.Exception

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.