Search in sources :

Example 1 with JcrProperties

use of com.thinkbiganalytics.metadata.modeshape.common.JcrProperties 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;
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) HashMap(java.util.HashMap) JcrProperties(com.thinkbiganalytics.metadata.modeshape.common.JcrProperties) ConstraintViolationException(javax.jcr.nodetype.ConstraintViolationException) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)1 JcrProperties (com.thinkbiganalytics.metadata.modeshape.common.JcrProperties)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)1