Package org.wso2.carbon.governance.api.exception

Examples of org.wso2.carbon.governance.api.exception.GovernanceException


        } catch (RegistryException e) {
            String msg =
                    "Error in retrieving the endpoint resource. url:" + url + ", path:" + path +
                            ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        }
        String artifactId = r.getProperty(GovernanceConstants.ARTIFACT_ID_PROP_KEY);
        if (artifactId != null) {
            return getEndpoint(artifactId);
        }
View Full Code Here


                                break;
                            }
                        } catch (Exception e) {
                            String msg = "Error in performing the regular expression matches for: " +
                                    referenceValue + ".";
                            throw new GovernanceException(msg, e);
                        }
                    }
                    if (satisfied) {
                        break;
                    }
View Full Code Here

        } catch (RegistryException e) {
            String msg =
                    "Error in getting the content for the artifact. artifact id: " + id + ", " +
                            "path: " + path + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        }

        // and then iterate all the properties and add.
        Properties properties = resource.getProperties();
        if (properties != null) {
View Full Code Here

            policy.loadPolicyDetails();
            succeeded = true;
        } catch (RegistryException e) {
            String msg = "Error in adding the Policy. policy id: " + policy.getId() + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        } catch (MalformedURLException e) {
            String msg = "Malformed policy url provided. url: " + url + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        } finally {
            if (succeeded) {
                try {
                    registry.commitTransaction();
                } catch (RegistryException e) {
View Full Code Here

            String msg =
                    "Updates are only accepted if the policy content is available. " +
                            "So no updates will be done. " + "policy id: " + policy.getId() +
                            ", policy path: " + policy.getPath() + ".";
            log.error(msg);
            throw new GovernanceException(msg);
        }
        boolean succeeded = false;
        String url = policy.getUrl();
        try {
            registry.beginTransaction();

            // getting the old policy.
            Policy oldPolicy = getPolicy(policy.getId());
            if (oldPolicy == null) {
                addPolicy(policy);
                return;
            }
            Resource policyResource = registry.newResource();
            policyResource.setMediaType(GovernanceConstants.POLICY_XML_MEDIA_TYPE);

            // setting the policy content
            setContent(policy, policyResource);

            // remove the old policy resource.
            registry.delete(oldPolicy.getPath());

            String tmpPath;
            if (policy.getQName() != null) {
                tmpPath = "/" + policy.getQName().getLocalPart();
            } else if (url != null) {
                tmpPath = RegistryUtils.getResourceName(new URL(url).getFile().replace("~", ""));
            } else {
                String msg =
                        "Error in identifying the name for the policy. State the name for the policy.";
                log.error(msg);
                throw new GovernanceException(msg);
            }
            registry.put(tmpPath, policyResource);
            policy.updatePath();

            succeeded = true;
        } catch (RegistryException e) {
            String msg =
                    "Error in updating the policy, policy id: " + policy.getId() +
                            ", policy path: " + policy.getPath() + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        } catch (MalformedURLException e) {
            String msg = "Malformed url found, url " + url + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        } finally {
            if (succeeded) {
                try {
                    registry.commitTransaction();
                } catch (RegistryException e) {
View Full Code Here

        GovernanceArtifact artifact =
                GovernanceUtils.retrieveGovernanceArtifactById(registry, policyId);
        if (artifact != null && !(artifact instanceof Policy)) {
            String msg = "The artifact request is not a policy. id: " + policyId + ".";
            log.error(msg);
            throw new GovernanceException(msg);
        }
        return (Policy) artifact;
    }
View Full Code Here

            } catch (RegistryException e) {
                String msg =
                        "Error in setting the content from policy, policy id: " + policy.getId() +
                                ", policy path: " + policy.getPath() + ".";
                log.error(msg, e);
                throw new GovernanceException(msg, e);
            }
        }
        // and set all the attributes as properties.
        String[] attributeKeys = policy.getAttributeKeys();
        if (attributeKeys != null) {
View Full Code Here

     */
    public void addSLA(SLA sla) throws GovernanceException {
        if (sla.getQName() == null) {
            String msg = "Name is not set. It have to be set as an qname.";
            log.error(msg);
            throw new GovernanceException(msg);
        }
        String slaName = sla.getQName().getLocalPart();
        sla.setAttributes(GovernanceConstants.SERVICE_NAME_ATTRIBUTE,
                new String[]{slaName});

        sla.associateRegistry(registry);
        boolean succeeded = false;
        try {
            registry.beginTransaction();
            String slaId = sla.getId();
            Resource slaResource = registry.newResource();
            slaResource.setMediaType(GovernanceConstants.SLA_MEDIA_TYPE);
            setContent(sla, slaResource);
            slaResource.setProperty(GovernanceConstants.ARTIFACT_ID_PROP_KEY, slaId);
            // the sla will not actually stored in the tmp path.
            String tmpPath = "/" + slaName;
            registry.put(tmpPath, slaResource);
            succeeded = true;
        } catch (RegistryException e) {
            String msg = "Failed to add artifact: artifact id: " + sla.getId() +
                    ", path: " + sla.getPath() + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        } finally {
            if (succeeded) {
                try {
                    registry.commitTransaction();
                } catch (RegistryException e) {
View Full Code Here

            succeeded = true;
        } catch (RegistryException e) {
            String msg = "Error in updating the artifact, artifact id: " + sla.getId() +
                    ", artifact path: " + sla.getPath() + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        } finally {
            if (succeeded) {
                try {
                    registry.commitTransaction();
                } catch (RegistryException e) {
View Full Code Here

        GovernanceArtifact artifact =
                GovernanceUtils.retrieveGovernanceArtifactById(registry, slaId);
        if (artifact != null && !(artifact instanceof SLA)) {
            String msg = "The artifact request is not an SLA. id: " + slaId + ".";
            log.error(msg);
            throw new GovernanceException(msg);
        }
        return (SLA) artifact;
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.governance.api.exception.GovernanceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.