/** * @param session the session * @param path the path */ @Override public FedoraResource findOrCreate(final FedoraSession session, final String path) { throw new RepositoryRuntimeException("unimplemented"); } }
protected Node getDescriptionNodeOrNull() { try { return getDescriptionNode(); } catch (final RepositoryRuntimeException e) { if (e.getCause() instanceof PathNotFoundException) { return null; } throw new RepositoryRuntimeException(e); } }
@Override public Response toResponse(final RepositoryRuntimeException e) { final Throwable cause = e.getCause(); @SuppressWarnings("unchecked") final ExceptionMapper<Throwable> exceptionMapper = (ExceptionMapper<Throwable>) providers.getExceptionMapper(cause.getClass()); if (exceptionMapper != null) { return exceptionMapper.toResponse(cause); } LOGGER.error("Caught a repository exception: {}", e.getMessage()); debugException(this, cause, LOGGER); return serverError().entity(getStackTraceAsString(e)).type(TEXT_PLAIN_WITH_CHARSET).build(); } }
if (e.getCause() instanceof ItemExistsException) { throw new ClientErrorException("Memento with provided datetime already exists", CONFLICT);
/** * Every REAP_INTERVAL milliseconds, check for expired sessions. If the * tx is expired, roll it back and remove it from the registry. */ @Override @Scheduled(fixedRate = REAP_INTERVAL) public void removeExpired() { final Set<String> reapable = sessions.entrySet().stream() .filter(e -> e.getValue().getExpires().isPresent()) .filter(e -> e.getValue().getExpires().get().isBefore(now())) .map(Map.Entry::getKey).collect(toSet()); reapable.forEach(key -> { final FedoraSession s = sessions.get(key); if (s != null) { try { s.expire(); } catch (final RepositoryRuntimeException e) { LOGGER.error("Got exception rolling back expired session {}: {}", s, e.getMessage()); } } sessions.remove(key); }); }
return created(new URI(destinationUri)).build(); } catch (final RepositoryRuntimeException e) { final Throwable cause = e.getCause();
@Override public String getPath() { try { final String path = node.getPath(); return path.endsWith("/" + JCR_CONTENT) ? path.substring(0, path.length() - JCR_CONTENT.length() - 1) : path; } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
protected String getMimeTypeValue() { try { if (hasDescriptionProperty(HAS_MIME_TYPE)) { return getDescriptionProperty(HAS_MIME_TYPE).getString() .replace(FIELD_DELIMITER + XSDstring.getURI(), ""); } } catch (final RepositoryRuntimeException e) { if (!(e.getCause() instanceof PathNotFoundException) || !isMemento()) { throw e; } } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } return DEFAULT_MIME_TYPE; }
final Throwable cause = e.getCause();
@Override public String toString() { try { String txt = node.getPath(); if (node.hasProperty(JCR_CREATED)) { txt += ", departed: "; txt += node.getProperty(JCR_CREATED).getString(); } return txt; } catch (RepositoryException e) { throw new RepositoryRuntimeException(e); } } }
@Override public void delete() { try { node.remove(); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override public FedoraResource getOriginalResource() { try { final Property originalProperty = node.getProperty(MEMENTO_ORIGINAL); final Node originalNode = originalProperty.getNode(); return Optional.of(originalNode).map(nodeConverter::convert).orElse(null); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } } }
@Override protected boolean hasDescriptionProperty(final String relPath) { try { final Node descNode = getDescriptionNodeOrNull(); if (descNode == null) { return false; } return descNode.hasProperty(relPath); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
/** * 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); } }
@Override public boolean hasProperty(final String relPath) { try { return getNode().hasProperty(relPath); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
protected Session getSession() { try { return getNode().getSession(); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
protected Property getProperty(final String relPath) { try { return getNode().getProperty(relPath); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
/** * Set the content size * * @param size the new value of the content size. */ protected void setContentSize(final long size) { try { getDescriptionNode().setProperty(CONTENT_SIZE, size); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } } }
/** * Return the description property for this binary. * * @param relPath - path to the property * @return Property object */ private Property getDescriptionProperty(final String relPath) { try { return getDescriptionNode().getProperty(relPath); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }