Search in sources :

Example 76 with MetadataRepositoryException

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

the class JcrAllowableAction method getHierarchy.

@Override
public List<Action> getHierarchy() {
    try {
        List<Action> list = new ArrayList<>();
        Node current = getNode();
        while (current.getPrimaryNodeType().isNodeType(NODE_TYPE)) {
            list.add(0, JcrUtil.createJcrObject(current, JcrAllowableAction.class));
            current = current.getParent();
        }
        return list;
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to derive the perentage of action node: " + getNode(), e);
    }
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Action(com.thinkbiganalytics.security.action.Action) AllowableAction(com.thinkbiganalytics.security.action.AllowableAction) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException)

Example 77 with MetadataRepositoryException

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

the class JcrObligation method setMetrics.

public void setMetrics(Set<Metric> metrics) {
    try {
        NodeIterator nodes = this.node.getNodes(METRICS);
        while (nodes.hasNext()) {
            Node metricNode = (Node) nodes.next();
            metricNode.remove();
        }
        for (Metric metric : metrics) {
            Node metricNode = this.node.addNode(METRICS, METRIC_TYPE);
            JcrPropertyUtil.setProperty(metricNode, NAME, metric.getClass().getSimpleName());
            JcrPropertyUtil.setProperty(metricNode, DESCRIPTION, metric.getDescription());
            JcrUtil.addGenericJson(metricNode, JSON, metric);
        }
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to retrieve the metric nodes", e);
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException)

Example 78 with MetadataRepositoryException

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

the class JcrServiceLevelAgreement method getObligationGroups.

/* (non-Javadoc)
         * @see com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement#getObligationGroups()
         */
@Override
public List<ObligationGroup> getObligationGroups() {
    try {
        @SuppressWarnings("unchecked") Iterator<Node> defItr = (Iterator<Node>) this.node.getNodes(DEFAULT_GROUP);
        @SuppressWarnings("unchecked") Iterator<Node> grpItr = (Iterator<Node>) this.node.getNodes(GROUPS);
        return Lists.newArrayList(Iterators.concat(Iterators.transform(defItr, (groupNode) -> {
            return JcrUtil.createJcrObject(groupNode, JcrObligationGroup.class, JcrServiceLevelAgreement.this);
        }), Iterators.transform(grpItr, (groupNode) -> {
            return JcrUtil.createJcrObject(groupNode, JcrObligationGroup.class, JcrServiceLevelAgreement.this);
        })));
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to retrieve the obligation nodes", e);
    }
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) Iterator(java.util.Iterator) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException)

Example 79 with MetadataRepositoryException

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

the class JcrServiceLevelAgreementCheck method setActionConfigurations.

public void setActionConfigurations(List<? extends ServiceLevelAgreementActionConfiguration> actionConfigurations) {
    try {
        NodeIterator nodes = this.node.getNodes(ACTION_CONFIGURATIONS);
        while (nodes.hasNext()) {
            Node metricNode = (Node) nodes.next();
            metricNode.remove();
        }
        for (ServiceLevelAgreementActionConfiguration actionConfiguration : actionConfigurations) {
            Node node = this.node.addNode(ACTION_CONFIGURATIONS, ACTION_CONFIGURATION_TYPE);
            JcrPropertyUtil.setProperty(node, JcrPropertyConstants.TITLE, actionConfiguration.getClass().getSimpleName());
            ServiceLevelAgreementActionConfig annotation = actionConfiguration.getClass().getAnnotation(ServiceLevelAgreementActionConfig.class);
            String desc = actionConfiguration.getClass().getSimpleName();
            if (annotation != null) {
                desc = annotation.description();
            }
            JcrPropertyUtil.setProperty(node, DESCRIPTION, desc);
            JcrUtil.addGenericJson(node, JcrPropertyConstants.JSON, actionConfiguration);
        }
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to retrieve the metric nodes", e);
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) ServiceLevelAgreementActionConfig(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig)

Example 80 with MetadataRepositoryException

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

the class JcrServiceLevelAgreementProvider method builder.

public ServiceLevelAgreementBuilder builder(ServiceLevelAgreement.ID id) {
    try {
        Session session = getSession();
        Node slaNode = session.getNodeByIdentifier(id.toString());
        if (slaNode == null || !slaNode.isNodeType("tba:sla")) {
            throw new MetadataRepositoryException("Failed to get sla node for " + id);
        }
        // clear out any obligations/metrics associated to this node as the builder will bring in new ones
        JcrServiceLevelAgreement sla = new JcrServiceLevelAgreement(slaNode);
        sla.clear();
        return builder(slaNode);
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to create an sla node", e);
    }
}
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)

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