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 String
CURRENT_NODE_KEY
Current node keystatic String
OUTPUT_KEY
output keystatic String
REPO_ADDRESS_KEY
address keystatic String
REPOSITORY_KEY
repository keystatic String
SESSION_KEY
session key
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourceBundle
getBundle()
static Node
getCurrentNode(org.apache.commons.chain.Context ctx)
Gets the current workingNode
static Item
getItem(org.apache.commons.chain.Context ctx, String path)
Gets theItem
at the given path.static Iterator<Item>
getItems(org.apache.commons.chain.Context ctx, Node node, String pattern)
Gets theItem
s under the givenNode
that match the patternstatic Node
getNode(org.apache.commons.chain.Context ctx, String path)
Gets theNode
at the given path.static NodeIterator
getNodes(org.apache.commons.chain.Context ctx, Node node, String pattern)
Gets theNode
s under the givenNode
that match the given pattern.static PrintWriter
getOutput(org.apache.commons.chain.Context ctx)
Gets the currentPrintWriter
static PropertyIterator
getProperties(org.apache.commons.chain.Context ctx, Node node, String pattern)
Gets theProperty
s under the current working node for the given patternstatic Repository
getRepository(org.apache.commons.chain.Context ctx)
Gets the current workingRepository
static String
getRepositoryAddress(org.apache.commons.chain.Context ctx)
static Session
getSession(org.apache.commons.chain.Context ctx)
Gets the current workingSession
static boolean
hasNode(org.apache.commons.chain.Context ctx, String path)
ChecksNode
existence.static void
setCurrentNode(org.apache.commons.chain.Context ctx, Node node)
Sets the current workingNode
.static void
setOutput(org.apache.commons.chain.Context ctx, PrintWriter out)
Sets the currentPrintWriter
.static void
setRepository(org.apache.commons.chain.Context ctx, Repository repository, String address)
Sets the current workingRepository
static void
setSession(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
- theContext
out
- thePrintWriter
-
setCurrentNode
public static void setCurrentNode(org.apache.commons.chain.Context ctx, Node node)
Sets the current workingNode
.- Parameters:
ctx
- theContext
node
- the current workingNode
.
-
setRepository
public static void setRepository(org.apache.commons.chain.Context ctx, Repository repository, String address)
Sets the current workingRepository
- Parameters:
ctx
- theContext
repository
- the current workingRepository
-
setSession
public static void setSession(org.apache.commons.chain.Context ctx, Session session) throws CommandException
Sets the current workingSession
- Parameters:
ctx
- theContext
session
- 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 workingNode
can'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 workingRepository
is 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 workingSession
is unset.
-
getNode
public static Node getNode(org.apache.commons.chain.Context ctx, String path) throws CommandException, RepositoryException
Gets theNode
at the given path.- Parameters:
ctx
- theContext
path
- the path to theNode
- Returns:
- the
Node
at the given path - Throws:
CommandException
- if theNode
isn'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 theItem
at the given path.
If the path is null it returns the current workingNode
.- Parameters:
ctx
- theContext
path
- the path to theItem
- Returns:
- the
Item
at the given path - Throws:
CommandException
- if aCommand
internal error occurs.PathNotFoundException
- if there's noNode
at 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, RepositoryException
ChecksNode
existence.- Parameters:
ctx
- theContext
path
- the path to theNode
- Returns:
- true if the
Node
exists at the given path - Throws:
CommandException
- if the current workingSession
is 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 theNode
s under the givenNode
that match the given pattern.- Parameters:
ctx
- theContext
node
- the parentNode
pattern
- the pattern- Returns:
- an
Iterator
that 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 theProperty
s under the current working node for the given pattern- Parameters:
ctx
- theContext
node
- the parentNode
pattern
- 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 theItem
s under the givenNode
that match the pattern- Parameters:
ctx
- theContext
node
- the parentNode
pattern
- the pattern- Returns:
- an
Iterator
with theItem
s that match the given pattern. - Throws:
RepositoryException
- if the underlying repository throws aRepositoryException
-
-