Examples of LoggedRuntimeException


Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

     * @return <code>String</code> representation of the given object
     */
    public static String toString(Object value, Map<String, Object> properties) {

        if (value == null) {
            throw new LoggedRuntimeException("Cannot convert null object to a string", log);
        }

        if (value instanceof String) {
            return (String) value;
        }

        if (value instanceof OMElement) {
            return ((OMElement) (value)).getText();
        } else if (value instanceof OMText) {
            DataHandler dataHandler = (DataHandler) ((OMText) value).getDataHandler();
            if (dataHandler != null) {
                try {
                    return toString(dataHandler.getInputStream());
                } catch (IOException e) {
                    throw new LoggedRuntimeException("Error in reading content as a string ", log);
                }
            } else {
                return ((OMText) value).getText();
            }
        } else if (value instanceof URI) {
            try {
                return toString(((URI) (value)).toURL().openStream());
            } catch (IOException e) {
                throw new LoggedRuntimeException("Error opening stream form URI", e, log);
            }
        } else {
            throw new LoggedRuntimeException("Cannot convert object to a String", log);
        }

    }
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

        try {
            while ((str = br.readLine()) != null) {
                sb.append(str);
            }
        } catch (IOException e) {
            throw new LoggedRuntimeException("Error converting stream to String ", e, log);
        } finally {
            try {
                br.close();
            } catch (IOException ignored) {
            }
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

            } else {
                OMElement inLinedSource = ruleSet.getFirstElement();
                if (inLinedSource == null) {
                    String inLinedText = ruleSet.getText();
                    if (inLinedText == null || "".equals(inLinedText.trim())) {
                        throw new LoggedRuntimeException("The cep query source cannot be found " +
                                "from either in-lined or key. It is required.", log);
                    } else {
                        description.setQuerySource(inLinedText.trim());
                    }
                } else {
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

    public OMElement serialize(ExtensibleConfiguration configuration,
                               XPathSerializer xPathSerializer,
                               OMElement parent) {

        if (!(configuration instanceof RuleSetDescription)) {
            throw new LoggedRuntimeException("Invalid rule configuration," +
                    "expect RuleSetDescription.", log);
        }

        RuleSetDescription description = (RuleSetDescription) configuration;
        String key = description.getKey();
        String path = description.getPath();
        Object inLinedScript = description.getRuleSource();

        if (key == null && inLinedScript == null && path == null) {
            throw new LoggedRuntimeException("Invalid Configuration !!- Either script in-lined " +
                    "value or key or path should be presented", log);
        }

        if (key != null && !"".equals(key)) {
            parent.addAttribute(OM_FACTORY.createOMAttribute(
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

                OMNamespaceFactory omNamespaceFactory = OMNamespaceFactory.getInstance();
                opElement = OM_FACTORY.createOMElement(CommonsConstants.ELE_OPERATION, NULL_NS);
                opElement.addAttribute(OM_FACTORY.createOMAttribute("name",
                        omNamespaceFactory.createOMNamespace(name), name.getLocalPart()));
            } else {
                throw new LoggedRuntimeException("Operation name missing", log);
            }
        }

        if (description.isForceInOnly()) {
            opElement.addAttribute(OM_FACTORY.createOMAttribute("mep",
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

        QName name = description.getName();
        if (name != null) {
            opElement.addAttribute(OM_FACTORY.createOMAttribute("name",
                    omNamespaceFactory.createOMNamespace(name), name.getLocalPart()));
        } else {
            throw new LoggedRuntimeException("Operation name missing", log);
        }
        extensionSerializer.serialize(description, xPathSerializer, opElement);
        serialize(description, xPathSerializer, opElement);

        return opElement;
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

        QName elementQName = qNameFactory.createQName(CommonsConstants.ELE_ELEMENT, omNamespace);
        if (description.isContainsResult()) {
            ResourceDescription firstDescription = description.getResultDescriptions().get(0);
            if (!"omelement".equals(firstDescription.getType())) { //todo
                throw new LoggedRuntimeException("Invalid result !! result type is invalid", log);
            }
            OMElement resultElement = OM_FACTORY.createOMElement(CommonsConstants.ELE_RESULT,
                    omNamespace);
            String name = firstDescription.getName();
            if (name != null && !"".equals(name)) {
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

            RuleSetDescription description =
                    RuleSetDescriptionFactory.create(executionSetElement, xPathFactory,
                            configurationExtensionBuilder);
            ruleMediatorDescription.setRuleSetDescription(description);
        } else {
            throw new LoggedRuntimeException("ruleset configuration element must be given",
                    log);
        }

        QName factsQName = qNameFactory.createQName("facts", tagQName);
        OMElement factsElement = configurationXML.getFirstChildWithName(factsQName);
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

            XMLStreamReader parser = XMLInputFactory.newInstance().
                    createXMLStreamReader(inputStream);
            StAXOMBuilder builder = new StAXOMBuilder(parser);
            return builder.getDocumentElement();
        } catch (FileNotFoundException e) {
            throw new LoggedRuntimeException(COMPONENT_CONF + "cannot be found in" +
                    " the path : " + path,
                    e, log);
        } catch (XMLStreamException e) {
            throw new LoggedRuntimeException("Invalid XML for " + COMPONENT_CONF + " located in" +
                    " the path : " +
                    path, e, log);
        } finally {
            try {
                if (inputStream != null) {
View Full Code Here

Examples of org.wso2.carbon.rulecep.commons.LoggedRuntimeException

    public void build(ExtensibleConfiguration extensibleConfiguration,
                      OMElement ruleSet, XPathFactory xPathFactory) {

        if (!(extensibleConfiguration instanceof RuleSetDescription)) {
            throw new LoggedRuntimeException("Invalid rule configuration," +
                    "expect RuleSetDescription.", log);
        }

        RuleSetDescription description = (RuleSetDescription) extensibleConfiguration;
        QName parentQName = ruleSet.getQName();
        QNameFactory qNameFactory = QNameFactory.getInstance();
        QName sourceQName = qNameFactory.createQName(CommonsConstants.ELE_SOURCE,
                parentQName);

        OMElement sourceElement = ruleSet.getFirstChildWithName(sourceQName);
        if (sourceElement == null) {
            throw new LoggedRuntimeException("Invalid configuration. " +
                    "The rule set source cannot be found.", log);
        }

        String ruleKey = sourceElement.getAttributeValue(CommonsConstants.ATT_KEY_Q);
        if (ruleKey != null && !"".equals(ruleKey)) {
            description.setKey(ruleKey.trim());
        } else {
            OMElement inLinedSource = sourceElement.getFirstElement();
            if (inLinedSource == null) {
                String inLinedText = sourceElement.getText();
                if (inLinedText == null || "".equals(inLinedText.trim())) {
                    throw new LoggedRuntimeException("The rule set source cannot be found " +
                            "from either in-lined or key. It is required.", log);
                } else {
                    description.setRuleSource(inLinedText.trim());
                }
            } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.