use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrUserDatasource method toDetailsObject.
@Nonnull
private JcrDatasourceDetails toDetailsObject(@Nonnull final Node detailsNode) {
// Determine type class
final Class<? extends JcrDatasourceDetails> typeClass;
try {
final String typeName = detailsNode.getPrimaryNodeType().getName();
typeClass = DETAILS_NODE_TYPES_MAP.getOrDefault(typeName, JcrDatasourceDetails.class);
} catch (final RepositoryException e) {
throw new MetadataRepositoryException("Failed to determine type of node: " + detailsNode, e);
}
// Convert node to object
return JcrUtil.getJcrObject(detailsNode, typeClass);
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrExtensibleEntityProvider method getEntities.
@Override
public List<ExtensibleEntity> getEntities() {
List<ExtensibleEntity> list = new ArrayList<>();
Session session = getSession();
try {
String path = EntityUtil.pathForExtensibleEntity();
Node genericsNode = session.getNode(path);
NodeIterator typeNameItr = genericsNode.getNodes();
while (typeNameItr.hasNext()) {
Node typeNameNode = (Node) typeNameItr.next();
NodeIterator entityItr = typeNameNode.getNodes();
while (entityItr.hasNext()) {
Node entNode = (Node) entityItr.next();
list.add(new JcrExtensibleEntity(entNode));
}
}
return list;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to retrieve list of extensible entities", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrPropertiesEntity method clearAdditionalProperties.
public void clearAdditionalProperties() {
getPropertiesObject().ifPresent(propsObj -> {
try {
Node propsNode = propsObj.getNode();
Map<String, Object> props = propsObj.getProperties();
for (Map.Entry<String, Object> prop : props.entrySet()) {
if (!JcrPropertyUtil.hasProperty(propsNode.getPrimaryNodeType(), prop.getKey())) {
try {
Property property = propsNode.getProperty(prop.getKey());
property.remove();
} catch (AccessDeniedException e) {
// Failed remove the extra property
log.debug("Access denied", e);
throw new AccessControlException("You do not have the permission to remove property \"" + prop.getKey() + "\"");
}
}
}
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to clear the Properties for this entity. ", e);
}
});
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrExtensibleEntityProvider method getEntity.
@Override
public ExtensibleEntity getEntity(ID id) {
JcrExtensibleEntity.EntityId idImpl = (JcrExtensibleEntity.EntityId) id;
try {
Session session = getSession();
Node node = session.getNodeByIdentifier(idImpl.getIdValue());
if (node != null) {
return new JcrExtensibleEntity(node);
} else {
return null;
}
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failure while finding entity by ID: " + idImpl.getIdValue(), e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrExtensibleEntityProvider method findEntitiesMatchingProperty.
/**
* Return a list of the ExtensibleEntity objects that match a given ExtensibleEntity property and value
* restricting to a specific jcr extension type
*/
public List<? extends ExtensibleEntity> findEntitiesMatchingProperty(String typeName, String propName, Object value) {
String qualifiedName = this.typeProvider.ensureTypeName(typeName);
HashMap<String, String> params = new HashMap<>();
String query = "SELECT * FROM [" + qualifiedName + "] as t WHERE t.[" + propName + "] = $v";
params.put("v", value.toString());
QueryResult result = null;
try {
result = JcrQueryUtil.query(getSession(), query, params);
List<JcrExtensibleEntity> entities = JcrQueryUtil.queryResultToList(result, JcrExtensibleEntity.class);
return entities;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to execute Criteria Query for " + typeName + ". Query is: " + query, e);
}
}
Aggregations