Package org.wso2.carbon.registry.core.exceptions

Examples of org.wso2.carbon.registry.core.exceptions.RegistryException


        try {
            wsdlElement = buildOMElement(new String(wsdlContentBytes));
        } catch (Exception e) {
            String msg = "Error in building the wsdl element for path: " + wsdlPath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        // saving soap11 endpoints
        List<OMElement> soap11Elements;
        try {
            soap11Elements =  evaluateXPathToElements(SOAP11_ENDPOINT_EXPR, wsdlElement);
        } catch (Exception e) {
            String msg = "Error in evaluating xpath expressions to extract endpoints, wsdl path: " + wsdlPath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        for (OMElement soap11Element: soap11Elements) {
            String locationUrl = soap11Element.getAttributeValue(new QName(LOCATION_ATTR));
            Map<String, String> properties = new HashMap<String, String>();
            properties.put(CommonConstants.SOAP11_ENDPOINT_ATTRIBUTE, "true");
            saveEndpoint(registry, locationUrl, wsdlPath, properties, systemRegistry);
        }

        // saving soap12 endpoints
        List<OMElement> soap12Elements;
        try {
            soap12Elements =  evaluateXPathToElements(SOAP12_ENDPOINT_EXPR, wsdlElement);
        } catch (Exception e) {
            String msg = "Error in evaluating xpath expressions to extract endpoints, wsdl path: " + wsdlPath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        for (OMElement soap12Element: soap12Elements) {
            String locationUrl = soap12Element.getAttributeValue(new QName(LOCATION_ATTR));
            Map<String, String> properties = new HashMap<String, String>();
            properties.put(CommonConstants.SOAP12_ENDPOINT_ATTRIBUTE, "true");
            saveEndpoint(registry, locationUrl, wsdlPath, properties, systemRegistry);
        }

        // saving http endpoints
        List<OMElement> httpElements;
        try {
            httpElements =  evaluateXPathToElements(HTTP_ENDPOINT_EXPR, wsdlElement);
        } catch (Exception e) {
            String msg = "Error in evaluating xpath expressions to extract endpoints, wsdl path: " + wsdlPath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        for (OMElement httpElement: httpElements) {
            String locationUrl = httpElement.getAttributeValue(new QName(LOCATION_ATTR));
            Map<String, String> properties = new HashMap<String, String>();
            properties.put(CommonConstants.HTTP_ENDPOINT_ATTRIBUTE, "true");
View Full Code Here


                serviceEndpointEntryElements =  evaluateXPathToElements(SERVICE_ENDPOINT_ENTRY_EXPR, serviceElement);
            } catch (Exception e) {
                String msg = "Error in evaluating xpath expressions to extract endpoints, " +
                        "service path: " + servicePath + ".";
                log.error(msg, e);
                throw new RegistryException(msg, e);
            }

            // and add the associations and before adding them first remove all the endpoint dependencies
            Association[] associations = registry.getAllAssociations(servicePath);
            for(Association association:associations){
View Full Code Here

        try {
            serviceElement = buildOMElement(serviceContent);
        } catch (Exception e) {
            String msg = "Failed building the service element. " + servicePath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        OMElement serviceEndpointElement;
        OMNamespace namespace = OMAbstractFactory.getOMFactory().createOMNamespace(
                CommonConstants.SERVICE_ELEMENT_NAMESPACE, null);
        try {
            List<OMElement> endpointElements = evaluateXPathToElements(
                    SERVICE_ENDPOINT_EXPR, serviceElement);
            if (endpointElements.size() == 0) {
                // we need to create the element.
                serviceEndpointElement =
                        OMAbstractFactory.getOMFactory().createOMElement(
                                SERVICE_ENDPOINTS_ELEMENT, namespace);
                serviceElement.addChild(serviceEndpointElement);
            } else {
                serviceEndpointElement = endpointElements.get(0);
            }
        } catch (Exception e) {
            String msg = "Error in getting the endpoint element of the service. " +
                    "service path: " + servicePath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        Iterator it = serviceEndpointElement.getChildElements();
        List<String> currentEndpoints = new ArrayList<String>();
        while(it.hasNext()){
            currentEndpoints.add(((OMElement) it.next()).getText());
View Full Code Here

        try {
            serviceElement = buildOMElement(serviceContent);
        } catch (Exception e) {
            String msg = "Failed building the service element. " + servicePath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        OMElement serviceEndpointElement;
        OMNamespace namespace = OMAbstractFactory.getOMFactory().createOMNamespace(
                CommonConstants.SERVICE_ELEMENT_NAMESPACE, null);
        try {
            List<OMElement> endpointElements = evaluateXPathToElements(
                    SERVICE_ENDPOINT_EXPR, serviceElement);
            if (endpointElements.size() == 0) {
                // we need to create the element.
                serviceEndpointElement =
                        OMAbstractFactory.getOMFactory().createOMElement(
                                SERVICE_ENDPOINTS_ELEMENT, namespace);
                serviceElement.addChild(serviceEndpointElement);
            } else {
                serviceEndpointElement = endpointElements.get(0);
            }
        } catch (Exception e) {
            String msg = "Error in getting the endpoint element of the service. " +
                    "service path: " + servicePath + ".";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        Iterator it = serviceEndpointElement.getChildElements();
        while(it.hasNext()){
            OMElement next = (OMElement) it.next();
            if (next.getText().equals(endpointEnv + ":" + endpointUrl)) {
View Full Code Here

        } else if (contentObj instanceof byte[]) {
            size = ((byte[]) contentObj).length;
        } else {
            String msg = "Unsupported type for the content.";
            log.error(msg);
            throw new RegistryException(msg);
        }


        // persisting bandwidth
        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
View Full Code Here

        // the import resource logic
        URL url;
        try {
            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
                String msg = "The source URL must not be file in the server's local file system";
                throw new RegistryException(msg);
            }
            url = new URL(sourceURL);
        } catch (MalformedURLException e) {
            String msg = "Given source URL " + sourceURL + "is not valid.";
            throw new RegistryException(msg, e);
        }

        try {
            URLConnection uc = url.openConnection();
            InputStream in = uc.getInputStream();
            byte[] inByteArr = RegistryUtils.getByteArray(in);
            int size = inByteArr.length;

            // persisting bandwidth
            BandwidthPersistor.storeIncomingBandwidth(tenantId, size);

        } catch (IOException e) {

            String msg = "Could not read from the given URL: " + sourceURL;
            throw new RegistryException(msg, e);
        }
    }
View Full Code Here

        } else if (contentObj instanceof byte[]) {
            size = ((byte[]) contentObj).length;
        } else {
            String msg = "Unsupported type for the content.";
            log.error(msg);
            throw new RegistryException(msg);
        }
        // persisting bandwidth
        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
        return resource;
    }
View Full Code Here

    }

    public static boolean updateHandler(Registry configSystemRegistry, String oldName, String payload) throws RegistryException,
            XMLStreamException {
        if (isHandlerNameInUse(oldName))
            throw new RegistryException("Could not update handler since it is already in use!");

        String newName = null;
        OMElement element = AXIOMUtil.stringToOM(payload);
        if (element != null) {
            newName = element.getAttributeValue(new QName("class"));
        }

        if (newName == null || newName.equals(""))
            return false; // invalid configuration

        if (oldName == null || oldName.equals("")) {
            String path = getContextRoot() + newName;
            Resource resource;
            if (handlerExists(configSystemRegistry, newName)) {
                return false; // we are adding a new handler
            }
            else {
                resource = new ResourceImpl();
            }
            resource.setContent(payload);
            try {
                configSystemRegistry.beginTransaction();
                configSystemRegistry.put(path, resource);
                generateHandler(configSystemRegistry, path);
                configSystemRegistry.commitTransaction();
            } catch (Exception e) {
                configSystemRegistry.rollbackTransaction();
                throw new RegistryException("Unable to generate handler", e);
            }
            return true;
        }

        if (newName.equals(oldName)) {
            //updating the rest of the content
            String oldPath = getContextRoot() + oldName;
            Resource resource;
            if (handlerExists(configSystemRegistry, oldName)) {
                resource = configSystemRegistry.get(oldPath);
            }
            else {
                resource = new ResourceImpl(); // will this ever happen?
            }
            resource.setContent(payload);
            try {
                configSystemRegistry.beginTransaction();
                configSystemRegistry.put(oldPath, resource);
                generateHandler(configSystemRegistry, oldPath);
                configSystemRegistry.commitTransaction();
            } catch (Exception e) {
                configSystemRegistry.rollbackTransaction();
                throw new RegistryException("Unable to generate handler", e);
            }
            return true;
        }
        else {
            String oldPath = getContextRoot() + oldName;
            String newPath = getContextRoot() + newName;

            if (handlerExists(configSystemRegistry, newName)) {
                return false; // we are trying to use the name of a existing handler
            }

            Resource resource;
            if (handlerExists(configSystemRegistry, oldName)) {
                resource = configSystemRegistry.get(oldPath);
            }
            else {
                resource = new ResourceImpl(); // will this ever happen?
            }

            resource.setContent(payload);
            try {
                configSystemRegistry.beginTransaction();
                configSystemRegistry.put(newPath, resource);
                generateHandler(configSystemRegistry, newPath);
                configSystemRegistry.delete(oldPath);
                removeHandler(configSystemRegistry, oldName);
                configSystemRegistry.commitTransaction();
            } catch (Exception e) {
                configSystemRegistry.rollbackTransaction();
                throw new RegistryException("Unable to renew handler", e);
            }
            return true;
        }
    }
View Full Code Here

        }
        else
            return false;

        if (isHandlerNameInUse(name))
            throw new RegistryException("The added handler name is already in use!");

        String path = getContextRoot() + name;
        Resource resource;
        if (!handlerExists(configSystemRegistry, name)) {
            resource = new ResourceImpl();
        }
        else {
            throw new RegistryException("The added handler name is already in use!");
        }
        resource.setContent(payload);
        try {
            configSystemRegistry.beginTransaction();
            configSystemRegistry.put(path, resource);
            generateHandler(configSystemRegistry, path);
            configSystemRegistry.commitTransaction();
        } catch (Exception e) {
            configSystemRegistry.rollbackTransaction();
            throw new RegistryException("Unable to generate handler", e);
        }
        return true;
    }
View Full Code Here

        return configSystemRegistry.resourceExists(getContextRoot() + name);
    }

    public static boolean deleteHandler(Registry configSystemRegistry, String name) throws RegistryException, XMLStreamException {
        if (isHandlerNameInUse(name))
            throw new RegistryException("Handler could not be deleted, since it is already in use!");

        String path = getContextRoot() + name;
        if (configSystemRegistry.resourceExists(path)) {
            try {
                configSystemRegistry.beginTransaction();
                configSystemRegistry.delete(path);
                removeHandler(configSystemRegistry, name);
                configSystemRegistry.commitTransaction();
            } catch (Exception e) {
                configSystemRegistry.rollbackTransaction();
                throw new RegistryException("Unable to remove handler", e);
            }
            return true;
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.exceptions.RegistryException

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.