use of javax.jcr.PropertyIterator in project sling by apache.
the class ConfigNodeConverter method loadProperties.
/** Load properties of n into d */
protected void loadProperties(Dictionary<String, Object> d, Node n) throws RepositoryException {
final PropertyIterator pi = n.getProperties();
while (pi.hasNext()) {
final Property p = pi.nextProperty();
final String name = p.getName();
// ignore jcr: and similar properties
if (name.contains(":")) {
continue;
}
if (p.getDefinition().isMultiple()) {
Object[] data = null;
final Value[] values = p.getValues();
int i = 0;
for (Value v : values) {
Object o = convertValue(v);
if (i == 0) {
data = (Object[]) Array.newInstance(o.getClass(), values.length);
}
data[i++] = o;
}
// create empty array in case no value is specified
if (data == null) {
data = new String[0];
}
d.put(name, data);
} else {
final Object o = convertValue(p.getValue());
if (o != null) {
d.put(name, o);
}
}
}
}
use of javax.jcr.PropertyIterator in project sling by apache.
the class JcrCommand method nodeToResource.
protected ResourceProxy nodeToResource(Node node) throws RepositoryException {
ResourceProxy resource = new ResourceProxy(node.getPath());
resource.addAdapted(Node.class, node);
PropertyIterator properties = node.getProperties();
while (properties.hasNext()) {
Property property = properties.nextProperty();
String propertyName = property.getName();
Object propertyValue = ConversionUtils.getPropertyValue(property);
if (propertyValue != null) {
resource.addProperty(propertyName, propertyValue);
}
}
return resource;
}
use of javax.jcr.PropertyIterator in project acs-aem-commons by Adobe-Consulting-Services.
the class EntryNodeToCacheContentHandler method retrieveProperties.
private void retrieveProperties() throws RepositoryException {
final PropertyIterator propertyIterator = entryNode.getProperties();
while (propertyIterator.hasNext()) {
final Property property = propertyIterator.nextProperty();
final String propName = property.getName();
final Value value = property.getValue();
if (propName.equals(JCRHttpCacheStoreConstants.PN_CONTENT_TYPE)) {
contentType = value.getString();
} else if (propName.equals(JCRHttpCacheStoreConstants.PN_CHAR_ENCODING)) {
charEncoding = value.getString();
} else if (propName.equals(JCRHttpCacheStoreConstants.PN_STATUS)) {
status = (int) value.getLong();
}
}
}
use of javax.jcr.PropertyIterator in project acs-aem-commons by Adobe-Consulting-Services.
the class EntryNodeToCacheContentHandler method retrieveHeaders.
private void retrieveHeaders() throws RepositoryException {
if (entryNode.hasNode(JCRHttpCacheStoreConstants.PATH_HEADERS)) {
final Node headerNode = entryNode.getNode(JCRHttpCacheStoreConstants.PATH_HEADERS);
final PropertyIterator propertyIterator = headerNode.getProperties();
while (propertyIterator.hasNext()) {
final Property property = propertyIterator.nextProperty();
final String name = property.getName();
if (!isNativeProperty(name)) {
Value[] values = property.getValues();
List<String> stringValues = new ArrayList<String>(values.length);
for (Value value : values) {
stringValues.add(value.getString());
}
headers.put(name, stringValues);
}
}
}
}
use of javax.jcr.PropertyIterator in project jackrabbit by apache.
the class ChildrenCollectorFilter method collectProperties.
public static PropertyIterator collectProperties(Node node, String[] nameGlobs) throws RepositoryException {
Collection<Item> properties = Collections.emptySet();
PropertyIterator pit = node.getProperties();
while (pit.hasNext()) {
Property p = pit.nextProperty();
if (matches(p.getName(), nameGlobs)) {
properties = addToCollection(properties, p);
}
}
return new PropertyIteratorAdapter(properties);
}
Aggregations