Examples of LoggedRuntimeException


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;

        String ruleKey = ruleSet.getAttributeValue(CommonsConstants.ATT_KEY_Q);
        if (ruleKey != null && !"".equals(ruleKey)) {
            description.setKey(ruleKey.trim());
        } else {
            String path = ruleSet.getAttributeValue(CommonsConstants.ATT_PATH_Q);
            if (path != null && !"".equals(path)) {
                description.setPath(path);
            } else {
                OMElement inLinedSource = ruleSet.getFirstElement();
                if (inLinedSource == null) {
                    String inLinedText = ruleSet.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

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;

        OMNamespace omNamespace = parent.getNamespace();
        OMElement sourceOmElement = OM_FACTORY.createOMElement("source", omNamespace);
        String key = description.getKey();
        Object inLinedScript = description.getRuleSource();
        if (key == null && inLinedScript == null) {
            throw new LoggedRuntimeException("Invalid Configuration !!- Either script in-lined " +
                    "value or key should be presented", log);
        }

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

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

        OMElement prop = OM_FACTORY.createOMElement("property", OmNamespace);
        if (property.getName() != null) {
            prop.addAttribute(OM_FACTORY.createOMAttribute("name", NULL_NS, property.getName()));
        } else {
            throw new LoggedRuntimeException("Property name missing", log);
        }

        if (property.getValue() != null) {
            prop.addAttribute(OM_FACTORY.createOMAttribute("value", NULL_NS, property.getValue()));

        } else if (property.getExpression() != null) {
            xPathSerializer.serializeXPath(property.getExpression(), prop, "expression");

        } else {
            throw new LoggedRuntimeException("Property must have a literal" +
                    " value or be an expression", log);
        }
        return prop;
    }
View Full Code Here

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

                    attributeName, nullNS, xpath.toString()));

            serializeNameSpaces(element, xpath);

        } else {
            throw new LoggedRuntimeException("Couldn't find the xpath in the AXIOMXPath", log);
        }
    }
View Full Code Here

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

     * @return the stream object of the given object value
     */
    public static InputStream toInputStream(Object value, Map<String, Object> properties) {

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

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

        if (log.isDebugEnabled()) {
            log.debug("Value to be converted to stream : " + value);
        }

        if (value instanceof OMElement) {
            if (properties != null) {
                String sourceFormat = (String) properties.get(CommonsConstants.SOURCE);
                if (!CommonsConstants.FORMAT_XML.equals(sourceFormat)) {
                    // if the rule format is native , it have to be wrapped by CDATA
                    String source = ((OMElement) (value)).getText();
                    if (source != null && !"".equals(source)) {
                        return new ByteArrayInputStream(source.trim().getBytes());
                    }
                }
            }
            OMElement omElement = (OMElement) value;
            ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
            try {
                omElement.serialize(arrayOutputStream);
                return new ByteArrayInputStream(arrayOutputStream.toByteArray());
            } catch (XMLStreamException e) {
                throw new LoggedRuntimeException("Error converting to a Stream from OMElement : " +
                        value, e, log);
            }

        } else if (value instanceof OMText) {
            DataHandler dataHandler = (DataHandler) ((OMText) value).getDataHandler();
            if (dataHandler != null) {
                try {
                    return dataHandler.getInputStream();
                } catch (IOException e) {
                    throw new LoggedRuntimeException("Error in reading content as a stream " +
                            "from DataHandler", log);
                }
            }
        } else if (value instanceof URI) {
            try {
                return ((URI) (value)).toURL().openStream();
            } catch (IOException e) {
                throw new LoggedRuntimeException("Error opening stream form URI " + value, e, log);
            }
        } else if (value instanceof String) {
            return new ByteArrayInputStream(((String) value).trim().getBytes());
        } else {
            throw new LoggedRuntimeException("Cannot convert object to a Stream : " + value, log);
        }
        return null;
    }
View Full Code Here

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

            try {
                AXIOMXPath xpath = new AXIOMXPath(omAttribute.getAttributeValue());
                XPathHelper.addNameSpaces(xpath, element);
                return xpath;
            } catch (JaxenException e) {
                throw new LoggedRuntimeException("Invalid XPapth expression : " +
                        omAttribute.getAttributeValue(), e, log);
            }

        } else {
            throw new LoggedRuntimeException("Couldn't find the XPath attribute with the QName : "
                    + attributeName.toString() + " in the element : " + element.toString(), log);
        }
    }
View Full Code Here

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

     * @return <code>AXIOMXPath</code> if the expression is valid
     */
    public BaseXPath createXPath(String xpath, Collection<OMNamespace> omNameSpaces) {

        if (xpath == null || "".equals(xpath)) {
            throw new LoggedRuntimeException("XPath expression is null or empty", log);
        }
        try {
            AXIOMXPath axiomxPath = new AXIOMXPath(xpath.trim());
            for (OMNamespace omNamespace : omNameSpaces) {
                if (omNamespace != null) {
                    axiomxPath.addNamespace(omNamespace.getPrefix(), omNamespace.getNamespaceURI());
                }
            }
            return axiomxPath;
        } catch (JaxenException e) {
            throw new LoggedRuntimeException("Invalid XPapth expression : " +
                    xpath, e, log);
        }
    }
View Full Code Here

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

    public static OMElement serialize(ResourceDescription description,
                                      QName root,
                                      XPathSerializer xPathSerializer) {

        if (description == null) {
            throw new LoggedRuntimeException("Invalid Resource description !! ." +
                    " The Resource description is null.", log);
        }

        String id = description.getName();
        OMElement resourceElem = OM_FACTORY.createOMElement(root.getLocalPart(),
View Full Code Here

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

        }
        try {
            return classLoader.loadClass(className);

        } catch (ClassNotFoundException e) {
            throw new LoggedRuntimeException("The class with name '" + className +
                    " ' cannot found " + e, log);

        }
    }
View Full Code Here

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

            return null;
        }
        try {
            return aClass.newInstance();
        } catch (IllegalAccessException e) {
            throw new LoggedRuntimeException("Error when initiating new class" +
                    " instance with name " +
                    "' " + className + " '", e, log);
        } catch (InstantiationException e) {
            throw new LoggedRuntimeException("Error when initiating new class " +
                    "instance with name " +
                    "' " + className + " '", e, log);
        }
    }
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.