private String getNameOfDdlContent( Property inputProperty ) throws RepositoryException { Node parentNode = inputProperty.getParent(); if (JcrConstants.JCR_CONTENT.equalsIgnoreCase(parentNode.getName())) { parentNode = parentNode.getParent(); } return parentNode.getName(); } }
public static Property renameProperty(Property property, String newName) throws RepositoryException { // Do nothing if the property already has this name, otherwise we would remove the property if (property.getName().equals(newName)) { return property; } Node node = property.getParent(); Property newProperty = node.setProperty(newName, property.getValue()); property.remove(); return newProperty; }
/** * Tests if getParent() returns parent node */ public void testGetParent() throws RepositoryException { assertTrue("getParent() of a property must return the parent node.", testRootNode.isSame(property.getParent())); }
@Override public Time lastModifiedTime() { try { final Node node = model.getProperty().getParent(); return Time.valueOf(JcrUtils.getDateProperty(node, "jcr:lastModified", Calendar.getInstance()).getTime()); } catch (RepositoryException e) { log.error("Unexpected exception while determining last modified date", e); } return Time.valueOf(new Date()); } }
protected boolean skip(final Property prop) throws RepositoryException { final String primaryNodeTypeName = prop.getParent().getPrimaryNodeType().getName(); if (primaryNodeTypeName.equals(NT_FACETSEARCH) && HIPPO_COUNT.equals(prop.getName())) { return true; } if (prop.getName().equals(HIPPO_PATHS)) { return true; } return false; } }
public static Node getParent(Property prop) { try { return prop.getParent(); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to get the parent node of the property: " + prop, e); } }
public Property getProperty(String s) throws RepositoryException { Property property = this.item.getProperty(s); Node parent = property.getParent(); return new PropertyProxy(property, item == parent ? this : new NodeProxy(parent)); }
public CurrentEvolutionEntryImpl(Property property, EvolutionConfig config) { try { this.config = config; this.type = EvolutionEntryType.PROPERTY; this.name = property.getName(); this.depth = EvolutionPathUtil.getLastDepthForPath(property.getPath()); this.path = property.getParent().getName(); this.value = config.printProperty(property); } catch (Exception e) { log.error("Could not inititalize VersionEntry", e); } }
@Override public boolean evaluateProperty(Property property) { try { return evaluateNode(property.getParent()) && propertyPredicate.evaluate(property); } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } }
@Override public final boolean isSame( Item otherItem ) throws RepositoryException { checkSession(); if (otherItem instanceof Property) { Property otherProperty = (Property)otherItem; // The nodes that own the properties must be the same ... if (!getParent().isSame(otherProperty.getParent())) return false; // The properties must have the same name ... return getName().equals(otherProperty.getName()); } return false; }
@Override public final boolean isSame( Item otherItem ) throws RepositoryException { checkSession(); if (otherItem instanceof Property) { Property otherProperty = (Property)otherItem; // The nodes that own the properties must be the same ... if (!getParent().isSame(otherProperty.getParent())) return false; // The properties must have the same name ... return getName().equals(otherProperty.getName()); } return false; }
@Override public boolean shouldRegenerate(Property cachedBinary, ParameterProvider<ThemeAwareParameter> parameterProvider) throws RepositoryException { final Calendar cacheLastMod = NodeTypes.LastModified.getLastModified(cachedBinary.getParent().getParent()); final Calendar srcLastMod = NodeTypes.LastModified.getLastModified(parameterProvider.getParameter().getNode()); return cacheLastMod.before(srcLastMod); }
@Test public void testWorkspaceReturnsLogicalName4() throws RepositoryException { // GIVEN Node root = MgnlContext.getJCRSession("magnolia-mgnlSystem").getRootNode(); root.addNode("test", NodeTypes.ContentNode.NAME).setProperty("testProp", "testVal"); root.getSession().save(); // WHEN String name = root.getNode("test").getProperty("testProp").getParent().getSession().getWorkspace().getName(); // THEN assertTrue(name.equals("magnolia-mgnlSystem")); }
private Property updateProperty( Property property, JSONObject jsonItem ) throws RepositoryException, JSONException { String propertyName = property.getName(); String jsonPropertyName = jsonItem.has(propertyName) ? propertyName : propertyName + BASE64_ENCODING_SUFFIX; Node node = property.getParent(); setPropertyOnNode(node, jsonPropertyName, jsonItem.get(jsonPropertyName)); return property; }
public Link(Property property) { try { setJCRNode(property.getParent()); setWorkspace(property.getSession().getWorkspace().toString()); setProperty(property); setPropertyName(property.getName()); } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } }
@SuppressWarnings("unchecked") private static Stream<Property> getMembershipContext(final FedoraResource resource) throws RepositoryException { return iteratorToStream(getJcrNode(resource).getReferences(LDP_MEMBER_RESOURCE)) .filter(UncheckedPredicate.uncheck((final Property p) -> { final Node container = p.getParent(); return container.isNodeType(LDP_DIRECT_CONTAINER) || container.isNodeType(LDP_INDIRECT_CONTAINER); })); }
@Override public boolean shouldRegenerate(Property cachedBinary, ParameterProvider<STKParameter> parameterProvider) throws RepositoryException { final Calendar cacheLastMod = NodeTypes.LastModified.getLastModified(cachedBinary.getParent().getParent()); final Calendar srcLastMod = NodeTypes.LastModified.getLastModified(parameterProvider.getParameter().getNodeData().getParent().getJCRNode()); return cacheLastMod.before(srcLastMod); }
@Test public void setPropertyAgain() throws RepositoryException { Session session = getAdminSession(); Property p1 = session.getProperty("/foo/stringProp"); Property p2 = p1.getParent().setProperty("stringProp", "newValue"); Property p3 = session.getProperty("/foo/stringProp"); assertEquals("newValue", p1.getString()); assertEquals("newValue", p2.getString()); assertEquals("newValue", p3.getString()); }
@Test public void testPropertyFromNodeReturnedFromPropertyIsWrapped() throws Exception { MockSession session = new MockSession("sessionName"); Node rootNode = session.getRootNode(); Node foo = rootNode.addNode("foo"); foo.setProperty("text", "<html/>"); HTMLEscapingNodeWrapper wrapper = new HTMLEscapingNodeWrapper(foo, false); Property property = wrapper.getProperty("text").getParent().getProperty("text"); assertTrue(property instanceof HTMLEscapingPropertyWrapper); assertEquals("<html/>", property.getString()); }
@Test public void testExecute() throws RepositoryException, TaskExecutionException { // GIVEN Property property1 = NodeUtil.createPath(session.getRootNode(), "/demo-project/about/subsection-articles/article", NodeTypes.ContentNode.NAME).setProperty("someProperty", "someValue"); Task task = new RemovePropertyTask("name", property1.getParent().getPath(), "someProperty"); // WHEN task.execute(ctx); // THEN assertFalse("Property should have been removed", session.propertyExists("/demo-project/about/subsection-articles/article/someProperty")); assertEquals("Remove property 'config:/demo-project/about/subsection-articles/article/someProperty'.", task.getDescription()); } }