use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrServiceLevelAgreementProvider method removeAgreement.
/* (non-Javadoc)
* @see com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider#removeAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement.ID)
*/
@Override
public boolean removeAgreement(ID id) {
try {
Session session = getSession();
SlaId slaId = (SlaId) id;
Node slaNode = session.getNodeByIdentifier(slaId.getIdValue());
if (slaNode != null) {
JcrServiceLevelAgreement sla = new JcrServiceLevelAgreement(slaNode);
addPostSlaChangeAction(sla, MetadataChange.ChangeType.DELETE);
// remove any other relationships
feedServiceLevelAgreementProvider.removeAllRelationships(id);
slaNode.remove();
}
return true;
} catch (ItemNotFoundException e) {
return false;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to retrieve the SLA node", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrServiceLevelAgreementProvider method builder.
/* (non-Javadoc)
* @see com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider#builder()
*/
@Override
public ServiceLevelAgreementBuilder builder() {
try {
Session session = getSession();
Node slasNode = session.getNode(EntityUtil.pathForSla());
Node slaNode = slasNode.addNode("sla-" + UUID.randomUUID(), "tba:sla");
return builder(slaNode);
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to create an sla node", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrPropertyUtil method getProperties.
public static Map<String, Object> getProperties(Node node) {
try {
Map<String, Object> propMap = new HashMap<>();
PropertyIterator itr = node.getProperties();
while (itr.hasNext()) {
try {
Property prop = (Property) itr.next();
Object value = asValue(prop);
propMap.put(prop.getName(), value);
} catch (AccessDeniedException e) {
log.debug("Access denied - skipping property", e);
}
}
return propMap;
} catch (AccessDeniedException e) {
log.debug("Access denied", e);
throw new AccessControlException(e.getMessage());
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to access properties", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class PropertiedMixin method clearAdditionalProperties.
default void clearAdditionalProperties() {
try {
Node propsNode = getPropertiesObject().getNode();
Map<String, Object> props = getPropertiesObject().getProperties();
for (Map.Entry<String, Object> prop : props.entrySet()) {
if (!JcrPropertyUtil.hasProperty(propsNode.getPrimaryNodeType(), prop.getKey())) {
Property property = propsNode.getProperty(prop.getKey());
property.remove();
}
}
} 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 PropertiedMixin method mergeProperties.
/**
* Merges any new properties in with the other Extra Properties
*/
@Override
default Map<String, Object> mergeProperties(Map<String, Object> props) {
Map<String, Object> newProps = new HashMap<>();
Map<String, Object> origProps = getProperties();
if (origProps != null) {
newProps.putAll(origProps);
}
if (props != null) {
newProps.putAll(props);
}
JcrProperties properties = getPropertiesObject();
for (Map.Entry<String, Object> entry : newProps.entrySet()) {
try {
properties.setProperty(entry.getKey(), entry.getValue());
} catch (MetadataRepositoryException e) {
if (ExceptionUtils.getRootCause(e) instanceof ConstraintViolationException) {
// this is ok
} else {
throw e;
}
}
}
return newProps;
}
Aggregations