use of com.thinkbiganalytics.metadata.modeshape.extension.JcrExtensiblePropertyCollection in project kylo by Teradata.
the class JcrPropertyUtil method setProperties.
public static Node setProperties(Session session, Node entNode, Map<String, Object> props) {
ValueFactory factory;
try {
factory = session.getValueFactory();
if (props != null) {
// JcrVersionUtil.ensureCheckoutNode(entNode);
for (Map.Entry<String, Object> entry : props.entrySet()) {
if (entry.getValue() instanceof JcrExtensiblePropertyCollection) {
JcrExtensiblePropertyCollection propertyCollection = ((JcrExtensiblePropertyCollection) entry.getValue());
propertyCollection.getCollectionType();
Value[] values = new Value[propertyCollection.getCollection().size()];
int i = 0;
for (Object o : propertyCollection.getCollection()) {
boolean weak = false;
if (propertyCollection.getCollectionType() == PropertyType.WEAKREFERENCE) {
weak = true;
}
Value value = createValue(session, o, weak);
values[i] = value;
i++;
}
entNode.setProperty(entry.getKey(), values);
} else {
Value value = asValue(factory, entry.getValue());
entNode.setProperty(entry.getKey(), value);
}
}
}
return entNode;
} catch (AccessDeniedException e) {
log.debug("Access denied", e);
throw new AccessControlException(e.getMessage());
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to set properties", e);
}
}
Aggregations