use of javax.jcr.Item in project jackrabbit by apache.
the class ReorderSNSTest method testReorder3.
public void testReorder3() throws RepositoryException {
String pathBefore = child3.getPath();
testRootNode.orderBefore(getRelPath(child3), getRelPath(child1));
testRootNode.save();
Item itemIndex3 = testRootNode.getSession().getItem(pathBefore);
assertTrue(itemIndex3.isSame(child2));
Item item3 = testRootNode.getSession().getItem(child3.getPath());
assertTrue(item3.isSame(child3));
}
use of javax.jcr.Item in project jackrabbit by apache.
the class Save method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String path = (String) ctx.get(this.pathKey);
if (path == null) {
log.debug("saving session");
CommandHelper.getSession(ctx).save();
} else {
log.debug("saving node at " + path);
Item i = CommandHelper.getItem(ctx, path);
i.save();
}
return false;
}
use of javax.jcr.Item in project jackrabbit by apache.
the class Move method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String srcAbsPath = (String) ctx.get(this.srcAbsPathKey);
String destAbsPath = (String) ctx.get(this.destAbsPathKey);
boolean persistent = Boolean.valueOf((String) ctx.get(this.persistentKey)).booleanValue();
if (!srcAbsPath.startsWith("/") || !destAbsPath.startsWith("/")) {
throw new IllegalArgumentException(bundle.getString("exception.illegalargument") + ". " + bundle.getString("exception.only.absolute.path") + ".");
}
Session s = CommandHelper.getSession(ctx);
if (log.isDebugEnabled()) {
log.debug("moving node from " + srcAbsPath + " to " + destAbsPath);
}
if (destAbsPath.endsWith("/")) {
Item source = s.getItem(srcAbsPath);
destAbsPath = destAbsPath + source.getName();
}
if (persistent) {
s.getWorkspace().move(srcAbsPath, destAbsPath);
} else {
s.move(srcAbsPath, destAbsPath);
}
return false;
}
use of javax.jcr.Item in project jackrabbit by apache.
the class RemoveItems method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String pattern = (String) ctx.get(this.patternKey);
String path = (String) ctx.get(this.pathKey);
Node n = CommandHelper.getNode(ctx, path);
if (log.isDebugEnabled()) {
log.debug("removing nodes from " + n.getPath() + " that match pattern " + pattern);
}
List children = new ArrayList();
ChildrenCollectorFilter collector = new ChildrenCollectorFilter(pattern, children, true, true, 1);
collector.visit(n);
Iterator items = children.iterator();
while (items.hasNext()) {
Item item = (Item) items.next();
if (item.isSame(CommandHelper.getCurrentNode(ctx)) && item.getDepth() > 0) {
CommandHelper.setCurrentNode(ctx, item.getParent());
}
item.remove();
}
return false;
}
use of javax.jcr.Item in project jackrabbit by apache.
the class Copy method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String srcWorkspace = (String) ctx.get(this.srcWorkspaceKey);
String srcAbsPath = (String) ctx.get(this.srcAbsPathKey);
String destAbsPath = (String) ctx.get(this.destAbsPathKey);
Workspace w = CommandHelper.getSession(ctx).getWorkspace();
if (srcWorkspace == null) {
srcWorkspace = w.getName();
}
if (log.isDebugEnabled()) {
log.debug("copying node from [" + srcWorkspace + ":" + srcAbsPath + "] to [" + w.getName() + ":" + destAbsPath + "]");
}
if (destAbsPath.endsWith("/")) {
Item source = CommandHelper.getSession(ctx).getItem(srcAbsPath);
destAbsPath = destAbsPath + source.getName();
}
w.copy(srcWorkspace, srcAbsPath, destAbsPath);
return false;
}
Aggregations