@Override public Node getNode() throws RepositoryException { Node internalNode = delegate.getNode(); return NodeFacade.wrap(internalNode, session); }
/** * @inheritDoc */ public Node getNode() throws ValueFormatException, RepositoryException { return factory.getNodeDecorator(session, property.getNode()); }
@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); } } }
public Node getReferenceProperty(final Node node, final String name, final Node defaultValue) { try { return node.getProperty(name).getNode(); } catch (final PathNotFoundException e) { return defaultValue; } catch (final RepositoryException e) { throw new RepositoryAccessException(e.getMessage(), e); } }
@Override public ObligationBuilder<ServiceLevelAgreementBuilder> obligationBuilder(Condition condition) { try { Node groupNode = this.slaNode.getProperty(JcrServiceLevelAgreement.DEFAULT_GROUP).getNode(); groupNode.setProperty(JcrObligationGroup.CONDITION, condition.name()); Node obNode = groupNode.addNode(JcrObligationGroup.OBLIGATIONS, JcrObligationGroup.OBLIGATION_TYPE); return new ObligationBuilderImpl<ServiceLevelAgreementBuilder>(obNode, this); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to build the obligation group node", e); } }
/** * @see Node#getBaseVersion() */ public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException { checkIsVersionable(); return (Version) getProperty(NameConstants.JCR_BASEVERSION).getNode(); }
public static <T extends JcrObject> T getReferencedObject(Node node, String property, JcrObjectTypeResolver<T> typeResolver) { try { Property prop = node.getProperty(property); return createJcrObject(prop.getNode(), typeResolver.resolve(prop.getNode())); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to dereference object of type using: " + typeResolver, e); } }
/** * @see Node#getBaseVersion() */ public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException { checkIsVersionable(); return (Version) getProperty(NameConstants.JCR_BASEVERSION).getNode(); }
/** * @see Node#getVersionHistory() */ public VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryException { checkIsVersionable(); return (VersionHistory) getProperty(NameConstants.JCR_VERSIONHISTORY).getNode(); }
@Override protected Content getContentFromJCRReference() throws RepositoryException { return getHierarchyManager().getContent(getJCRProperty().getNode().getPath()); }
/** * Test the persistence of a property modified with an Node parameter and * saved from the Session Requires a Node value (node) */ public void testNodeSession() throws RepositoryException, NotExecutableException { property1.setValue(node); superuser.save(); assertTrue("Reference property not saved", node.isSame(property1.getNode())); }
public Node getNode(Property property) throws RepositoryException { if (getPrevious() != null) { return getPrevious().getNode(property); } else { return property.getNode(); } }
public void testCreateConfiguration() throws Exception { Node config = vm.createConfiguration(versionableNode.getPath()); assertNotNull(config); NodeType nt = config.getPrimaryNodeType(); assertTrue("created node must be subtype of nt:configuration", nt.isNodeType(ntConfiguration)); // check if the configuration points to the versionable assertTrue("jcr:root property of the configuration must reference the versionable node", config.getProperty("jcr:root").getNode().isSame(versionableNode)); // check if the versionable points to the configuration assertTrue("jcr:configuration property of the versionable node must reference the configuration", versionableNode.getProperty("jcr:configuration").getNode().isSame(config)); }
public void testResolvedIdentifierBasedPropertyValue() throws RepositoryException { ValueFactory vf = superuser.getValueFactory(); Value pathValue = vf.createValue("[" +identifier+ "]", PropertyType.PATH); Property p = testRootNode.setProperty(propertyName1, pathValue); assertTrue("Identifier-based PATH value must resolve to the Node the identifier has been obtained from.", testRootNode.isSame(p.getNode())); }
public void testMultipleReferencesOnSameNode() throws RepositoryException { Node ref = testRootNode.addNode(nodeName2, testNodeType); ref.addMixin(mixReferenceable); superuser.save(); Node n = testRootNode.addNode(nodeName1, testNodeType); n.setProperty("myref0", ref); n.setProperty("myref1", ref); superuser.save(); assertEquals("ref", ref.getPath(), n.getProperty("myref0").getNode().getPath()); assertEquals("ref", ref.getPath(), n.getProperty("myref1").getNode().getPath()); checkReferences("refs", ref.getReferences(), n.getPath() + "/myref0", n.getPath() + "/myref1"); }
/** * Test the persistence of a property modified with an Node parameter and * saved from the parent Node Requires a Node value (node) */ public void testNodeParent() throws RepositoryException { property1.setValue(node); node.save(); assertTrue("Reference property not saved", node.isSame(property1.getNode())); }
public void testSimpleReferences() throws RepositoryException { Node ref = testRootNode.addNode(nodeName2, testNodeType); ref.addMixin(mixReferenceable); superuser.save(); Node n = testRootNode.addNode(nodeName1, testNodeType); n.setProperty("myref", ref); superuser.save(); assertEquals("ref", ref.getPath(), n.getProperty("myref").getNode().getPath()); checkReferences("refs", ref.getReferences(), n.getPath() + "/myref"); checkReferences("refs", ref.getWeakReferences()); }
public void testSimpleWeakReferences() throws RepositoryException { Node ref = testRootNode.addNode(nodeName2, testNodeType); ref.addMixin(mixReferenceable); superuser.save(); Node n = testRootNode.addNode(nodeName1, testNodeType); n.setProperty("myref", superuser.getValueFactory().createValue(ref, true)); superuser.save(); assertEquals("ref", ref.getPath(), n.getProperty("myref").getNode().getPath()); checkReferences("refs", ref.getReferences()); checkReferences("refs", ref.getWeakReferences(), n.getPath() + "/myref"); }
@Test public void testSetReferenceProperty() throws Exception { final String reference2bPropertyName = "reference2b"; Node a = root.addNode("a"); Node b = root.addNode("b"); a.setProperty(reference2bPropertyName, b); Node referencedByPropertyB = a.getProperty(reference2bPropertyName).getNode(); assertEquals(b, referencedByPropertyB); }
@Test public void testNodeReturnedFromPropertyIsWrapped() throws Exception { MockSession session = new MockSession("sessionName"); Node rootNode = session.getRootNode(); Node referredTo = rootNode.addNode("referredTo"); referredTo.setProperty("text", "<html/>"); Node referrer = rootNode.addNode("referrer"); referrer.setProperty("reference", referredTo); HTMLEscapingNodeWrapper wrapper = new HTMLEscapingNodeWrapper(referrer, false); Property property = wrapper.getProperty("reference").getNode().getProperty("text"); assertTrue(property instanceof HTMLEscapingPropertyWrapper); assertEquals("<html/>", property.getString()); }