org.alfresco.repo.forms.processor.node
Class ContentModelFormProcessor

java.lang.Object
  extended by org.alfresco.repo.forms.processor.AbstractFormProcessor
      extended by org.alfresco.repo.forms.processor.FilteredFormProcessor
          extended by org.alfresco.repo.forms.processor.node.ContentModelFormProcessor
All Implemented Interfaces:
FormProcessor
Direct Known Subclasses:
NodeFormProcessor, TypeFormProcessor

public abstract class ContentModelFormProcessor
extends FilteredFormProcessor

Abstract FormProcessor implementation that provides common functionality for form processors that deal with Alfresco content models i.e. types and nodes.


Field Summary
static java.lang.String ASSOC
           
static java.lang.String ASSOC_DATA_ADDED_SUFFIX
           
static java.lang.String ASSOC_DATA_PREFIX
           
static java.lang.String ASSOC_DATA_REMOVED_SUFFIX
           
protected  java.util.regex.Pattern associationNamePattern
          A regular expression which can be used to match association names.
protected  ContentService contentService
           
static java.lang.String DATA_KEY_SEPARATOR
           
protected static java.lang.String DEFAULT_CONTENT_MIMETYPE
          Protected constants
protected  DictionaryService dictionaryService
           
protected  FileFolderService fileFolderService
           
protected static java.lang.String MSG_ENCODING_DESC
           
protected static java.lang.String MSG_ENCODING_LABEL
           
protected static java.lang.String MSG_MIMETYPE_DESC
           
protected static java.lang.String MSG_MIMETYPE_LABEL
           
protected static java.lang.String MSG_SIZE_DESC
           
protected static java.lang.String MSG_SIZE_LABEL
           
protected  NamespaceService namespaceService
           
protected  NodeService nodeService
          Services
static java.lang.String ON
          Public constants
static java.lang.String PROP
           
static java.lang.String PROP_DATA_PREFIX
           
protected  java.util.regex.Pattern propertyNamePattern
          A regular expression which can be used to match property names.
static java.lang.String TRANSIENT_ENCODING
           
static java.lang.String TRANSIENT_MIMETYPE
           
static java.lang.String TRANSIENT_SIZE
           
protected  java.util.regex.Pattern transientPropertyPattern
          A regular expression which can be used to match tranisent property names.
 
Fields inherited from class org.alfresco.repo.forms.processor.FilteredFormProcessor
filterRegistry
 
Fields inherited from class org.alfresco.repo.forms.processor.AbstractFormProcessor
active, matchPattern, patternMatcher, processorRegistry
 
Constructor Summary
ContentModelFormProcessor()
           
 
Method Summary
protected  java.lang.String determineDefaultMimetype(FormData data)
          Looks through the form data for the 'mimetype' transient field and returns it's value if found, otherwise the default 'text/plain' is returned
static void generateAssociationField(AssociationDefinition assocDef, Form form, java.util.List assocValues, FieldGroup group, NamespaceService namespaceService)
          Sets up a field definition for the given association.
static void generateAssociationField(AssociationDefinition assocDef, Form form, java.util.List assocValues, NamespaceService namespaceService)
          Sets up a field definition for the given association.
static void generateAssociationField(AssociationDefinition assocDef, Form form, NamespaceService namespaceService)
          Sets up a field definition for the given association.
protected  void generateEncodingPropertyField(ContentData content, Form form)
          Generates the field definition for the transient encoding property
protected  void generateForcedField(java.lang.String fieldName, Form form)
          Generates a field definition for the given field that is being forced to show.
protected  void generateMimetypePropertyField(ContentData content, Form form)
          Generates the field definition for the transient mimetype property
static void generatePropertyField(PropertyDefinition propDef, Form form, NamespaceService namespaceService)
          Sets up a field definition for the given property.
static void generatePropertyField(PropertyDefinition propDef, Form form, java.io.Serializable propValue, FieldGroup group, NamespaceService namespaceService)
          Sets up a field definition for the given property.
static void generatePropertyField(PropertyDefinition propDef, Form form, java.io.Serializable propValue, NamespaceService namespaceService)
          Sets up a field definition for the given property.
protected  void generateSelectedFields(NodeRef nodeRef, TypeDefinition typeDef, java.util.List fields, java.util.List forcedFields, Form form)
          Sets up the field definitions for all the requested fields.
protected  void generateSizePropertyField(ContentData content, Form form)
          Generates the field definition for the transient size property
protected abstract  org.apache.commons.logging.Log getLogger()
          Retrieves a logger instance to log to.
protected  void persistNode(NodeRef nodeRef, FormData data)
          Persists the given FormData on the given NodeRef
protected  void processAssociationPersist(NodeRef nodeRef, java.util.Map assocDefs, java.util.Map childAssocDefs, FormData.FieldData fieldData, java.util.List assocCommands)
          Processes the given field data for persistence as an association.
protected  void processContentPropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, java.util.Map propsToPersist, FormData data)
          Persists the given field data as the content
protected  void processEncodingPropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, java.util.Map propsToPersist)
          Persists the given field data as the encoding property
protected  void processMimetypePropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, java.util.Map propsToPersist)
          Persists the given field data as the mimetype property
protected  void processNamePropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData)
          Persists the given field data as the name property
protected  void processPropertyPersist(NodeRef nodeRef, java.util.Map propDefs, FormData.FieldData fieldData, java.util.Map propsToPersist, FormData data)
          Processes the given field data for persistence as a property.
protected  void processWorkingCopy(NodeRef nodeRef, Form form)
          Determines whether the given node represents a working copy, if it does the name field is searched for and set to protected as the name field should not be edited for a working copy.
protected  java.util.List retrieveAssociationValues(NodeRef nodeRef, AssociationDefinition assocDef)
          Retrieves the values of the given association definition on the given node.
 void setContentService(ContentService contentService)
          Sets the content service
 void setDictionaryService(DictionaryService dictionaryService)
          Sets the data dictionary service
 void setFileFolderService(FileFolderService fileFolderService)
          Sets the file folder service
 void setNamespaceService(NamespaceService namespaceService)
          Sets the namespace service
 void setNodeService(NodeService nodeService)
          Sets the node service
 
Methods inherited from class org.alfresco.repo.forms.processor.FilteredFormProcessor
generate, getTypedItem, internalGenerate, internalPersist, persist, setFilterRegistry
 
Methods inherited from class org.alfresco.repo.forms.processor.AbstractFormProcessor
isActive, isApplicable, register, setActive, setFormItemType, setFormItemUrl, setMatchPattern, setProcessorRegistry, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ON

public static final java.lang.String ON
Public constants

See Also:
Constant Field Values

PROP

public static final java.lang.String PROP
See Also:
Constant Field Values

ASSOC

public static final java.lang.String ASSOC
See Also:
Constant Field Values

DATA_KEY_SEPARATOR

public static final java.lang.String DATA_KEY_SEPARATOR
See Also:
Constant Field Values

PROP_DATA_PREFIX

public static final java.lang.String PROP_DATA_PREFIX
See Also:
Constant Field Values

ASSOC_DATA_PREFIX

public static final java.lang.String ASSOC_DATA_PREFIX
See Also:
Constant Field Values

ASSOC_DATA_ADDED_SUFFIX

public static final java.lang.String ASSOC_DATA_ADDED_SUFFIX
See Also:
Constant Field Values

ASSOC_DATA_REMOVED_SUFFIX

public static final java.lang.String ASSOC_DATA_REMOVED_SUFFIX
See Also:
Constant Field Values

TRANSIENT_MIMETYPE

public static final java.lang.String TRANSIENT_MIMETYPE
See Also:
Constant Field Values

TRANSIENT_SIZE

public static final java.lang.String TRANSIENT_SIZE
See Also:
Constant Field Values

TRANSIENT_ENCODING

public static final java.lang.String TRANSIENT_ENCODING
See Also:
Constant Field Values

DEFAULT_CONTENT_MIMETYPE

protected static final java.lang.String DEFAULT_CONTENT_MIMETYPE
Protected constants

See Also:
Constant Field Values

MSG_MIMETYPE_LABEL

protected static final java.lang.String MSG_MIMETYPE_LABEL
See Also:
Constant Field Values

MSG_MIMETYPE_DESC

protected static final java.lang.String MSG_MIMETYPE_DESC
See Also:
Constant Field Values

MSG_ENCODING_LABEL

protected static final java.lang.String MSG_ENCODING_LABEL
See Also:
Constant Field Values

MSG_ENCODING_DESC

protected static final java.lang.String MSG_ENCODING_DESC
See Also:
Constant Field Values

MSG_SIZE_LABEL

protected static final java.lang.String MSG_SIZE_LABEL
See Also:
Constant Field Values

MSG_SIZE_DESC

protected static final java.lang.String MSG_SIZE_DESC
See Also:
Constant Field Values

nodeService

protected NodeService nodeService
Services


fileFolderService

protected FileFolderService fileFolderService

dictionaryService

protected DictionaryService dictionaryService

namespaceService

protected NamespaceService namespaceService

contentService

protected ContentService contentService

propertyNamePattern

protected java.util.regex.Pattern propertyNamePattern
A regular expression which can be used to match property names. These names will look like "prop_cm_name". The pattern can also be used to extract the "cm" and the "name" parts.


transientPropertyPattern

protected java.util.regex.Pattern transientPropertyPattern
A regular expression which can be used to match tranisent property names. These names will look like "prop_name". The pattern can also be used to extract the "name" part.


associationNamePattern

protected java.util.regex.Pattern associationNamePattern
A regular expression which can be used to match association names. These names will look like "assoc_cm_references_added". The pattern can also be used to extract the "cm", the "name" and the suffix parts.

Constructor Detail

ContentModelFormProcessor

public ContentModelFormProcessor()
Method Detail

setNodeService

public void setNodeService(NodeService nodeService)
Sets the node service

Parameters:
nodeService - The NodeService instance

setFileFolderService

public void setFileFolderService(FileFolderService fileFolderService)
Sets the file folder service

Parameters:
fileFolderService - The FileFolderService instance

setDictionaryService

public void setDictionaryService(DictionaryService dictionaryService)
Sets the data dictionary service

Parameters:
dictionaryService - The DictionaryService instance

setNamespaceService

public void setNamespaceService(NamespaceService namespaceService)
Sets the namespace service

Parameters:
namespaceService - The NamespaceService instance

setContentService

public void setContentService(ContentService contentService)
Sets the content service

Parameters:
contentService - The ContentService instance

generatePropertyField

public static void generatePropertyField(PropertyDefinition propDef,
                                         Form form,
                                         NamespaceService namespaceService)
Sets up a field definition for the given property.

NOTE: This method is static so that it can serve as a helper method for FormFilter implementations as adding additional property fields is likely to be a common extension.

Parameters:
propDef - The PropertyDefinition of the field to generate
form - The Form instance to populate
namespaceService - NamespaceService instance

generatePropertyField

public static void generatePropertyField(PropertyDefinition propDef,
                                         Form form,
                                         java.io.Serializable propValue,
                                         NamespaceService namespaceService)
Sets up a field definition for the given property.

NOTE: This method is static so that it can serve as a helper method for FormFilter implementations as adding additional property fields is likely to be a common extension.

Parameters:
propDef - The PropertyDefinition of the field to generate
form - The Form instance to populate
propValue - The value of the property field
namespaceService - NamespaceService instance

generatePropertyField

public static void generatePropertyField(PropertyDefinition propDef,
                                         Form form,
                                         java.io.Serializable propValue,
                                         FieldGroup group,
                                         NamespaceService namespaceService)
Sets up a field definition for the given property.

NOTE: This method is static so that it can serve as a helper method for FormFilter implementations as adding additional property fields is likely to be a common extension.

Parameters:
propDef - The PropertyDefinition of the field to generate
form - The Form instance to populate
propValue - The value of the property field
group - The FieldGroup the property field belongs to, can be null
namespaceService - NamespaceService instance

generateAssociationField

public static void generateAssociationField(AssociationDefinition assocDef,
                                            Form form,
                                            NamespaceService namespaceService)
Sets up a field definition for the given association.

NOTE: This method is static so that it can serve as a helper method for FormFilter implementations as adding additional association fields is likely to be a common extension.

Parameters:
assocDef - The AssociationDefinition of the field to generate
form - The Form instance to populate
namespaceService - NamespaceService instance

generateAssociationField

public static void generateAssociationField(AssociationDefinition assocDef,
                                            Form form,
                                            java.util.List assocValues,
                                            NamespaceService namespaceService)
Sets up a field definition for the given association.

NOTE: This method is static so that it can serve as a helper method for FormFilter implementations as adding additional association fields is likely to be a common extension.

Parameters:
assocDef - The AssociationDefinition of the field to generate
form - The Form instance to populate
assocValues - The values of the association field, can be null
namespaceService - NamespaceService instance

generateAssociationField

public static void generateAssociationField(AssociationDefinition assocDef,
                                            Form form,
                                            java.util.List assocValues,
                                            FieldGroup group,
                                            NamespaceService namespaceService)
Sets up a field definition for the given association.

NOTE: This method is static so that it can serve as a helper method for FormFilter implementations as adding additional association fields is likely to be a common extension.

Parameters:
assocDef - The AssociationDefinition of the field to generate
form - The Form instance to populate
assocValues - The values of the association field, can be null
group - The FieldGroup the association field belongs to, can be null
namespaceService - NamespaceService instance

getLogger

protected abstract org.apache.commons.logging.Log getLogger()
Retrieves a logger instance to log to.

Returns:
Log instance to log to.

generateSelectedFields

protected void generateSelectedFields(NodeRef nodeRef,
                                      TypeDefinition typeDef,
                                      java.util.List fields,
                                      java.util.List forcedFields,
                                      Form form)
Sets up the field definitions for all the requested fields.

A NodeRef or TypeDefinition can be provided, however, if a NodeRef is provided all type information will be derived from the NodeRef and the TypeDefinition will be ignored.

If any of the requested fields are not present on the type and they appear in the forcedFields list an attempt to find a model definition for those fields is made so they can be included.

Parameters:
nodeRef - The NodeRef of the item being generated
typeDef - The TypeDefiniton of the item being generated
fields - Restricted list of fields to include
forcedFields - List of field names that should be included even if the field is not currently present
form - The Form instance to populate

generateForcedField

protected void generateForcedField(java.lang.String fieldName,
                                   Form form)
Generates a field definition for the given field that is being forced to show.

Parameters:
fieldName - Name of the field to force
form - The Form instance to populated

generateMimetypePropertyField

protected void generateMimetypePropertyField(ContentData content,
                                             Form form)
Generates the field definition for the transient mimetype property

Parameters:
content - The ContentData object to generate the field from
form - The Form instance to populate

generateEncodingPropertyField

protected void generateEncodingPropertyField(ContentData content,
                                             Form form)
Generates the field definition for the transient encoding property

Parameters:
content - The ContentData object to generate the field from
form - The Form instance to populate

generateSizePropertyField

protected void generateSizePropertyField(ContentData content,
                                         Form form)
Generates the field definition for the transient size property

Parameters:
content - The ContentData object to generate the field from
form - The Form instance to populate

processWorkingCopy

protected void processWorkingCopy(NodeRef nodeRef,
                                  Form form)
Determines whether the given node represents a working copy, if it does the name field is searched for and set to protected as the name field should not be edited for a working copy. If the node is not a working copy this method has no effect.

Parameters:
nodeRef - NodeRef of node to check and potentially process
form - The generated form

retrieveAssociationValues

protected java.util.List retrieveAssociationValues(NodeRef nodeRef,
                                                   AssociationDefinition assocDef)
Retrieves the values of the given association definition on the given node.

Parameters:
nodeRef - The node to get the association values for
assocDef - The association definition to look for values for
Returns:
List of values for association or null of the association does not exist for the given node.

persistNode

protected void persistNode(NodeRef nodeRef,
                           FormData data)
Persists the given FormData on the given NodeRef

Parameters:
nodeRef - The NodeRef to persist the form data on
data - The FormData to persist

processPropertyPersist

protected void processPropertyPersist(NodeRef nodeRef,
                                      java.util.Map propDefs,
                                      FormData.FieldData fieldData,
                                      java.util.Map propsToPersist,
                                      FormData data)
Processes the given field data for persistence as a property.

Parameters:
nodeRef - The NodeRef to persist the properties on
propDefs - Map of PropertyDefinition's for the node being persisted
fieldData - Data to persist for the property
propsToPersist - Map of properties to be persisted
data - The FormData to persist

processAssociationPersist

protected void processAssociationPersist(NodeRef nodeRef,
                                         java.util.Map assocDefs,
                                         java.util.Map childAssocDefs,
                                         FormData.FieldData fieldData,
                                         java.util.List assocCommands)
Processes the given field data for persistence as an association.

Parameters:
nodeRef - The NodeRef to persist the associations on
fieldData - Data to persist for the associations
assocCommands - List of associations to be persisted

processNamePropertyPersist

protected void processNamePropertyPersist(NodeRef nodeRef,
                                          FormData.FieldData fieldData)
Persists the given field data as the name property

Parameters:
nodeRef - The NodeRef to update the name for
fieldData - The data representing the new name value

processMimetypePropertyPersist

protected void processMimetypePropertyPersist(NodeRef nodeRef,
                                              FormData.FieldData fieldData,
                                              java.util.Map propsToPersist)
Persists the given field data as the mimetype property

Parameters:
nodeRef - The NodeRef to update the mimetype for
fieldData - The data representing the new mimetype value
propsToPersist - Map of properties to be persisted

processEncodingPropertyPersist

protected void processEncodingPropertyPersist(NodeRef nodeRef,
                                              FormData.FieldData fieldData,
                                              java.util.Map propsToPersist)
Persists the given field data as the encoding property

Parameters:
nodeRef - The NodeRef to update the encoding for
fieldData - The data representing the new encoding value
propsToPersist - Map of properties to be persisted

processContentPropertyPersist

protected void processContentPropertyPersist(NodeRef nodeRef,
                                             FormData.FieldData fieldData,
                                             java.util.Map propsToPersist,
                                             FormData data)
Persists the given field data as the content

Parameters:
nodeRef - The NodeRef to update the content for
fieldData - The data representing the new content
propsToPersist - Map of properties to be persisted
data - The form data being persisted

determineDefaultMimetype

protected java.lang.String determineDefaultMimetype(FormData data)
Looks through the form data for the 'mimetype' transient field and returns it's value if found, otherwise the default 'text/plain' is returned

Parameters:
data - Form data being persisted
Returns:
The default mimetype


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.