private String getDimension(Node image, String propertyName) { if (image != null) { try { return image.getProperty(propertyName).getString(); } catch (PathNotFoundException ignored) { log.debug("Ignoring missing image property {}: {}", propertyName, ignored.getMessage()); } catch (RepositoryException ignored) { log.debug("Ignoring error while reading image property {}: {}", propertyName, ignored.getMessage()); } } return null; }
/** * Returns the Oak path for the given JCR path, or throws a * {@link javax.jcr.PathNotFoundException} if the path can not be mapped. * * @param jcrPath JCR path * @return Oak path * @throws javax.jcr.PathNotFoundException if the path can not be mapped */ @Nonnull public String getOakPathOrThrowNotFound(String jcrPath) throws PathNotFoundException { String oakPath = getOakPath(jcrPath); if (oakPath != null) { return oakPath; } else { throw new PathNotFoundException(jcrPath); } }
@Override public IResourceStream getResourceStream() { try { return new JcrResourceStream(node.getNode("hst:icon")); } catch (PathNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RepositoryException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
@Nonnull @Override public Node perform() throws RepositoryException { String propName = PathUtils.getName(parentPath); if (grandParent.getPropertyOrNull(propName) != null) { throw new ConstraintViolationException("Can't add new node to property."); throw new PathNotFoundException(relPath);
/** * @see Query#storeAsNode(String) */ public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException { NamePathResolver resolver = mgrProvider.getNamePathResolver(); try { Path p = resolver.getQPath(absPath).getNormalizedPath(); if (!p.isAbsolute()) { throw new RepositoryException(absPath + " is not an absolute path"); } String jcrParent = resolver.getJCRPath(p.getAncestor(1)); if (!session.itemExists(jcrParent)) { throw new PathNotFoundException(jcrParent); } String relPath = resolver.getJCRPath(p).substring(1); String ntName = resolver.getJCRName(NameConstants.NT_QUERY); Node queryNode = session.getRootNode().addNode(relPath, ntName); // set properties queryNode.setProperty(resolver.getJCRName(NameConstants.JCR_LANGUAGE), getLanguage()); queryNode.setProperty(resolver.getJCRName(NameConstants.JCR_STATEMENT), getStatement()); node = queryNode; return node; } catch (NameException e) { throw new RepositoryException(e.getMessage(), e); } }
@Override public void performVoid() throws RepositoryException { ItemDelegate item = sd.getItem(oakPath); if (item == null) { throw new PathNotFoundException(absPath); } else if (item.isProtected()) { throw new ConstraintViolationException( item.getPath() + " is protected"); } else if (!item.remove()) { throw new RepositoryException( item.getPath() + " could not be removed"); } } });
nodeModel.getNode().getSession().save(); nodeModel.getNode().getSession().save(); nodeModel.getNode().getSession().refresh(false); log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (ItemExistsException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (ConstraintViolationException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (VersionException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (RepositoryException ex) { log.error("Error initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex); error("Import failed: " + ex.getMessage()); } catch (IOException ex) { log.error("IOException initializing content in '" + nodeModel.getItemModel().getPath() + "' : " + ex.getMessage(), ex);
/** * @see AbstractAccessControlManager#checkValidNodePath(String) */ @Override protected void checkValidNodePath(String absPath) throws PathNotFoundException, RepositoryException { if (absPath != null) { Path path = resolver.getQPath(absPath); if (!path.isAbsolute()) { throw new RepositoryException("Absolute path expected. Found: " + absPath); } if (hierMgr.resolveNodePath(path) == null) { throw new PathNotFoundException(absPath); } } }
RepositoryException ex) { if (ex instanceof AccessDeniedException) { return new AccessDeniedException(ex.getMessage()); } else if (ex instanceof ConstraintViolationException) { return new ConstraintViolationException(ex.getMessage()); } else if (ex instanceof InvalidItemStateException) { return new InvalidItemStateException(ex.getMessage()); } else if (ex instanceof InvalidQueryException) { return new InvalidQueryException(ex.getMessage()); return new NoSuchWorkspaceException(ex.getMessage()); } else if (ex instanceof PathNotFoundException) { return new PathNotFoundException(ex.getMessage()); } else if (ex instanceof ReferentialIntegrityException) { return new ReferentialIntegrityException(ex.getMessage());
@Override protected String load() { Node node = FacetSelectTemplatePlugin.this.getModelObject(); try { if (node != null && node.hasProperty("hippo:docbase")) { String docbaseUUID = node.getProperty("hippo:docbase").getString(); if (docbaseUUID == null || docbaseUUID.equals("") || docbaseUUID.startsWith("cafebabe-")) { return EMPTY_LINK_TEXT; } return node.getSession().getNodeByUUID(docbaseUUID).getPath(); } } 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 (RepositoryException e) { log.error("Invalid docbase" + e.getMessage(), e); } return EMPTY_LINK_TEXT; } };
checkIsWritable(); Path nodePath = getPath(relPath).getNormalizedPath(); if (nodePath.getIndex() != Path.INDEX_UNDEFINED) { String msg = "Illegal subscript specified: " + relPath; log.debug(msg); throw new RepositoryException(msg); if (nodePath.getLength() == 1) { parentNode = this; } else { String msg = "Cannot add a node to property " + LogUtil.safeGetJCRPath(parentPath, session.getPathResolver()); log.debug(msg); throw new ConstraintViolationException(msg); } else { throw new PathNotFoundException("Cannot add a new node to a non-existing parent at " + LogUtil.safeGetJCRPath(parentPath, session.getPathResolver()));
public NodeImpl getImportTargetNode() throws RepositoryException { try { Path p = session.getQPath(parentAbsPath).getNormalizedPath(); if (!p.isAbsolute()) { throw new RepositoryException("not an absolute path: " + parentAbsPath); } return session.getItemManager().getNode(p); } catch (NameException e) { String msg = parentAbsPath + ": invalid path"; throw new RepositoryException(msg, e); } catch (AccessDeniedException ade) { throw new PathNotFoundException(parentAbsPath); } }
private void assertPathNotFoundExceptionFor(final String path) throws RepositoryException { try { MgnlContext.getJCRSession("config").getRootNode().getNode(path); fail("should have failed"); } catch (PathNotFoundException e) { assertEquals(path, e.getMessage()); } }
node.getPrimaryPath(), context.getQPath(relPath), true); } catch (NameException e) { throw new RepositoryException( "Failed to resolve path " + relPath + " relative to " + node, e); if (!path.denotesName() || path.getIndex() != Path.INDEX_UNDEFINED) { throw new RepositoryException( "Invalid last path element for adding node " + relPath + " relative to " + node); Path parentPath = path.getAncestor(1); try { parentNode = itemMgr.getNode(parentPath); } catch (PathNotFoundException e) { if (itemMgr.propertyExists(parentPath)) { throw new ConstraintViolationException( "Unable to add a child node to property " + context.getJCRPath(parentPath)); throw new PathNotFoundException( "Failed to resolve path " + relPath + " relative to " + node);
/** * @see CopyMoveHandler#copy(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource, org.apache.jackrabbit.webdav.DavResource) */ public boolean copy(CopyMoveContext context, DavResource source, DavResource destination) throws DavException { if (context.isShallowCopy() && source.isCollection()) { // TODO: currently no support for shallow copy; however this is // only relevant if the source resource is a collection, because // otherwise it doesn't make a difference throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy."); } try { context.getSession().getWorkspace().copy(source.getLocator().getRepositoryPath(), destination.getLocator().getRepositoryPath()); return true; } catch (PathNotFoundException e) { // according to rfc 2518: missing parent throw new DavException(DavServletResponse.SC_CONFLICT, e.getMessage()); } catch (RepositoryException e) { throw new JcrDavException(e); } }
/** * If this resource represents an existing <code>Node</code> the system * view is spooled as resource content. * * @param outputContext * @throws IOException * @see Session#exportSystemView(String, OutputStream, boolean, boolean) */ @Override public void spool(OutputContext outputContext) throws IOException { // spool properties super.spool(outputContext); // spool data try { OutputStream out = outputContext.getOutputStream(); if (out != null && exists()) { getRepositorySession().exportSystemView(item.getPath(), out, false, true); } } catch (PathNotFoundException e) { log.error("Error while spooling resource content: " + e.getMessage()); } catch (RepositoryException e) { log.error("Error while spooling resource content: " + e.getMessage()); } }
public static Node findNodeAndWait( Session session, String path, long maxWaitTime, TimeUnit unit ) throws RepositoryException, InterruptedException { long start = System.currentTimeMillis(); long maxWaitInMillis = TimeUnit.MILLISECONDS.convert(maxWaitTime, unit); do { try { // This method either returns a non-null Node reference, or throws an exception ... return session.getNode(path); } catch (PathNotFoundException e) { // The node wasn't there yet, so try again ... } Thread.sleep(10L); } while ((System.currentTimeMillis() - start) <= maxWaitInMillis); throw new PathNotFoundException("Failed to find node '" + path + "' even after waiting " + maxWaitTime + " " + unit); } }
/** * Asserts that a specific node with the given absolute path exists in the session * * @param session * the session to search for the node * @param absPath * the absolute path to look for a node * @throws RepositoryException * if the repository access failed */ public static void assertNodeExistByPath(final Session session, final String absPath) throws RepositoryException { try { session.getNode(absPath); } catch (final PathNotFoundException e) { LOG.debug("Node path {} does not exist", absPath, e); fail(e.getMessage()); } }
/** * @see HierarchyManager#getPropertyEntry(Path) */ public PropertyEntry getPropertyEntry(Path qPath) throws PathNotFoundException, RepositoryException { // shortcut if (qPath.denotesRoot()) { throw new PathNotFoundException("The root path never points to a Property."); } if (!qPath.isCanonical()) { String msg = "Path is not canonical"; log.debug(msg); throw new RepositoryException(msg); } return getRootEntry().getDeepPropertyEntry(qPath); }
/** * @see Report#init(DavResource, ReportInfo) */ @Override public void init(DavResource resource, ReportInfo info) throws DavException { // delegate validation to super class super.init(resource, info); // report specific validation: resource must represent an existing // repository node absNodePath = resource.getLocator().getRepositoryPath(); try { if (!(getRepositorySession().itemExists(absNodePath) && getRepositorySession().getItem(absNodePath).isNode())) { throw new JcrDavException(new PathNotFoundException(absNodePath + " does not exist.")); } } catch (RepositoryException e) { throw new JcrDavException(e); } }