@Override public void runTest() throws Exception { Node node = session.getRootNode().getNode(ROOT_NODE_NAME); for (int i = 1; i < CHILD_COUNT; i++) { node.getNode("node" + i).setProperty("foo", "bar"); session.save(); node.getNode("node" + i).getProperty("foo").remove(); node.getNode("node0").setProperty("foo", i); session.save(); } }
/** * remove specified property. * * @param name of the property to be removed * @throws PathNotFoundException if property does not exist * @throws RepositoryException if unable to remove */ public void removeProperty(String name) throws PathNotFoundException, RepositoryException { this.node.getProperty(this.getInternalPropertyName(name)).remove(); }
@Override public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException { getWrappedProperty().remove(); } }
@MgnlDeprecated(since = "5.6.2", description = "No need to call since #addComment should not be called.") @Deprecated protected void cleanComment(final Node node) throws RepositoryException { synchronized (ExclusiveWrite.getInstance()) { if (node.hasProperty(NodeTypes.Versionable.COMMENT) && !StringUtils.EMPTY.equals(node.getProperty(NodeTypes.Versionable.COMMENT).getString())) { node.getProperty(NodeTypes.Versionable.COMMENT).remove(); node.getSession().save(); } } }
public void removeProperty(String key) throws RepositoryException { Node parent = getParent(key); Property p = parent.getProperty(key); p.remove(); treeManager.join(this, parent, p); if (autoSave) { parent.getSession().save(); } }
protected void setStringsProperty(String relPath, String[] values) throws RepositoryException { if (hasNode()) { Node node = getCheckedOutNode(); if (values == null) { if (node.hasProperty(relPath)) { node.getProperty(relPath).remove(); } } else { node.setProperty(relPath, values); } } }
protected void setStringProperty(String relPath, String value) throws RepositoryException { if (hasNode()) { Node node = getCheckedOutNode(); if (value == null) { if (node.hasProperty(relPath)) { node.getProperty(relPath).remove(); } } else { node.setProperty(relPath, value); } } }
private void assertNoEffect(Node target, String childName, String propName) throws RepositoryException { Session s = target.getSession(); Node n = target.addNode(childName); Value v = getJcrValue(s, RepositoryStub.PROP_PROP_VALUE2, RepositoryStub.PROP_PROP_TYPE2, "test"); Property p = target.setProperty(propName, v); n.remove(); p.remove(); }
public void removeProperty(String key) throws RepositoryException { Node parent = getParent(key); Property p = parent.getProperty(key); p.remove(); treeManager.join(this, parent, p); if (autoSave) { parent.getSession().save(); } }
@Override protected void operateOnNode(InstallContext installContext, Node node) { try { node.getProperty("icon").remove(); } catch (RepositoryException e) { installContext.warn(String.format("The legacy icon property couldn't be removed for the following node: %s", NodeUtil.getNodePathIfPossible(node))); } } }
/** * Move <code>property</code> to the new <code>parent</code>. */ protected void move(Property property, Node parent) throws RepositoryException { parent.setProperty(property.getName(), property.getValue()); property.remove(); }
@Override public void delete() throws RepositoryException { if (isExist()) { getJCRProperty().remove(); } }
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; }
public static void moveProperty(Property source, Node targetNode) throws RepositoryException { // JCR props can't be moved, we gotta recreate w/ same value and delete if (source.isMultiple()) { targetNode.setProperty(source.getName(), source.getValues()); } else { targetNode.setProperty(source.getName(), source.getValue()); } source.remove(); }
private void handleNode(Node node, String[] properties) throws RepositoryException { PropertyIterator propertyIterator = node.getProperties(properties); while (propertyIterator.hasNext()) { Property property = propertyIterator.nextProperty(); if (DEPRECATED_I18N_PROPERTIES.contains(property.getName())) { log.info("SiteMap i18n property removed: '{}' ", property.getPath()); property.remove(); } } }
protected void purgeContent(Node node) throws RepositoryException { // delete paragraphs & collections for (Iterator<Node> iter = new FilteringNodeIterator(node.getNodes(), new RuleBasedNodePredicate(getRule())); iter.hasNext(); ) { iter.next().remove(); } // delete properties (incl title ??) for (Iterator<Property> iter = new FilteringPropertyIterator(node.getProperties(), new JCRMgnlPropertyHidingPredicate()); iter.hasNext(); ) { Property property = iter.next(); property.remove(); } }
public void testRemovedNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException { Property p = testRootNode.setProperty(propertyName1, testValue); p.remove(); testRootNode.refresh(false); try { p.getString(); fail("Refresh 'false' must not bring a removed new child property back to life."); } catch (InvalidItemStateException e) { // ok } assertFalse("Refresh 'false' must not bring a removed new child property back to life.", testRootNode.hasProperty(propertyName1)); }
@Test public void descendantSuggestionRequirePathRestrictionIndex() throws Exception { Node rootIndexDef = root.getNode("oak:index/sugg-idx"); rootIndexDef.getProperty(EVALUATE_PATH_RESTRICTION).remove(); rootIndexDef.setProperty(REINDEX_PROPERTY_NAME, true); session.save(); //Without path restriction indexing, descendant clause shouldn't be respected validateSuggestions( createSuggestQuery(NT_OAK_UNSTRUCTURED, "te", "/content1"), newHashSet("test1", "test2", "test3", "test4", "test5", "test6")); }
@Test public void accessRemovedProperty() throws RepositoryException { Node foo = getNode("/foo"); Property p = foo.setProperty("name", "value"); p.remove(); try { p.getPath(); fail("Expected InvalidItemStateException"); } catch (InvalidItemStateException expected) { } }
@Test public void testMoveAndRemovePropertyAtSource2() throws Exception { setupMovePermissions(); allow(childNPath, privilegesFromName(PrivilegeConstants.REP_REMOVE_PROPERTIES)); testSession.move(nodePath3, siblingDestPath); Node n = testSession.getNode(childNPath); assertTrue(n.hasProperty(propertyName1)); n.getProperty(propertyName1).remove(); testSession.save(); }