Search in sources :

Example 81 with MetadataRepositoryException

use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.

the class JcrServiceLevelAgreementProvider method getAgreement.

/* (non-Javadoc)
     * @see com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider#getAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement.ID)
     */
@Override
public ServiceLevelAgreement getAgreement(ID id) {
    try {
        Session session = getSession();
        SlaId slaId = (SlaId) id;
        return new JcrServiceLevelAgreement(session.getNodeByIdentifier(slaId.getIdValue()));
    } catch (ItemNotFoundException e) {
        return null;
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to retrieve the SLA node", e);
    }
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) SlaId(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement.SlaId) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) Session(javax.jcr.Session) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 82 with MetadataRepositoryException

use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.

the class JcrServiceLevelAgreementProvider method slaCheckBuilder.

public ServiceLevelAgreementCheckBuilder slaCheckBuilder(ServiceLevelAgreement.ID slaId) {
    try {
        Session session = getSession();
        Node n = session.getNodeByIdentifier(slaId.toString());
        return new SLACheckBuilderImpl(n);
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Unable to create slaCheckBuilder. Error attempting to find related SLA by id of " + slaId);
    }
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) Session(javax.jcr.Session)

Example 83 with MetadataRepositoryException

use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException 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);
    }
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) AccessDeniedException(javax.jcr.AccessDeniedException) JcrExtensiblePropertyCollection(com.thinkbiganalytics.metadata.modeshape.extension.JcrExtensiblePropertyCollection) AccessControlException(java.security.AccessControlException) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) ValueFactory(javax.jcr.ValueFactory) Value(javax.jcr.Value) JcrObject(com.thinkbiganalytics.metadata.modeshape.common.JcrObject) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)83 RepositoryException (javax.jcr.RepositoryException)79 Node (javax.jcr.Node)54 AccessDeniedException (javax.jcr.AccessDeniedException)29 AccessControlException (java.security.AccessControlException)28 Session (javax.jcr.Session)25 ArrayList (java.util.ArrayList)16 HashMap (java.util.HashMap)14 HashSet (java.util.HashSet)12 NodeIterator (javax.jcr.NodeIterator)12 Nonnull (javax.annotation.Nonnull)10 Value (javax.jcr.Value)10 Map (java.util.Map)9 Property (javax.jcr.Property)8 ItemNotFoundException (javax.jcr.ItemNotFoundException)7 QueryResult (javax.jcr.query.QueryResult)7 JcrObject (com.thinkbiganalytics.metadata.modeshape.common.JcrObject)6 AccessControlManager (javax.jcr.security.AccessControlManager)6 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)5 List (java.util.List)5