Package org.apache.sling.pipes
Class BasePipe
- java.lang.Object
-
- org.apache.sling.pipes.BasePipe
-
- All Implemented Interfaces:
Pipe
- Direct Known Subclasses:
AbstractInputStreamPipe,AbstractSlingQueryPipe,SuperPipe
public class BasePipe extends Object implements Pipe
provides generic utilities for a pipe, is also a dummy pipe (outputs its input, without changing anything)
-
-
Field Summary
Fields Modifier and Type Field Description protected StringafterHookprotected StringbeforeHookprotected List<BindingProvider>bindingProvidersprotected PipeBindingsbindingsprotected StringdistributionAgentstatic StringDRYRUN_EXPRstatic StringDRYRUN_KEYstatic Iterator<org.apache.sling.api.resource.Resource>EMPTY_ITERATOREmpty resource iteratorprotected static List<String>IGNORED_NODESprotected static List<String>IGNORED_PROPERTIESprotected SuperPipeparentprotected Plumberplumberstatic StringPN_AFTERHOOKstatic StringPN_BEFOREHOOKstatic StringPN_STATUSstatic StringPN_STATUS_MODIFIEDprotected org.apache.sling.api.resource.ValueMappropertiesstatic StringREAD_ONLYprotected org.apache.sling.api.resource.ResourceResolverresolverprotected org.apache.sling.api.resource.Resourceresourcestatic StringRESOURCE_TYPEstatic StringRT_PREFIXstatic StringSLASHstatic StringSTATUS_FINISHEDstatic StringSTATUS_STARTED
-
Constructor Summary
Constructors Constructor Description BasePipe(@NotNull Plumber plumber, @NotNull org.apache.sling.api.resource.Resource resource, @Nullable PipeBindings upperBindings)Pipe Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafter()to be executed before output is retrievedvoidbefore()to be executed before output is retrievedprotected Iterator<org.apache.sling.api.resource.Resource>computeOutput()PipeBindingsgetBindings()returns the pipe's bindingsprotected StringgetComputedPath()org.apache.sling.api.resource.ResourcegetConfiguration()Get configuration nodeStringgetDistributionAgent()Get Distribution agentStringgetExpr()Get pipe's expression, instanciated or not@Nullable org.apache.sling.api.resource.ResourcegetInput()Get pipe current's resource *before* next execution, meaning either the configured resource, either previous' pipe output resourceStringgetName()Return the name of that pipeIterator<org.apache.sling.api.resource.Resource>getOutput()default execution, just returns current resourceObjectgetOutputBinding()returns the binding output used in container pipe's expressionSuperPipegetParent()StringgetPath()Get pipe's path, instanciated or notprotected PipegetPreviousPipe()Retrieves previous pipe if contained by a parent, or referrer'sprotected org.apache.sling.api.resource.ResourcegetPreviousResource()StringgetRawExpression()protected StringgetRawPath()org.apache.sling.api.resource.ResourcegetResource()get the pipe configuration resourcebooleanisDryRun()returns true if that pipe is set not to write contentprotected booleanisRootPath(String path)booleanmodifiesContent()returns true if that pipe modifies content during its executionprotected voidprovideAdditionalBindings()will execute in parallel binding providers if any, and updated Pipe bindings with returned valuesvoidsetParent(SuperPipe parent)sets the parent pipe this pipe is referred byStringtoString()
-
-
-
Field Detail
-
SLASH
public static final String SLASH
- See Also:
- Constant Field Values
-
RT_PREFIX
public static final String RT_PREFIX
- See Also:
- Constant Field Values
-
RESOURCE_TYPE
public static final String RESOURCE_TYPE
- See Also:
- Constant Field Values
-
DRYRUN_KEY
public static final String DRYRUN_KEY
- See Also:
- Constant Field Values
-
DRYRUN_EXPR
public static final String DRYRUN_EXPR
- See Also:
- Constant Field Values
-
READ_ONLY
public static final String READ_ONLY
- See Also:
- Constant Field Values
-
PN_STATUS
public static final String PN_STATUS
- See Also:
- Constant Field Values
-
PN_STATUS_MODIFIED
public static final String PN_STATUS_MODIFIED
- See Also:
- Constant Field Values
-
PN_BEFOREHOOK
public static final String PN_BEFOREHOOK
- See Also:
- Constant Field Values
-
PN_AFTERHOOK
public static final String PN_AFTERHOOK
- See Also:
- Constant Field Values
-
STATUS_STARTED
public static final String STATUS_STARTED
- See Also:
- Constant Field Values
-
STATUS_FINISHED
public static final String STATUS_FINISHED
- See Also:
- Constant Field Values
-
resolver
protected org.apache.sling.api.resource.ResourceResolver resolver
-
properties
protected org.apache.sling.api.resource.ValueMap properties
-
resource
protected org.apache.sling.api.resource.Resource resource
-
parent
protected SuperPipe parent
-
distributionAgent
protected String distributionAgent
-
bindings
protected PipeBindings bindings
-
bindingProviders
protected List<BindingProvider> bindingProviders
-
beforeHook
protected String beforeHook
-
afterHook
protected String afterHook
-
plumber
protected Plumber plumber
-
EMPTY_ITERATOR
public static final Iterator<org.apache.sling.api.resource.Resource> EMPTY_ITERATOR
Empty resource iterator
-
-
Constructor Detail
-
BasePipe
public BasePipe(@NotNull @NotNull Plumber plumber, @NotNull @NotNull org.apache.sling.api.resource.Resource resource, @Nullable @Nullable PipeBindings upperBindings)Pipe Constructor- Parameters:
plumber- plumberresource- configuration resourceupperBindings- already set bindings, can be null
-
-
Method Detail
-
getParent
public SuperPipe getParent()
-
setParent
public void setParent(SuperPipe parent)
Description copied from interface:Pipesets the parent pipe this pipe is referred by
-
getResource
public org.apache.sling.api.resource.Resource getResource()
Description copied from interface:Pipeget the pipe configuration resource- Specified by:
getResourcein interfacePipe- Returns:
- Pipe configruation root resource
-
isDryRun
public boolean isDryRun()
Description copied from interface:Pipereturns true if that pipe is set not to write content
-
modifiesContent
public boolean modifiesContent()
Description copied from interface:Pipereturns true if that pipe modifies content during its execution- Specified by:
modifiesContentin interfacePipe- Returns:
- true for write / false for read
-
getName
public String getName()
Description copied from interface:PipeReturn the name of that pipe
-
getRawExpression
public String getRawExpression()
- Returns:
- configured expression (not computed)
-
getExpr
public String getExpr()
Get pipe's expression, instanciated or not- Returns:
- configured expression
-
getRawPath
protected String getRawPath()
- Returns:
- configured input path (not computed)
-
getPath
public String getPath()
Get pipe's path, instanciated or not- Returns:
- configured path (can be empty)
-
getComputedPath
protected String getComputedPath()
- Returns:
- computed path: getPath, with relative path taken in account
-
isRootPath
protected boolean isRootPath(String path)
- Parameters:
path- path to be checked- Returns:
- true if path is root (aka not relative)
-
getPreviousPipe
protected Pipe getPreviousPipe()
Retrieves previous pipe if contained by a parent, or referrer's- Returns:
- pipe before this one or the referrer's can be null in case there is no parent
-
getPreviousResource
protected org.apache.sling.api.resource.Resource getPreviousResource()
- Returns:
- previous pipe's output if in a container, null otherwise
-
getInput
@Nullable public @Nullable org.apache.sling.api.resource.Resource getInput()
Description copied from interface:PipeGet pipe current's resource *before* next execution, meaning either the configured resource, either previous' pipe output resource
-
getOutputBinding
public Object getOutputBinding()
Description copied from interface:Pipereturns the binding output used in container pipe's expression- Specified by:
getOutputBindingin interfacePipe- Returns:
- object, either value map or something else, that will be used in nashorn for computing expressions
-
getBindings
public PipeBindings getBindings()
Description copied from interface:Pipereturns the pipe's bindings- Specified by:
getBindingsin interfacePipe- Returns:
- PipeBindings instance containing all bindings of that pipe
-
provideAdditionalBindings
protected void provideAdditionalBindings() throws InterruptedException, ExecutionExceptionwill execute in parallel binding providers if any, and updated Pipe bindings with returned values- Throws:
InterruptedException- can happen while a binding provider is executedExecutionException- can happen when a binding provider is executed
-
getOutput
public Iterator<org.apache.sling.api.resource.Resource> getOutput()
default execution, just returns current resource
-
before
public void before()
Description copied from interface:Pipeto be executed before output is retrieved
-
after
public void after()
Description copied from interface:Pipeto be executed before output is retrieved
-
computeOutput
protected Iterator<org.apache.sling.api.resource.Resource> computeOutput()
- Returns:
- outputs of the pipe, as an iterator of resources
-
getConfiguration
public org.apache.sling.api.resource.Resource getConfiguration()
Get configuration node- Returns:
- configuration node if any
-
getDistributionAgent
public String getDistributionAgent()
Description copied from interface:PipeGet Distribution agent- Specified by:
getDistributionAgentin interfacePipe- Returns:
- configured distribution agent
-
-