/** * @deprecated use {@link #getVariant(javax.jcr.Node, org.hippoecm.repository.util.WorkflowUtils.Variant)} instead */ @Deprecated protected Node getVariant(Node handle, String state) throws RepositoryException { String handlePath = handle.getPath(); for (Node variant : new NodeIterable(handle.getNodes(handle.getName()))) { if (variant.hasProperty(HippoStdNodeType.HIPPOSTD_STATE) && state.equals(variant.getProperty(HippoStdNodeType.HIPPOSTD_STATE).getString())) { return variant; } } throw new ItemNotFoundException("No " + state + " variant found under path: " + handlePath); }
public HstSiteService(Node site, SiteMount siteMount) throws ServiceException{ super(site); try { this.name = site.getName(); this.siteMount = siteMount; if(site.hasNode(HstNodeTypes.NODENAME_HST_CONTENTNODE) && site.hasNode(HstNodeTypes.NODEPATH_HST_CONFIGURATION) ) { Node contentNode = site.getNode(HstNodeTypes.NODENAME_HST_CONTENTNODE); contentPath = contentNode.getPath(); Item item = contentNode.getSession().getNodeByUUID(docbaseUuid); if(item instanceof Node) { log.warn("Docbase from '{}' does not contain a valid uuid. Content mirror is broken", contentNode.getPath()); } catch (ItemNotFoundException e) { log.warn("ItemNotFoundException: Content mirror is broken. ", e.getMessage()); } catch (RepositoryException e) { log.error("RepositoryException: Content mirror is broken. ", e);
switch (value.getType()) { case PropertyType.REFERENCE: case PropertyType.WEAKREFERENCE: return getSession().getNodeByIdentifier(value.getString()); String path = value.getString(); if (path.startsWith("[") && path.endsWith("]")) { return getSession().getNodeByIdentifier(identifier); return (path.charAt(0) == '/') ? getSession().getNode(path) : getParent().getNode(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(path); path = pathValue.getString(); try { return (path.charAt(0) == '/') ? getSession().getNode(path) : getParent().getNode(path); } catch (PathNotFoundException e1) { throw new ItemNotFoundException(pathValue.getString());
private Document createGalleryItem(final Node document) throws RepositoryException { final String primaryItemName = getPrimaryItemName(document); if (primaryItemName != null) { final Node primaryItem; if (!document.hasNode(primaryItemName)) { primaryItem = document.addNode(primaryItemName); } else { primaryItem = document.getNode(primaryItemName); } primaryItem.setProperty(JCR_DATA, ""); primaryItem.setProperty(JCR_MIME_TYPE, "application/octet-stream"); primaryItem.setProperty(JCR_LAST_MODIFIED, Calendar.getInstance()); } else { throw new ItemNotFoundException("No primary item definition found"); } rootSession.save(); return new Document(document); }
@Override protected Node doExec(Node context, ErrorHandler errorHandler) throws RepositoryException { if (!context.hasProperty(name)) { throw new ItemNotFoundException(String.format("Property %s does not exist at %s", name, context.getPath())); } final Value value = PropertyUtil.createValue(newValue, context.getSession().getValueFactory()); context.setProperty(name, value); return context; } };
public Node getNode() throws ValueFormatException, RepositoryException { Session session = getSession(); Value value = getValue(); int type = value.getType(); switch (type) { case REFERENCE: case WEAKREFERENCE: return session.getNodeByUUID(value.getString()); String path = value.getString(); Path p = sessionContext.getQPath(path); boolean absolute = p.isAbsolute(); try { return (absolute) ? session.getNode(path) : getParent().getNode(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(path); Value refValue = ValueHelper.convert(value, REFERENCE, session.getValueFactory()); return session.getNodeByUUID(refValue.getString()); } catch (RepositoryException e) { Value pathValue = ValueHelper.convert(value, PATH, session.getValueFactory()); p = sessionContext.getQPath(pathValue.getString()); absolute = p.isAbsolute(); try { return (absolute) ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString()); } catch (PathNotFoundException e1) { throw new ItemNotFoundException(pathValue.getString());
protected void setUp() throws Exception { super.setUp(); a = testRootNode.addNode("a", "nt:unstructured"); a.setProperty("p", 1); b = testRootNode.addNode("b", "nt:unstructured"); b.setProperty("p", 1); superuser.save(); principal = NodeImplTest.getReadOnlyPrincipal(getHelper()); NodeImplTest.changeReadPermission(principal, a, false); superuser.save(); readOnly = getHelper().getReadOnlySession(); // preliminary tests try { readOnly.getNodeByIdentifier(a.getIdentifier()); fail("Access to the node '" + a.getPath() + "' has to be denied."); } catch (ItemNotFoundException e) { // good acl } try { readOnly.getNodeByIdentifier(b.getIdentifier()); } catch (ItemNotFoundException e) { fail(e.getMessage()); } }
public Node getTranslation(String language) throws RepositoryException { final String id = node.getProperty(HippoTranslationNodeType.ID).getString(); final Query query = node.getSession().getWorkspace().getQueryManager().createQuery( "SELECT * FROM " + HippoTranslationNodeType.NT_TRANSLATED + " WHERE " + HippoTranslationNodeType.ID + "='" + id + "'" + " AND " + HippoTranslationNodeType.LOCALE + "='" + language + "'", Query.SQL); final QueryResult result = query.execute(); final NodeIterator nodes = result.getNodes(); if (!nodes.hasNext()) { throw new ItemNotFoundException("Node " + node.getPath() + " was not translated to " + language); } if (nodes.getSize() > 3) { // check 3 for the stable draft/unpublished/published versions log.warn("Not a maximum of 3 but {} translated variants found for node {} with translation id {} and language {}.", nodes.getSize(), node.getPath(), id, language); } return nodes.nextNode(); }
if (!node.hasProperty(HippoNodeType.HIPPO_PATHS)) { throw new ItemNotFoundException("No hippo:paths property present"); Value[] ancestors = node.getProperty(HippoNodeType.HIPPO_PATHS).getValues(); if (ancestors.length <= 1) { throw new ItemNotFoundException("No ancestors in hippo:paths property"); String uuid = ancestors[1].getString(); Node parent = node.getSession().getNodeByUUID(uuid); VersionHistory history = parent.getVersionHistory(); Version best = null; return best; throw new ItemNotFoundException();
private void removeHasVersionMixin(Node versionedNode) throws RepositoryException { Node node = versionedNode; while (node.getDepth() != 1) { node = node.getParent(); } String uuid = versionedNode.getIdentifier(); try { Node original = Components.getComponent(SystemContext.class).getJCRSession(sourceWorkspace).getNodeByIdentifier(uuid); if (NodeUtil.hasMixin(original, NodeTypes.HasVersion.NAME)) { original.removeMixin(NodeTypes.HasVersion.NAME); original.getSession().save(); } } catch (ItemNotFoundException e) { // in case original node does not exist, print warning log.warn("Original node for version {} not found.", e.getMessage()); } }
private void collectUniquePropertyNames(final Node node, final String repositoryName, final String subnodeName, final Collection<String> set, final boolean isDeep) throws RepositoryException { if (!MgnlContext.isSystemInstance()) { if (log.isDebugEnabled()) { log.debug("Collecting user properties in user context. List might not include all properties. Please check the calling code (see stacktrace)", new Exception()); } else { log.warn("Collecting user properties in user context. List might not include all properties. Please check the calling code (stacktrace will be printed for this call when debug logging is enabled)"); } } Session session = MgnlContext.getJCRSession(repositoryName); for (PropertyIterator iter = new FilteringPropertyIterator(node.getProperties(), new JCRMgnlPropertyHidingPredicate()); iter.hasNext();) { Property property = iter.nextProperty(); final String uuid = property.getString(); try { final Node targetNode = session.getNodeByIdentifier(uuid); set.add(targetNode.getName()); if (isDeep && targetNode.hasNode(subnodeName)) { collectUniquePropertyNames(targetNode.getNode(subnodeName), repositoryName, subnodeName, set, true); } } catch (ItemNotFoundException t) { final String path = property.getPath(); // TODO: why we are using UUIDs here? shouldn't be better to use group names, since uuids can change??? log.warn("Can't find {} node by UUID {} referred by node {}", repositoryName, t.getMessage(), path); log.debug("Failed while reading node by UUID", t); // we continue since it can happen that target node is removed // - UUID's are kept as simple strings thus have no referential integrity } } }
favoriteNode.setName(favorite.getName()); favoriteNode.setTitle(getTitle(favorite)); favoriteNode.setDateAddFavorite(getDateFormat(favorite.getProperty(DATE_MODIFIED).getDate())); favoriteNode.setNodePath(favorite.getPath()); String linkImage = "Icon16x16 default16x16Icon" + getNodeTypeIcon(favorite, "16x16Icon"); favoriteNode.setLinkImage(linkImage); LOG.error(e.getMessage(),e); } catch (RepositoryException e) { LOG.error(e.getMessage(),e); } catch (Exception e) { LOG.error(e.getMessage(),e);
UUID uuidObj = UUID.fromString(uuid); Session session = request.getRequestContext().getSession(); Node persistedFormData = session.getNodeByUUID(uuid); if(persistedFormData.hasProperty(HST_PREDECESSOR)) { formMap.setPrevious(persistedFormData.getProperty(HST_PREDECESSOR).getString()); if(persistedFormData.hasProperty(HST_PARAMETERNAMES) && persistedFormData.hasProperty(HST_PARAMETERVALUES)) { Value[] names = persistedFormData.getProperty(HST_PARAMETERNAMES).getValues(); Value[] values = persistedFormData.getProperty(HST_PARAMETERVALUES).getValues(); } else { for(int i = 0 ; i < names.length ; i ++ ){ formMap.addFormField(names[i].getString(), values[i].getString()); log.warn("LoginException '{}'. Return" , e.getMessage()); } catch (ItemNotFoundException e) { log.warn("ItemNotFoundException '{}' while trying to retrieve persisted formdata. Return" , e.getMessage()); } catch (RepositoryException e) { log.warn("RepositoryException '{}'. Return" , e.getMessage());
public Property getProperty() throws RepositoryException { Value value = getValue(); Value pathValue = ValueHelper.convert(value, PATH, getSession().getValueFactory()); String path = pathValue.getString(); boolean absolute; try { Path p = sessionContext.getQPath(path); absolute = p.isAbsolute(); } catch (RepositoryException e) { throw new ValueFormatException("Property value cannot be converted to a PATH"); } try { return (absolute) ? getSession().getProperty(path) : getParent().getProperty(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(path); } }
@NotNull @Override public Property perform() throws RepositoryException { // TODO: avoid nested calls Value value = getValue(); Value pathValue = ValueHelper.convert(value, PropertyType.PATH, getValueFactory()); String path = pathValue.getString(); try { return (path.charAt(0) == '/') ? getSession().getProperty(path) : getParent().getProperty(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(path); } } });
private String getMirrorPath() { Node node = GalleryPickerPlugin.this.getModelObject(); try { if (node != null && node.hasProperty(HippoNodeType.HIPPO_DOCBASE)) { return getPath(node.getProperty(HippoNodeType.HIPPO_DOCBASE).getString()); } } catch (ValueFormatException e) { log.warn("Invalid value format for docbase " + e.getMessage()); log.debug("Invalid value format for docbase ", e); } catch (PathNotFoundException e) { log.warn("Docbase not found " + e.getMessage()); log.debug("Docbase not found ", e); } catch (ItemNotFoundException e) { log.info("Docbase " + e.getMessage() + " could not be dereferenced"); } catch (RepositoryException e) { log.error("Invalid docbase " + e.getMessage(), e); } return StringUtils.EMPTY; }
void checkout() throws RepositoryException { // copy nodetype if (draft == null) { if (current == null) { throw new ItemNotFoundException("Remodel node " + HippoNodeType.HIPPOSYSEDIT_NODETYPE + ", current version was not found for type " + subject.getPath()); } draft = ((HippoSession) current.getSession()).copy(current, current.getParent().getPath() + "/" + HippoNodeType.HIPPOSYSEDIT_NODETYPE); draft.removeMixin(HippoNodeType.NT_REMODEL); } }
private Item getPrimaryItem(Node node) throws Exception { NodeType primaryType = node.getPrimaryNodeType(); String primaryItemName = primaryType.getPrimaryItemName(); while (primaryItemName == null && !"nt:base".equals(primaryType.getName())) { for (NodeType nt : primaryType.getSupertypes()) { if (nt.getPrimaryItemName() != null) { primaryItemName = nt.getPrimaryItemName(); break; } if (nt.isNodeType("nt:base")) { primaryType = nt; } } } if (primaryItemName == null) { throw new ItemNotFoundException("No primary item definition found in type hierarchy"); } return node.getSession().getItem(node.getPath() + "/" + primaryItemName); }
switch (value.getType()) { case PropertyType.REFERENCE: case PropertyType.WEAKREFERENCE: return session.getNodeByIdentifier(value.getString()); String path = value.getString(); Path p = session.getPathResolver().getQPath(path); try { return (p.isAbsolute()) ? session.getNode(path) : getParent().getNode(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(path); p = session.getPathResolver().getQPath(pathValue.getString()); try { return (p.isAbsolute()) ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString()); } catch (PathNotFoundException e1) { throw new ItemNotFoundException(pathValue.getString());
/** * @see Query#getStoredQueryPath() */ public String getStoredQueryPath() throws ItemNotFoundException, RepositoryException { if (node == null) { throw new ItemNotFoundException("Not a persistent query."); } return node.getPath(); }