Package com.cuubez.core.transform.xml

Examples of com.cuubez.core.transform.xml.DefaultXMLTransformer


        String content = null;
        Object output;
        Document document = null;

        log.trace("request transformation[XML] started");
        DefaultXMLTransformer transformer = new DefaultXMLTransformer();

        try {

            document = XMLTransformerUtil.createDocument(messageContext.getRequestConfigurationContext().getRequest());

            if(XMLTransformerUtil.isEmpty(document)) {
                content = XMLTransformerUtil.getDocumentAsString(document);
            }

        } catch (ParserConfigurationException e) {
            log.error(e);
            throw new CuubezException(CuubezExceptionConstance.PARSING_EXCEPTION);
        } catch (TransformerException e) {
            log.error(e);
            throw new CuubezException(CuubezExceptionConstance.PARSING_EXCEPTION);
        }

        if (content != null) {
            Class<?> inputObjectType = messageContext.getRequestContext().getSelectedResource().getSelectedMethodMetaData().getInputObjectType();
            String rootNode = XMLTransformerUtil.getRootNodeName(document);
            output = transformer.unMarshal(rootNode, content, inputObjectType);
            setInputObjectToParameterArray(messageContext, output);
        }

    }
View Full Code Here


           messageContext.getResponseContext().setContent(responseContent);

        } else if (MediaType.APPLICATION_XML.equals(messageContext.getResponseContext().getMediaType()) && messageContext.getResponseContext().isNeedToTransform()) {

            log.trace("response transformation[XML] started");
            Transformer transformer = new DefaultXMLTransformer();
            String output = transformer.marshal(messageContext.getResponseContext().getReturnObject());
            messageContext.getResponseContext().setContent(output);

        } else if (MediaType.APPLICATION_JSON.equals(messageContext.getResponseContext().getMediaType()) && messageContext.getResponseContext().isNeedToTransform()) {

            log.trace("response transformation[JSON] started");
            Transformer transformer = new DefaultJSONTransformer();
            String output = transformer.marshal(messageContext.getResponseContext().getReturnObject());
            messageContext.getResponseContext().setContent(output);

        } else if (MediaType.TEXT_PLAIN.equals(messageContext.getResponseContext().getMediaType()) && messageContext.getResponseContext().isNeedToTransform()) {

            log.trace("response transformation[Text] started");
            Transformer transformer = new DefaultTextTransformer();
            String output = transformer.marshal(messageContext.getResponseContext().getReturnObject());
            messageContext.getResponseContext().setContent(output);

        }

    }
View Full Code Here


        if (MediaType.APPLICATION_XML.equals(messageContext.getResponseContext().getMediaType())) {

            log.trace("response transformation[XML] started");
            Transformer transformer = new DefaultXMLTransformer();
            String output = transformer.marshal(messageContext.getResponseContext().getReturnObject());
            messageContext.getResponseContext().setContent(output);

        } else if (MediaType.APPLICATION_JSON.equals(messageContext.getResponseContext().getMediaType())) {

            log.trace("response transformation[JSON] started");
            Transformer transformer = new DefaultJSONTransformer();
            String output = transformer.marshal(messageContext.getResponseContext().getReturnObject());
            messageContext.getResponseContext().setContent(output);

        }

    }
View Full Code Here

        String content = null;
        Object output;
        Document document = null;

        log.trace("request transformation[XML] started");
        DefaultXMLTransformer transformer = new DefaultXMLTransformer();

        try {

            document = XMLTransformerUtil.createDocument(messageContext.getRequestConfigurationContext().getRequest());

            if(XMLTransformerUtil.isEmpty(document)) {
                content = XMLTransformerUtil.getDocumentAsString(document);
            }

        } catch (ParserConfigurationException e) {
            log.error(e);
            throw new CuubezException(CuubezExceptionConstance.PARSING_EXCEPTION);
        } catch (TransformerException e) {
            log.error(e);
            throw new CuubezException(CuubezExceptionConstance.PARSING_EXCEPTION);
        }

        if (content != null) {
            Class<?> inputObjectType = messageContext.getRequestContext().getSelectedResource().getSelectedMethodMetaData().getInputObjectType();
            String rootNode = XMLTransformerUtil.getRootNodeName(document);
            output = transformer.unMarshal(rootNode, content, inputObjectType);
            setInputObjectToParameterArray(messageContext, output);
        }

    }
View Full Code Here

TOP

Related Classes of com.cuubez.core.transform.xml.DefaultXMLTransformer

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.