use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyItemIsModifiedTest method testPersistentPropertyItemIsModified.
/**
* Test if Item.isModified() returns false for an already exixting and modified
* PropertyItem after the current node is saved (persistent).
*
* @see javax.jcr.Item#isModified()
*/
public void testPersistentPropertyItemIsModified() throws RepositoryException {
Property testProperty = testNode.setProperty(propertyName1, "test1");
testNode.save();
testProperty.setValue("test2");
testNode.save();
Item testPropertyItem = superuser.getItem(testProperty.getPath());
// check testPropertyItem.isModified() after save
assertFalse("Item.isModified() must return false after an existing Property is modified and the current Node is saved", testPropertyItem.isModified());
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyUtil method searchMultivalProp.
/**
* Helper method to find a multivalue property.
*
* @param node the node to start the search from.
* @return a multivalue property or null if not found any.
*/
public static Property searchMultivalProp(Node node) throws RepositoryException {
Property multiVal = null;
for (PropertyIterator props = node.getProperties(); props.hasNext(); ) {
Property property = props.nextProperty();
if (property.getDefinition().isMultiple()) {
multiVal = property;
break;
}
}
if (multiVal == null) {
for (NodeIterator nodes = node.getNodes(); nodes.hasNext(); ) {
Node n = nodes.nextNode();
multiVal = searchMultivalProp(n);
if (multiVal != null) {
break;
}
}
}
return multiVal;
}
use of javax.jcr.Property in project jackrabbit by apache.
the class PropertyUtil method searchMultivalProp.
/**
* Helper method to find a multivalue property of a given type.
*
* @param node the node to start the search from.
* @param type the property type.
* @return a multivalue property or null if not found any.
*/
public static Property searchMultivalProp(Node node, int type) throws RepositoryException {
Property multiVal = null;
for (PropertyIterator props = node.getProperties(); props.hasNext(); ) {
Property property = props.nextProperty();
if (property.getDefinition().isMultiple() && property.getType() == type) {
multiVal = property;
break;
}
}
if (multiVal == null) {
for (NodeIterator nodes = node.getNodes(); nodes.hasNext(); ) {
Node n = nodes.nextNode();
multiVal = searchMultivalProp(n, type);
if (multiVal != null) {
break;
}
}
}
return multiVal;
}
use of javax.jcr.Property in project jackrabbit by apache.
the class ReferencePropertyTest method testEquals.
/**
* Tests equals method of Reference value.
*/
public void testEquals() throws RepositoryException {
Property prop2 = referencedNode.getProperty(jcrUUID);
assertTrue("Incorrect equals method of Reference value.", PropertyUtil.equalValues(prop2.getValue(), prop.getValue()));
}
use of javax.jcr.Property in project jackrabbit by apache.
the class ReferencePropertyTest method testPropValue.
/**
* Tests if the referenced node has this property in its referers list in
* case the property is not transient. Also tests in theis case that the
* node retrieved by property.getNode() is the same as the one retrieved by
* session.getNodeByUUID() .
*/
public void testPropValue() throws RepositoryException {
Node referenced = session.getNodeByUUID(prop.getString());
PropertyIterator referers = referenced.getReferences();
if (!prop.isNew()) {
boolean found = false;
while (referers.hasNext()) {
Property propp = referers.nextProperty();
if (propp.isSame(prop)) {
found = true;
}
}
assertTrue("Referencing property of node " + referenced.getName() + " not found.", found);
assertTrue("Referenced node retrieved with getNode is different " + "from the node retrieved with getNodeByUUID", referenced.isSame(referencedNode));
} else {
log.println("Reference property " + prop.getName() + " is in transient state.");
}
}
Aggregations