org.alfresco.repo.rendition.executer
Class AbstractRenderingEngine

java.lang.Object
  extended by org.alfresco.repo.action.CommonResourceAbstractBase
      extended by org.alfresco.repo.action.ParameterizedItemAbstractBase
          extended by org.alfresco.repo.action.executer.ActionExecuterAbstractBase
              extended by org.alfresco.repo.rendition.executer.AbstractRenderingEngine
All Implemented Interfaces:
ActionExecuter, org.springframework.beans.factory.BeanNameAware
Direct Known Subclasses:
AbstractTransformationRenderingEngine, BaseTemplateRenderingEngine, CompositeRenderingEngine, HTMLRenderingEngine

public abstract class AbstractRenderingEngine
extends ActionExecuterAbstractBase

This class adds some new behaviour to the standard ActionExecuterAbstractBase in order to support the RenditionService.

Since:
3.3

Nested Class Summary
protected  class AbstractRenderingEngine.RenderingContext
           
 
Field Summary
protected static java.lang.String CONTENT_READER_NOT_FOUND_MESSAGE
           
protected  ContentService contentService
           
protected  org.alfresco.repo.content.MimetypeMap mimetypeMap
           
protected  org.alfresco.service.cmr.repository.NodeService nodeService
           
static java.lang.String PARAM_ENCODING
          This optional String paramter specifies the encoding used to create the rendition content.
static java.lang.String PARAM_MIME_TYPE
          This optional String parameter specifies the mime type of the rendition content.
static java.lang.String PARAM_PLACEHOLDER_RESOURCE_PATH
          This optional String parameter specifies the location of a classpath resource which can be used as a placeholder while a rendition is being generated.
static java.lang.String PARAM_RUN_AS
          This optional String parameter specifies what user permissions are used when creating a rendition.
static java.lang.String PARAM_SOURCE_CONTENT_PROPERTY
          This optional QName parameter specifies which property the Rendering Engine uses to read content from the source node in order to create a rendition.
static java.lang.String PARAM_TARGET_CONTENT_PROPERTY
          This optional QName parameter specifies which property the Rendering Engine uses to write content to the rendition node.
static java.lang.String PARAM_UPDATE_RENDITIONS_ON_ANY_PROPERTY_CHANGE
          This optional Boolean flag property specifies whether a rendition should be updated automatically if the source node changes.
 
Fields inherited from class org.alfresco.repo.action.executer.ActionExecuterAbstractBase
actionDefinition, applicableTypes, publicAction
 
Fields inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase
DISPLAY_LABEL, runtimeActionService
 
Fields inherited from class org.alfresco.repo.action.CommonResourceAbstractBase
name
 
Fields inherited from interface org.alfresco.repo.action.executer.ActionExecuter
PARAM_RESULT
 
Constructor Summary
AbstractRenderingEngine()
           
AbstractRenderingEngine(NodeLocator temporaryParentNodeLocator, org.alfresco.service.namespace.QName temporaryRenditionLinkType)
           
 
Method Summary
protected  void addParameterDefinitions(java.util.List paramList)
          Adds the parameter definitions to the list
protected  RenditionDefinition checkActionIsRenditionDefinition(Action action)
           
protected  void checkParameterValues(Action action)
          This method can be overridden by subclasses to provide checking of parameter values.
protected  void checkSourceNodeExists(org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)
           
protected  ActionDefinition createActionDefinition(java.lang.String definitionName)
          This method returns an instance of an ActionDefinition implementation class.
protected  void executeImpl(Action action, org.alfresco.service.cmr.repository.NodeRef sourceNode)
          Execute the action implementation
protected  void executeImpl(RenditionDefinition renditionDef, org.alfresco.service.cmr.repository.NodeRef sourceNode)
           
protected  void executeRenditionImpl(Action action, org.alfresco.service.cmr.repository.NodeRef sourceNode)
           
static java.lang.Object getCheckedParam(java.lang.String paramName, java.lang.Class clazz, RenditionDefinition definition)
          Gets the value for the named parameter.
protected  org.alfresco.service.namespace.QName getDefaultRenditionContentProp()
          This method returns the QName of the property that defines the location of the rendition content.
protected  org.alfresco.service.namespace.QName getDefaultRenditionNodeType()
          This method returns the type of the default rendition node type.
protected  java.lang.String getParamDisplayLabel(java.lang.String paramName)
          This method gets the parameter definition display label from the properties file.
protected  java.util.Collection getParameterDefinitions()
          Supplies the list of parameters required by this rendering engine.
static java.lang.Object getParamWithDefault(java.lang.String paramName, java.lang.Object defaultValue, RenditionDefinition definition)
          Gets the value for the named parameter.
protected  org.alfresco.service.namespace.QName getRenditionContentProperty(RenditionDefinition renditionDefinition)
           
protected  java.lang.String getTargetEncoding(AbstractRenderingEngine.RenderingContext context)
           
protected  java.lang.String getTargetMimeType(AbstractRenderingEngine.RenderingContext context)
           
protected  void notifyCallbackOfException(RenditionDefinition renditionDefinition, java.lang.Throwable t)
           
protected  void notifyCallbackOfResult(RenditionDefinition renditionDefinition, org.alfresco.service.cmr.repository.ChildAssociationRef result)
           
protected abstract  void render(AbstractRenderingEngine.RenderingContext context)
           
protected  RenditionLocation resolveRenditionLocation(org.alfresco.service.cmr.repository.NodeRef sourceNode, RenditionDefinition definition, org.alfresco.service.cmr.repository.NodeRef tempRendition)
          Given a rendition definition, a source node and a temporary rendition node, this method uses a RenditionLocationResolver to calculate the RenditionLocation of the rendition.
 void setBehaviourFilter(BehaviourFilter behaviourFilter)
           
 void setContentService(ContentService contentService)
          Set the content service
 void setDefaultRenditionContentProp(java.lang.String prop)
          Sets the default rendition content property.
 void setDefaultRenditionNodeType(java.lang.String type)
          Sets the default rendition-node type.
 void setMimetypeMap(org.alfresco.repo.content.MimetypeMap mimetypeMap)
           
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
          Injects the nodeService bean.
 void setRenditionLocationResolver(RenditionLocationResolver renditionLocationResolver)
           
 void setRenditionService(RenditionService renditionService)
          Injects the renditionService bean.
protected  void switchToFinalRenditionNode(RenditionDefinition renditionDef, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)
           
protected  void tagSourceNodeAsRenditioned(RenditionDefinition renditionDef, org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)
           
protected  void throwWrappedException(java.lang.Throwable t)
           
 
Methods inherited from class org.alfresco.repo.action.executer.ActionExecuterAbstractBase
execute, getActionDefinition, getIgnoreLock, getQueueName, getTrackStatus, init, setApplicableTypes, setBaseNodeService, setIgnoreLock, setLockService, setPublicAction, setQueueName, setTrackStatus
 
Methods inherited from class org.alfresco.repo.action.ParameterizedItemAbstractBase
checkMandatoryProperties, getAdhocPropertiesAllowed, getDescriptionKey, getParameterDefintions, getTitleKey, setRuntimeActionService, toString
 
Methods inherited from class org.alfresco.repo.action.CommonResourceAbstractBase
setBeanName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTENT_READER_NOT_FOUND_MESSAGE

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

contentService

protected ContentService contentService

mimetypeMap

protected org.alfresco.repo.content.MimetypeMap mimetypeMap

PARAM_PLACEHOLDER_RESOURCE_PATH

public static final java.lang.String PARAM_PLACEHOLDER_RESOURCE_PATH
This optional String parameter specifies the location of a classpath resource which can be used as a placeholder while a rendition is being generated. For example, this might be a simple icon to indicate a rendition is not yet available. This is intended to be used in conjunction with asynchronous generation of renditions.

See Also:
Constant Field Values

PARAM_SOURCE_CONTENT_PROPERTY

public static final java.lang.String PARAM_SOURCE_CONTENT_PROPERTY
This optional QName parameter specifies which property the Rendering Engine uses to read content from the source node in order to create a rendition. By default this property will be cm:content.

See Also:
Constant Field Values

PARAM_TARGET_CONTENT_PROPERTY

public static final java.lang.String PARAM_TARGET_CONTENT_PROPERTY
This optional QName parameter specifies which property the Rendering Engine uses to write content to the rendition node. By default the property used is cm:content.

See Also:
Constant Field Values

PARAM_UPDATE_RENDITIONS_ON_ANY_PROPERTY_CHANGE

public static final java.lang.String PARAM_UPDATE_RENDITIONS_ON_ANY_PROPERTY_CHANGE
This optional Boolean flag property specifies whether a rendition should be updated automatically if the source node changes. If set to true then the rendition will be re-rendered any time any property changes occur on the source node. This parameter defaults to false.

See Also:
Constant Field Values

PARAM_RUN_AS

public static final java.lang.String PARAM_RUN_AS
This optional String parameter specifies what user permissions are used when creating a rendition. By default the system user is used.

See Also:
Constant Field Values

PARAM_MIME_TYPE

public static final java.lang.String PARAM_MIME_TYPE
This optional String parameter specifies the mime type of the rendition content. This defaults to the mime type of the source node content.

See Also:
Constant Field Values

PARAM_ENCODING

public static final java.lang.String PARAM_ENCODING
This optional String paramter specifies the encoding used to create the rendition content. The derfault encoding is UTF-8.

See Also:
Constant Field Values

nodeService

protected org.alfresco.service.cmr.repository.NodeService nodeService
Constructor Detail

AbstractRenderingEngine

public AbstractRenderingEngine(NodeLocator temporaryParentNodeLocator,
                               org.alfresco.service.namespace.QName temporaryRenditionLinkType)

AbstractRenderingEngine

public AbstractRenderingEngine()
Method Detail

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Injects the nodeService bean.

Parameters:
nodeService - the nodeService.

setRenditionService

public void setRenditionService(RenditionService renditionService)
Injects the renditionService bean.

Parameters:
renditionService -

setBehaviourFilter

public void setBehaviourFilter(BehaviourFilter behaviourFilter)
Parameters:
behaviourFilter - policy behaviour filter

setRenditionLocationResolver

public void setRenditionLocationResolver(RenditionLocationResolver renditionLocationResolver)

setDefaultRenditionNodeType

public void setDefaultRenditionNodeType(java.lang.String type)
Sets the default rendition-node type.

Parameters:
type -

getDefaultRenditionNodeType

protected org.alfresco.service.namespace.QName getDefaultRenditionNodeType()
This method returns the type of the default rendition node type.

Returns:
the QName representing the type of the default rendition node type.

getTargetMimeType

protected java.lang.String getTargetMimeType(AbstractRenderingEngine.RenderingContext context)

getTargetEncoding

protected java.lang.String getTargetEncoding(AbstractRenderingEngine.RenderingContext context)

setDefaultRenditionContentProp

public void setDefaultRenditionContentProp(java.lang.String prop)
Sets the default rendition content property.

Parameters:
prop -

getDefaultRenditionContentProp

protected org.alfresco.service.namespace.QName getDefaultRenditionContentProp()
This method returns the QName of the property that defines the location of the rendition content. An example would be cm:content.

Returns:
the QName the property defining the location of the rendition content.

setContentService

public void setContentService(ContentService contentService)
Set the content service

Parameters:
contentService - the content service

setMimetypeMap

public void setMimetypeMap(org.alfresco.repo.content.MimetypeMap mimetypeMap)

createActionDefinition

protected ActionDefinition createActionDefinition(java.lang.String definitionName)
Description copied from class: ActionExecuterAbstractBase
This method returns an instance of an ActionDefinition implementation class. By default this will be an ActionDefinitionImpl, but this could be overridden.

Overrides:
createActionDefinition in class ActionExecuterAbstractBase

executeImpl

protected void executeImpl(Action action,
                           org.alfresco.service.cmr.repository.NodeRef sourceNode)
Description copied from class: ActionExecuterAbstractBase
Execute the action implementation

Specified by:
executeImpl in class ActionExecuterAbstractBase
Parameters:
action - the action
sourceNode - the actioned upon node

executeImpl

protected void executeImpl(RenditionDefinition renditionDef,
                           org.alfresco.service.cmr.repository.NodeRef sourceNode)

executeRenditionImpl

protected void executeRenditionImpl(Action action,
                                    org.alfresco.service.cmr.repository.NodeRef sourceNode)

checkParameterValues

protected void checkParameterValues(Action action)
This method can be overridden by subclasses to provide checking of parameter values. If a parameter value is illegal or inappropriate, an exception should be thrown.


getRenditionContentProperty

protected org.alfresco.service.namespace.QName getRenditionContentProperty(RenditionDefinition renditionDefinition)
Parameters:
renditionDefinition -
Returns:

render

protected abstract void render(AbstractRenderingEngine.RenderingContext context)

checkSourceNodeExists

protected void checkSourceNodeExists(org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)
Parameters:
actionedUponNodeRef -

checkActionIsRenditionDefinition

protected RenditionDefinition checkActionIsRenditionDefinition(Action action)
Parameters:
action -

addParameterDefinitions

protected final void addParameterDefinitions(java.util.List paramList)
Description copied from class: ParameterizedItemAbstractBase
Adds the parameter definitions to the list

Specified by:
addParameterDefinitions in class ParameterizedItemAbstractBase
Parameters:
paramList - the parameter definitions list

getParamDisplayLabel

protected java.lang.String getParamDisplayLabel(java.lang.String paramName)
This method gets the parameter definition display label from the properties file. It looks first for a property whose key has a fixed rendition service-specific prefix and if that gets null, it then delegates to the standard bean name-based approach.

Overrides:
getParamDisplayLabel in class ParameterizedItemAbstractBase
Parameters:
paramName - the name of the parameter
Returns:
the display label of the parameter

getParameterDefinitions

protected java.util.Collection getParameterDefinitions()
Supplies the list of parameters required by this rendering engine.

Returns:

getCheckedParam

public static java.lang.Object getCheckedParam(java.lang.String paramName,
                                               java.lang.Class clazz,
                                               RenditionDefinition definition)
Gets the value for the named parameter. Checks the type of the parameter is correct and throws a RenditionServiceException if it isn't. Returns null if the parameter value is null

Parameters:
paramName - the name of the parameter being checked.
clazz - the expected Class of the parameter value.
definition - the RenditionDefinition containing the parameters.
Returns:
the parameter value or null.

getParamWithDefault

public static java.lang.Object getParamWithDefault(java.lang.String paramName,
                                                   java.lang.Object defaultValue,
                                                   RenditionDefinition definition)
Gets the value for the named parameter. Checks the type of the parameter is the same as the type of defaultValue and throws a RenditionServiceException if it isn't. Returns defaultValue if the parameter value is null

Parameters:
paramName -
defaultValue -
definition -
Returns:

tagSourceNodeAsRenditioned

protected void tagSourceNodeAsRenditioned(RenditionDefinition renditionDef,
                                          org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)

switchToFinalRenditionNode

protected void switchToFinalRenditionNode(RenditionDefinition renditionDef,
                                          org.alfresco.service.cmr.repository.NodeRef actionedUponNodeRef)

notifyCallbackOfException

protected void notifyCallbackOfException(RenditionDefinition renditionDefinition,
                                         java.lang.Throwable t)

throwWrappedException

protected void throwWrappedException(java.lang.Throwable t)

notifyCallbackOfResult

protected void notifyCallbackOfResult(RenditionDefinition renditionDefinition,
                                      org.alfresco.service.cmr.repository.ChildAssociationRef result)

resolveRenditionLocation

protected RenditionLocation resolveRenditionLocation(org.alfresco.service.cmr.repository.NodeRef sourceNode,
                                                     RenditionDefinition definition,
                                                     org.alfresco.service.cmr.repository.NodeRef tempRendition)
Given a rendition definition, a source node and a temporary rendition node, this method uses a RenditionLocationResolver to calculate the RenditionLocation of the rendition.



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