private Node getCanonicalNode(final Node node) throws RepositoryException { if (node instanceof HippoNode) { return ((HippoNode) node).getCanonicalNode(); } else { return node; } }
@Override public String getDisplayName() throws RepositoryException { return ((HippoNode) version).getDisplayName(); }
/** * @param node the node to check * @return whether the node is virtual * @throws RepositoryException */ public static boolean isVirtual(Node node) throws RepositoryException { return node instanceof HippoNode && ((HippoNode) node).isVirtual(); }
private String fetchComparatorId(HippoNode node) { if(node == null) { return null; } try { if (node.hasProperty(HippoNodeType.HIPPO_UUID)) { return node.getProperty(HippoNodeType.HIPPO_UUID).getString(); } else if (node.isNodeType("mix:referenceable")) { return node.getUUID(); } } catch (RepositoryException e) { log.warn("RepositoryException while comparing HippoStdNodes. Return false"); } return null; } }
@IndexField(ignoreInCompound = true) public String getComparePath() { if (comparePath != null) { return comparePath; } HippoNode node = (HippoNode)getNode(); if (node == null) { throw new IllegalStateException("Cannot get comparePath if jcr node is null"); } Node canonical = null; try { canonical = node.getCanonicalNode(); if (canonical == null) { // virtual only comparePath = node.getPath(); } else { comparePath = canonical.getPath(); } } catch (RepositoryException e) { throw new IllegalStateException("Cannot get comparePath", e); } return comparePath; }
@Override protected String load() { if (nodeModel != null) { HippoNode node = (HippoNode) nodeModel.getObject(); if (node != null) { try { if (!node.isNodeType(HippoNodeType.NT_NAMED) && node.isNodeType(HippoNodeType.NT_DOCUMENT) && node.getParent().isNodeType(HippoNodeType.NT_HANDLE)) { node = (HippoNode)node.getParent(); } return node.getDisplayName(); } catch (RepositoryException e) { log.error("Failed to load display name of node {}", getNodePathQuietly(node), e); } } else if (nodeModel instanceof JcrNodeModel) { String path = ((JcrNodeModel ) nodeModel).getItemModel().getPath(); if (path != null) { String name = path.substring(path.lastIndexOf('/') + 1); if (name.indexOf('[') > 0) { name = name.substring(0, name.indexOf('[')); } name = NodeNameCodec.decode(name); return name; } } } return null; }
HippoNode canonical = (HippoNode)hnode.getCanonicalNode(); if(!canonical.isNodeType("mix:referenceable") && !canonical.isNodeType(HippoNodeType.NT_FACETSELECT)) { throw new HstContextualizeException("Cannot create a context where clause for node '"+canonical.getPath()+"'"); if (canonical.isSame(node)){ getFacetSelectClauses(hnode.getSession(), hnode, facetSelectClauses , false); } else { log.debug("Not a search in a virtual structure. Return the scope for the node '{}' only.", node.getPath()); String scopeUUID = canonical.getUUID(); facetSelectClauses.append("@").append(HippoNodeType.HIPPO_PATHS).append("='").append(scopeUUID).append("'"); String scopeUUID = canonical.getUUID(); facetSelectClauses.append("@").append(HippoNodeType.HIPPO_PATHS).append("='").append(scopeUUID).append("'"); getFacetSelectClauses(hnode.getSession(), hnode, facetSelectClauses , true);
private void getFacetSelectClauses(Session jcrSession, HippoNode node, StringBuilder facetSelectClauses, boolean traversUp) throws HstContextualizeException{ try { if(node == null || node.isSame(jcrSession.getRootNode())) { return; if (node.isNodeType(HippoNodeType.NT_FACETSELECT)) { Value[] modes = node.getProperty(HippoNodeType.HIPPO_MODES).getValues(); Value[] facets = node.getProperty(HippoNodeType.HIPPO_FACETS).getValues(); Value[] values = node.getProperty(HippoNodeType.HIPPO_VALUES).getValues(); HippoNode parent = (HippoNode)node.getParent(); Node canonicalParent = parent.getCanonicalNode(); if(canonicalParent != null) { if(parent.isSame(canonicalParent)) { if(parent.isNodeType(HippoNodeType.NT_FACETSELECT)) { getFacetSelectClauses(jcrSession,(HippoNode)node.getParent(), facetSelectClauses, false); getFacetSelectClauses(jcrSession, (HippoNode)node.getParent(), facetSelectClauses, traversUp);
if (!hn.isVirtual()) { Node canonical = hn.getCanonicalNode(); if (canonical == null) { log.debug("Cannot get canonical for a node that is virtual only: '{}'. Return null", this.getPath());
node = (HippoNode) UserSession.get().getJcrSession().getNodeByIdentifier(document.getIdentity()); DefaultWorkflow defaultWorkflow = (DefaultWorkflow) manager.getWorkflow("core", node); if (!node.getDisplayName().equals(localName)) { defaultWorkflow.setDisplayName(localName); try { galleryProcessor.makeImage(node, istream, mimetype, filename); node.getSession().save(); } catch (RepositoryException ex) { log.error(ex.getMessage()); node.getSession().refresh(false); } catch (RepositoryException e) {
@Override protected IDialogService.Dialog createRequestDialog() { String locale = null; try { final HippoNode node = getModelNode(); locale = CodecUtils.getLocaleFromNodeAndAncestors(node); renameDocumentArguments = new RenameDocumentArguments( node.getDisplayName(), node.getName() ); } catch (RepositoryException ex) { renameDocumentArguments = new RenameDocumentArguments(); } return new RenameDocumentDialog(renameDocumentArguments, new StringResourceModel("rename-title", DocumentWorkflowPlugin.this, null), this, CodecUtils.getNodeNameCodecModel(context, locale), this.getModel()); }
protected HippoNode createFolder(HippoNode parentNode, String name) throws RepositoryException, RemoteException, WorkflowException { Session session = getSession().getJcrSession(); HippoWorkspace workspace = (HippoWorkspace) session.getWorkspace(); WorkflowManager workflowMgr = workspace.getWorkflowManager(); // get the folder node's workflow Workflow workflow = workflowMgr.getWorkflow("internal", parentNode); if (workflow instanceof FolderWorkflow) { FolderWorkflow fw = (FolderWorkflow) workflow; // create the new folder String category = "new-folder"; NodeType[] mixinNodeTypes = parentNode.getMixinNodeTypes(); for (NodeType mixinNodeType : mixinNodeTypes) { if (mixinNodeType.getName().equals(HippoTranslationNodeType.NT_TRANSLATED)) { category = "new-translated-folder"; break; } } fw.add(category, HippoStdNodeType.NT_FOLDER, name); HippoNode newFolder = (HippoNode) parentNode.getNode(name); // give the new folder the same folder types as its parent Property parentFolderType = parentNode.getProperty("hippostd:foldertype"); newFolder.setProperty("hippostd:foldertype", parentFolderType.getValues()); // try to reorder the folder reorderFolder(fw, parentNode); return newFolder; } else { throw new WorkflowException("Workflow is not an instance of FolderWorkflow"); } }
public ResetDialog() { Component message; try { HippoNode rootNode = (HippoNode) ((UserSession) Session.get()).getJcrSession().getRootNode(); if (rootNode.getSession().hasPendingChanges()) { hasPendingChanges = true; StringBuffer buf; buf = new StringBuffer("Pending changes:\n"); NodeIterator it = rootNode.pendingChanges(); if (it.hasNext()) { while (it.hasNext()) { Node node = it.nextNode(); buf.append(node.getPath()).append("\n"); } } message = new MultiLineLabel("message", buf.toString()); } else { message = new Label("message", "There are no pending changes"); } } catch (RepositoryException e) { message = new Label("message", "exception: " + e.getMessage()); e.printStackTrace(); } add(message); setFocusOnOk(); }
getQuery(), getDocumentType(), arguments, folder.getPath()); final String path = fw.add(getQuery(), getDocumentType(), arguments); final JcrNodeModel nodeModel = new JcrNodeModel(path);
private JcrNodeModel getFolder() { JcrNodeModel folderModel = new JcrNodeModel("/"); try { WorkflowDescriptorModel wdm = (WorkflowDescriptorModel) getDefaultModel(); if (wdm != null) { HippoNode node = (HippoNode) wdm.getNode(); if (node != null) { folderModel = new JcrNodeModel(node.getParent().getParent()); } } } catch (RepositoryException ex) { log.warn("Could not determine folder path", ex); } return folderModel; }
public SaveDialog() { Component message; try { HippoNode rootNode = (HippoNode) UserSession.get().getJcrSession().getRootNode(); if (rootNode.getSession().hasPendingChanges()) { StringBuilder buf = new StringBuilder("Pending changes:\n"); appendPendingChangesFromNodeToBuffer(rootNode, buf,"\n"); message = new MultiLineLabel("message", buf.toString()); } else { message = new Label("message", "There are no pending changes"); setOkVisible(false); setFocusOnCancel(); } } catch (RepositoryException e) { log.error("Error while rendering save dialog", e); message = new Label("message", "exception: " + e.getMessage()); setOkVisible(false); setFocusOnCancel(); } add(message); setFocusOnOk(); }
canonical = node.getCanonicalNode(); if (canonical == null) { compareItem.comparePath = node.getPath(); } else { compareItem.comparePath = canonical.getPath(); canonical = node.getCanonicalNode(); if (canonical == null) { HippoItem.this.comparePath = node.getPath(); } else { HippoItem.this.comparePath = canonical.getPath();
Node canonical; boolean copyChildren = true; if (srcNode instanceof HippoNode && ((HippoNode) srcNode).isVirtual()) { copyChildren = false; for (NodeIterator iter = srcNode.getNodes(); iter.hasNext();) { Node node = iter.nextNode(); if (!(node instanceof HippoNode) || ((canonical = ((HippoNode) node).getCanonicalNode()) != null && canonical.isSame(node))) { Node child;
private String fetchComparatorId(HippoNode node) { if(node == null) { return null; } try { if (node.hasProperty(HippoNodeType.HIPPO_UUID)) { return node.getProperty(HippoNodeType.HIPPO_UUID).getString(); } else if (node.isNodeType("mix:referenceable")) { return node.getUUID(); } } catch (RepositoryException e) { log.warn("RepositoryException while comparing HippoStdNodes. Return false"); } return null; } }
public ResetDialog() { Component message; try { HippoNode rootNode = (HippoNode) UserSession.get().getJcrSession().getRootNode(); if (rootNode.getSession().hasPendingChanges()) { hasPendingChanges = true; StringBuffer buf; buf = new StringBuffer("Pending changes:\n"); NodeIterator it = rootNode.pendingChanges(); if (it.hasNext()) { while (it.hasNext()) { Node node = it.nextNode(); buf.append(node.getPath()).append("\n"); } } message = new MultiLineLabel("message", buf.toString()); } else { message = new Label("message", "There are no pending changes"); } } catch (RepositoryException e) { message = new Label("message", "exception: " + e.getMessage()); e.printStackTrace(); } add(message); setFocusOnOk(); }