Package org.apache.woden.wsdl20.extensions.http

Examples of org.apache.woden.wsdl20.extensions.http.HTTPLocation


    }   
       
    public void testGetOriginalLocation() {
       
        String origLoc = "/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}";
        HTTPLocation loc;
        loc = new HTTPLocation(origLoc);
        String returnedLoc = loc.getOriginalLocation();
        assertEquals("Unexpected location value", origLoc, returnedLoc);
       
        origLoc = "/travel/flight?no=BA6&dep=13.55";
        loc = new HTTPLocation(origLoc);
        returnedLoc = loc.getOriginalLocation();
        assertEquals("Unexpected location value", origLoc, returnedLoc);
    }
View Full Code Here


    }
   
    public void testGetFormattedLocation() {
       
        String origLoc = "/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}";
        HTTPLocation loc;
        loc = new HTTPLocation(origLoc);
        HTTPLocationTemplate template;
        HTTPLocationTemplate[] templates;
        templates = loc.getTemplates("town");
        templates[0].setValue("Perth");
        template = loc.getTemplate("state");
        template.setValue("WA");
        template = loc.getTemplate("country");
        template.setValue("Australia");
        template = loc.getTemplate("tmp");
        template.setValue("41.5");
        template = loc.getTemplate("mth");
        template.setValue("February");
        template = loc.getTemplate("dt");
        template.setValue("28th");
        templates[1].setValue("Fremantle");
        String formattedLoc = "/temperature/Perth/WA/Australia?temp=41.5&month=February&date=28th&place=Fremantle";
        String returnedLoc = loc.getFormattedLocation();
        assertEquals("Unexpected formatted location value", formattedLoc, returnedLoc);
       
        origLoc = "/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}";
        loc = new HTTPLocation(origLoc);
        templates = loc.getTemplates("town");
        //templates[0].setValue("Perth"); //if {town} is not substituted, it will be replaced by empty string
        template = loc.getTemplate("state");
        template.setValue("WA");
        template = loc.getTemplate("country");
        template.setValue("Australia");
        template = loc.getTemplate("tmp");
        template.setValue("41.5");
        template = loc.getTemplate("mth");
        template.setValue("February");
        template = loc.getTemplate("dt");
        //template.setValue("28th");  //if {!dt} is not substituted, it will be replaced by empty string
        templates[1].setValue("Fremantle");
        formattedLoc = "/temperature//WA/Australia?temp=41.5&month=February&date=&place=Fremantle";
        returnedLoc = loc.getFormattedLocation();
        assertEquals("Unexpected formatted location value", formattedLoc, returnedLoc);
       
        origLoc = "/travel/flight?no=BA6&dep=13.55";
        loc = new HTTPLocation(origLoc);
        returnedLoc = loc.getFormattedLocation();
        assertEquals("Unexpected location value", origLoc, returnedLoc);
       
        origLoc = "{invalid:name}";
        loc = new HTTPLocation(origLoc);
        returnedLoc = loc.getFormattedLocation();
        assertNull("Location is invalid, so null was expected", returnedLoc);
    }
View Full Code Here

        }
        String queryParameterSeparator = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
        if (queryParameterSeparator == null) {
            queryParameterSeparator = WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT;
        }
        HTTPLocation httpLocation = new HTTPLocation(rawURLString);
        HTTPLocationTemplate[] templates = httpLocation.getTemplates();

        for (int i = 0; i < templates.length; i++) {
            HTTPLocationTemplate template = templates[i];
            String localName = template.getName();
            String elementValue = getOMElementValue(localName, firstElement);
            if (template.isEncoded()) {
                try {

                    if (template.isQuery()) {
                        template.setValue(URIEncoderDecoder.quoteIllegal(
                                elementValue,
                                WSDL2Constants.LEGAL_CHARACTERS_IN_QUERY.replaceAll(queryParameterSeparator, "")));
                    } else {
                        template.setValue(URIEncoderDecoder.quoteIllegal(
                                elementValue,
                                WSDL2Constants.LEGAL_CHARACTERS_IN_PATH));
                    }
                } catch (UnsupportedEncodingException e) {
                    throw new AxisFault("Unable to encode Query String");
                }

            } else {
                template.setValue(elementValue);
            }
        }

        return httpLocation.getFormattedLocation();
    }
View Full Code Here

            URI soapMep = soapBindingOperationExtensions.getSoapMep();
            if (soapMep != null) {
                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MEP,
                                                 soapMep.toString());
            }
            HTTPLocation httpLocation = soapBindingOperationExtensions.getHttpLocation();
            // If httpLocation is not null we should extract a constant part from it and add its value and the
            // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
            // the operation name into this map.
            String httpLocationString = "";
            if (httpLocation != null) {
                String httpLocationTemplete = httpLocation.getOriginalLocation();
                axisBindingOperation
                        .setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
                httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete);

            }
View Full Code Here

            axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_FAULT_SERIALIZATION,
                                             httpBindingOperationExtensions.getHttpFaultSerialization());
            axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION,
                                             httpBindingOperationExtensions.getHttpInputSerialization());
            HTTPLocation httpLocation = httpBindingOperationExtensions.getHttpLocation();

            // If httpLocation is not null we should extract a constant part from it and add its value and the
            // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
            // the operation name into this map.
            String httpLocationString = "";
            if (httpLocation != null) {
                String httpLocationTemplete = httpLocation.getOriginalLocation();
                axisBindingOperation
                        .setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
                httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete);

            }
View Full Code Here

            URI soapMep = soapBindingOperationExtensions.getSoapMep();
            if (soapMep != null) {
                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MEP,
                                                 soapMep.toString());
            }
            HTTPLocation httpLocation = soapBindingOperationExtensions.getHttpLocation();
            // If httpLocation is not null we should extract a constant part from it and add its value and the
            // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
            // the operation name into this map.
            String httpLocationString = "";
            if (httpLocation != null) {
                String httpLocationTemplete = httpLocation.getOriginalLocation();
                axisBindingOperation
                        .setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
                httpLocationString = WSDLUtil.getConstantFromHTTPLocation(httpLocationTemplete, HTTPConstants.HEADER_POST);

            }
View Full Code Here

                    }
                }
            }
            axisBindingOperation
                    .setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpMethod);
            HTTPLocation httpLocation = httpBindingOperationExtensions.getHttpLocation();

            // If httpLocation is not null we should extract a constant part from it and add its value and the
            // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
            // the operation name into this map.
            String httpLocationString = "";
            if (httpLocation != null) {
                String httpLocationTemplete = httpLocation.getOriginalLocation();
                axisBindingOperation
                        .setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
                httpLocationString = WSDLUtil.getConstantFromHTTPLocation(httpLocationTemplete, httpMethod);

            }
View Full Code Here

        }
        String queryParameterSeparator = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
        if (queryParameterSeparator == null) {
            queryParameterSeparator = WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT;
        }
        HTTPLocation httpLocation = new HTTPLocation(rawURLString);
        HTTPLocationTemplate[] templates = httpLocation.getTemplates();

        for (int i = 0; i < templates.length; i++) {
            HTTPLocationTemplate template = templates[i];
            String localName = template.getName();
            String elementValue = getOMElementValue(localName, firstElement);
            if (template.isEncoded()) {
                try {

                    if (template.isQuery()) {
                        template.setValue(URIEncoderDecoder.quoteIllegal(
                                elementValue,
                                WSDL2Constants.LEGAL_CHARACTERS_IN_QUERY.replaceAll(queryParameterSeparator, "")));
                    } else {
                        template.setValue(URIEncoderDecoder.quoteIllegal(
                                elementValue,
                                WSDL2Constants.LEGAL_CHARACTERS_IN_PATH));
                    }
                } catch (UnsupportedEncodingException e) {
                    throw new AxisFault("Unable to encode Query String");
                }

            } else {
                template.setValue(elementValue);
            }
        }

        return httpLocation.getFormattedLocation();
    }
View Full Code Here

        }
        String queryParameterSeparator = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
        if (queryParameterSeparator == null) {
            queryParameterSeparator = WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT;
        }
        HTTPLocation httpLocation = new HTTPLocation(rawURLString);
        HTTPLocationTemplate[] templates = httpLocation.getTemplates();

        for (int i = 0; i < templates.length; i++) {
            HTTPLocationTemplate template = templates[i];
            String localName = template.getName();
            String elementValue = getOMElementValue(localName, firstElement);
            if (template.isEncoded()) {
                try {

                    if (template.isQuery()) {
                        template.setValue(URIEncoderDecoder.quoteIllegal(
                                elementValue,
                                WSDL2Constants.LEGAL_CHARACTERS_IN_QUERY.replaceAll(queryParameterSeparator, "")));
                    } else {
                        template.setValue(URIEncoderDecoder.quoteIllegal(
                                elementValue,
                                WSDL2Constants.LEGAL_CHARACTERS_IN_PATH));
                    }
                } catch (UnsupportedEncodingException e) {
                    throw new AxisFault("Unable to encode Query String");
                }

            } else {
                template.setValue(elementValue);
            }
        }

        return httpLocation.getFormattedLocation();
    }
View Full Code Here

            URI soapMep = soapBindingOperationExtensions.getSoapMep();
            if (soapMep != null) {
                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MEP,
                                                 soapMep.toString());
            }
            HTTPLocation httpLocation = soapBindingOperationExtensions.getHttpLocation();
            // If httpLocation is not null we should extract a constant part from it and add its value and the
            // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
            // the operation name into this map.
            String httpLocationString = null;
            if (httpLocation != null) {
                String httpLocationTemplete = httpLocation.getOriginalLocation();
                axisBindingOperation
                        .setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
                httpLocationString = WSDLUtil.getConstantFromHTTPLocation(httpLocationTemplete, HTTPConstants.HEADER_POST);

            }
View Full Code Here

TOP

Related Classes of org.apache.woden.wsdl20.extensions.http.HTTPLocation

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.