Examples of StAXPolicyWriter


Examples of org.apache.ws.policy.util.StAXPolicyWriter

        writer.writeAttribute("style", soapop.getStyle());
        writer.writeEndElement();
    }
   
    protected void writePolicyExtensibilityElement(PolicyExtensibilityElement policyExtensibilityElement) throws XMLStreamException {
        StAXPolicyWriter policyWriter = (StAXPolicyWriter) PolicyFactory.getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
        Object policyElement = policyExtensibilityElement.getPolicyElement();
       
        if (policyElement instanceof Policy) {
            policyWriter.writePolicy((Policy) policyElement, writer);
                       
        } else if (policyElement instanceof PolicyReference) {
            policyWriter.writePolicyReference((PolicyReference) policyElement, writer);
        }
    }
View Full Code Here

Examples of org.apache.ws.policy.util.StAXPolicyWriter

  }

  public static String getPolicyAsString(Policy policy) {
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    StAXPolicyWriter pwtr = (StAXPolicyWriter) PolicyFactory
        .getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
   
    pwtr.writePolicy(policy, baos);
    return getSafeString(baos.toString());
  }
View Full Code Here

Examples of org.apache.ws.policy.util.StAXPolicyWriter

        writer.writeAttribute("style", soapop.getStyle());
        writer.writeEndElement();
    }
   
    protected void writePolicyExtensibilityElement(PolicyExtensibilityElement policyExtensibilityElement) throws XMLStreamException {
        StAXPolicyWriter policyWriter = (StAXPolicyWriter) PolicyFactory.getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
        Object policyElement = policyExtensibilityElement.getPolicyElement();
       
        if (policyElement instanceof Policy) {
            policyWriter.writePolicy((Policy) policyElement, writer);
                       
        } else if (policyElement instanceof PolicyReference) {
            policyWriter.writePolicyReference((PolicyReference) policyElement, writer);
        }
    }
View Full Code Here

Examples of org.apache.ws.policy.util.StAXPolicyWriter

    }

    private void addPolicy(int type, PolicyInclude policyInclude,
            OMElement element, OMFactory factory) throws Exception {
        ArrayList elementList = policyInclude.getPolicyElements(type);
        StAXPolicyWriter pwrt = (StAXPolicyWriter) PolicyFactory
                .getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);

        for (Iterator iterator = elementList.iterator(); iterator.hasNext();) {
            Object policyElement = iterator.next();

            if (policyElement instanceof Policy) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                pwrt.writePolicy((Policy) policyElement, baos);

                ByteArrayInputStream bais = new ByteArrayInputStream(baos
                        .toByteArray());
                element.addChild(OMXMLBuilderFactory.createStAXOMBuilder(
                        factory,
                        StAXUtils.createXMLStreamReader(
                                bais)).getDocumentElement());

            } else if (policyElement instanceof PolicyReference) {
                OMNamespace ns = factory.createOMNamespace(PolicyConstants.WS_POLICY_NAMESPACE_URI, PolicyConstants.WS_POLICY_PREFIX);
                OMElement refElement = factory.createOMElement(PolicyConstants.WS_POLICY_REFERENCE, ns);
                String policyURIString = ((PolicyReference) policyElement).getPolicyURIString();
                OMAttribute attribute = factory.createOMAttribute("URI", null, policyURIString);
                refElement.addAttribute(attribute);
                element.addChild(refElement);
               
                PolicyRegistry reg = policyInclude.getPolicyRegistry();
                Policy p = reg.lookup(policyURIString);
               
                if(p == null) {
                    throw new Exception("Policy not found for uri : " + policyURIString);
                }
               
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                pwrt.writePolicy(p, baos);

                ByteArrayInputStream bais = new ByteArrayInputStream(baos
                        .toByteArray());
                getDefinitionElement().addChild(OMXMLBuilderFactory.createStAXOMBuilder(
                        factory,
View Full Code Here

Examples of org.apache.ws.policy.util.StAXPolicyWriter

  }

  public static String getPolicyAsString(Policy policy) {
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    StAXPolicyWriter pwtr = (StAXPolicyWriter) PolicyFactory
        .getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
   
    pwtr.writePolicy(policy, baos);
    return getSafeString(baos.toString());
  }
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.