Class CommandHelper
- java.lang.Object
-
- org.apache.jackrabbit.standalone.cli.CommandHelper
-
public final class CommandHelper extends Object
Utility class for getting and setting context attributes.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCURRENT_NODE_KEYCurrent node keystatic StringOUTPUT_KEYoutput keystatic StringREPO_ADDRESS_KEYaddress keystatic StringREPOSITORY_KEYrepository keystatic StringSESSION_KEYsession key
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourceBundlegetBundle()static NodegetCurrentNode(org.apache.commons.chain.Context ctx)Gets the current workingNodestatic ItemgetItem(org.apache.commons.chain.Context ctx, String path)Gets theItemat the given path.static Iterator<Item>getItems(org.apache.commons.chain.Context ctx, Node node, String pattern)Gets theItems under the givenNodethat match the patternstatic NodegetNode(org.apache.commons.chain.Context ctx, String path)Gets theNodeat the given path.static NodeIteratorgetNodes(org.apache.commons.chain.Context ctx, Node node, String pattern)Gets theNodes under the givenNodethat match the given pattern.static PrintWritergetOutput(org.apache.commons.chain.Context ctx)Gets the currentPrintWriterstatic PropertyIteratorgetProperties(org.apache.commons.chain.Context ctx, Node node, String pattern)Gets thePropertys under the current working node for the given patternstatic RepositorygetRepository(org.apache.commons.chain.Context ctx)Gets the current workingRepositorystatic StringgetRepositoryAddress(org.apache.commons.chain.Context ctx)static SessiongetSession(org.apache.commons.chain.Context ctx)Gets the current workingSessionstatic booleanhasNode(org.apache.commons.chain.Context ctx, String path)ChecksNodeexistence.static voidsetCurrentNode(org.apache.commons.chain.Context ctx, Node node)Sets the current workingNode.static voidsetOutput(org.apache.commons.chain.Context ctx, PrintWriter out)Sets the currentPrintWriter.static voidsetRepository(org.apache.commons.chain.Context ctx, Repository repository, String address)Sets the current workingRepositorystatic voidsetSession(org.apache.commons.chain.Context ctx, Session session)Sets the current workingSession
-
-
-
Field Detail
-
CURRENT_NODE_KEY
public static final String CURRENT_NODE_KEY
Current node key- See Also:
- Constant Field Values
-
REPOSITORY_KEY
public static final String REPOSITORY_KEY
repository key- See Also:
- Constant Field Values
-
SESSION_KEY
public static final String SESSION_KEY
session key- See Also:
- Constant Field Values
-
OUTPUT_KEY
public static final String OUTPUT_KEY
output key- See Also:
- Constant Field Values
-
REPO_ADDRESS_KEY
public static final String REPO_ADDRESS_KEY
address key- See Also:
- Constant Field Values
-
-
Method Detail
-
setOutput
public static void setOutput(org.apache.commons.chain.Context ctx, PrintWriter out)Sets the currentPrintWriter.- Parameters:
ctx- theContextout- thePrintWriter
-
setCurrentNode
public static void setCurrentNode(org.apache.commons.chain.Context ctx, Node node)Sets the current workingNode.- Parameters:
ctx- theContextnode- the current workingNode.
-
setRepository
public static void setRepository(org.apache.commons.chain.Context ctx, Repository repository, String address)Sets the current workingRepository- Parameters:
ctx- theContextrepository- the current workingRepository
-
setSession
public static void setSession(org.apache.commons.chain.Context ctx, Session session) throws CommandExceptionSets the current workingSession- Parameters:
ctx- theContextsession- the current workingSession- Throws:
CommandException- if there's an open workingSession
-
getOutput
public static PrintWriter getOutput(org.apache.commons.chain.Context ctx)
Gets the currentPrintWriter- Parameters:
ctx- theContext- Returns:
- the current
PrintWriter
-
getCurrentNode
public static Node getCurrentNode(org.apache.commons.chain.Context ctx) throws CommandException
Gets the current workingNode- Parameters:
ctx- theContext- Returns:
- the current working
Node - Throws:
CommandException- if the current workingNodecan't be found.
-
getRepository
public static Repository getRepository(org.apache.commons.chain.Context ctx) throws CommandException
Gets the current workingRepository- Parameters:
ctx- theContext- Returns:
- the current working
Repository - Throws:
CommandException- if the current workingRepositoryis unset.
-
getRepositoryAddress
public static String getRepositoryAddress(org.apache.commons.chain.Context ctx) throws CommandException
- Throws:
CommandException
-
getSession
public static Session getSession(org.apache.commons.chain.Context ctx) throws CommandException
Gets the current workingSession- Parameters:
ctx- theContext- Returns:
- the current working
Session - Throws:
CommandException- if the current workingSessionis unset.
-
getNode
public static Node getNode(org.apache.commons.chain.Context ctx, String path) throws CommandException, RepositoryException
Gets theNodeat the given path.- Parameters:
ctx- theContextpath- the path to theNode- Returns:
- the
Nodeat the given path - Throws:
CommandException- if theNodeisn't found.RepositoryException- if the underlying repository throws aRepositoryException
-
getItem
public static Item getItem(org.apache.commons.chain.Context ctx, String path) throws CommandException, PathNotFoundException, RepositoryException
Gets theItemat the given path.
If the path is null it returns the current workingNode.- Parameters:
ctx- theContextpath- the path to theItem- Returns:
- the
Itemat the given path - Throws:
CommandException- if aCommandinternal error occurs.PathNotFoundException- if there's noNodeat the given path.RepositoryException- if the underlying repository throws aRepositoryException
-
hasNode
public static boolean hasNode(org.apache.commons.chain.Context ctx, String path) throws CommandException, RepositoryExceptionChecksNodeexistence.- Parameters:
ctx- theContextpath- the path to theNode- Returns:
- true if the
Nodeexists at the given path - Throws:
CommandException- if the current workingSessionis unset.RepositoryException- if the underlying repository throws aRepositoryException
-
getNodes
public static NodeIterator getNodes(org.apache.commons.chain.Context ctx, Node node, String pattern) throws RepositoryException
Gets theNodes under the givenNodethat match the given pattern.- Parameters:
ctx- theContextnode- the parentNodepattern- the pattern- Returns:
- an
Iteratorthat contains the matching nodes - Throws:
RepositoryException- if the underlying repository throws aRepositoryException
-
getProperties
public static PropertyIterator getProperties(org.apache.commons.chain.Context ctx, Node node, String pattern) throws RepositoryException
Gets thePropertys under the current working node for the given pattern- Parameters:
ctx- theContextnode- the parentNodepattern- the pattern- Returns:
- a
PropertyIterator - Throws:
RepositoryException- if the underlying repository throws aRepositoryException
-
getBundle
public static ResourceBundle getBundle()
- Returns:
- the default
ResourceBundle
-
getItems
public static Iterator<Item> getItems(org.apache.commons.chain.Context ctx, Node node, String pattern) throws RepositoryException
Gets theItems under the givenNodethat match the pattern- Parameters:
ctx- theContextnode- the parentNodepattern- the pattern- Returns:
- an
Iteratorwith theItems that match the given pattern. - Throws:
RepositoryException- if the underlying repository throws aRepositoryException
-
-