public void execute() throws Exception { getDelegate().getSession().save(); } });
public Node getNode() throws ValueFormatException, RepositoryException { return origin.getSession().getNodeByUUID(getValue().getString()); }
@Override public boolean isSame(Item otherItem) throws RepositoryException { if (this == otherItem) { return true; } if (otherItem instanceof Node) { return this.getIdentifier().equals(((Node) otherItem).getIdentifier()) && getSession().getWorkspace().getName().equals( otherItem.getSession().getWorkspace().getName()); } return false; }
protected boolean isSameRepository( Item otherItem ) throws RepositoryException { assert getSession() != null; assert otherItem.getSession() != null; assert getSession().getRepository() != null; assert otherItem.getSession().getRepository() != null; if (getSession().getRepository() != otherItem.getSession().getRepository()) { return false; } return true; }
protected boolean isSameRepository( Item otherItem ) throws RepositoryException { assert getSession() != null; assert otherItem.getSession() != null; assert getSession().getRepository() != null; assert otherItem.getSession().getRepository() != null; if (getSession().getRepository() != otherItem.getSession().getRepository()) { return false; } return true; }
/** * * @param item * @return */ private boolean isFilteredNamespace(Item item) { try { return isFilteredNamespace(item.getName(), item.getSession()); } catch (RepositoryException e) { log.warn(e.getMessage()); } return false; }
public void move(Object src, Object dstParent, String name) throws PersistenceException { try { final Session session = ((Item)src).getSession(); final Item source = ((Item)src); final String targetParentPath = ((Node)dstParent).getPath(); final String targetPath = (targetParentPath.equals("/") ? "" : targetParentPath) + '/' + name; session.move(source.getPath(), targetPath); } catch ( final RepositoryException re) { throw new PersistenceException(re.getMessage(), re); } }
@Override public boolean execute(Context ctx) throws Exception { log.debug("Going to remove item [{}].", getPath()); Item jcrItem = MgnlContext.getJCRSession(this.getRepository()).getItem(getPath()); jcrItem.remove(); jcrItem.getSession().save(); return true; }
public ConsoleFile getFile(String path, boolean mustExist) throws IOException { try { if (item.isNode()) { if (path.startsWith("/")) { return new RepositoryCFile(item.getSession().getItem(path)); } else { return new RepositoryCFile(((Node) item).getNode(path)); } } else { throw new ExecutionException("can't cd into property"); } } catch (PathNotFoundException e) { throw new FileNotFoundException(path); } catch (RepositoryException e) { throw new IOException(e.toString()); } }
try item.getSession().refresh(false);
try { Item item = context.getExportRoot(); Repository rep = item.getSession().getRepository(); String repName = rep.getDescriptor(Repository.REP_NAME_DESC); String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
public void moveTo(TreeItem newParent) throws JcrDiffException { if (!(newParent instanceof JcrTreeNode)) { throw new IllegalArgumentException("newParent must be a JcrTreeNode"); } JcrTreeItem jcrTreeNode = (JcrTreeItem) newParent; try { String name = jcrItem.getName(); Session session = jcrItem.getSession(); Node targetParent = (Node) jcrTreeNode.jcrItem; if (jcrItem instanceof Node) { session.move(jcrItem.getPath(), targetParent.getPath() + "/" + name); NodeIterator nodes = targetParent.getNodes(name); while (nodes.hasNext()) { jcrItem = nodes.nextNode(); } } else { Property property = (Property) jcrItem; Property newProp; if (!property.isMultiple()) { newProp = targetParent.setProperty(property.getName(), property.getValue()); } else { newProp = targetParent.setProperty(property.getName(), property.getValues(), property.getType()); } property.remove(); jcrItem = newProp; } } catch (RepositoryException e) { throw new JcrDiffException("Could not move item to new parent", e); } }
try { Item item = context.getExportRoot(); Repository rep = item.getSession().getRepository(); String repName = rep.getDescriptor(Repository.REP_NAME_DESC); String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
/** * @see Item#isSame(javax.jcr.Item) */ @Override public boolean isSame(Item otherItem) throws RepositoryException { if (this == otherItem) { return true; } // The objects are either both Node objects or both Property objects. if (isNode() != otherItem.isNode()) { return false; } // Test if both items belong to the same repository // created by the same Repository object if (!getSession().getRepository().equals(otherItem.getSession().getRepository())) { return false; } // Both objects were acquired through Session objects bound to the same // repository workspace. if (!getSession().getWorkspace().getName().equals(otherItem.getSession().getWorkspace().getName())) { return false; } if (isNode()) { return ((Node) this).getIdentifier().equals(((Node) otherItem).getIdentifier()); } else { return getName().equals(otherItem.getName()) && getParent().isSame(otherItem.getParent()); } }
/** * @see Item#isSame(javax.jcr.Item) */ @Override public boolean isSame(Item otherItem) throws RepositoryException { if (this == otherItem) { return true; } // The objects are either both Node objects or both Property objects. if (isNode() != otherItem.isNode()) { return false; } // Test if both items belong to the same repository // created by the same Repository object if (!getSession().getRepository().equals(otherItem.getSession().getRepository())) { return false; } // Both objects were acquired through Session objects bound to the same // repository workspace. if (!getSession().getWorkspace().getName().equals(otherItem.getSession().getWorkspace().getName())) { return false; } if (isNode()) { return ((Node) this).getIdentifier().equals(((Node) otherItem).getIdentifier()); } else { return getName().equals(otherItem.getName()) && getParent().isSame(otherItem.getParent()); } }
/** * @see Item#isSame(javax.jcr.Item) */ @Override public boolean isSame(Item otherItem) throws RepositoryException { if (this == otherItem) { return true; } // The objects are either both Node objects or both Property objects. if (isNode() != otherItem.isNode()) { return false; } // Test if both items belong to the same repository // created by the same Repository object if (!getSession().getRepository().equals(otherItem.getSession().getRepository())) { return false; } // Both objects were acquired through Session objects bound to the same // repository workspace. if (!getSession().getWorkspace().getName().equals(otherItem.getSession().getWorkspace().getName())) { return false; } if (isNode()) { return ((Node) this).getIdentifier().equals(((Node) otherItem).getIdentifier()); } else { return getName().equals(otherItem.getName()) && getParent().isSame(otherItem.getParent()); } }
origin.getSession().move(origin.getPath(), (parent.origin.getPath().equals("/") ? "/"+name : parent.origin.getPath()+"/"+name)); origin = null; for(NodeIterator findMoved = ((Node)parent.origin).getNodes(name); findMoved.hasNext(); ) { NodeTypeManager ntMgr = origin.getSession().getWorkspace().getNodeTypeManager(); nodetypes.add(ntMgr.getNodeType(getInternalProperty("jcr:primaryType")[0])); for(String mixin : newMixins) { parent.origin.getSession().move(parent.origin.getPath() + "/" + noSameNameSiblingWorkaround, parent.origin.getPath() + "/" + nodeName);