Package org.apache.axis2.description

Examples of org.apache.axis2.description.PolicyInclude


    }
  }
 
 
  public void configureOperationPolices(AxisOperation op)throws AxisFault{
    PolicyInclude policyInclude = op.getPolicyInclude();
   
    if(policyInclude != null ){
      Policy policy = policyInclude.getEffectivePolicy();
      if(policy != null){
        if (!policy.isNormalized()) {
          policy = (Policy) policy.normalize();
        }
View Full Code Here


        // setting the name
        axisService.setName(wsdl4jService.getQName().getLocalPart());

        // ///////////////// adding Policies ////////////////////////////

        PolicyInclude policyInclude = axisService.getPolicyInclude();

        List wsdlPolicies = getPoliciesAsExtElements(wsdlDefinition
                .getExtensibilityElements());
        Iterator wsdlPolicyIterator = wsdlPolicies.iterator();

        while (wsdlPolicyIterator.hasNext()) {
            Policy wsdlPolicy = (Policy) wsdlPolicyIterator.next();

            if (wsdlPolicy.getPolicyURI() != null) {
                policyInclude.registerPolicy(wsdlPolicy);
            }
        }

        // /////////////////////////////////////////////////////////////////

        // setting the schema
        Types types = wsdlDefinition.getTypes();

        if (types != null) {
            Iterator extElements = types.getExtensibilityElements().iterator();
            ExtensibilityElement extElement;

            while (extElements.hasNext()) {
                extElement = (ExtensibilityElement) extElements.next();

                if (extElement instanceof Schema) {
                    Element schemaElement = ((Schema) extElement).getElement();
                    axisService.setSchema(getXMLSchema(schemaElement));
                }
            }
        }

        HashMap resolvedRPCWrapperElements = new HashMap();
        XmlSchema xmlSchemaForWrappedElements = generateWrapperSchema(
                wsdlDefinition, resolvedRPCWrapperElements);

        if (xmlSchemaForWrappedElements != null) {
            axisService.setSchema(xmlSchemaForWrappedElements);
        }

        // getting the port of the service with SOAP binding
        Map ports = wsdl4jService.getPorts();

        if (ports.isEmpty()) {
            logger.error(Messages.getMessage("serviceporterror"));
            throw new WSDLProcessingException(Messages.getMessage("serviceporterror"));
        }

        Port wsdl4jPort = getPortWithSoapBinding(ports);

        if (wsdl4jPort == null) {
            logger.error(Messages.getMessage("soapbindingerror"));
            throw new WSDLProcessingException(Messages.getMessage("soapbindingerror"));
        }

        Binding wsdl4jBinding = wsdl4jPort.getBinding();
        PortType wsdl4jPortType = wsdl4jBinding.getPortType();

        // ///////////// Adding policies //////////////////////////////////

        List axisServicePolicies;

        // wsdl:Service
        axisServicePolicies = getPoliciesAsExtElements(wsdl4jService
                .getExtensibilityElements());
        addPolicyElements(PolicyInclude.SERVICE_POLICY, axisServicePolicies,
                policyInclude);

        // wsdl:Port
        axisServicePolicies = getPoliciesAsExtElements(wsdl4jPort
                .getExtensibilityElements());
        addPolicyElements(PolicyInclude.PORT_POLICY, axisServicePolicies,
                policyInclude);

        // wsdl:PortType
        axisServicePolicies = getPoliciesAsExtAttributes(wsdl4jPortType
                .getExtensionAttributes());
        addPolicyElements(PolicyInclude.PORT_TYPE_POLICY, axisServicePolicies,
                policyInclude);

        // wsdl:Binding
        axisServicePolicies = getPoliciesAsExtElements(wsdl4jBinding
                .getExtensibilityElements());
        addPolicyElements(PolicyInclude.BINDING_POLICY, axisServicePolicies,
                policyInclude);

        // ////////////////////////////////////////////////////////////////

        Iterator wsdl4jOperations = wsdl4jPortType.getOperations().iterator();

        while (wsdl4jOperations.hasNext()) {
            Operation wsdl4jOperation = (Operation) wsdl4jOperations.next();
            BindingOperation wsdl4jBindingOperation = wsdl4jBinding
                    .getBindingOperation(wsdl4jOperation.getName(), null, null);

            AxisOperation axisOperation;

            try {
                axisOperation = AxisOperationFactory
                        .getAxisOperation(getMessageExchangePattern(wsdl4jOperation));

                // setting parent
                axisOperation.setParent(axisService);
                // setting operation name
                axisOperation.setName(new QName(wsdl4jOperation.getName()));

                // //////////////adding Policy //////////////////////////////

                PolicyInclude operationPolicyInclude = axisOperation
                        .getPolicyInclude();
                operationPolicyInclude.setPolicyRegistry(policyInclude.getPolicyRegistry());
               
                List operationPolicies;

                // wsdl:PortType -> wsdl:Operation
                operationPolicies = getPoliciesAsExtElements(wsdl4jOperation
                        .getExtensibilityElements());
                addPolicyElements(PolicyInclude.OPERATION_POLICY,
                        operationPolicies, operationPolicyInclude);

                // wsdl:Binding -> wsdl:Operation
                operationPolicies = getPoliciesAsExtElements(wsdl4jBindingOperation
                        .getExtensibilityElements());
                addPolicyElements(PolicyInclude.BINDING_OPERATION_POLICY,
                        operationPolicies, operationPolicyInclude);

                // /////////////////////////////////////////////////////////////

                String soapActionURI = getSOAPActionURI(wsdl4jBindingOperation
                        .getExtensibilityElements());

                if (soapActionURI != null) {
                    axisService.mapActionToOperation(soapActionURI,
                            axisOperation);
                }

                // Input
                Input wsdl4jInput = wsdl4jOperation.getInput();
                BindingInput wsdl4jBindingInput = wsdl4jBindingOperation
                        .getBindingInput();
                Message wsdl4jInputMessage = wsdl4jInput.getMessage();

                AxisMessage axisInputMessage = axisOperation
                        .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

                // ////////////////// adding Policies /////////////////////////

                PolicyInclude inputPolicyInclue = axisInputMessage
                        .getPolicyInclude();
                inputPolicyInclue.setPolicyRegistry(operationPolicyInclude.getPolicyRegistry());
               
                List inputMessagePolicies;

                // wsdl:PortType -> wsdl:Operation -> wsdl:Input
                inputMessagePolicies = getPoliciesAsExtAttributes(wsdl4jInput
                        .getExtensionAttributes());
                addPolicyElements(PolicyInclude.INPUT_POLICY,
                        inputMessagePolicies, inputPolicyInclue);

                // wsdl:Binding -> wsdl:Operation -> wsdl:Input
                inputMessagePolicies = getPoliciesAsExtElements(wsdl4jBindingInput
                        .getExtensibilityElements());
                addPolicyElements(PolicyInclude.BINDING_INPUT_POLICY,
                        inputMessagePolicies, inputPolicyInclue);

                // wsdl:Message
                inputMessagePolicies = getPoliciesAsExtElements(wsdl4jInputMessage
                        .getExtensibilityElements());
                addPolicyElements(PolicyInclude.MESSAGE_POLICY,
                        inputMessagePolicies, inputPolicyInclue);

                // /////////////////////////////////////////////////////////////

                // setting the element qname
                QName elementName = generateReferenceQname(
                        new QName(wsdl4jPortType.getQName().getNamespaceURI(),
                                wsdl4jOperation.getName()), wsdl4jInputMessage,
                        findWrapppable(wsdl4jInputMessage),
                        resolvedRPCWrapperElements);
                axisInputMessage.setElementQName(elementName);

                // setting wsa:Action
                String wsaActionForInput = getWsaAction(wsdl4jInput
                        .getExtensionAttributes());

                if (wsaActionForInput != null
                        && wsaActionForInput.length() != 0) {
                    axisService.mapActionToOperation(wsaActionForInput,
                            axisOperation);
                }

                Output wsdl4jOutput = wsdl4jOperation.getOutput();
                BindingOutput wsdl4jBindingOutput = wsdl4jBindingOperation
                        .getBindingOutput();

                if (wsdl4jOutput != null) {

                    AxisMessage axisOutputMessage = axisOperation
                            .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);

                    Message wsdl4jOutputMessage = wsdl4jOutput.getMessage();

                    // ///////////// adding Policies ///////////////////////////

                    PolicyInclude outputPolicyInclude = axisOutputMessage
                            .getPolicyInclude();
                    outputPolicyInclude.setPolicyRegistry(operationPolicyInclude.getPolicyRegistry());
                    List outputPolicies;

                    // wsdl:Output
                    outputPolicies = getPoliciesAsExtAttributes(wsdl4jOutput
                            .getExtensionAttributes());
View Full Code Here

                            out.write(outStr.getBytes());
                        }

                    } else {

                        PolicyInclude policyInclude = ((AxisService) serviceObj).getPolicyInclude();
                        Policy effecPolicy = policyInclude.getEffectivePolicy();

                        if (effecPolicy != null) {
                            XMLStreamWriter writer;

                            try {
View Full Code Here

                            out.write(outStr.getBytes());
                        }

                    } else {
                       
                        PolicyInclude policyInclude = ((AxisService) serviceObj).getPolicyInclude();
                        Policy effecPolicy = policyInclude.getEffectivePolicy();

                        if (effecPolicy != null) {
                            XMLStreamWriter writer;

                            try {
View Full Code Here

    // setting the name
    axisService.setName(wsdl4jService.getQName().getLocalPart());

    // ///////////////// adding Policies ////////////////////////////

    PolicyInclude policyInclude = new PolicyInclude();

    List wsdlPolicies = getPoliciesAsExtElements(wsdlDefinition
        .getExtensibilityElements());
    Iterator wsdlPolicyIterator = wsdlPolicies.iterator();

    while (wsdlPolicyIterator.hasNext()) {
      Policy wsdlPolicy = (Policy) wsdlPolicyIterator.next();

      if (wsdlPolicy.getPolicyURI() != null) {
        policyInclude.registerPolicy(wsdlPolicy);
      }
    }

    axisService.setPolicyInclude(policyInclude);

    // ////////////////////////////////////////////////////////////////

    // setting the schema
    Types types = wsdlDefinition.getTypes();

    if (types != null) {
      Iterator extElements = types.getExtensibilityElements().iterator();
      ExtensibilityElement extElement;

      while (extElements.hasNext()) {
        extElement = (ExtensibilityElement) extElements.next();

        if (extElement instanceof Schema) {
          Element schemaElement = ((Schema) extElement).getElement();
          axisService.setSchema(getXMLSchema(schemaElement));
        }
      }
    }

    HashMap resolvedRPCWrapperElements = new HashMap();
    XmlSchema xmlSchemaForWrappedElements = generateWrapperSchema(
        wsdlDefinition, resolvedRPCWrapperElements);

    if (xmlSchemaForWrappedElements != null) {
      axisService.setSchema(xmlSchemaForWrappedElements);
    }

    // getting the port of the service with SOAP binding
    Map ports = wsdl4jService.getPorts();

    if (ports.isEmpty()) {
      logger.error("atleast one port should be specified");
      throw new WSDLProcessingException(
          "atleast one Port should be specified");
    }

    Port wsdl4jPort = getPortWithSoapBinding(ports);

    if (wsdl4jPort == null) {
      logger
          .error("atleast one port with a soap binding should be specified");
      throw new WSDLProcessingException("no port with soap binding found");
    }

    Binding wsdl4jBinding = wsdl4jPort.getBinding();
    PortType wsdl4jPortType = wsdl4jBinding.getPortType();

    // ///////////// Adding policies //////////////////////////////////

    List axisServicePolicies;

    // wsdl:Service
    axisServicePolicies = getPoliciesAsExtElements(wsdl4jService
        .getExtensibilityElements());
    addPolicyElements(PolicyInclude.SERVICE_POLICY, axisServicePolicies,
        policyInclude);

    // wsdl:Port
    axisServicePolicies = getPoliciesAsExtElements(wsdl4jPort
        .getExtensibilityElements());
    addPolicyElements(PolicyInclude.PORT_POLICY, axisServicePolicies,
        policyInclude);

    // wsdl:PortType
    axisServicePolicies = getPoliciesAsExtAttributes(wsdl4jPortType
        .getExtensionAttributes());
    addPolicyElements(PolicyInclude.PORT_TYPE_POLICY, axisServicePolicies,
        policyInclude);

    // wsdl:Binding
    axisServicePolicies = getPoliciesAsExtElements(wsdl4jBinding
        .getExtensibilityElements());
    addPolicyElements(PolicyInclude.BINDING_POLICY, axisServicePolicies,
        policyInclude);

    // ////////////////////////////////////////////////////////////////

    Iterator wsdl4jOperations = wsdl4jPortType.getOperations().iterator();

    while (wsdl4jOperations.hasNext()) {
      Operation wsdl4jOperation = (Operation) wsdl4jOperations.next();
      BindingOperation wsdl4jBindingOperation = wsdl4jBinding
          .getBindingOperation(wsdl4jOperation.getName(), null, null);

      AxisOperation axisOperation;

      try {
        axisOperation = AxisOperationFactory
            .getAxisOperation(getMessageExchangePattern(wsdl4jOperation));

        // setting parent
        axisOperation.setParent(axisService);
        // setting operation name
        axisOperation.setName(new QName(wsdl4jOperation.getName()));

        // //////////////adding Policy //////////////////////////////

        PolicyInclude operationPolicyInclude = new PolicyInclude(
            axisService.getPolicyInclude());

        List operationPolicies;

        // wsdl:PortType -> wsdl:Operation
        operationPolicies = getPoliciesAsExtElements(wsdl4jOperation
            .getExtensibilityElements());
        addPolicyElements(PolicyInclude.OPERATION_POLICY,
            operationPolicies, operationPolicyInclude);

        // wsdl:Binding -> wsdl:Operation
        operationPolicies = getPoliciesAsExtElements(wsdl4jBindingOperation
            .getExtensibilityElements());
        addPolicyElements(PolicyInclude.BINDING_OPERATION_POLICY,
            operationPolicies, operationPolicyInclude);

        axisOperation.setPolicyInclude(operationPolicyInclude);

        // /////////////////////////////////////////////////////////////

        String soapActionURI = getSOAPActionURI(wsdl4jBindingOperation
            .getExtensibilityElements());

        if (soapActionURI != null) {
          axisService.mapActionToOperation(soapActionURI,
              axisOperation);
        }

        // Input
        Input wsdl4jInput = wsdl4jOperation.getInput();
        BindingInput wsdl4jBindingInput = wsdl4jBindingOperation
            .getBindingInput();
        Message wsdl4jInputMessage = wsdl4jInput.getMessage();

        AxisMessage axisInputMessage = axisOperation
            .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

        // ////////////////// adding Policies /////////////////////////

        PolicyInclude inputPolicyInclue = new PolicyInclude(
            axisOperation.getPolicyInclude());

        List inputMessagePolicies;

        // wsdl:PortType -> wsdl:Operation -> wsdl:Input
        inputMessagePolicies = getPoliciesAsExtAttributes(wsdl4jInput
            .getExtensionAttributes());
        addPolicyElements(PolicyInclude.INPUT_POLICY,
            inputMessagePolicies, inputPolicyInclue);

        // wsdl:Binding -> wsdl:Operation -> wsdl:Input
        inputMessagePolicies = getPoliciesAsExtElements(wsdl4jBindingInput
            .getExtensibilityElements());
        addPolicyElements(PolicyInclude.BINDING_INPUT_POLICY,
            inputMessagePolicies, inputPolicyInclue);

        // wsdl:Message
        inputMessagePolicies = getPoliciesAsExtElements(wsdl4jInputMessage
            .getExtensibilityElements());
        addPolicyElements(PolicyInclude.MESSAGE_POLICY,
            inputMessagePolicies, inputPolicyInclue);

        axisInputMessage.setPolicyInclude(policyInclude);

        // /////////////////////////////////////////////////////////////

        // setting the element qname
        axisInputMessage.setElementQName(generateReferenceQname(
            new QName(wsdl4jPortType.getQName().getNamespaceURI(),
                wsdl4jOperation.getName()), wsdl4jInputMessage,
            findWrapppable(wsdl4jInputMessage),
            resolvedRPCWrapperElements));

        // setting wsa:Action
        String wsaActionForInput = getWsaAction(wsdl4jInput
            .getExtensionAttributes());

        if (wsaActionForInput != null
            && wsaActionForInput.length() != 0) {
          axisService.mapActionToOperation(wsaActionForInput,
              axisOperation);
        }

        Output wsdl4jOutput = wsdl4jOperation.getOutput();
        BindingOutput wsdl4jBindingOutput = wsdl4jBindingOperation
            .getBindingOutput();

        if (wsdl4jOutput != null) {

          AxisMessage axisOutputMessage = axisOperation
              .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);

          Message wsdl4jOutputMessage = wsdl4jOutput.getMessage();

          // ///////////// adding Policies ///////////////////////////

          PolicyInclude outputPolicyInclude = new PolicyInclude(
              axisService.getPolicyInclude());
          List outputPolicies;

          // wsdl:Output
          outputPolicies = getPoliciesAsExtAttributes(wsdl4jOutput
View Full Code Here

        faultyServices = new Hashtable();
        faultyModules = new Hashtable();
        observersList = new ArrayList();
        inPhasesUptoAndIncludingPostDispatch = new ArrayList();

        policyInclude = new PolicyInclude();

        systemClassLoader = Thread.currentThread().getContextClassLoader();
        serviceClassLoader = Thread.currentThread().getContextClassLoader();
        moduleClassLoader = Thread.currentThread().getContextClassLoader();
View Full Code Here

       
        if (axisServiceGroup == null) {
            axisConfiguration = axisServiceGroup.getParent();
        }

        PolicyInclude servicePolicyInclude = axisService.getPolicyInclude();

        List policyList;

        // Policies defined in Axis2.xml
        if (axisConfiguration != null) {
        policyList = axisConfiguration.getPolicyInclude().getPolicyElements(
                PolicyInclude.AXIS_POLICY);
        addPolicyAsExtElements(description, policyList, wsdlService,
                servicePolicyInclude);
        }

        // Policies defined in wsdl:Service
        policyList = servicePolicyInclude
                .getPolicyElements(PolicyInclude.SERVICE_POLICY);
        addPolicyAsExtElements(description, policyList, wsdlService,
                servicePolicyInclude);

        Iterator wsdlEndpoints = wsdlService.getEndpoints().values().iterator();
View Full Code Here

        populatePolicy(description, wsdlEndpoint, axisService);
    }

    private static void populatePolicy(WSDLDescription description,
                                       WSDLEndpoint wsdlEndpoint, AxisService axisService) {
        PolicyInclude policyInclude = axisService.getPolicyInclude();
        List policyList = policyInclude
                .getPolicyElements(PolicyInclude.PORT_POLICY);
        addPolicyAsExtElements(description, policyList, wsdlEndpoint,
                policyInclude);

        WSDLBinding wsdlBinding = wsdlEndpoint.getBinding();
View Full Code Here

    }

    private static void populatePolicy(WSDLDescription description,
                                       WSDLInterface wsdlInterface, AxisService axisService) {
        PolicyInclude policyInclude = axisService.getPolicyInclude();
        List policyList = policyInclude
                .getPolicyElements(PolicyInclude.PORT_TYPE_POLICY);
        addPolicyAsExtAttributes(description, policyList, wsdlInterface,
                policyInclude);

        Iterator wsdlOperations = wsdlInterface.getOperations().values()
View Full Code Here

    }

    private static void populatePolicy(WSDLDescription description,
                                       WSDLOperation wsdlOperation, AxisOperation axisOperation) {

        PolicyInclude policyInclude = axisOperation.getPolicyInclude();

        // wsdl:PortType -> wsdl:Operation
        List policyList = policyInclude
                .getPolicyElements(PolicyInclude.OPERATION_POLICY);
        addPolicyAsExtElements(description, policyList, wsdlOperation,
                policyInclude);

        if (WSDLConstants.MEP_URI_IN_ONLY.equals(axisOperation
                .getMessageExchangePattern())) {
            AxisMessage input = axisOperation
                    .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            PolicyInclude policyInclude2 = input.getPolicyInclude();

            // wsdl:PortType -> wsdl:Operation -> wsdl:Input
            List policyList2 = policyInclude2
                    .getPolicyElements(PolicyInclude.INPUT_POLICY);
            addPolicyAsExtAttributes(description, policyList2, wsdlOperation
                    .getInputMessage(), policyInclude2);

        } else if (WSDLConstants.MEP_URI_IN_OUT.equals(axisOperation
                .getMessageExchangePattern())) {
            PolicyInclude policyInclude2;
            List policyList2;

            AxisMessage input = axisOperation
                    .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            policyInclude2 = input.getPolicyInclude();

            // wsdl:PortType -> wsdl:Operation -> wsdl:Input
            policyList2 = policyInclude2
                    .getPolicyElements(PolicyInclude.INPUT_POLICY);
            addPolicyAsExtAttributes(description, policyList2, wsdlOperation
                    .getInputMessage(), policyInclude2);

            AxisMessage output = axisOperation
                    .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
            policyInclude2 = output.getPolicyInclude();

            // wsdl:PortType -> wsdl:Operation -> wsdl:Output
            policyList2 = policyInclude2
                    .getPolicyElements(PolicyInclude.OUTPUT_POLICY);
            addPolicyAsExtAttributes(description, policyList2, wsdlOperation
                    .getOutputMessage(), policyInclude2);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.axis2.description.PolicyInclude

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.