use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrUtil method getGenericJson.
public static <T extends Serializable> T getGenericJson(Node jsonNode, boolean allowClassNotFound) {
try {
String className = jsonNode.getProperty("tba:type").getString();
@SuppressWarnings("unchecked") Class<T> type = (Class<T>) ClassNameChangeRegistry.findClass(className);
return JcrPropertyUtil.getJsonObject(jsonNode, "tba:json", type);
} catch (RepositoryException | ClassNotFoundException | ClassCastException e) {
if (e instanceof ClassNotFoundException && allowClassNotFound) {
// swallow this exception
return null;
} else {
throw new MetadataRepositoryException("Failed to deserialize generic JSON property", e);
}
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrUtil method getJcrObjects.
/**
* get All Child nodes under a parentNode and create the wrapped JCRObject the second argument, name, can be null to get all the nodes under the parent
*/
public static <T extends JcrObject> List<T> getJcrObjects(Node parentNode, String name, NodeType nodeType, JcrObjectTypeResolver<T> typeResolver, Object... args) {
List<T> list = new ArrayList<>();
try {
javax.jcr.NodeIterator nodeItr = null;
if (StringUtils.isBlank(name)) {
nodeItr = parentNode.getNodes();
} else {
nodeItr = parentNode.getNodes(name);
}
if (nodeItr != null) {
while (nodeItr.hasNext()) {
Node n = nodeItr.nextNode();
if (nodeType == null || n.isNodeType(nodeType.getName())) {
T entity = constructNodeObject(n, typeResolver.resolve(n), args);
list.add(entity);
}
}
}
} catch (AccessDeniedException e) {
log.debug("Access denied", e);
throw new AccessControlException(e.getMessage());
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to retrieve the Node named" + name, e);
}
return list;
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrVersionUtil method isVersionable.
/**
* @param node the node to test
* @return true if this node is versionable
*/
public static boolean isVersionable(Node node) {
String name = "";
boolean versionable = false;
try {
name = node.getName();
versionable = JcrUtil.hasMixinType(node, "mix:versionable");
return versionable;
} catch (AccessDeniedException e) {
log.debug("Access denied", e);
throw new AccessControlException(e.getMessage());
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to check if versionable for Node " + name, e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrVersionUtil method getVersionedNode.
public static <T extends JcrObject> T getVersionedNode(Version version, Class<T> type, Object[] constructorArgs) {
String nodeName = null;
String versionName = null;
try {
versionName = version.getName();
Node node = version.getFrozenNode();
nodeName = node.getName();
String entityId = version.getContainingHistory().getVersionableIdentifier();
T obj = JcrUtil.constructNodeObject(node, type, constructorArgs);
obj.setVersionName(versionName);
obj.setVersionableIdentifier(entityId);
return obj;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to find Version " + versionName + " for Node " + nodeName, e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class TagProvider method findByTag.
public List<JcrObject> findByTag(String tag) {
String query = "SELECT * FROM [tba:taggable] AS taggable\n" + "WHERE taggable.[tba:tags] = $tag ";
JcrTools tools = new JcrTools();
Map<String, String> params = new HashMap<>();
params.put("tag", tag);
try {
QueryResult result = JcrQueryUtil.query(getSession(), query, params);
return JcrQueryUtil.queryResultToList(result, JcrObject.class);
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to find objects by tag " + tag, e);
}
}
Aggregations