Return-Path: Delivered-To: apmail-incubator-jackrabbit-commits-archive@www.apache.org Received: (qmail 87334 invoked from network); 11 Aug 2005 18:06:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Aug 2005 18:06:36 -0000 Received: (qmail 87578 invoked by uid 500); 11 Aug 2005 18:06:34 -0000 Mailing-List: contact jackrabbit-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-commits@incubator.apache.org Received: (qmail 87341 invoked by uid 500); 11 Aug 2005 18:06:32 -0000 Delivered-To: apmail-incubator-jackrabbit-cvs@incubator.apache.org Received: (qmail 87328 invoked by uid 99); 11 Aug 2005 18:06:32 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 11 Aug 2005 11:06:25 -0700 Received: (qmail 87210 invoked by uid 65534); 11 Aug 2005 18:06:25 -0000 Message-ID: <20050811180625.87209.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r231495 [4/7] - in /incubator/jackrabbit/trunk/contrib/jcr-commands: ./ applications/test/ applications/test/fs/ applications/test/fs/dummy folder/ benchmarking/ src/java/ src/java/org/apache/jackrabbit/chain/ src/java/org/apache/jackrabbit... Date: Thu, 11 Aug 2005 18:06:07 -0000 To: jackrabbit-cvs@incubator.apache.org From: edgarpoce@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/command-line.xml URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/command-line.xml?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/command-line.xml (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/command-line.xml Thu Aug 11 11:04:29 2005 @@ -0,0 +1,602 @@ + + + + + + + + + + + + + + + + + + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/command-line.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/digester-rules.dtd URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/digester-rules.dtd?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/digester-rules.dtd (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/digester-rules.dtd Thu Aug 11 11:04:29 2005 @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/digester-rules.dtd ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/exceptions.properties URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/exceptions.properties?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/exceptions.properties (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/exceptions.properties Thu Aug 11 11:04:29 2005 @@ -0,0 +1,18 @@ +cat.unsupported.type=Unsupported type to display contents "{0}". +missing.paramater=Missing parameter "{0}". +file.flag.unset=The file flag is unset. +file.not.found=File not found at {0}. +illegalargument.no.iterator.under=Illegal argument. There is no iterator under "{0}". +more.arguments.than.expected=More arguments than expected. +no.attribute.for.name=No attribute for name "{0}" in Command "{1}". +no.opt.for.name=No Option for name "{0}". +no.option.for.name=No Option for name "{0}". +no.flag.for.name=No Flag for name "{0}". +no.command.in.catalog.for.name=No Command in Catalog for name "{0}". +no.command.for.name=No Command for name "{0}". +parse.input.empty=Unable to parse, input is empty. +parse.arguments=Unable to parse arguments. {0}. +parse.instantiate.command=Unable to instantiate Command "{0}". +parse.command.property=Unable to set "{0}-{1}" with value "{2}". +parse.unable.to.get.descriptor=Unable to get command descriptor. {0}. +unkown.arguments=unkown arguments. Known arguments = {0}, received = {1}. Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/exceptions.properties ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/package.html URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/package.html?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/package.html (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/package.html Thu Aug 11 11:04:29 2005 @@ -0,0 +1,2 @@ +

This package contains a JCR Command Line Interface backed by Commons chain + commands.

\ No newline at end of file Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/package.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/resources.properties URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/resources.properties?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/resources.properties (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/resources.properties Thu Aug 11 11:04:29 2005 @@ -0,0 +1,231 @@ +#welcome +welcome=welcome + +# common +boolean=boolean +classname=class name +commandname=command name +destination=destination +elapsedtime=elapsed time +exception.occurred=an exception occurred +exception=exception +export.overwrite=overwrite the file in the given path if necessary. +exportview.from=Source node +exportview.to=Target file where the xml view will be stored +exportview.skipBinary=if it's true the binary properties will be serialized as if they are empty +exportview.noRecurse=if it's true it doesn't include the child nodes +file=file +flag=flag +folder=folder +fs.path=file system path +from=from +in=in +jcr.path=jcr path +message=message +mixin.name=mixin name +name.pattern=name pattern +unknown.command=unknown command +node.name=node name +node.path=node path +not.connected=not connected +not.logged.in=not logged in +overwrite=overwrite +running=running +show.max.items=max number of items to show +stmt=statement +source=source +to=to +var.name=variable name + +# --------------------------------- +# CLI +# --------------------------------- + +# prompt +prompt.display.stacktrace=Do you want to see the stack trace? [y/n] + +# source +source=Execute the script at the given file + +# --------------------------------- +# JCR COMMANDS +# --------------------------------- + +# addmixin +addmixin=Add a mixin node type to the given node +addmixin.mixin=mixin name + +# addnode +addnode=Add a node to the current working node + +# clear workspace +clearworkspace=Clear the Workspace by removing all the nodes and properties. + +# collect +collectitems=Collect items under the current working node +collectitems.target=target variable where the collected items will be stored + +# collect nodes +collectnodes=Collect nodes under the current working node +collectnodes.target=target variable where the collected nodes will be stored + +# collect properties +collectproperties=Collect properties under the current working node +collectproperties.target=target variable where the collected properties will be stored + +# copy +copy=copy a node +copy.from=source, absolute or relative path +copy.to=destination, only absolute path + +# current node +currentnode=Change the current working node to the given path + +# export doc view +exportdocview=Serialize the node to the given file using the document view format + +# export fs +exportfilesystem=Export node of type nt:file and nt:folder to the file system. + +# export property +exportproperty=Export the given property to the file system +exportproperty.idx=value index to export + +# export sys view +exportsysview=Serialize the node to the given file using the system view format + +# import fs +importfilesystem= \ +This command imports data from the file system. \n \ +If the given path refers to a file, it's imported \ +to the repostitory to a node of type nt:file under \ +the current working node. \ +If the given path refers to a folder, all the tree under the given folder is \ +imported. + +# import xml +importxml=Import the given xml file either in system or documen view to the repository +importxml.uuidBehaviour=uuid creation behaviour + +# login +login=login to the current repository. +login.u=user name [default = anonymous] +login.p=password [default = anonymous] +login.w=workspace + +#logout +logout=logout from the current repository. + +#move +move=move a node +move.from=source, absolute or relative path +move.to=destination, only absolute path + +# refresh +refresh=Refresh the session to reflect the current saved state. +refresh.keepChanges=keep or discard the changes flag + +# remove item +remove=Remove the item at the given path. + +# remove items +removeitems=Remove any item under the current working node that match the given name pattern. + +# removemixin +removemixin=Remove a mixin from the given node + +# rename +rename=rename the child node with the given name +rename.from=source node +rename.to=destination node + +# Save session +save=Save the current session + +# Save node +savenode=Save the current working node + +# set multivalue property +setmultivalueproperty=Set a multivalue property. +setmultivalueproperty.regExp=Regular expression used to split the value into tokens. + +# set property +setproperty=Set the given value to the property. +setproperty.name=property name +setproperty.value=property value +setproperty.type=property type. Default is String. + +# set property +setpropertyfromfile=Set the property's value with the content of the given path. +setpropertyfromfile.path=path to the file + +# sql query +sql=SQL query +sql.statement=SQL statement +sql.target=target variables to store the nodes included in te query result + +# start jackrabbit +startjackrabbit=Start a local Jackrabbit instance +startjackrabbit.config=Repository config file, usually called repository.xml +startjackrabbit.home=Repository location + +# stop jackrabbit +stopjackrabbit=Stop the Jackrabbit instance in use + +# --------------------------------- +# INFO COMMANDS +# --------------------------------- + +# help +help=Show available commands +help.command=[optional] Command help + +# ls items +lsitems=Lists nodes and properties under the current node +lsitems.pattern=filter pattern + +# lscollec +lscollect=List collected items under the current node +lscollect.namepattern=[optional] name pattern + +# lsnodes +lsnodes=List nodes under the current node +lsnodes.nsize=Show the number of nodes under the current working node +lsnodes.psize=Show the number of properties under the current working node +lsnodes.rsize=Show the number of references that point to the current working node +lsnodes.m=Show the full list o mixin that apply to the current working node +lsnodes.v=Show whether the current working node is versionable +lsnodes.l=Show whether the current working node is lockable +lsnodes.r=Show whether the current working node is referenceable +lsnodes.locked=Show whether the current working node is locked +lsnodes.hasLock=Show whether the current working node has a lock +lsnodes.new=Show whether the current working node is new +lsnodes.mod=Show whether the current working node is modified +lsnodes.path=Show the full path to the node + +# ls collect nodes +lscollectnodes=List collected nodes under the current node +lscollectnodes.namepattern=[optional] name pattern + + +# ls collect properties +lscollectproperties=List collected properties under the current node +lscollectproperties.namepattern=[optional] name pattern + +# lsproperties +lsproperties=List properties under the current node +lsproperties.namepattern=[optional] name pattern + +# lsreferences +lsreferences=List references to the given node. + +# cat property +cat=Display the content of a property, or the content of a node of type nt:file or nt:resource. +cat.idx=index of the value to show + +# dump +dump=Dump stored data from the current working node + +# xpathquery +xpathquery=xpath query +xpathquery.statement=statement \ No newline at end of file Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/cli/resources.properties ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractCollect.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractCollect.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractCollect.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractCollect.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,185 @@ +/* + * Copyright 2002-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.jackrabbit.chain.command; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.ResourceBundle; + +import javax.jcr.Node; + +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; +import org.apache.jackrabbit.chain.CtxHelper; +import org.apache.jackrabbit.util.ChildrenCollectorFilter; + +/** + * Collect the children items and store them under the given key.
+ * The Command attributes are set from the specified literal values, or from the + * context attributes stored under the given keys. + * + */ +public abstract class AbstractCollect implements Command +{ + /** Resource bundle */ + protected ResourceBundle bundle = ResourceBundle.getBundle(this.getClass() + .getPackage().getName() + + ".resources"); + + // ---------------------------- < literals > + + /** depth literal value */ + private String depth; + + /** name pattern literal value */ + private String namePattern; + + // ---------------------------- < keys > + + /** context attribute key for the depth attribute */ + private String depthKey; + + /** context attribute key for the name pattern attribute */ + private String namePatternKey; + + /** context attribute key for the destination attribute */ + private String toKey; + + /** + * @inheritDoc + */ + public final boolean execute(Context ctx) throws Exception + { + if (this.toKey == null || this.toKey.length() == 0) + { + throw new IllegalStateException("target variable is not set"); + } + + Node node = CtxHelper.getCurrentNode(ctx); + + String namePattern = CtxHelper.getAttr(this.namePattern, + this.namePatternKey, ctx); + + int depth = CtxHelper.getIntAttr(this.depth, + this.depthKey, 1, ctx); + + if (namePattern == null || namePattern.length() == 0) + { + namePattern = "*"; + } + + Collection items = new ArrayList(); + ChildrenCollectorFilter collector = new ChildrenCollectorFilter( + namePattern, items, isCollectNodes(), isCollectProperties(), + depth); + collector.visit(node); + ctx.put(this.toKey, items.iterator()); + + return false; + } + + /** + * @return Returns the depth. + */ + public String getDepth() + { + return depth; + } + + /** + * @param depth + * The depth to set. + */ + public void setDepth(String depth) + { + this.depth = depth; + } + + /** + * @return Returns the depthKey. + */ + public String getDepthKey() + { + return depthKey; + } + + /** + * @param depthKey + * Set the context attribute key for the depth attribute + */ + public void setDepthKey(String depthKey) + { + this.depthKey = depthKey; + } + + /** + * @return Returns the namePattern. + */ + public String getNamePattern() + { + return namePattern; + } + + /** + * @param namePattern + * The namePattern to set. + */ + public void setNamePattern(String namePattern) + { + this.namePattern = namePattern; + } + + /** + * @return Returns the namePatternKey. + */ + public String getNamePatternKey() + { + return namePatternKey; + } + + /** + * @param namePatternKey + * context attribute key for the name pattern attribute + */ + public void setNamePatternKey(String namePatternKey) + { + this.namePatternKey = namePatternKey; + } + + /** + * @return Returns the toKey. + */ + public String getToKey() + { + return toKey; + } + + /** + * @param toKey + * context attribute key for the destination attribute + */ + public void setToKey(String toKey) + { + this.toKey = toKey; + } + + /** Collect nodes flag */ + protected abstract boolean isCollectNodes(); + + /** Collect properties flag */ + protected abstract boolean isCollectProperties(); +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractCollect.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractSetProperty.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractSetProperty.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractSetProperty.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractSetProperty.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,153 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +import org.apache.commons.chain.Command; + +/** + * SetProperty superclass.
+ * The Command attributes are set from the specified literal values, or from the + * context attributes stored under the given keys. + */ +public abstract class AbstractSetProperty implements Command +{ + + // ---------------------------- < literals > + + /** Property name */ + protected String propertyName; + + /** Propety type */ + protected String propertyType; + + /** Property value */ + protected String value; + + // ---------------------------- < keys > + + /** Property name key */ + protected String propertyNameKey; + + /** Propety type key */ + protected String propertyTypeKey; + + /** Property value key */ + protected String valueKey; + + /** + * @return Returns the name. + */ + public String getPropertyName() + { + return propertyName; + } + + /** + * @param name + * The name to set. + */ + public void setPropertyName(String name) + { + this.propertyName = name; + } + + /** + * @return Returns the type. + */ + public String getPropertyType() + { + return propertyType; + } + + /** + * @param type + * The type to set. + */ + public void setPropertyType(String type) + { + this.propertyType = type; + } + + /** + * @return the property value + */ + public String getValue() + { + return value; + } + + /** + * Sets property value + * + * @param value + */ + public void setValue(String value) + { + this.value = value; + } + + /** + * @return Returns the nameKey. + */ + public String getPropertyNameKey() + { + return propertyNameKey; + } + + /** + * @param nameKey + * Set the context attribute key for the name attribute. + */ + public void setPropertyNameKey(String nameKey) + { + this.propertyNameKey = nameKey; + } + + /** + * @return Returns the propertyTypeKey. + */ + public String getPropertyTypeKey() + { + return propertyTypeKey; + } + + /** + * @param propertyTypeKey + * Set the context attribute key for the property type attribute. + */ + public void setPropertyTypeKey(String propertyTypeKey) + { + this.propertyTypeKey = propertyTypeKey; + } + + /** + * @return Returns the valueKey. + */ + public String getValueKey() + { + return valueKey; + } + + /** + * @param valueKey + * Set the context attribute key for the value attribute. + */ + public void setValueKey(String valueKey) + { + this.valueKey = valueKey; + } +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AbstractSetProperty.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddMixin.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddMixin.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddMixin.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddMixin.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,126 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +import javax.jcr.Node; + +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; +import org.apache.jackrabbit.chain.CtxHelper; + +/** + * Add a mixin to the given node + */ +public class AddMixin implements Command +{ + // ---------------------------- < literals > + /** node path */ + private String path; + + /** mixin name */ + private String mixinName; + + // ---------------------------- < keys > + /** node path */ + private String pathKey; + + /** mixin name */ + private String mixinNameKey; + + /** + * @return Returns the mixinName. + */ + public String getMixinName() + { + return mixinName; + } + + /** + * @param mixinName + * The mixinName to set. + */ + public void setMixinName(String mixinName) + { + this.mixinName = mixinName; + } + + /** + * @return Returns the mixinNameKey. + */ + public String getMixinNameKey() + { + return mixinNameKey; + } + + /** + * @param mixinNameKey + * The mixinNameKey to set. + */ + public void setMixinNameKey(String mixinNameKey) + { + this.mixinNameKey = mixinNameKey; + } + + /** + * @return Returns the path. + */ + public String getPath() + { + return path; + } + + /** + * @param path + * The path to set. + */ + public void setPath(String path) + { + this.path = path; + } + + /** + * @return Returns the pathKey. + */ + public String getPathKey() + { + return pathKey; + } + + /** + * @param pathKey + * The pathKey to set. + */ + public void setPathKey(String pathKey) + { + this.pathKey = pathKey; + } + + /** + * @inheritDoc + */ + public boolean execute(Context ctx) throws Exception + { + String path = CtxHelper.getAttr(this.path, this.pathKey, ctx); + String mixin = CtxHelper + .getAttr(this.mixinName, this.mixinNameKey, ctx); + + Node n = CtxHelper.getNode(ctx, path); + n.addMixin(mixin); + + return false; + } +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddMixin.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddNode.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddNode.java?rev=231495&r1=231494&r2=231495&view=diff ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddNode.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/AddNode.java Thu Aug 11 11:04:29 2005 @@ -20,60 +20,118 @@ import org.apache.commons.chain.Command; import org.apache.commons.chain.Context; -import org.apache.jackrabbit.chain.ContextHelper; +import org.apache.jackrabbit.chain.CtxHelper; /** - * Adds a node to the current working node. + * Add a node to the current working node.
+ * The Command attributes are set from the specified literal values, or from the + * context attributes stored under the given keys. */ -public class AddNode implements Command { - /** Node type */ - private String type; - - /** Node name */ - private String name; - - /* - * (non-Javadoc) - * - * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context) - */ - public boolean execute(Context ctx) throws Exception { - Node node = ContextHelper.getCurrentNode(ctx); - if (this.type == null) { - node.addNode(name); - } else { - node.addNode(type, name); - } - return false; - } - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @param name - * The name to set. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - /** - * @param type - * The type to set. - */ - public void setType(String type) { - this.type = type; - } +public class AddNode implements Command +{ + + // ---------------------------- < literals > + /** Node type */ + private String nodeType; + + /** Node name */ + private String nodeName; + + // ---------------------------- < keys > + /** Node type key */ + private String nodeTypeKey; + + /** Node name key */ + private String nodeNameKey; + + /** + * @inheritDoc + */ + public boolean execute(Context ctx) throws Exception + { + Node node = CtxHelper.getCurrentNode(ctx); + + String nodeType = CtxHelper.getAttr(this.nodeType, + this.nodeTypeKey, ctx); + + String name = CtxHelper.getAttr(this.nodeName, this.nodeNameKey, ctx); + + if (nodeType == null) + { + node.addNode(name); + } else + { + node.addNode(name, nodeType); + } + return false; + } + + /** + * @return Returns the name. + */ + public String getNodeName() + { + return nodeName; + } + + /** + * @param name + * The literal name to set. + */ + public void setNodeName(String name) + { + this.nodeName = name; + } + + /** + * @return Returns the type. + */ + public String getNodeType() + { + return nodeType; + } + + /** + * @param type + * The literal note type to set. + */ + public void setNodeType(String type) + { + this.nodeType = type; + } + + /** + * @return Returns the nameKey. + */ + public String getNodeNameKey() + { + return nodeNameKey; + } + + /** + * @param nameKey + * Set the context attribute key for the name attribute. + */ + public void setNodeNameKey(String nameKey) + { + this.nodeNameKey = nameKey; + } + + /** + * @return Returns the nodeTypeKey. + */ + public String getNodeTypeKey() + { + return nodeTypeKey; + } + + /** + * @param nodeTypeKey + * Set the context attribute key for the node type attribute. + */ + public void setNodeTypeKey(String nodeTypeKey) + { + this.nodeTypeKey = nodeTypeKey; + } + } Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ClearWorkspace.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ClearWorkspace.java?rev=231495&r1=231494&r2=231495&view=diff ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ClearWorkspace.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ClearWorkspace.java Thu Aug 11 11:04:29 2005 @@ -18,28 +18,40 @@ import javax.jcr.Node; import javax.jcr.NodeIterator; +import javax.jcr.Property; +import javax.jcr.PropertyIterator; import javax.jcr.Session; import org.apache.commons.chain.Command; import org.apache.commons.chain.Context; import org.apache.jackrabbit.JcrConstants; -import org.apache.jackrabbit.chain.ContextHelper; +import org.apache.jackrabbit.chain.CtxHelper; /** - * Clears the Workspace + * Clear the Workspace */ public class ClearWorkspace implements Command { public boolean execute(Context ctx) throws Exception { - Session s = ContextHelper.getSession(ctx) ; - NodeIterator iter = s.getRootNode().getNodes() ; + Session s = CtxHelper.getSession(ctx); + NodeIterator iter = s.getRootNode().getNodes(); while (iter.hasNext()) { Node n = (Node) iter.next(); - if (!n.getName().equals(JcrConstants.JCR_SYSTEM)) { - n.remove() ; + if (!n.getName().equals(JcrConstants.JCR_SYSTEM)) + { + n.remove(); + } + } + PropertyIterator pIter = s.getRootNode().getProperties(); + while (pIter.hasNext()) + { + Property p = pIter.nextProperty(); + if (!p.getName().equals(JcrConstants.JCR_PRIMARYTYPE)) + { + p.remove(); } } return false; Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectItems.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectItems.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectItems.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectItems.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,40 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +/** + * Collect children, either nodes or properties + */ +public class CollectItems extends AbstractCollect +{ + + /** + * @inheritDoc + */ + protected boolean isCollectNodes() + { + return true; + } + + /** + * @inheritDoc + */ + protected boolean isCollectProperties() + { + return true; + } +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectItems.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectNodes.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectNodes.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectNodes.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectNodes.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,41 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +/** + * Collect nodes only + */ +public class CollectNodes extends AbstractCollect +{ + + /** + * @inheritDoc + */ + protected boolean isCollectNodes() + { + return true; + } + + /** + * @inheritDoc + */ + protected boolean isCollectProperties() + { + return false; + } + +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectNodes.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectProperties.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectProperties.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectProperties.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectProperties.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,41 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +/** + * Collect properties only + */ +public class CollectProperties +{ + + /** + * @inheritDoc + */ + protected boolean isCollectNodes() + { + return false; + } + + /** + * @inheritDoc + */ + protected boolean isCollectProperties() + { + return true; + } + +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CollectProperties.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Copy.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Copy.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Copy.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Copy.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,130 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +import javax.jcr.Node; +import javax.jcr.Session; + +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; +import org.apache.jackrabbit.chain.CtxHelper; + +/** + * Copy a Node.
+ * The destination path must be absolute.
+ * See Workspace.copy(String srcAbsPath, String destAbsPath). + */ +public class Copy implements Command +{ + // ---------------------------- < literals > + /** source path */ + private String from; + + /** destination path */ + private String to; + + // ---------------------------- < keys > + /** source path */ + private String fromKey; + + /** destination path */ + private String toKey; + + /** + * @return Returns the from. + */ + public String getFrom() + { + return from; + } + + /** + * @param from + * The from to set. + */ + public void setFrom(String from) + { + this.from = from; + } + + /** + * @return Returns the fromKey. + */ + public String getFromKey() + { + return fromKey; + } + + /** + * @param fromKey + * The fromKey to set. + */ + public void setFromKey(String fromKey) + { + this.fromKey = fromKey; + } + + /** + * @return Returns the to. + */ + public String getTo() + { + return to; + } + + /** + * @param to + * The to to set. + */ + public void setTo(String to) + { + this.to = to; + } + + /** + * @return Returns the toKey. + */ + public String getToKey() + { + return toKey; + } + + /** + * @param toKey + * The toKey to set. + */ + public void setToKey(String toKey) + { + this.toKey = toKey; + } + + /** + * @inheritDoc + */ + public boolean execute(Context ctx) throws Exception + { + String from = CtxHelper.getAttr(this.from, this.fromKey, ctx); + String to = CtxHelper.getAttr(this.to, this.toKey, ctx); + + Node fromNode = CtxHelper.getNode(ctx, from); + + Session s = CtxHelper.getSession(ctx); + s.getWorkspace().copy(fromNode.getPath(), to); + + return false; + } +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Copy.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CurrentNode.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CurrentNode.java?rev=231495&r1=231494&r2=231495&view=diff ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CurrentNode.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/CurrentNode.java Thu Aug 11 11:04:29 2005 @@ -21,26 +21,34 @@ import org.apache.commons.chain.Command; import org.apache.commons.chain.Context; -import org.apache.jackrabbit.chain.ContextHelper; +import org.apache.jackrabbit.chain.CtxHelper; /** - * Sets the current working Node + * Set the current working Node.
+ * The Command attributes are set from the specified literal values, or from the + * context attributes stored under the given keys. */ public class CurrentNode implements Command { + // ---------------------------- < literals > + /** path to the current node */ private String path; - /* - * (non-Javadoc) - * - * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context) + // ---------------------------- < keys > + + /** context attribute key for the path attribute */ + private String pathKey; + + /** + * @inheritDoc */ public boolean execute(Context ctx) throws Exception { - Session s = ContextHelper.getSession(ctx); - Node n = ContextHelper.getNode(ctx, path); - ContextHelper.setCurrentNode(ctx, n); + String path = CtxHelper.getAttr(this.path, this.pathKey, ctx); + Session s = CtxHelper.getSession(ctx); + Node n = CtxHelper.getNode(ctx, path); + CtxHelper.setCurrentNode(ctx, n); return false; } @@ -59,5 +67,22 @@ public void setPath(String path) { this.path = path; + } + + /** + * @return Returns the pathKey. + */ + public String getPathKey() + { + return pathKey; + } + + /** + * @param pathKey + * Set the context attribute key for the path attribute. + */ + public void setPathKey(String pathKey) + { + this.pathKey = pathKey; } } Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Login.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Login.java?rev=231495&r1=231494&r2=231495&view=diff ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Login.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Login.java Thu Aug 11 11:04:29 2005 @@ -23,85 +23,181 @@ import org.apache.commons.chain.Command; import org.apache.commons.chain.Context; -import org.apache.jackrabbit.chain.ContextHelper; +import org.apache.jackrabbit.chain.CtxHelper; +import org.apache.jackrabbit.chain.JcrCommandException; /** - * Login command. + * Login command.
+ * The Command attributes are set from the specified literal values, or from the + * context attributes stored under the given keys. */ -public class Login implements Command { - /** user */ - private String user; - - /** password */ - private String password; - - /** workspace */ - private String workspace; - - /* - * (non-Javadoc) - * - * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context) - */ - public boolean execute(Context ctx) throws Exception { - Session session = null; - Repository repo = ContextHelper.getRepository(ctx); +public class Login implements Command +{ + + // ---------------------------- < literals > + + /** user */ + private String user; + + /** password */ + private String password; + + /** workspace */ + private String workspace; + + // ---------------------------- < keys > + /** user key */ + private String userKey; + + /** password key */ + private String passwordKey; + + /** workspace key */ + private String workspaceKey; + + /** + * @inheritDoc + */ + public boolean execute(Context ctx) throws Exception + { + if (CtxHelper.getSession(ctx) != null) + { + throw new JcrCommandException("already.logged.in"); + } + + String anon = "anonymous"; + + String user = CtxHelper.getAttr(this.user, this.userKey, anon, + ctx); + + String password = CtxHelper.getAttr(this.password, + this.passwordKey, anon, ctx); + + String workspace = CtxHelper.getAttr(this.workspace, + this.workspaceKey, ctx); + + Session session = null; + Repository repo = CtxHelper.getRepository(ctx); + + if (repo == null) + { + throw new JcrCommandException("repository.not.in.context"); + } Credentials credentials = new SimpleCredentials(user, password - .toCharArray()); + .toCharArray()); - if (this.workspace == null) { - session = repo.login(credentials); - } else { - session = repo.login(credentials, workspace); - } - ContextHelper.setSession(ctx, session); - ContextHelper.setCurrentNode(ctx, session.getRootNode()); - return false; - } - - /** - * @return Returns the password. - */ - public String getPassword() { - return password; - } - - /** - * @param password - * The password to set. - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * @return Returns the user. - */ - public String getUser() { - return user; - } - - /** - * @param user - * The user to set. - */ - public void setUser(String user) { - this.user = user; - } - - /** - * @return Returns the workspace. - */ - public String getWorkspace() { - return workspace; - } - - /** - * @param workspace - * The workspace to set. - */ - public void setWorkspace(String workspace) { - this.workspace = workspace; - } + if (workspace == null) + { + session = repo.login(credentials); + } else + { + session = repo.login(credentials, workspace); + } + CtxHelper.setSession(ctx, session); + CtxHelper.setCurrentNode(ctx, session.getRootNode()); + return false; + } + + /** + * @return Returns the password. + */ + public String getPassword() + { + return password; + } + + /** + * @param password + * The password to set. + */ + public void setPassword(String password) + { + this.password = password; + } + + /** + * @return Returns the user. + */ + public String getUser() + { + return user; + } + + /** + * @param user + * The user to set. + */ + public void setUser(String user) + { + this.user = user; + } + + /** + * @return Returns the workspace. + */ + public String getWorkspace() + { + return workspace; + } + + /** + * @param workspace + * The workspace to set. + */ + public void setWorkspace(String workspace) + { + this.workspace = workspace; + } + + /** + * @return Returns the passwordKey. + */ + public String getPasswordKey() + { + return passwordKey; + } + + /** + * @param passwordKey + * Set the context attribute key for the password attribute. + */ + public void setPasswordKey(String passwordKey) + { + this.passwordKey = passwordKey; + } + + /** + * @return Returns the userKey. + */ + public String getUserKey() + { + return userKey; + } + + /** + * @param userKey + * Set the context attribute key for the user attribute. + */ + public void setUserKey(String userKey) + { + this.userKey = userKey; + } + + /** + * @return Returns the workspaceKey. + */ + public String getWorkspaceKey() + { + return workspaceKey; + } + + /** + * @param workspaceKey + * Set the context attribute key for the workspace attribute. + */ + public void setWorkspaceKey(String workspaceKey) + { + this.workspaceKey = workspaceKey; + } } Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Logout.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Logout.java?rev=231495&r1=231494&r2=231495&view=diff ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Logout.java (original) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Logout.java Thu Aug 11 11:04:29 2005 @@ -20,7 +20,7 @@ import org.apache.commons.chain.Command; import org.apache.commons.chain.Context; -import org.apache.jackrabbit.chain.ContextHelper; +import org.apache.jackrabbit.chain.CtxHelper; /** * Logout command @@ -35,9 +35,10 @@ */ public boolean execute(Context ctx) throws Exception { - Session session = ContextHelper.getSession(ctx); + Session session = CtxHelper.getSession(ctx); session.logout(); - ContextHelper.setSession(ctx, null); + CtxHelper.setCurrentNode(ctx, null); + CtxHelper.setSession(ctx, null); return false; } } Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Move.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Move.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Move.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Move.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,130 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +import javax.jcr.Node; +import javax.jcr.Session; + +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; +import org.apache.jackrabbit.chain.CtxHelper; + +/** + * Move a Node.
+ * The destination path must be absolute.
+ * See Session.move(String srcAbsPath, String destAbsPath). + */ +public class Move implements Command +{ + // ---------------------------- < literals > + /** source path */ + private String from; + + /** destination path */ + private String to; + + // ---------------------------- < keys > + /** source path */ + private String fromKey; + + /** destination path */ + private String toKey; + + /** + * @return Returns the from. + */ + public String getFrom() + { + return from; + } + + /** + * @param from + * The from to set. + */ + public void setFrom(String from) + { + this.from = from; + } + + /** + * @return Returns the fromKey. + */ + public String getFromKey() + { + return fromKey; + } + + /** + * @param fromKey + * The fromKey to set. + */ + public void setFromKey(String fromKey) + { + this.fromKey = fromKey; + } + + /** + * @return Returns the to. + */ + public String getTo() + { + return to; + } + + /** + * @param to + * The to to set. + */ + public void setTo(String to) + { + this.to = to; + } + + /** + * @return Returns the toKey. + */ + public String getToKey() + { + return toKey; + } + + /** + * @param toKey + * The toKey to set. + */ + public void setToKey(String toKey) + { + this.toKey = toKey; + } + + /** + * @inheritDoc + */ + public boolean execute(Context ctx) throws Exception + { + String from = CtxHelper.getAttr(this.from, this.fromKey, ctx); + String to = CtxHelper.getAttr(this.to, this.toKey, ctx); + + Node fromNode = CtxHelper.getNode(ctx, from); + + Session s = CtxHelper.getSession(ctx); + s.move(fromNode.getPath(), to); + + return false; + } +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Move.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ReadValue.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ReadValue.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ReadValue.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ReadValue.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,160 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +import javax.jcr.Property; + +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; +import org.apache.jackrabbit.chain.CtxHelper; + +/** + * Read the Value of the given property and store it under the given context + * attribute.
+ * The Command attributes are set from the specified literal values, or from the + * context attributes stored under the given keys. + */ +public class ReadValue implements Command +{ + + // ---------------------------- < literals > + + /** property path */ + private String path; + + /** value index */ + private String index; + + // ---------------------------- < keys > + + /** property path key */ + private String pathKey; + + /** value index key */ + private String indexKey; + + /** destination context attribute */ + private String toKey; + + /* + * (non-Javadoc) + * + * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context) + */ + public boolean execute(Context ctx) throws Exception + { + String path = CtxHelper.getAttr(this.path, this.pathKey, ctx); + int index = CtxHelper.getIntAttr(this.index, this.indexKey, 0, + ctx); + + Property p = (Property) CtxHelper.getItem(ctx, path); + + if (p.getDefinition().isMultiple()) + { + ctx.put(this.toKey, p.getValues()[index].getString()); + } else + { + ctx.put(this.toKey, p.getValue().getString()); + } + return false; + } + + /** + * @return Returns the index. + */ + public String getIndex() + { + return index; + } + + /** + * @param index + * The index to set. + */ + public void setIndex(String index) + { + this.index = index; + } + + /** + * @return Returns the indexKey. + */ + public String getIndexKey() + { + return indexKey; + } + + /** + * @param indexKey + * Set the context attribute key for the index attribute. + */ + public void setIndexKey(String indexKey) + { + this.indexKey = indexKey; + } + + /** + * @return Returns the path. + */ + public String getPath() + { + return path; + } + + /** + * @param path + * The path to set. + */ + public void setPath(String path) + { + this.path = path; + } + + /** + * @return Returns the pathKey. + */ + public String getPathKey() + { + return pathKey; + } + + /** + * @param pathKey + * Set the context attribute key for the path attribute. + */ + public void setPathKey(String pathKey) + { + this.pathKey = pathKey; + } + + /** + * @return Returns the toKey. + */ + public String getToKey() + { + return toKey; + } + + /** + * @param toKey + * The toKey to set. + */ + public void setToKey(String toKey) + { + this.toKey = toKey; + } +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/ReadValue.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Refresh.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Refresh.java?rev=231495&view=auto ============================================================================== --- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Refresh.java (added) +++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Refresh.java Thu Aug 11 11:04:29 2005 @@ -0,0 +1,135 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.chain.command; + +import javax.jcr.Item; +import javax.jcr.Session; + +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; +import org.apache.jackrabbit.chain.CtxHelper; + +/** + * Refresh the session to reflect the current saved state.
+ * If the path is set then only that Item is refreshed. + */ +public class Refresh implements Command +{ + // ---------------------------- < literals > + /** keep changes */ + private String keepChanges; + + /** path to the node to refresh */ + private String path; + + // ---------------------------- < keys > + /** keep changes key */ + private String keepChangesKey; + + /** path to the node to refresh key */ + private String pathKey; + + /** + * @return Returns the keepChanges. + */ + public String getKeepChanges() + { + return keepChanges; + } + + /** + * @param keepChanges + * The keepChanges to set. + */ + public void setKeepChanges(String keepChanges) + { + this.keepChanges = keepChanges; + } + + /** + * @return Returns the keepChangesKey. + */ + public String getKeepChangesKey() + { + return keepChangesKey; + } + + /** + * @param keepChangesKey + * The keepChangesKey to set. + */ + public void setKeepChangesKey(String keepChangesKey) + { + this.keepChangesKey = keepChangesKey; + } + + /** + * @inheritDoc + */ + public boolean execute(Context ctx) throws Exception + { + boolean keepChanges = CtxHelper.getBooleanAttr(this.keepChanges, + this.keepChangesKey, true, ctx); + + String path = CtxHelper.getAttr(this.path, this.pathKey, ctx); + if (path == null) + { + Session s = CtxHelper.getSession(ctx); + s.refresh(keepChanges); + } else + { + Item i = CtxHelper.getItem(ctx, path); + i.refresh(keepChanges); + } + + return false; + } + + /** + * @return Returns the path. + */ + public String getPath() + { + return path; + } + + /** + * @param path + * The path to set. + */ + public void setPath(String path) + { + this.path = path; + } + + /** + * @return Returns the pathKey. + */ + public String getPathKey() + { + return pathKey; + } + + /** + * @param pathKey + * The pathKey to set. + */ + public void setPathKey(String pathKey) + { + this.pathKey = pathKey; + } +} Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Refresh.java ------------------------------------------------------------------------------ svn:eol-style = native