}
return graph;
}
private void createPropertiesAsRDF(Node n, NonLiteral subject, MGraph graph) throws RepositoryException {
LiteralFactory literalFactory = LiteralFactory.getInstance();
PropertyIterator pit = n.getProperties();
while (pit.hasNext()) {
try {
Property p = pit.nextProperty();
UriRef pURI = getPropertyURI(p.getName());
if (pURI == null || excludedProperties.contains(pURI)) {
continue;
}
List<Object> values = new ArrayList<Object>();
if (p.isMultiple()) {
values.addAll(JCRUtils.getTypedPropertyValues(p.getType(), p.getValues()));
} else {
values.add(JCRUtils.getTypedPropertyValue(p.getType(), p.getValue()));
}
for (Object val : values) {
/*
* As JCR does not support retrieval of values of URI typed properties, object properties
* are reflected as String properties in JCR. So, when creating RDF from JCR repository,
* currently just look at the value of property starts with "http" prefix.
*
* TODO: Other dirty workaround may be including some prefixes to the object properties to
* identify them
*
* TODO: Fix this when JCR supports retrieval of URI typed property values
*/
try {
String valStr = (String) val;
if (valStr.startsWith("http")) {
graph.add(new TripleImpl(subject, pURI, new UriRef(valStr)));
continue;
}
} catch (Exception e) {
// ignore the exception
}
graph.add(new TripleImpl(subject, pURI, literalFactory.createTypedLiteral(val)));
}
} catch (RepositoryException e) {
log.warn("Failed to process property of node", e);
}
}