Package org.wso2.carbon.utils.xml

Examples of org.wso2.carbon.utils.xml.XMLPrettyPrinter


    public static String prettyPrint(String rawXML) {
        rawXML = rawXML.replaceAll("\n|\\r|\\f|\\t", "");
        rawXML = rawXML.replaceAll("> +<", "><");
        InputStream xmlIn = new ByteArrayInputStream(rawXML.getBytes());
        XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn);
        rawXML = xmlPrettyPrinter.xmlFormat();
//        rawXML = rawXML.replaceAll("\n", "<br>");

        return rawXML;
    }
View Full Code Here


  /** 
   * Prettify a given XML string
   */
  public static String prettifyXML(String xmlContent) {
    ByteArrayInputStream byteIn = new ByteArrayInputStream(xmlContent.getBytes());
    XMLPrettyPrinter prettyPrinter = new XMLPrettyPrinter(byteIn);
    return prettyPrinter.xmlFormat().trim();
  }
View Full Code Here

 
  /**
   * Prettify a given XML file
   */ 
  public static void prettifyXMLFile(String filePath) throws IOException {
    XMLPrettyPrinter prettyPrinter = new XMLPrettyPrinter(new FileInputStream(filePath));
    String prettyXML = prettyPrinter.xmlFormat().trim();
    if (prettyXML != null && prettyXML.trim().length() > 0) {
        FileUtils.writeStringToFile(new File(filePath), prettyXML);
    }
  }
View Full Code Here

            XMLStreamWriter writer =
                    XMLOutputFactory.newInstance().createXMLStreamWriter(outBuffer);
            policy.serialize(writer);
            writer.flush();
            ByteArrayInputStream bais = new ByteArrayInputStream(outBuffer.toByteArray());
            XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(bais);
            return xmlPrettyPrinter.xmlFormat();

        } catch (XMLStreamException e) {
            throw new RuntimeException("Serialization of Policy object failed " + e);
        }
View Full Code Here

                            StAXUtils.createXMLStreamReader(
                                    new ByteArrayInputStream(serviceParameter.getBytes()));
                    OMElement paramEle = new StAXOMBuilder(xmlSR).getDocumentElement();
                    String paramName = paramEle.getAttribute(new QName("name")).getAttributeValue();
                    InputStream xmlIn = new ByteArrayInputStream(serviceParameter.getBytes());
                    XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn, null);
                    Parameter parameter = new Parameter(paramName,
                                                        xmlPrettyPrinter.xmlFormat());
                    boolean isLocked = false;
                    OMAttribute lockedAttrib = paramEle.getAttribute(new QName("locked"));
                    if(lockedAttrib != null) {
                        isLocked = "true".equals(lockedAttrib.getAttributeValue());
                    }
View Full Code Here

                                            .getBytes()));
                            OMElement paramEle = new StAXOMBuilder(xmlSR).getDocumentElement();
                            String paramName = paramEle.getAttribute(new QName("name"))
                                    .getAttributeValue();
                            InputStream xmlIn = new ByteArrayInputStream(groupParameter.getBytes());
                            XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn, null);
                            Parameter parameter = new Parameter(paramName,
                                                                xmlPrettyPrinter.xmlFormat());
                            boolean isLocked = false;
                            OMAttribute lockedAttrib = paramEle.getAttribute(new QName("locked"));
                            if (lockedAttrib != null) {
                                isLocked = "true".equals(lockedAttrib.getAttributeValue());
                            }
View Full Code Here

            XMLStreamWriter writer =
                    XMLOutputFactory.newInstance().createXMLStreamWriter(outBuffer);
            policy.serialize(writer);
            writer.flush();
            ByteArrayInputStream bais = new ByteArrayInputStream(outBuffer.toByteArray());
            XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(bais);
            return xmlPrettyPrinter.xmlFormat();

        } catch (XMLStreamException e) {
            throw new RuntimeException("Serialization of Policy object failed " + e);
        }
View Full Code Here

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.utils.xml.XMLPrettyPrinter

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.