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 theLiveActioninterface. This abstract class offers some basic configuration tasks for building aLiveActionand also default implementations for the deprecated methods. It will speed up the implementation of aLiveActionby 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 voidexecute(ResourceResolver resolver, LiveRelationship relation, ActionConfig config, boolean autoSave)Deprecated.voidexecute(ResourceResolver resolver, LiveRelationship relation, ActionConfig config, boolean autoSave, boolean isResetRollout)Deprecated.voidexecute(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 theResourceparameters (source,target) to be non-null when used in conjunction with the autoSave flag since aResourceResolverwill need to be obtained to save the changes.java.lang.StringgetName()The name of this action.java.lang.StringgetParameterName()Deprecated.java.lang.String[]getPropertiesNames()Deprecated.intgetRank()Deprecated.java.lang.StringgetTitle()Deprecated.static booleanisPage(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 booleanresourceHasNode(Resource resource)Simple test if a Resource exists and is adaptable toNodevoidwrite(JSONWriter jsonWriter)Deprecated.
-
-
-
Method Detail
-
getName
public java.lang.String getName()
The name of this action. It must match thecreatesAction() from LiveActionFactorythat creates this action- Specified by:
getNamein 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 theResourceparameters (source,target) to be non-null when used in conjunction with the autoSave flag since aResourceResolverwill need to be obtained to save the changes. ANonExistingResourceshould be used when dealing with non existing resources.- Specified by:
executein interfaceLiveAction- Parameters:
source- The Resource to roll-out. This may beenulltarget- The Resource to receive modification. This may beenullrelation- 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 theRolloutManagercalls theLiveActionswith 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:LiveActionExecutes action. Is called by the Rollout Manager.- Specified by:
executein 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:LiveActionExecutes action. Is called by the Rollout Manager.- Specified by:
executein 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:LiveActionReturns the global parameter name of current action. Parameter name is used in requests.- Specified by:
getParameterNamein interfaceLiveAction- Returns:
- action parameter name
-
getRank
@Deprecated public int getRank()
Deprecated.Description copied from interface:LiveActionReturns execution rank of the action: actions are executed by ascending ranks- Specified by:
getRankin interfaceLiveAction- Returns:
- action rank
-
getTitle
@Deprecated public java.lang.String getTitle()
Deprecated.Description copied from interface:LiveActionReturns the title of current action. Title is used to be displayed to end-user.- Specified by:
getTitlein interfaceLiveAction- Returns:
- action name
-
getPropertiesNames
@Deprecated public java.lang.String[] getPropertiesNames()
Deprecated.Description copied from interface:LiveActionReturns names of the properties defined for this action.- Specified by:
getPropertiesNamesin interfaceLiveAction- Returns:
- array of parameters names
-
write
@Deprecated public void write(JSONWriter jsonWriter) throws JSONException
Deprecated.Description copied from interface:JSONItemSerializes this descriptor to json- Specified by:
writein interfaceJSONItem- Specified by:
writein interfaceLiveAction- Parameters:
jsonWriter- json writer- Throws:
JSONException- if a JSON error occurs
-
-