Author: buildbot
Date: Wed Aug 30 14:00:06 2017
New Revision: 1017481
Log:
Staging update by buildbot for sling
Modified:
websites/staging/sling/trunk/content/ (props changed)
websites/staging/sling/trunk/content/documentation/bundles/sling-pipes.html
Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Aug 30 14:00:06 2017
@@ -1 +1 @@
-1806688
+1806694
Modified:
websites/staging/sling/trunk/content/documentation/bundles/sling-pipes.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/bundles/sling-pipes.html
(original)
+++ websites/staging/sling/trunk/content/documentation/bundles/sling-pipes.html
Wed Aug 30 14:00:06 2017
@@ -115,10 +115,11 @@ h2:hover > .headerlink, h3:hover > .head
visibility: hidden;
}
h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink,
h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink,
dt:hover > .elementid-permalink { visibility: visible }</style>
-<p>tool for doing extract - transform - load operations through a resource
tree configuration.</p>
+<p>tool set for doing extract - transform - load operations by chaining proven
code bits.</p>
<p>often one-shot data transformations need sample code to be written &
executed. This tiny tool set intends to provide ability to do such
transformations with proven & reusable blocks called pipes, streaming
resources from one to the other.</p>
<h2 id="what-is-a-pipe">What is a pipe<a class="headerlink"
href="#what-is-a-pipe" title="Permanent link">¶</a></h2>
<div class="codehilite"><pre> <span class="n">getOutputBinding</span>
+
^
<span class="o">|</span>
<span class="n">getInput</span> <span class="o">+---+---+</span> <span
class="n">getOutput</span>
@@ -131,20 +132,20 @@ h2:hover > .headerlink, h3:hover > .head
<p>A sling pipe is essentially a sling resource stream:</p>
<ul>
-<li>it provides an output as a sling resource iterator</li>
-<li>it gets its input either from a configured path, either, if its chained
(see container pipes below), from another pipe's output</li>
-<li>each pipe can have additional dynamic inputs using other's bindings, and
outputing its own bindings</li>
+<li>it provides an output as a sling resource iterator,</li>
+<li>it gets its input either from a configured path, either from former pipe's
output,</li>
+<li>each pipe can have contextual inputs using any other pipe's bindings, and
outputting its own bindings</li>
</ul>
<p>At this moment, there are 3 types of pipes to consider:</p>
<ul>
<li>"reader" pipes, that will just output a set of resource depending on the
input</li>
-<li>"writer" pipes, that write to the repository, depending on configuration
and output</li>
+<li>"writer" pipes, that modify the repository, depending on configuration and
input</li>
<li>"container" pipes, that contains pipes, and whose job is to chain their
execution : input is the input of their first pipe,
output is the output of the last pipe it contains.</li>
</ul>
-<p>A <code>Plumber</code> osgi service is provided to help getting &
executing pipes.</p>
-<h2 id="registered-pipes">Registered Pipes<a class="headerlink"
href="#registered-pipes" title="Permanent link">¶</a></h2>
-<p>a pipe configuration is a jcr node, with:</p>
+<p>A <code>Plumber</code> osgi service is provided to help getting, building
& executing pipes.</p>
+<h2 id="how-to-configure-execute-a-pipe">How to configure & execute a
pipe<a class="headerlink" href="#how-to-configure-execute-a-pipe"
title="Permanent link">¶</a></h2>
+<p>A pipe configuration is ultimately a jcr node, with properties (varying a
lot depending on the pipe type):</p>
<ul>
<li><code>sling:resourceType</code> property, which must be a pipe type
registered by the plumber </li>
<li><code>name</code> property, that will be used in bindings as an id, and
will be the key for the output bindings (default value being a value map of the
current output resource). Note that the node name will be used in case no name
is provided.</li>
@@ -154,45 +155,130 @@ h2:hover > .headerlink, h3:hover > .head
<li><code>additionalScripts</code> is a multi value property to declare
scripts that can be reused in expressions</li>
<li><code>conf</code> optional child node that contains addition configuration
of the pipe (depending on the type)</li>
</ul>
+<p>This configuration can be generated quickly through Pipe Builder API.</p>
+<p>Once configuration is done, it's possible to execute Pipes </p>
+<ul>
+<li>through plain java, with configured pipe resource as parameter,</li>
+<li>through PipeBuilder API,</li>
+<li>through HTTP API with GET (read) or POST (read/write) methods against
configured pipe resource</li>
+</ul>
+<h3 id="pipe-builder-api">Pipe Builder API<a class="headerlink"
href="#pipe-builder-api" title="Permanent link">¶</a></h3>
+<p>Plumber can provider a PipeBuilder with <code>newPipe(ResourceResolver
resolver)</code> API, that gives a fluent
+API to quickly configure and run pipes.
+e.g. </p>
+<div class="codehilite"><pre>`<span class="n">plumber</span><span
class="p">.</span><span class="n">newPipe</span><span class="p">(</span><span
class="n">resolver</span><span class="p">).</span><span
class="n">xpath</span><span class="p">(</span><span
class="s">'//element(*,nt:unstructured)[@sling:resourceType='</span><span
class="n">to</span><span class="o">/</span><span class="n">delete</span><span
class="o">'</span><span class="p">]</span>"<span
class="p">).</span><span class="n">rm</span><span class="p">().</span><span
class="n">run</span><span class="p">();</span>`
+</pre></div>
+
+
+<p>will search for resource of type <code>to/delete</code> and remove them.</p>
+<p>PipeBuilder basically will automatically configure a container pipe,
chaining pipes you can configure
+ with a fluent API:</p>
+<ul>
+<li><code>pipe(type)</code> generate a new subpipe,</li>
+<li><code>with(Object...)</code> add to actual subpipe configuration node
key/value configurations,</li>
+<li><code>expr(String)</code> add an expression configuration</li>
+<li><code>path(String)</code> add an input path,</li>
+<li><code>name(String)</code> specify a name (there would be a default one,
named 'one', 'two', ... depending on the position otherwise),</li>
+<li><code>conf(Object...)</code> add an extra configuration node with
key/value properties/values</li>
+</ul>
+<p>note that that configuration part has shortcuts for some pipes. Typically,
above sample is a shorter equivalent of </p>
+<p><code>plumber.newPipe(resolver).pipe('slingPipes/xpath').expr('//element(*,nt:unstructured)[@sling:resourceType='to/delete']").pipe('slingPipes/rm').run();</code></p>
+<p>when available, shortcuts will be specified next to each pipe type
documentation.</p>
+<p>Once you are happy with the pipe you have created, you can terminate the
builder with following command:</p>
+<ul>
+<li><code>build()</code> will build the pipe under /var/pipes/... (random node
under timed base path),</li>
+<li><code>run(bindings)</code> will build the pipe, and run it with additional
<code>bindings</code>,</li>
+<li><code>runAsync(bindings)</code> will do the same, but asynchronously,</li>
+<li><code>run()</code> will build & run synchronously the pipe, with no
bindings. </li>
+</ul>
+<h3 id="http-api">HTTP API<a class="headerlink" href="#http-api"
title="Permanent link">¶</a></h3>
+<h5 id="request-path">Request Path<a class="headerlink" href="#request-path"
title="Permanent link">¶</a></h5>
+<ul>
+<li>
+<p>either you'll need to create a slingPipes/plumber resource, say
<code>etc/pipes</code> and then to execute</p>
+<p>curl -u admin:admin -F "path=/etc/pipes/mySamplePipe"
http://localhost:8080/etc/pipes.json</p>
+</li>
+<li>
+<p>either you execute the request directly on the pipe Path, e.g.</p>
+<p>curl -u admin:admin http://localhost:8080/etc/pipes/mySamplePipe.json</p>
+</li>
+</ul>
+<p>which will return you the path of the resources that have been through the
output of the configured pipe.</p>
+<p>In the eventuality of a long execution (synchronous or asynchronous), you
can retrieve the status of a pipe, by executing</p>
+<p>GET /etc/pipes/mySamplePipe<strong>.status</strong>.json</p>
+<h5 id="request-parameter-binding">Request Parameter <code>binding</code><a
class="headerlink" href="#request-parameter-binding" title="Permanent
link">¶</a></h5>
+<p>you can add as <code>bindings</code> parameter a json object of global
bindings you want to add for the execution of the pipe</p>
+<p>e.g.</p>
+<div class="codehilite"><pre><span class="n">curl</span> <span
class="o">-</span><span class="n">u</span> <span class="n">admin</span><span
class="p">:</span><span class="n">admin</span> <span class="o">-</span><span
class="n">F</span> "<span class="n">path</span><span
class="p">=</span><span class="o">/</span><span class="n">etc</span><span
class="o">/</span><span class="n">pipes</span><span class="o">/</span><span
class="n">test</span>" <span class="o">-</span><span class="n">F</span>
"<span class="n">bindings</span><span class="p">={</span><span
class="n">testBinding</span><span class="p">:</span><span
class="s">'foo'</span><span class="p">}</span>" <span
class="n">http</span><span class="p">:</span><span class="o">//</span><span
class="n">localhost</span><span class="p">:</span>4502<span
class="o">/</span><span class="n">etc</span><span class="o">/</span><span
class="n">pipes</span><span class="p">.</span><span class="n">json</span>
+</pre></div>
+
+
+<p>will returns something like</p>
+<div class="codehilite"><pre><span class="p">{</span>"<span
class="nb">size</span>"<span class="p">:</span>2<span class="p">,</span>
"<span class="n">items</span>"<span class="p">:[</span>"<span
class="o">/</span><span class="n">one</span><span class="o">/</span><span
class="n">output</span><span class="o">/</span><span
class="n">resource</span>"<span class="p">,</span> "<span
class="n">another</span><span class="o">/</span><span
class="n">one</span>"<span class="p">]}</span>
+</pre></div>
+
+
+<h5 id="request-parameter-writer">Request Parameter <code>writer</code><a
class="headerlink" href="#request-parameter-writer" title="Permanent
link">¶</a></h5>
+<p>you can configure output of your servlet, with <code>writer</code>
parameter, a json object as a pattern to the result you want to have. The
values of the json
+object are expressions and can reuse each pipe's subpipe binding. </p>
+<p>e.g.</p>
+<div class="codehilite"><pre>curl -u admin:admin
http://localhost:4502/etc/pipes/users.json?writer={"user":"<span
class="cp">${</span><span class="n">user</span><span class="o">.</span><span
class="n">fullName</span><span class="cp">}</span>"}
+</pre></div>
+
+
+<p>will returns something similar to</p>
+<p>{"size":2, "items":[{'user':'John
Smith','path':'/home/users/q/q123jk1UAZS'},{'user':'John
Doe','path':'/home/users/q/q153jk1UAZS'}]}</p>
+<h5 id="request-parameter-dryrun">Request Parameter <code>dryRun</code><a
class="headerlink" href="#request-parameter-dryrun" title="Permanent
link">¶</a></h5>
+<p>if parameter dryRun is set to true, and the executed pipe is supposed to
modify content, it will log (at best it can) the change it <em>would</em> have
done, without doing anything</p>
+<h5 id="request-parameter-size">Request Parameter <code>size</code><a
class="headerlink" href="#request-parameter-size" title="Permanent
link">¶</a></h5>
+<p>default response is truncated to 10 items, if you need more (or less), you
can modify that settings with the size parameter</p>
+<h5 id="request-parameter-async">Request Parameter <code>async</code><a
class="headerlink" href="#request-parameter-async" title="Permanent
link">¶</a></h5>
+<p>allow asynchronous execution of the given type. This is advised in case you
plan your pipe execution to last longer than the session of your HTTP client.
+If used, the returned value will be id of the created sling Job.</p>
+<h2 id="registered-pipes">Registered Pipes<a class="headerlink"
href="#registered-pipes" title="Permanent link">¶</a></h2>
<h3 id="readers">readers<a class="headerlink" href="#readers" title="Permanent
link">¶</a></h3>
-<h4 id="base-pipe">Base pipe<a class="headerlink" href="#base-pipe"
title="Permanent link">¶</a></h4>
-<p>rather dummy pipe, outputs what is in input (so what is configured in
path). Handy for doing some test mostly, and giving basic functionalities to
others that inherit from it</p>
+<h5 id="base-pipe-echopath">Base pipe <code>echo(path)</code><a
class="headerlink" href="#base-pipe-echopath" title="Permanent
link">¶</a></h5>
+<p>outputs what is in input (so what is configured in path)</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/base</code></li>
</ul>
-<h4 id="slingquery-pipe">SlingQuery Pipe<a class="headerlink"
href="#slingquery-pipe" title="Permanent link">¶</a></h4>
+<h5 id="slingquery-pipe-expr">SlingQuery Pipe (<code>$(expr)</code>)<a
class="headerlink" href="#slingquery-pipe-expr" title="Permanent
link">¶</a></h5>
<p>executes $(getInput()).children(expression)</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/slingQuery</code></li>
<li><code>expr</code> mandatory property, contains slingQuery expression
through which getInput()'s children will be computed to getOutput()</li>
</ul>
-<h4 id="jsonpipe">JsonPipe<a class="headerlink" href="#jsonpipe"
title="Permanent link">¶</a></h4>
-<p>feeds bindings with remote json</p>
-<ul>
-<li><code>sling:resourceType</code> is <code>slingPipes/json</code></li>
-<li><code>expr</code> mandatory property contains url that will be called, the
json be sent to the output bindings, getOutput = getInput.
-An empty url or a failing url will block the pipe at that given place.</li>
-</ul>
-<h4 id="multipropertypipe">MultiPropertyPipe<a class="headerlink"
href="#multipropertypipe" title="Permanent link">¶</a></h4>
+<h5 id="multipropertypipe">MultiPropertyPipe<a class="headerlink"
href="#multipropertypipe" title="Permanent link">¶</a></h5>
<p>iterates through values of input multi value property and write them to
bindings</p>
<ul>
<li><code>sling:resourceType</code> is
<code>slingPipes/multiProperty</code></li>
<li><code>path</code> should be the path of a mv property</li>
</ul>
-<h4 id="xpathpipe">XPathPipe<a class="headerlink" href="#xpathpipe"
title="Permanent link">¶</a></h4>
+<h5 id="xpathpipe-xpathexpr">XPathPipe (<code>xpath(expr)</code>)<a
class="headerlink" href="#xpathpipe-xpathexpr" title="Permanent
link">¶</a></h5>
<p>retrieve resources resulting of an xpath query</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/xpath</code></li>
<li><code>expr</code> should be a valid xpath query</li>
</ul>
-<h3 id="jsonpipe_1">JsonPipe<a class="headerlink" href="#jsonpipe_1"
title="Permanent link">¶</a></h3>
+<h5 id="traversepipe-traverse">TraversePipe (<code>traverse()</code>)<a
class="headerlink" href="#traversepipe-traverse" title="Permanent
link">¶</a></h5>
+<p>traverse current input resource's tree, outputing, as resources, either the
node of the tree, either its properties</p>
+<ul>
+<li><code>sling:resourceType</code> is <code>slingPipes/traverse</code>,</li>
+<li><code>breadthFirst</code> the tree visit will be done deep first, unless
this flag is set to true,</li>
+<li><code>depth</code> max depth the visit should go to,</li>
+<li><code>properties</code> is a flag mentioning the pipe should traverse
node's property,</li>
+<li><code>nameGlobs</code> filters the property that should get outputed</li>
+</ul>
+<h5 id="jsonpipe-jsonexpr">JsonPipe (<code>json(expr)</code>)<a
class="headerlink" href="#jsonpipe-jsonexpr" title="Permanent
link">¶</a></h5>
<p>feeds bindings with remote json</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/json</code></li>
<li><code>expr</code> mandatory property contains url that will be called, the
json be sent to the output bindings, getOutput = getInput.
An empty url or a failing url will block the pipe at that given place.</li>
</ul>
-<h4 id="authorizablepipe">AuthorizablePipe<a class="headerlink"
href="#authorizablepipe" title="Permanent link">¶</a></h4>
+<p>In case the json is an array, the pipe will loop over
+the array elements, and output each one in the binding. Output resource
remains each time the input one.</p>
+<h5 id="authorizablepipe-authconf">AuthorizablePipe
(<code>auth(conf)</code>)<a class="headerlink"
href="#authorizablepipe-authconf" title="Permanent link">¶</a></h5>
<p>retrieve authorizable resource corresponding to the id passed in
expression, or if not found (or void expression),
from the input path, output the found authorizable's resource</p>
<ul>
@@ -203,10 +289,12 @@ from the input path, output the found au
<li><code>addToGroup</code> (expression) add found authorizable to
instanciated group (in that case, considered as a write pipe)</li>
<li><code>bindMembers</code> (boolean) if found authorizable is a group, bind
the members (in that case, considered as a write pipe)</li>
</ul>
-<h4 id="parentpipe">ParentPipe<a class="headerlink" href="#parentpipe"
title="Permanent link">¶</a></h4>
-<p>outputs the parent resource of input resource
-- <code>sling:resourceType</code> is <code>slingPipes/parent</code></p>
-<h4 id="filterpipe">FilterPipe<a class="headerlink" href="#filterpipe"
title="Permanent link">¶</a></h4>
+<h5 id="parentpipe-parent">ParentPipe (<code>parent()</code>)<a
class="headerlink" href="#parentpipe-parent" title="Permanent
link">¶</a></h5>
+<p>outputs the parent resource of input resource</p>
+<ul>
+<li><code>sling:resourceType</code> is <code>slingPipes/parent</code></li>
+</ul>
+<h5 id="filterpipe-grepconf">FilterPipe (<code>grep(conf)</code>)<a
class="headerlink" href="#filterpipe-grepconf" title="Permanent
link">¶</a></h5>
<p>outputs the input resource if its matches its configuration</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/filter</code></li>
@@ -215,21 +303,24 @@ on <code>./sub@prop</code> property of t
property is there with the value instantiated as a true boolean, then filter
will pass if corresponding node has no children.</li>
<li><code>slingPipesFilter_not='true'</code> inverts the expected result of
the filter</li>
</ul>
+<p><code>echo('/content/foo').grep('foo','bar','slingPipesFilter_not',true).run()</code>
will either return <code>/content/foo</code> either nothing depending on it
+not containing <code>@foo=bar</code></p>
<h3 id="containers">containers<a class="headerlink" href="#containers"
title="Permanent link">¶</a></h3>
-<h4 id="container-pipe">Container Pipe<a class="headerlink"
href="#container-pipe" title="Permanent link">¶</a></h4>
+<h5 id="container-pipe">Container Pipe<a class="headerlink"
href="#container-pipe" title="Permanent link">¶</a></h5>
<p>assemble a sequence of pipes</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/container</code></li>
<li><code>conf</code> node contains child pipes' configurations, that will be
configured in the order they are found (note you should use
sling:OrderedFolder)</li>
</ul>
-<h4 id="referencepipe">ReferencePipe<a class="headerlink"
href="#referencepipe" title="Permanent link">¶</a></h4>
+<p>Note that pipe builder api automatically creates one for you to chain the
subpipe you are configuring</p>
+<h5 id="referencepipe">ReferencePipe<a class="headerlink"
href="#referencepipe" title="Permanent link">¶</a></h5>
<p>execute the pipe referenced in path property</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/reference</code></li>
<li><code>path</code> path of the referenced pipe</li>
</ul>
<h3 id="writers">writers<a class="headerlink" href="#writers" title="Permanent
link">¶</a></h3>
-<h4 id="write-pipe">Write Pipe<a class="headerlink" href="#write-pipe"
title="Permanent link">¶</a></h4>
+<h5 id="write-pipe-writeconf">Write Pipe (<code>write(conf)</code>)<a
class="headerlink" href="#write-pipe-writeconf" title="Permanent
link">¶</a></h5>
<p>writes given nodes & properties to current input</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/write</code></li>
@@ -239,13 +330,14 @@ Note that properties that will be evalua
removed from it. E.g. <code>./conf/some/node@prop=${null}</code> will add
<code>./conf/some/node</code> structure
if not in current input resource, but remove its <code>prop</code> property if
any).</li>
</ul>
-<h3 id="movepipe">MovePipe<a class="headerlink" href="#movepipe"
title="Permanent link">¶</a></h3>
+<p>e.g. <code>echo('/content/foo').write('foo','bar').run()</code> will write
<code>@foo=bar</code> in <code>/content/foo</code></p>
+<h5 id="movepipe-mvexpr">MovePipe (<code>mv(expr)</code>)<a class="headerlink"
href="#movepipe-mvexpr" title="Permanent link">¶</a></h5>
<p>JCR move of current input to target path (can be a node or a property)</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/mv</code></li>
-<li><code>expr</code> target path, note that parent path must exists</li>
+<li><code>expr</code> full target path, note that parent path must exists</li>
</ul>
-<h4 id="removepipe">RemovePipe<a class="headerlink" href="#removepipe"
title="Permanent link">¶</a></h4>
+<h5 id="removepipe-rm">RemovePipe (<code>rm()</code>)<a class="headerlink"
href="#removepipe-rm" title="Permanent link">¶</a></h5>
<p>removes the input resource, returns the parent, regardless of the resource
being a node, or
a property</p>
<ul>
@@ -253,7 +345,7 @@ a property</p>
<li><code>conf</code> node tree that will be used to filter relative
properties & subtrees to the current resource to remove.
A subnode is considered to be removed if it has no property configured, nore
any child.</li>
</ul>
-<h4 id="pathpipe">PathPipe<a class="headerlink" href="#pathpipe"
title="Permanent link">¶</a></h4>
+<h5 id="pathpipe-mkdirexpr">PathPipe (<code>mkdir(expr)</code>)<a
class="headerlink" href="#pathpipe-mkdirexpr" title="Permanent
link">¶</a></h5>
<p>get or create path given in expression</p>
<ul>
<li><code>sling:resourceType</code> is <code>slingPipes/path</code></li>
@@ -272,113 +364,25 @@ A subnode is considered to be removed if
is the path of the current resource of previous pipe named
<code>previousPipe</code></p>
<p>global bindings can be set at pipe execution, external scripts can be added
to the execution as well (see pipe
configurations)</p>
-<h2 id="how-to-execute-a-pipe">How to execute a pipe<a class="headerlink"
href="#how-to-execute-a-pipe" title="Permanent link">¶</a></h2>
-<p>for now it's possible to execute Pipes through GET (read) or POST
(read/write) commands:</p>
-<h3 id="request-path">Request Path<a class="headerlink" href="#request-path"
title="Permanent link">¶</a></h3>
-<ul>
-<li>
-<p>either you'll need to create a slingPipes/plumber resource, say
<code>etc/pipes</code> and then to execute</p>
-<p>curl -u admin:admin -F "path=/etc/pipes/mySamplePipe"
http://localhost:8080/etc/pipes.json</p>
-</li>
-<li>
-<p>either you execute the request directly on the pipe Path, e.g.</p>
-<p>curl -u admin:admin http://localhost:8080/etc/pipes/mySamplePipe.json</p>
-</li>
-</ul>
-<p>which will return you the path of the pipes that have been through the
output of the configured pipe.</p>
-<h3 id="request-parameter-binding">Request Parameter <code>binding</code><a
class="headerlink" href="#request-parameter-binding" title="Permanent
link">¶</a></h3>
-<p>you can add as <code>bindings</code> parameter a json object of global
bindings you want to add for the execution of the pipe</p>
-<p>e.g.</p>
-<div class="codehilite"><pre><span class="n">curl</span> <span
class="o">-</span><span class="n">u</span> <span class="n">admin</span><span
class="p">:</span><span class="n">admin</span> <span class="o">-</span><span
class="n">F</span> "<span class="n">path</span><span
class="p">=</span><span class="o">/</span><span class="n">etc</span><span
class="o">/</span><span class="n">pipes</span><span class="o">/</span><span
class="n">test</span>" <span class="o">-</span><span class="n">F</span>
"<span class="n">bindings</span><span class="p">={</span><span
class="n">testBinding</span><span class="p">:</span><span
class="s">'foo'</span><span class="p">}</span>" <span
class="n">http</span><span class="p">:</span><span class="o">//</span><span
class="n">localhost</span><span class="p">:</span>4502<span
class="o">/</span><span class="n">etc</span><span class="o">/</span><span
class="n">pipes</span><span class="p">.</span><span class="n">json</span>
-</pre></div>
-
-
-<p>will returns something like</p>
-<div class="codehilite"><pre><span class="p">{</span>"<span
class="nb">size</span>"<span class="p">:</span>2<span class="p">,</span>
"<span class="n">items</span>"<span class="p">:[</span>"<span
class="o">/</span><span class="n">one</span><span class="o">/</span><span
class="n">output</span><span class="o">/</span><span
class="n">resource</span>"<span class="p">,</span> "<span
class="n">another</span><span class="o">/</span><span
class="n">one</span>"<span class="p">]}</span>
-</pre></div>
-
-
-<h3 id="request-parameter-writer">Request Parameter <code>writer</code><a
class="headerlink" href="#request-parameter-writer" title="Permanent
link">¶</a></h3>
-<p>you can add as <code>writer</code> parameter a json object as a pattern to
the result you want to have. The values of the json
-object are expressions and can reuse each pipe's subpipe binding.
-Note
-this works only if the pipe called is a container
-pipe.</p>
-<p>e.g.</p>
-<div class="codehilite"><pre>curl -u admin:admin
http://localhost:4502/etc/pipes/users.json?writer={"user":"<span
class="cp">${</span><span class="n">user</span><span class="o">.</span><span
class="n">fullName</span><span class="cp">}</span>"}
-</pre></div>
-
-
-<p>will returns something similar to</p>
-<p>{"size":2, "items":[{'user':'John
Smith','path':'/home/users/q/q123jk1UAZS'},{'user':'John
Doe','path':'/home/users/q/q153jk1UAZS'}]}</p>
-<h3 id="request-parameter-dryrun">Request Parameter <code>dryRun</code><a
class="headerlink" href="#request-parameter-dryrun" title="Permanent
link">¶</a></h3>
-<p>if parameter dryRun is set to true, and the executed pipe is supposed to
modify content, it will log (at best it can) the change it <em>would</em> have
done, without doing anything</p>
-<h3 id="request-parameter-size">Request Parameter <code>size</code><a
class="headerlink" href="#request-parameter-size" title="Permanent
link">¶</a></h3>
-<p>default response is truncated to 10 items, if you need more (or less), you
can modify that settings with the size parameter</p>
<h2 id="sample-configurations">sample configurations<a class="headerlink"
href="#sample-configurations" title="Permanent link">¶</a></h2>
-<h3 id="slingquery-write">slingQuery | write<a class="headerlink"
href="#slingquery-write" title="Permanent link">¶</a></h3>
-<p>this pipe parse all profile nodes, and</p>
-<div class="codehilite"><pre>{
- "sling:resourceType":"slingPipes/container",
- "name":"Dummy User prefix Sample",
- "jcr:description":"prefix all full names of profile with
"Mr" or "Ms" depending on gender",
- "conf":{
- "profile": {
- "sling:resourceType":"slingPipes/slingQuery",
- "expr":"nt:unstructured#profile",
- "path":"/home/users"
- },
- "writeFullName": {
- "sling:resourceType":"slingPipes/write",
- "conf": {
- "fullName":"<span class="cp">${</span><span
class="p">(</span><span class="n">profile</span><span class="o">.</span><span
class="n">gender</span> <span class="o">===</span> <span
class="s">'female'</span> <span class="err">?</span> <span
class="s">'Ms '</span> <span class="o">+</span> <span
class="n">profile</span><span class="o">.</span><span class="n">fullName</span>
<span class="p">:</span> <span class="s">'Mr '</span> <span
class="o">+</span> <span class="n">profile</span><span class="o">.</span><span
class="n">fullName</span><span class="p">)</span><span
class="cp">}</span>",
- "generatedBy":"slingPipes"
- }
- }
- }
-}
+<h5 id="slingquery-write">slingQuery | write<a class="headerlink"
href="#slingquery-write" title="Permanent link">¶</a></h5>
+<p>write repository user prefix Ms/Mr depending on gender</p>
+<div class="codehilite"><pre>
.newPipe(resolver).xpath('/jcr:root/home/users//element(*,rep:Users)')
+ .$('nt:unstructured#profile')
+ .write("fullName","<span class="cp">${</span><span
class="p">(</span><span class="n">profile</span><span class="o">.</span><span
class="n">gender</span> <span class="o">===</span> <span
class="s">'female'</span> <span class="err">?</span> <span
class="s">'Ms '</span> <span class="o">+</span> <span
class="n">profile</span><span class="o">.</span><span class="n">fullName</span>
<span class="p">:</span> <span class="s">'Mr '</span> <span
class="o">+</span> <span class="n">profile</span><span class="o">.</span><span
class="n">fullName</span><span class="p">)</span><span
class="cp">}</span>")
+ .run()
</pre></div>
-<h3 id="slingquery-multiproperty-authorizable-write">slingQuery |
multiProperty | authorizable | write<a class="headerlink"
href="#slingquery-multiproperty-authorizable-write" title="Permanent
link">¶</a></h3>
-<div class="codehilite"><pre><span class="p">{</span>
- <span class="s">"jcr:primaryType"</span>: <span
class="s">"sling:Folder"</span><span class="p">,</span>
- <span class="s">"jcr:description"</span>: <span
class="s">"move badge<->user relation ship from badge MV property to
a user MV property"</span>
- <span class="s">"name"</span>: <span
class="s">"badges"</span><span class="p">,</span>
- <span class="s">"sling:resourceType"</span>: <span
class="s">"slingPipes/container"</span><span class="p">,</span>
- <span class="s">"conf"</span>: <span class="p">{</span>
- <span class="s">"jcr:primaryType"</span>: <span
class="s">"sling:OrderedFolder"</span><span class="p">,</span>
- <span class="s">"badge"</span>: <span class="p">{</span>
- <span class="s">"jcr:primaryType"</span>: <span
class="s">"sling:Folder"</span><span class="p">,</span>
- <span class="s">"jcr:description"</span>: <span
class="s">"outputs all badge component resources"</span><span
class="p">,</span>
- <span class="s">"expr"</span>: <span
class="s">"[sling:resourceType=myApp/components/badge]"</span><span
class="p">,</span>
- <span class="s">"path"</span>: <span
class="s">"/etc/badges/badges-admin/jcr:content"</span><span
class="p">,</span>
- <span class="s">"sling:resourceType"</span>: <span
class="s">"slingPipes/slingQuery"</span>
- <span class="p">},</span>
- <span class="s">"profile"</span>: <span class="p">{</span>
- <span class="s">"jcr:primaryType"</span>: <span
class="s">"sling:Folder"</span><span class="p">,</span>
- <span class="s">"jcr:description"</span>: <span
class="s">"retrieve all user ids from a mv property"</span><span
class="p">,</span>
- <span class="s">"path"</span>: <span
class="s">"${path.badge}/profiles"</span><span class="p">,</span>
- <span class="s">"sling:resourceType"</span>: <span
class="s">"slingPipes/multiProperty"</span>
- <span class="p">},</span>
- <span class="s">"user"</span>: <span class="p">{</span>
- <span class="s">"jcr:primaryType"</span>: <span
class="s">"sling:OrderedFolder"</span><span class="p">,</span>
- <span class="s">"jcr:description"</span>: <span
class="s">"outputs user resource"</span><span class="p">,</span>
- <span class="s">"expr"</span>: <span
class="s">"profile"</span><span class="p">,</span>
- <span class="s">"sling:resourceType"</span>: <span
class="s">"slingPipes/authorizable"</span>
- <span class="p">},</span>
- <span class="s">"write"</span>: <span class="p">{</span>
- <span class="s">"jcr:primaryType"</span>: <span
class="s">"sling:OrderedFolder"</span><span class="p">,</span>
- <span class="s">"jcr:descritption"</span>: <span
class="s">"patches the badge path to the badges property of the user
profile"</span>
- <span class="s">"path"</span>: <span
class="s">"${path.user}/profile"</span><span class="p">,</span>
- <span class="s">"sling:resourceType"</span>: <span
class="s">"slingPipes/write"</span><span class="p">,</span>
- <span class="s">"conf"</span>: <span class="p">{</span>
- <span class="s">"jcr:primaryType"</span>: <span
class="s">"nt:unstructured"</span><span class="p">,</span>
- <span class="s">"badges"</span>: <span
class="s">"+[${path.badge}]"</span>
- <span class="p">}</span>
- <span class="p">}</span>
- <span class="p">}</span>
-<span class="p">}</span>
+<h5 id="slingquery-multiproperty-authorizable-write">slingQuery |
multiProperty | authorizable | write<a class="headerlink"
href="#slingquery-multiproperty-authorizable-write" title="Permanent
link">¶</a></h5>
+<p>move badge<->user relation ship from badge->users MV property to a
user->badges MV property</p>
+<div class="codehilite"><pre>
.newPipe(resolver).echo('/etc/badges/jcr:content/par')
+
.$('[sling:resourceType=myApp/components/badge]').name('badge')
+ .pipe('slingPipes/multiProperty').path('<span
class="cp">${</span><span class="n">path</span><span class="o">.</span><span
class="n">badge</span><span
class="cp">}</span>/profiles').name('profile')
+ .auth('<span class="cp">${</span><span class="n">profile</span><span
class="cp">}</span>').name('user')
+ .echo('<span class="cp">${</span><span class="n">path</span><span
class="o">.</span><span class="n">user</span><span
class="cp">}</span>/profile')
+ .write('badges','+[<span class="cp">${</span><span
class="n">path</span><span class="o">.</span><span class="n">badge</span><span
class="cp">}</span>]')
+ .run()
</pre></div>
@@ -460,7 +464,7 @@ pipe.</p>
<li>jackrabbit api (2.7.5+) (used in AuthorizablePipe)</li>
</ul>
<div class="timestamp" style="margin-top: 30px; font-size: 80%;
text-align: right;">
- Rev. 1731045 by rombert on Thu, 18 Feb 2016 10:54:15 +0000
+ Rev. 1806694 by npeltier on Wed, 30 Aug 2017 13:59:44 +0000
</div>
<div class="trademarkFooter">
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache
Sling project