Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.core.utils
Class DocumentModelUtils

java.lang.Object
  extended by org.nuxeo.ecm.core.utils.DocumentModelUtils

public final class DocumentModelUtils
extends java.lang.Object

Utility methods to deal with property names retrieval.

Author:
Anahide Tchertchian

Method Summary
static java.lang.String decodePropertyName(java.lang.String propertyPath)
          Decodes a property path given in a url.
static java.lang.String encodePropertyName(java.lang.String propertyName)
          Encodes a property name to use it in a url.
static java.lang.Object getComplexPropertyValue(DocumentModel doc, java.lang.String propertyPath)
          Obtains a property value given its path.
static java.lang.String getFieldName(java.lang.String propertyName)
          Obtains the field name from the full propertyName.
static java.util.Map<java.lang.String,java.lang.Object> getProperties(DocumentModel docModel)
          Gets all properties defined in declared schemas of a DocumentModel.
static java.lang.Object getPropertyValue(DocumentModel doc, java.lang.String propertyName)
          The given propertyName should have 'schema_name:property_name' format.
static java.lang.String getSchemaName(java.lang.String propertyName)
          Obtains the schema name from the full propertyName.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodePropertyName

public static java.lang.String encodePropertyName(java.lang.String propertyName)
Encodes a property name to use it in a url.

Parameters:
propertyName - like dc:title, file:content.3.filename (?)

decodePropertyName

public static java.lang.String decodePropertyName(java.lang.String propertyPath)
Decodes a property path given in a url.

Parameters:
propertyPath - like dc:title file/content/3/filename (?)

getPropertyValue

public static java.lang.Object getPropertyValue(DocumentModel doc,
                                                java.lang.String propertyName)
The given propertyName should have 'schema_name:property_name' format.

Returns:
null if any error occurs.

getComplexPropertyValue

public static java.lang.Object getComplexPropertyValue(DocumentModel doc,
                                                       java.lang.String propertyPath)
Obtains a property value given its path.

Parameters:
doc - the document
propertyPath - the property path
Returns:
the property value or null if an error occured.

getSchemaName

public static java.lang.String getSchemaName(java.lang.String propertyName)
Obtains the schema name from the full propertyName.

Throws:
java.lang.IllegalArgumentException - if the propertyName does not have a schema:field pattern

getFieldName

public static java.lang.String getFieldName(java.lang.String propertyName)
Obtains the field name from the full propertyName.

Throws:
java.lang.IllegalArgumentException - if the propertyName does not have a schema:field pattern

getProperties

public static java.util.Map<java.lang.String,java.lang.Object> getProperties(DocumentModel docModel)
Gets all properties defined in declared schemas of a DocumentModel.

Returns:
map with property names as keys

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.