/** * @inheritDoc */ public NodeIterator pendingChanges() throws RepositoryException { return session.pendingChanges(this, null); }
/** * @inheritDoc */ public NodeIterator pendingChanges(String nodeType, boolean prune) throws RepositoryException { return session.pendingChanges(this, nodeType, prune); }
/** * @inheritDoc */ public NodeIterator pendingChanges(String nodeType) throws RepositoryException { return session.pendingChanges(this, nodeType); }
public NodeIterator pendingChanges(String nodeType, boolean prune) throws NamespaceException, NoSuchNodeTypeException, RepositoryException { return ((HippoSession)getSession()).pendingChanges(this, nodeType, prune); }
public static void appendPendingChangesFromNodeToBuffer(final HippoSession session, final StringBuilder buf, final String delimiter) throws RepositoryException { // we do *not* prune the pending changes as typically the number of changes in the hst config editor are small final NodeIterator it = session.pendingChanges(session.getRootNode(), "nt:base", true); while (it.hasNext()) { Node node = it.nextNode(); buf.append(node.getPath()); if (it.hasNext()) { buf.append(delimiter); } } }
@Override public boolean isModified() throws WorkflowException, MappingException, RepositoryException, RemoteException { final HippoSession session = (HippoSession) context.getUserSession(); final Node node = document.getNode(session); return session.pendingChanges(node, "nt:base", true).hasNext(); }
public boolean isModified() { String path = "<unknown>"; try { final Node documentNode = getEditorModel().getObject(); path = documentNode.getPath(); final HippoSession session = (HippoSession) documentNode.getSession(); if (!modified) { return session.pendingChanges(documentNode, JcrConstants.NT_BASE, true).hasNext(); } else { final EditableWorkflow workflow = getEditableWorkflow(); final Map<String,Serializable> hints = workflow.hints(); if (hints.containsKey("checkModified") && Boolean.TRUE.equals(hints.get("checkModified"))) { modified = workflow.isModified(); return modified; } else { modified = true; return true; } } } catch (EditorException | RepositoryException |RemoteException | WorkflowException e) { log.error("Could not determine whether there are pending changes for '" + path + "'", e); } return false; }
private Collection<Node> findModifiedDerivatives(final Node node) throws RepositoryException { final Collection<Node> result = new TreeSet<>(new Comparator<Node>() { @Override public int compare(final Node o1, final Node o2) { try { return o1.getPath().compareTo(o2.getPath()); } catch (RepositoryException e) { return 0; } } }); try { for (String baseType : new String[] { HippoNodeType.NT_DERIVED, HippoNodeType.NT_DOCUMENT }) { for (Node modified : new NodeIterable(session.pendingChanges(node, baseType))) { if (log.isDebugEnabled()) { log.debug("Derived engine found modified node " + modified.getPath() + " (" + modified.getIdentifier() + ") with derived mixin"); } result.add(modified); } } } catch (NamespaceException | NoSuchNodeTypeException ex) { throw new RepositoryException(HippoNodeType.NT_DERIVED + " not found"); } return result; }
private Map<NodePath, NodeInfo> getModificationTree(javax.jcr.Session jcrSession) { HippoSession hs = (HippoSession) jcrSession; Map<NodePath, NodeInfo> toPrint = new TreeMap<NodePath, NodeInfo>(); try { NodeIterator iter = hs.pendingChanges(); while (iter.hasNext()) { Node node = iter.nextNode(); Node ancestor = node; NodePath path = new NodePath(ancestor.getPath()); while (!toPrint.containsKey(path)) { toPrint.put(path, new NodeInfo(ancestor, false)); if (ancestor.getDepth() == 0) { break; } ancestor = ancestor.getParent(); path = new NodePath(ancestor.getPath()); } toPrint.put(new NodePath(node.getPath()), new NodeInfo(node, true)); } } catch (RepositoryException e) { log.error("Repository exception when analysing session", e); } catch (Throwable t) { log.error("Runtime exception when analysing session", t); } return toPrint; }
private static void tryLocks(final HippoSession session) throws RepositoryException, IllegalStateException { // we can prune: We only need to 'highest' changed nodes final NodeIterator it = session.pendingChanges(session.getRootNode(), "nt:base", false); while (it.hasNext()) { Node node = it.nextNode(); Node hstRootConfigNode = findRootConfigurationNode(node); if (hstRootConfigNode == null || node.isSame(hstRootConfigNode)) { continue; } String relativeNodePath = node.getPath().substring(hstRootConfigNode.getPath().length() + 1); // mainConfigNodeName is for example "hst:sitemap", "hst:pages", "hst:components" etc String mainConfigNodeName; int index = relativeNodePath.indexOf("/"); if (index > -1) { mainConfigNodeName = relativeNodePath.substring(0, index); } else { mainConfigNodeName = relativeNodePath; } Node mainConfigNode = hstRootConfigNode.getNode(mainConfigNodeName); for (String lockSupportedNodetype : LOCK_SUPPORTED_NODETYPES) { if (mainConfigNode.isNodeType(lockSupportedNodetype)) { tryLockIfNeeded(mainConfigNode); return; } } } }
public RemoteIterator pendingChanges(String absPath, String nodeType, boolean prune) throws NamespaceException, NoSuchNodeTypeException, RepositoryException, RemoteException { try { Node node = (absPath == null || "/".equals(absPath)) ? session.getRootNode() : session.getRootNode().getNode(absPath.substring(1)); return getFactory().getRemoteNodeIterator(session.pendingChanges(node, nodeType, prune)); } catch (NamespaceException ex) { throw getRepositoryException(ex); } catch (NoSuchNodeTypeException ex) { throw getRepositoryException(ex); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
public RemoteIterator pendingChanges(String absPath, String nodeType, boolean prune) throws NamespaceException, NoSuchNodeTypeException, RepositoryException, RemoteException { try { Node node = (absPath == null || "/".equals(absPath)) ? session.getRootNode() : session.getRootNode().getNode(absPath.substring(1)); return getFactory().getRemoteNodeIterator(session.pendingChanges(node, nodeType, prune)); } catch (NamespaceException ex) { throw getRepositoryException(ex); } catch (NoSuchNodeTypeException ex) { throw getRepositoryException(ex); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
public Object preClose() { try { Node node = ((WorkflowDescriptorModel) getDefaultModel()).getNode(); boolean dirty = node.isModified(); if (!dirty) { HippoSession session = (HippoSession) node.getSession(); NodeIterator nodes = session.pendingChanges(node, "nt:base", true); if (nodes.hasNext()) { dirty = true; } } validate(); if (dirty || !isValid()) { IDialogService dialogService = context.getService(IDialogService.class.getName(), IDialogService.class); dialogService.show(new OnCloseDialog()); } else { return new Object(); } } catch (RepositoryException ex) { log.error(ex.getMessage()); return new Object(); } return null; }
private Collection<Node> findDerivativesReferencingModifiedNodes(final Node node) throws RepositoryException { final Collection<Node> result = new ArrayList<Node>(); try { for (Node modified : new NodeIterable(session.pendingChanges(node, "mix:referenceable"))) { if (log.isDebugEnabled()) { log.debug("Derived engine found modified referenceable node " + modified.getPath() + " with " + modified.getReferences().getSize() + " references"); } for (Property property : new PropertyIterable(modified.getReferences())) { try { final Node dependentNode = property.getParent(); if (property.getName().equals(HippoNodeType.HIPPO_RELATED) && dependentNode.isNodeType(HippoNodeType.NT_DERIVED)) { result.add(dependentNode); } } catch (AccessDeniedException ex) { throw new RepositoryException("configuration problem", ex); } catch (ItemNotFoundException ex) { throw new RepositoryException("inconsistent state", ex); } } } } catch (NamespaceException ex) { throw new RepositoryException("jcr:uuid not accessible"); } catch (NoSuchNodeTypeException ex) { throw new RepositoryException("jcr:uuid not found"); } return result; }
NodeIterator pending = ((HippoSession) root.getSession()).pendingChanges(root, null, false); addVisibleNodes(pending, locallyModifiedNodes); NodeIterator pending = ((HippoSession) root.getSession()).pendingChanges(root, type, false); addVisibleNodes(pending, locallyModifiedNodes);