Package org.milyn

Examples of org.milyn.SmooksException


                }
            } else {
                performTransform(element, ghostElement, ownerDoc);
            }
        } catch (TransformerException e) {
            throw new SmooksException("Error applying XSLT to node [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "]", e);
        }

        if(getOutputStreamResource() != null || getAction() == Action.BIND_TO) {
            // For bindTo or streamTo actions, we need to serialize the content and supply is as a Text DOM node.
            // AbstractTemplateProcessor will look after the rest, by extracting the content from the
View Full Code Here


          try {
        Transformer transformer = xslTemplate.newTransformer();
        transformer.transform(source, result);
        return true;
      } catch (TransformerConfigurationException e) {
        throw new SmooksException("Error applying XSLT.", e);
      } catch (TransformerException e) {
        throw new SmooksException("Error applying XSLT.", e);
      }     
    }
       
    return false;
  }
View Full Code Here

            Writer writer = AbstractOutputStreamResource.getOutputWriter(outputStreamResourceName, executionContext);
            String text = extractTextContent(node, executionContext);
            try {
                writer.write(text);
            } catch (IOException e) {
                throw new SmooksException("Failed to write to output stream resource '" + outputStreamResourceName + "'.", e);
            }
        } else {
            if(action == Action.ADDTO) {
                element.appendChild(node);
            } else if(action == Action.INSERT_BEFORE) {
View Full Code Here

            String contextKey = ContextObjectSerializationUnit.getContextKey((Element) node);
            return (String) executionContext.getAttribute(contextKey);
        } else if(node.getNodeType() == Node.ELEMENT_NODE && TextSerializationUnit.isTextElement((Element) node)) {
            return TextSerializationUnit.getText((Element) node);
        } else {
            throw new SmooksException("Unsupported 'bindTo' or toOutStream templating action.  The bind data must be attached to a DOM Text node, or already bound to a <context-object> element.");
        }
    }
View Full Code Here

    public RuleEvalResult evaluate(String ruleName, CharSequence selectedData, ExecutionContext context) throws SmooksException {
        ExpressionEvaluator evaluator = rules.get(ruleName);

        if (evaluator == null) {
            throw new SmooksException("Unknown rule name '" + ruleName + "' on MVEL RuleProvider '" + name + "'.");
        }

        try {
            return new MVELRuleEvalResult(evaluator.eval(context.getBeanContext().getBeanMap()), ruleName, name, selectedData.toString());
        } catch(Throwable t) {
View Full Code Here

    }

    @SuppressWarnings("unchecked")
  private void loadRules() {
        if (src == null) {
            throw new SmooksException("ruleFile not specified.");
        }

        InputStream ruleStream;

        // Get the input stream...
        try {
            ruleStream = new URIResourceLocator().getResource(src);
        }
        catch (final IOException e) {
            throw new SmooksException("Failed to open rule file '" + src + "'.", e);
        }

        CSVReader csvLineReader = new CSVReader(new InputStreamReader(ruleStream));
        List<String[]> entries;
        try {
View Full Code Here

        AssertArgument.isNotNull(selectedData, "selectedData");

        final Pattern pattern = rules.get(ruleName);

        if (pattern == null) {
            throw new SmooksException("Unknown rule name '" + ruleName + "' on Regex RuleProvider '" + providerName + "'.");
        }

        final boolean matched = pattern.matcher(selectedData).matches();

        return new RegexRuleEvalResult(matched, ruleName, providerName, pattern, selectedData.toString());
View Full Code Here

     * @param ruleFile The rule file path.
     */
    protected void loadRules(final String ruleFile)
    {
        if (ruleFile == null) {
            throw new SmooksException("ruleFile not specified.");
        }

        InputStream ruleStream;

        // Get the input stream...
        try
        {
            ruleStream = new URIResourceLocator().getResource(ruleFile);
        }
        catch (final IOException e)
        {
            throw new SmooksException("Failed to open rule file '" + ruleFile + "'.", e);
        }

        Properties rawRuleTable = new Properties();

        // Load the rawRuleTable into a Properties instance...
        try
        {
            rawRuleTable.load(ruleStream);
        }
        catch (final IOException e)
        {
            throw new SmooksException("Error reading InputStream to rule file '" + ruleFile + "'.", e);
        }
        finally
        {
            try
            {
View Full Code Here

        // Get the current Config...
        try {
            currentConfig = resourceStack.peek();
        } catch (EmptyStackException e) {
            throw new SmooksException("No SmooksResourceConfiguration available in ExtensionContext stack.  Unable to set SmooksResourceConfiguration property '" + actualMapTo + "' with element text value.");
        }

        // Get the parent Config...
        try {
            parentConfig = resourceStack.get(resourceStack.size() - 1 + parentRelIndex);
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new SmooksException("No Parent SmooksResourceConfiguration available in ExtensionContext stack at relative index '" + parentRelIndex + "'.  Unable to set SmooksResourceConfiguration property '" + actualMapTo + "' with value of '" + mapFrom + "' from parent configuration.");
        }

        if(logger.isDebugEnabled()) {
          logger.debug("Mapping property '" + mapFrom + "' on parent resource configuration to property'" + actualMapTo + "'.");
        }
View Full Code Here

        String value = DomUtils.getAllText(element, false);
        String mapToPropertyName = mapTo;

        if(mapToPropertyName == null) {
            if(mapToSpecifier == null) {
                throw new SmooksException("One of attributes 'mapTo' or 'mapToSpecifier' must be specified.");
            }
            mapToPropertyName = DomUtils.getAttributeValue(element, mapToSpecifier);
        }

        try {
            config = ExtensionContext.getExtensionContext(executionContext).getResourceStack().peek();
        } catch (EmptyStackException e) {
            throw new SmooksException("No SmooksResourceConfiguration available in ExtensionContext stack.  Unable to set SmooksResourceConfiguration property '" + mapToPropertyName + "' with element text value.");
        }

        if (value == null) {
            value = defaultValue;
        }
View Full Code Here

TOP

Related Classes of org.milyn.SmooksException

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.