Package com.day.cq.wcm.msm.commons
Class BaseAction
- java.lang.Object
-
- com.day.cq.wcm.msm.commons.BaseAction
-
- All Implemented Interfaces:
JSONItem
,LiveAction
- Direct Known Subclasses:
FilteredAction
public abstract class BaseAction extends java.lang.Object implements LiveAction
Base implementation for theLiveAction
interface. This abstract class offers some basic configuration tasks for building aLiveAction
and also default implementations for the deprecated methods. It will speed up the implementation of aLiveAction
by only implementing the handles and doExecute abstract methods.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
execute(ResourceResolver resolver, LiveRelationship relation, ActionConfig config, boolean autoSave)
Deprecated.void
execute(ResourceResolver resolver, LiveRelationship relation, ActionConfig config, boolean autoSave, boolean isResetRollout)
Deprecated.void
execute(Resource source, Resource target, LiveRelationship relation, boolean autoSave, boolean isResetRollout)
Executes the current action.
- checks the preconditions usinghandles()
- if preconditions are met thedoExecute()
is called
- changes will be saved automatically if the autoSave flag is set to true
This method needs that at least one of theResource
parameters (source,target) to be non-null when used in conjunction with the autoSave flag since aResourceResolver
will need to be obtained to save the changes.java.lang.String
getName()
The name of this action.java.lang.String
getParameterName()
Deprecated.java.lang.String[]
getPropertiesNames()
Deprecated.int
getRank()
Deprecated.java.lang.String
getTitle()
Deprecated.static boolean
isPage(Node node)
Checks if the given Node is considered aPage
The check considers the "cq:Page" and its primary child the "jcr:content" Node as being a Page.static boolean
resourceHasNode(Resource resource)
Simple test if a Resource exists and is adaptable toNode
void
write(JSONWriter jsonWriter)
Deprecated.
-
-
-
Method Detail
-
getName
public java.lang.String getName()
The name of this action. It must match thecreatesAction() from LiveActionFactory
that creates this action- Specified by:
getName
in interfaceLiveAction
- Returns:
- action name
-
execute
public void execute(Resource source, Resource target, LiveRelationship relation, boolean autoSave, boolean isResetRollout) throws WCMException
Executes the current action.
- checks the preconditions usinghandles()
- if preconditions are met thedoExecute()
is called
- changes will be saved automatically if the autoSave flag is set to true
This method needs that at least one of theResource
parameters (source,target) to be non-null when used in conjunction with the autoSave flag since aResourceResolver
will need to be obtained to save the changes. ANonExistingResource
should be used when dealing with non existing resources.- Specified by:
execute
in interfaceLiveAction
- Parameters:
source
- The Resource to roll-out. This may beenull
target
- The Resource to receive modification. This may beenull
relation
- LiveRelationship between the two given ResourcesautoSave
- Save modificationsisResetRollout
- True if rollout is run in reset mode- Throws:
WCMException
- if an error occurs- See Also:
RolloutManager.rollout(com.day.cq.wcm.msm.api.RolloutManager.RolloutParams)
-
resourceHasNode
public static boolean resourceHasNode(Resource resource)
Simple test if a Resource exists and is adaptable toNode
- Parameters:
resource
- in question- Returns:
- true if the Resource is non-synthetic and can be adapted to a Node
-
isPage
public static boolean isPage(Node node) throws RepositoryException
Checks if the given Node is considered aPage
The check considers the "cq:Page" and its primary child the "jcr:content" Node as being a Page. This is as theRolloutManager
calls theLiveActions
with the later. As modifications should only be written to its content. Pages should not be changed.Pages are considered an aggregate of all the Nodes and sub-graph at its "jcr:content" Node. Thus Services may require special treatment of them. Eg. Replication, Revisions are bound to Pages.
- Parameters:
node
- to Test- Returns:
- true if the Node's NodeType is of "cq:Page" or it is the Page's "jcr:content" Node
- Throws:
RepositoryException
- on errors accessing the Repository
-
execute
@Deprecated public void execute(ResourceResolver resolver, LiveRelationship relation, ActionConfig config, boolean autoSave) throws WCMException
Deprecated.Description copied from interface:LiveAction
Executes action. Is called by the Rollout Manager.- Specified by:
execute
in interfaceLiveAction
- Parameters:
resolver
- resource resolverrelation
- live relationship concerned by action.config
- action configautoSave
- Save modifications- Throws:
WCMException
- if an error occurs- See Also:
ActionManager.executeAction(org.apache.sling.api.resource.ResourceResolver, LiveRelationship, ActionConfig, boolean)
-
execute
@Deprecated public void execute(ResourceResolver resolver, LiveRelationship relation, ActionConfig config, boolean autoSave, boolean isResetRollout) throws WCMException
Deprecated.Description copied from interface:LiveAction
Executes action. Is called by the Rollout Manager.- Specified by:
execute
in interfaceLiveAction
- Parameters:
resolver
- resource resolverrelation
- live relationship concerned by action.config
- action configautoSave
- Save modificationsisResetRollout
- True if rollout is run in reset mode- Throws:
WCMException
- if an error occurs- See Also:
ActionManager.executeAction(org.apache.sling.api.resource.ResourceResolver, LiveRelationship, ActionConfig, boolean, boolean)
-
getParameterName
@Deprecated public java.lang.String getParameterName()
Deprecated.Description copied from interface:LiveAction
Returns the global parameter name of current action. Parameter name is used in requests.- Specified by:
getParameterName
in interfaceLiveAction
- Returns:
- action parameter name
-
getRank
@Deprecated public int getRank()
Deprecated.Description copied from interface:LiveAction
Returns execution rank of the action: actions are executed by ascending ranks- Specified by:
getRank
in interfaceLiveAction
- Returns:
- action rank
-
getTitle
@Deprecated public java.lang.String getTitle()
Deprecated.Description copied from interface:LiveAction
Returns the title of current action. Title is used to be displayed to end-user.- Specified by:
getTitle
in interfaceLiveAction
- Returns:
- action name
-
getPropertiesNames
@Deprecated public java.lang.String[] getPropertiesNames()
Deprecated.Description copied from interface:LiveAction
Returns names of the properties defined for this action.- Specified by:
getPropertiesNames
in interfaceLiveAction
- Returns:
- array of parameters names
-
write
@Deprecated public void write(JSONWriter jsonWriter) throws JSONException
Deprecated.Description copied from interface:JSONItem
Serializes this descriptor to json- Specified by:
write
in interfaceJSONItem
- Specified by:
write
in interfaceLiveAction
- Parameters:
jsonWriter
- json writer- Throws:
JSONException
- if a JSON error occurs
-
-