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; }
private String getValue(final Node canonical, final IBrokenLinkDocumentListColumn column, String fieldName) throws RepositoryException { try { final String value = column.getValue(canonical); if (value != null) { return value; } } catch (PathNotFoundException e) { log.info("Skipped {} of {}, path not found: {}", new Object[]{fieldName, canonical.getPath(), e.getMessage()}); } return StringUtils.EMPTY; }
public static long getLastModifiedDate(Node resourceNode, String binaryLastModifiedPropName) { if (resourceNode == null) { return -1L; } Calendar lastModifiedDate = null; try { // don't check for existence first as the property will almost always exist lastModifiedDate = resourceNode.getProperty(binaryLastModifiedPropName).getDate(); } catch (PathNotFoundException e) { log.info("The property, {}, is not found {}", binaryLastModifiedPropName, e.getMessage()); } catch (ValueFormatException e) { log.warn("The property, {}, is not in valid format. {}", binaryLastModifiedPropName, e); } catch (RepositoryException e) { log.error("The property, {}, cannot be retrieved. {}", binaryLastModifiedPropName, e); } return lastModifiedDate != null ? lastModifiedDate.getTimeInMillis() : -1L; }
/** * Asserts that a specific node exists under the root node, where the specific node is specified using its relative * path * * @param rootNode * the root Node to start the search * @param relPath * the relative path of the node that is asserted to exist * @throws RepositoryException * if the repository access failed */ public static void assertNodeExist(final Node rootNode, final String relPath) throws RepositoryException { try { rootNode.getNode(relPath); } catch (final PathNotFoundException e) { LOG.debug("Node {} does not exist in path {}", relPath, rootNode.getPath(), e); fail(e.getMessage()); } }
public Component getRenderer(String id, IModel model) { Revision revision = (Revision) model.getObject(); Node node = revision.getDocument().getObject(); IModel nameModel; try { nameModel = new NodeTranslator(new JcrNodeModel(node.getNode("jcr:frozenNode"))).getNodeName(); } catch (PathNotFoundException e) { nameModel = new Model("Missing node " + e.getMessage()); log.error(e.getMessage(), e); } catch (RepositoryException e) { nameModel = new Model("Error " + e.getMessage()); log.error(e.getMessage(), e); } return new Label(id, nameModel); }
/** * 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()); } }
private int getDimension(final JcrNodeModel model, final String propertyName, final IPluginConfig config) { try { return (int)model.getNode().getProperty(propertyName).getLong(); } catch (final ValueFormatException ignored) { log.debug("Ignoring illegal long value of image property {}: {}", propertyName, ignored.getMessage()); } catch (final PathNotFoundException ignored) { log.debug("Ignoring missing image property {}: {}", propertyName, ignored.getMessage()); } catch (final RepositoryException ignored) { log.debug("Ignoring error while reading image property {}: {}", propertyName, ignored.getMessage()); } return config.getAsInteger("gallery.thumbnail.size", 0); }
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; }
private String getMirrorPath() { Node node = MirrorTemplatePlugin.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; }
/** * Retrieve the node type of a variant node of a document identified by its handle node, e.g. "project:blogpost". * * @param handle JCR node representing a document handle * @return Node type or nothing, wrapped in an Optional */ public static Optional<String> getVariantNodeType(final Node handle) { try { return Optional.of(getAnyVariant(handle).getPrimaryNodeType().getName()); } catch (PathNotFoundException e) { log.info(e.getMessage()); } catch (RepositoryException e) { if (log.isDebugEnabled()) { log.warn("Problem retrieving variant node type for handle(?) node '{}'", handle, e); } else { log.warn("Problem retrieving variant node type for handle(?) node '{}': {}", handle, e.getMessage()); } } return Optional.empty(); }
protected void doDelete( String path, Session session ) throws RepositoryException { Item item; try { item = session.getItem(path); } catch (PathNotFoundException pnfe) { throw new NotFoundException(pnfe.getMessage(), pnfe); } item.remove(); }
private synchronized Node getTaskRoot() { try { if (this.taskNode == null || !taskNode.getSession().isLive() ) { String taskID = formatID(taskCounter++); this.taskNode = NodeUtil.createPath(getModuleRoot(), taskID, NODETYPE); } else { String taskID = this.taskNode.getName(); try { this.taskNode = rereadNode(this.taskNode); } catch (PathNotFoundException pnf) { log.debug("Task node cannot be re-read, creating new one. ("+pnf.getMessage()+")"); this.taskNode = NodeUtil.createPath(getModuleRoot(), taskID, NODETYPE); } } } catch (RepositoryException e) { log.warn("Cannot read node for task ["+currentModuleName+":"+currentTask.getName()+"].", e); } return this.taskNode; }
private synchronized Node getModuleRoot() { try { if (this.moduleNode == null || !moduleNode.getSession().isLive()) { this.moduleNode = NodeUtil.createPath(getStorageRoot(), MODULE_PREFIX + getTimestamp() + "_" + currentModuleName, NODETYPE); } else { try { this.moduleNode = rereadNode(this.moduleNode); } catch (PathNotFoundException pnf) { log.debug("Module node cannot be re-read, creating new one. ("+pnf.getMessage()+")"); this.moduleNode = NodeUtil.createPath(getStorageRoot(), MODULE_PREFIX + getTimestamp() + "_" + currentModuleName, NODETYPE); } } } catch (RepositoryException e) { log.warn("Cannot read node for module ["+currentModuleName+"]. ",e); } return this.moduleNode; }
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()); } }
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()); } }
public void delete(String path) throws RecapSessionException { sanityCheck(); if (this.options.isReverse()) { trackMessage("Deleting %s from http://%s:%d/", path, this.address.getHostname(), this.address.getPort()); } else { trackMessage("Deleting %s from local repository", path); } try { getTargetSession().removeItem(path); } catch (PathNotFoundException e) { LOGGER.debug("PathNotFoundException while removing path: {}. Message: {}", path, e.getMessage()); trackError(path, e); } catch (RepositoryException e) { LOGGER.error("RepositoryException while removing path: {}. Message: {}", path, e.getMessage()); trackFailure(path, e); this.interrupted = true; this.finish(); throw new RecapSessionException("RepositoryException while removing path: " + path, e); } }
/** * @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); } }
private void assertPathNotFoundExceptionFor(final String path) throws RepositoryException { try { HierarchyManagerUtil.asHierarchyManager(MgnlContext.getJCRSession(RepositoryConstants.CONFIG)).getContent(path); fail("should have failed"); } catch (PathNotFoundException e) { assertEquals(path, e.getMessage()); } }
private void assertPathNotFoundExceptionFor(final String path) throws RepositoryException { try { HierarchyManagerUtil.asHierarchyManager(MgnlContext.getJCRSession(RepositoryConstants.CONFIG)).getContent(path); fail("should have failed"); } catch (PathNotFoundException e) { assertEquals(path, e.getMessage()); } }
@Test public void testDeletingReallyWorks() throws Exception { MockHierarchyManager hm = new MockHierarchyManager(); Content node = hm.createContent("/test/sub", "test1", ItemType.CONTENTNODE.getSystemName()); node.delete(); try { hm.getContent("/test/sub").getContent("test1"); fail("should have failed"); } catch (PathNotFoundException e) { assertEquals("test1", e.getMessage()); } try { hm.getContent("/test/sub/test1"); fail("should have failed"); } catch (PathNotFoundException e) { assertEquals("test1", e.getMessage()); } }