/** * @param session the session * @param path the path */ @Override public FedoraResource findOrCreate(final FedoraSession session, final String path) { throw new RepositoryRuntimeException("unimplemented"); } }
private HttpSession session() { if (session == null) { throw new SessionMissingException("Invalid session"); } return session; }
protected Node getDescriptionNodeOrNull() { try { return getDescriptionNode(); } catch (final RepositoryRuntimeException e) { if (e.getCause() instanceof PathNotFoundException) { return null; } throw new RepositoryRuntimeException(e); } }
/** * Retrieve the JCR Binary object * * @return a JCR-wrapped Binary object */ private javax.jcr.Binary getBinaryContent() { try { return getProperty(JCR_DATA).getBinary(); } catch (final PathNotFoundException e) { throw new PathNotFoundRuntimeException(e); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override public boolean exists(final FedoraSession session, final String path) { final Session jcrSession = getJcrSession(session); try { validatePath(jcrSession, path); return jcrSession.nodeExists(path); } catch (final IllegalArgumentException e) { throw new InvalidResourceIdentifierException("Illegal path: " + path); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override public void delete() { try { // check to remove references to the TimeMap if it exists removeReferences(node); // delete the TimeMap node node.remove(); } catch (final javax.jcr.AccessDeniedException e) { throw new AccessDeniedException(e); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
private static void assertIsType(final Node node) { if (!FedoraBinaryImpl.hasMixin(node)) { throw new ResourceTypeException(node + " can not be used as a binary"); } }
@Override public AcquiredLock lockForDelete(final String path) { try { return new AcquiredMultiPathLock(normalizePath(path)); } catch (InterruptedException e) { throw new InterruptedRuntimeException(e); } } }
private static void assertContainsRequiredTypes(final Model model, final Collection<Resource> types) { for (final Resource type : types) { if (!model.contains(null, RDF.type, type)) { throw new ConstraintViolationException("Missing required type " + type.getURI()); } } } }
@Override public void delete() { try { node.remove(); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
private Node getContentNode() { LOGGER.trace("Retrieved datastream content node."); try { if (isMemento()) { final String mementoName = node.getName(); return node.getParent().getParent().getParent().getNode(LDPCV_TIME_MAP).getNode(mementoName); } return node.getParent(); } catch (final PathNotFoundException e) { throw new PathNotFoundRuntimeException(e); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
private static void assertIsType(final Node node) { if (!hasMixin(node)) { throw new ResourceTypeException(node + " can not be used as a object"); } }
/** * Check if the node has a fedora:tombstone mixin * @param node the node * @return true if the node has the fedora object mixin */ public static boolean hasMixin(final Node node) { try { return node.isNodeType(FEDORA_TOMBSTONE); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override default boolean test(final T elem) { try { return testThrows(elem); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
/** * Check if the JCR node has a fedora:TimeMap mixin * @param node the JCR node * @return true if the JCR node has the fedora:TimeMap mixin */ public static boolean hasMixin(final Node node) { try { return node.isNodeType(FEDORA_TIME_MAP); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override default R apply(final T elem) { try { return applyThrows(elem); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override public String getExternalIdentifier() { try { return property.getPath(); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
/** * Check if the JCR node has a webac:Acl mixin * @param node the JCR node * @return true if the JCR node has the webac:Acl mixin */ public static boolean hasMixin(final Node node) { try { return node.isNodeType(FEDORA_WEBAC_ACL); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } } }
@Override public String getProxyURL() { try { if (hasProperty(PROXY_FOR)) { return getProperty(PROXY_FOR).getString(); } return null; } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override public void addType(final String type) { try { if (node.canAddMixin(type)) { node.addMixin(type); } } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }