@Override public List<URI> getTypes() { try { final List<NodeType> nodeTypes = new ArrayList<>(); final NodeType primaryNodeType = node.getPrimaryNodeType(); nodeTypes.add(primaryNodeType); nodeTypes.addAll(asList(primaryNodeType.getSupertypes())); final List<NodeType> mixinTypes = asList(node.getMixinNodeTypes()); nodeTypes.addAll(mixinTypes); mixinTypes.stream() .map(NodeType::getSupertypes) .flatMap(Arrays::stream) .forEach(nodeTypes::add); final List<URI> types = nodeTypes.stream() .map(uncheck(NodeType::getName)) .filter(hasInternalNamespace.negate()) .distinct() .map(nodeTypeNameToURI) .peek(x -> LOGGER.debug("node has rdf:type {}", x)) .collect(Collectors.toList()); return types; } catch (final PathNotFoundException e) { throw new PathNotFoundRuntimeException(e); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
@Override public boolean hasType(final String type) { try { if (type.equals(FEDORA_REPOSITORY_ROOT)) { return node.isNodeType(ROOT); } else if (isFrozen.test(node) && hasProperty(FROZEN_MIXIN_TYPES)) { return property2values.apply(getProperty(FROZEN_MIXIN_TYPES)).map(uncheck(Value::getString)) .anyMatch(type::equals); } return node.isNodeType(type); } catch (final PathNotFoundException e) { throw new PathNotFoundRuntimeException(e); } 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); } }
@Override public Instant getCreatedDate() { try { if (hasProperty(FEDORA_CREATED)) { return ofEpochMilli(getTimestamp(FEDORA_CREATED, NO_TIME)); } if (hasProperty(JCR_CREATED)) { return ofEpochMilli(getTimestamp(JCR_CREATED, NO_TIME)); } } catch (final PathNotFoundException e) { throw new PathNotFoundRuntimeException(e); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } LOGGER.debug("Node {} does not have a createdDate", node); return null; }
/** * 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 FedoraResource getTimeMap() { if (this instanceof FedoraTimeMap) { return this; } try { if (isOriginalResource()) { return findOrCreateTimeMap(); } else if (isMemento()) { return Optional.of(node.getParent()).map(nodeConverter::convert).orElse(null); } else { throw new PathNotFoundException( "getTimeMap() is not supported for this node: " + node.getPath()); } } catch (final PathNotFoundException e) { throw new PathNotFoundRuntimeException(e); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
throw new PathNotFoundRuntimeException(e); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e);