Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.ui.web.tag.fn
Class DocumentModelFunctions

java.lang.Object
  extended by org.nuxeo.ecm.platform.ui.web.tag.fn.DocumentModelFunctions
All Implemented Interfaces:
LiveEditConstants

public final class DocumentModelFunctions
extends Object
implements LiveEditConstants

Document model functions.

Author:
Anahide Tchertchian, Olivier Grisel

Field Summary
 
Fields inherited from interface org.nuxeo.ecm.platform.ui.web.tag.fn.LiveEditConstants
ACTION, ACTION_CREATE_DOCUMENT, ACTION_CREATE_DOCUMENT_FROM_TEMPLATE, ACTION_EDIT_DOCUMENT, actionSelectorTag, BLOB_FIELD, BLOB_PROPERTY_NAME, DEFAULT_BLOB_FIELD, DEFAULT_DOCTYPE, DEFAULT_FILENAME_FIELD, DEFAULT_SCHEMA, DEFAULT_SUB_BLOB_FIELD, DOC_REF, DOC_TYPE, docBlobFieldNameTag, docBlobFieldPathTag, docFieldNameTag, docfieldPathTag, docFileAuthorizedExtensionsTag, docFileAuthorizedExtensionTag, docFileExtensionTag, docFilenameFieldNameTag, docFilenameFieldPathTag, docfileNameTag, docIsLockedTag, docIsVersionTag, docMimetypeTag, docPathTag, docRefTag, docRepositoryTag, docSchemaNameTag, docTitleTag, docTypeTag, documentTag, editIdTag, FILENAME_FIELD, FILENAME_PROPERTY_NAME, liveEditTag, MIMETYPE, REPO_ID, requestBaseURLTag, requestCookiesTag, requestCookieTag, requestHeadersTag, requestHeaderTag, requestInfoTag, SCHEMA, serverInfoTag, serverVersionTag, TEMPLATE_BLOB_FIELD, TEMPLATE_DOC_REF, TEMPLATE_REPO_ID, TEMPLATE_SCHEMA, templateDocumentTag, URL_ENCODE_CHARSET, userInfoTag, userLocaleTag, userNameTag, userPasswordTag, userTokenTag, wsdlAccessWebServiceTag, wsdlLEWebServiceTag, wsdlLocationsTag, XML_LE_NAMESPACE
 
Method Summary
static String bigFileUrl(DocumentModel doc, String blobPropertyName, String filename)
           
static String bigIconExpandedPath(DocumentModel document)
           
static String bigIconPath(DocumentModel document)
           
static boolean canModify(DocumentModel document)
          Returns true if document can be modified.
static String complexFileUrl(String patternName, DocumentModel doc, int index, String filename)
          Convenient method to get the REST URL of a blob inside the Files schema.
static String complexFileUrl(String patternName, DocumentModel doc, String listElement, int index, String blobPropertyName, String filename)
          Get the REST URL for a blob inside a list of complex type.
static String complexLiveEditUrl(DocumentModel doc, String listPropertyName, int index, String blobPropertyName, String filenamePropertyName)
          Build the nxedit URL for the "edit existing document" use case
static Object defaultValue(String propertyName)
          Returns the default value for given property name.
static Object defaultValue(String schemaName, String fieldName)
          Deprecated. use defaultValue(propertyName) instead
static String documentUrl(DocumentModel doc)
           
static String documentUrl(DocumentModel doc, HttpServletRequest req)
           
static String documentUrl(String patternName, DocumentModel doc, String viewId, Map<String,String> parameters, boolean newConversation)
           
static String documentUrl(String patternName, DocumentModel doc, String viewId, Map<String,String> parameters, boolean newConversation, HttpServletRequest req)
           
static String extractJSessionId(HttpServletRequest request)
          Extract the current JSESSIONID value from the request context
static String fileDescription(DocumentModel document, String blobPropertyName, String filePropertyName, String filename)
           
static String fileIconPath(Blob blob)
           
static String fileUrl(String patternName, DocumentModel doc, String blobPropertyName, String filename)
           
static Collection<String> getAvailableLifeCycleTransitions(String lifeCycleName, String currentState)
          Returns all the available transitions given the current state.
static String getLabelFromId(String directoryName, String id)
          Deprecated. use DirectoryFunctions.getDirectoryEntry(String, String)
static String getPropertyPath(String listPropertyName, int index, String subPropertyName)
           
static boolean hasPermission(DocumentModel document, String permission)
           
static String iconExpandedPath(DocumentModel document)
           
static String iconPath(DocumentModel document)
           
static boolean isDirty(DocumentModel doc)
           
static String liveCreateFromTemplateUrl(DocumentModel template)
          Build the nxedit URL for the "create new document from template" use case with "File" doc type and "file" schema
static String liveCreateFromTemplateUrl(DocumentModel template, String templateSchemaName, String templateBlobFieldName, String docType, String schemaName, String blobFieldName, String filenameFieldName)
          Build the nxedit URL for the "create new document from template" use case
static String liveCreateUrl(String mimetype)
          Build the nxedit URL for the "create new document" use case with a document using the file:content field as Blob holder
static String liveCreateUrl(String mimetype, String docType, String schemaName, String blobFieldName, String filenameFieldName)
          Build the nxedit URL for the "create new document" use case
static String liveEditUrl(DocumentModel doc)
          Build the nxedit URL for the "edit existing document" use case for a document using the file:content field as Blob holder
static String liveEditUrl(DocumentModel doc, String schemaName, String blobFieldName, String filenameFieldName)
          Build the nxedit URL for the "edit existing document" use case
static String titleOrId(DocumentModel document)
           
static TypeInfo typeInfo(DocumentModel document)
           
static String typeLabel(DocumentModel document)
           
static String typeView(DocumentModel document, String viewId)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

typeInfo

public static TypeInfo typeInfo(DocumentModel document)

typeLabel

public static String typeLabel(DocumentModel document)

typeView

public static String typeView(DocumentModel document,
                              String viewId)

iconPath

public static String iconPath(DocumentModel document)

iconExpandedPath

public static String iconExpandedPath(DocumentModel document)

bigIconPath

public static String bigIconPath(DocumentModel document)

bigIconExpandedPath

public static String bigIconExpandedPath(DocumentModel document)

fileIconPath

public static String fileIconPath(Blob blob)

titleOrId

public static String titleOrId(DocumentModel document)

isDirty

public static boolean isDirty(DocumentModel doc)
                       throws ClientException
Throws:
ClientException

hasPermission

public static boolean hasPermission(DocumentModel document,
                                    String permission)
                             throws ClientException
Throws:
ClientException

canModify

public static boolean canModify(DocumentModel document)
                         throws ClientException
Returns true if document can be modified.

A document can be modified if current user has 'Write' permission on it and document is mutable (no archived version).

Parameters:
document -
Returns:
true if document can be modified.
Throws:
ClientException

defaultValue

@Deprecated
public static Object defaultValue(String schemaName,
                                             String fieldName)
                           throws Exception
Deprecated. use defaultValue(propertyName) instead

Returns the default value for given schema field.

Parameters:
schemaName - the schema name
fieldName - the field name
Returns:
the default value.
Throws:
Exception

defaultValue

public static Object defaultValue(String propertyName)
                           throws Exception
Returns the default value for given property name.

Parameters:
propertyName - as xpath
Returns:
the default value.
Throws:
Exception

fileUrl

public static String fileUrl(String patternName,
                             DocumentModel doc,
                             String blobPropertyName,
                             String filename)

bigFileUrl

public static String bigFileUrl(DocumentModel doc,
                                String blobPropertyName,
                                String filename)

fileDescription

public static String fileDescription(DocumentModel document,
                                     String blobPropertyName,
                                     String filePropertyName,
                                     String filename)

complexFileUrl

public static String complexFileUrl(String patternName,
                                    DocumentModel doc,
                                    int index,
                                    String filename)
Convenient method to get the REST URL of a blob inside the Files schema.

Parameters:
patternName -
doc - The document model.
index - index of the element containing the blob. index starts at 0.
filename - The filename of the blob.
Returns:
the REST URL for the blob, or null if an error occurred.

complexFileUrl

public static String complexFileUrl(String patternName,
                                    DocumentModel doc,
                                    String listElement,
                                    int index,
                                    String blobPropertyName,
                                    String filename)
Get the REST URL for a blob inside a list of complex type. For instance, http://localhost/nuxeo/nxfile/server/docId/files:files%5B0%5D/file/image.png for the blob property 'file' of the first element inside the 'files:files' list.

Parameters:
patternName -
doc - The document model.
listElement - Element containing a list of complex type.
index - Index of the element containing the blob inside the list. index starts at 0.
blobPropertyName - The property containing the blob.
filename - Filename of the blob.
Returns:
the REST URL for the blob, or null if an error occurred.

documentUrl

public static String documentUrl(DocumentModel doc,
                                 HttpServletRequest req)

documentUrl

public static String documentUrl(DocumentModel doc)

documentUrl

public static String documentUrl(String patternName,
                                 DocumentModel doc,
                                 String viewId,
                                 Map<String,String> parameters,
                                 boolean newConversation)

documentUrl

public static String documentUrl(String patternName,
                                 DocumentModel doc,
                                 String viewId,
                                 Map<String,String> parameters,
                                 boolean newConversation,
                                 HttpServletRequest req)

liveEditUrl

public static String liveEditUrl(DocumentModel doc)
                          throws ClientException
Build the nxedit URL for the "edit existing document" use case for a document using the file:content field as Blob holder

Returns:
the encoded URL string
Throws:
ClientException - if the URL encoding fails

liveEditUrl

public static String liveEditUrl(DocumentModel doc,
                                 String schemaName,
                                 String blobFieldName,
                                 String filenameFieldName)
                          throws ClientException
Build the nxedit URL for the "edit existing document" use case

Returns:
the encoded URL string
Throws:
ClientException - if the URL encoding fails

complexLiveEditUrl

public static String complexLiveEditUrl(DocumentModel doc,
                                        String listPropertyName,
                                        int index,
                                        String blobPropertyName,
                                        String filenamePropertyName)
                                 throws ClientException
Build the nxedit URL for the "edit existing document" use case

Returns:
the encoded URL string
Throws:
ClientException - if the URL encoding fails

liveCreateUrl

public static String liveCreateUrl(String mimetype)
                            throws ClientException
Build the nxedit URL for the "create new document" use case with a document using the file:content field as Blob holder

Parameters:
mimetype - the mime type of the newly created document
Returns:
the encoded URL string
Throws:
ClientException - if the URL encoding fails

liveCreateUrl

public static String liveCreateUrl(String mimetype,
                                   String docType,
                                   String schemaName,
                                   String blobFieldName,
                                   String filenameFieldName)
                            throws ClientException
Build the nxedit URL for the "create new document" use case

Parameters:
mimetype - the mime type of the newly created document
docType - the document type of the document to create
schemaName - the schema of the blob to hold the new attachment
blobFieldName - the field name of the blob to hold the new attachment
filenameFieldName - the field name of the filename of the new attachment
Returns:
the encoded URL string
Throws:
ClientException - if the URL encoding fails

liveCreateFromTemplateUrl

public static String liveCreateFromTemplateUrl(DocumentModel template)
                                        throws ClientException
Build the nxedit URL for the "create new document from template" use case with "File" doc type and "file" schema

Parameters:
template - the document holding the blob to be used as template
Returns:
the encoded URL string
Throws:
ClientException - if the URL encoding fails

liveCreateFromTemplateUrl

public static String liveCreateFromTemplateUrl(DocumentModel template,
                                               String templateSchemaName,
                                               String templateBlobFieldName,
                                               String docType,
                                               String schemaName,
                                               String blobFieldName,
                                               String filenameFieldName)
                                        throws ClientException
Build the nxedit URL for the "create new document from template" use case

Parameters:
template - the document holding the blob to be used as template
templateSchemaName - the schema of the blob holding the template
templateBlobFieldName - the field name of the blob holding the template
docType - the document type of the new document to create
schemaName - the schema of the new blob to be saved as attachment
blobFieldName - the field name of the new blob to be saved as attachment
filenameFieldName - the field name of the filename of the attachment
Returns:
the encoded URL string
Throws:
ClientException - if the URL encoding fails

extractJSessionId

public static String extractJSessionId(HttpServletRequest request)
Extract the current JSESSIONID value from the request context

Parameters:
request - the current HttpServletRequest request
Returns:
the current JSESSIONID string

getLabelFromId

@Deprecated
public static String getLabelFromId(String directoryName,
                                               String id)
                             throws DirectoryException
Deprecated. use DirectoryFunctions.getDirectoryEntry(String, String)

Returns the label for given directory and id.

Parameters:
directoryName - the directory name
id - the label id
Returns:
the label.
Throws:
DirectoryException

getPropertyPath

public static String getPropertyPath(String listPropertyName,
                                     int index,
                                     String subPropertyName)

getAvailableLifeCycleTransitions

public static Collection<String> getAvailableLifeCycleTransitions(String lifeCycleName,
                                                                  String currentState)
                                                           throws LifeCycleException
Returns all the available transitions given the current state.

Parameters:
lifeCycleName - the Life Cycle name
currentState - the state from which the transitions should start
Throws:
LifeCycleException
Since:
5.4.2

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.