Package ariba.ui.aribaweb.util

Examples of ariba.ui.aribaweb.util.Parameters


        try {
            AWStringKeyHashtable newHashtable = new AWStringKeyHashtable(1);
            AWMimeReader mimeReader = new AWMimeReader(
                contentStream(), contentLength(), contentType());
            while (true) {
                Parameters parameters = mimeReader.nextHeaders();
                if (parameters == null) {
                    break;
                }
                String disposition = parameters.getParameter(
                    MIME.HeaderContentDisposition);
                if (disposition == null) {
                        // This is the workaround to a bug in the Macintosh version of IE.
                    disposition = parameters.getParameter(
                        AWRequest.HeaderContentDispositionForMacintosh);
                }
                String name = AWMimeReader.mimeArgumentValue(
                    disposition, MIME.ParameterName);
                String fileName = AWMimeReader.mimeArgumentValue(
                    disposition, MIME.ParameterFilename);
                if (fileName != null) {
                    String headerContentType =
                        parameters.getParameter(MIME.HeaderContentType);
                    if (headerContentType == null) {
                        headerContentType = MIME.ContentTypeApplicationOctetStream;
                    }

                    // get locale for this request.  Default to browser preferred locale.
View Full Code Here


    }

    protected AWStringKeyHashtable parseFormEncodedRequest ()
    {
        AWStringKeyHashtable newHashtable = null;
        Parameters formValues = AWBaseRequest.parameters(this);
        if (formValues != null) {
            String characterEncodingName =
                formValues.getParameter(AWBaseRequest.CharacterEncodingKey);
            AWCharacterEncoding characterEncoding = null;
            if (!StringUtil.nullOrEmptyOrBlankString(characterEncodingName)) {
                characterEncoding = AWCharacterEncoding.characterEncodingNamed(
                    characterEncodingName);
                if (characterEncoding != null) {
                    setCharacterEncoding(characterEncoding);
                }
            }
            // subclass might have initialized it.
            characterEncoding = characterEncoding();
            int elementCount = formValues.getParameterCount();
            newHashtable =  new AWStringKeyHashtable(
                (elementCount == 0) ? 1 : elementCount);
            Iterator keyEnumerator = formValues.getParameterNames();

            String[] debugFilterKeys = null;
            boolean isAribawebDebugEnabled = Log.aribaweb_request.isDebugEnabled();
            if (isAribawebDebugEnabled) {
                Log.aribaweb_request.debug("---> form values");
                // check for debug filter values
                debugFilterKeys = formValues.getParameterValues(AWLogFilterListKey);
            }
            while (keyEnumerator.hasNext()) {
                String keyString = (String)keyEnumerator.next();
                String[] formValuesArray = formValues.getParameterValues(keyString);
                if (isAribawebDebugEnabled) {
                    boolean filter = false;
                    if (debugFilterKeys != null) {
                        for (int i=0, size=debugFilterKeys.length;
                             i < size && !filter; i++) {
View Full Code Here

        if (formValuesString.matches(".*&(amp|lt|gt|quot);.*")) {
            throw new AWGenericException(
                "Invalid formValuesString -- contains escaped html: " +
                formValuesString);
        }
        Parameters parameters = new Parameters();
        FastStringBuffer buffer = new FastStringBuffer();
        StringTokenizer tokens = new StringTokenizer(formValuesString, "&");
        while (tokens.hasMoreTokens()) {
            String keyValuePair = tokens.nextToken();
            int pos = keyValuePair.indexOf('=');
            if (pos == -1) {
                // if there is no = sign, then log warning and skip this parameter
                // "Invalid formValuesString -- missing '=', skipping: %s"
                Log.aribaweb.warning(9282, keyValuePair);
                continue;
            }
            String key = keyValuePair.substring(0, pos);
            String value = keyValuePair.substring(pos+1, keyValuePair.length());
            key = decodeString(key, buffer);
            value = decodeString(value, buffer);
            parameters.putParameter(key, value);
        }
        return parameters;
    }
View Full Code Here

    /**
        NOTE: This code is based on ariba.util.net.HTTPRequest
    */
    protected static Parameters parameters (AWRequest request)
    {
        Parameters parameters = null;
        String contentString = null;
        String queryStringForPost = null;
        String contentType = request.contentType();
        if (!StringUtil.nullOrEmptyOrBlankString(contentType)) {
            String[] values = StringUtil.delimitedStringToArray(contentType, ';');
            contentType = values[0].trim();
        }
        if (contentType == null || GETMethod.equals(request.method())) {
            String queryString = request.queryString();
            if (queryString != null) {
                contentString = queryString;
                if (contentString.equals("null")) {
                    contentString = null;
                }
            }
        }
        else if (contentType.equalsIgnoreCase(
            AWContentType.ApplicationWWWFormUrlEncoded.name)) {
            byte[] contentBytes = request.content();
            if (contentBytes != null && contentBytes.length > 0) {
                contentString = new String(contentBytes);
            }
            //sometimes we need parameters in the query string for POST also.
            //add query string parameters also to form values
            //if they don't exist already
            queryStringForPost = request.queryString();
            Log.aribaweb_request.debug("queryStringForPost:%s", queryStringForPost);
            if (queryStringForPost != null
                    && queryStringForPost.equals("null")) {
                queryStringForPost = null;
            }

        }
        if (!StringUtil.nullOrEmptyOrBlankString(contentString)) {
            parameters = parametersFromUrlEncodedString(contentString);           
        }
        if (!StringUtil.nullOrEmptyOrBlankString(queryStringForPost) &&
                parameters != null) {
            Parameters queryParameters = parametersFromUrlEncodedString(queryStringForPost);
            Iterator itr = queryParameters.getParameterNames();
            while(itr.hasNext()) {
                String name = (String)itr.next();
                //add to parameters if it is not already exist.
                if (parameters.getParameterValues(name) == null) {
                    Log.aribaweb_request.debug("Adding query string parameter to form:%s",
                                                        name);
                    parameters.putParameter(name,
                            queryParameters.getParameter(name));
                }
            }
        }

        return parameters;
View Full Code Here

        I'll unify the code paths so that my code uses this as well.
    */
    public static Map parseUrlEncodedFormValues (String formValuesString)
    {
        AWStringKeyHashtable newHashtable = null;
        Parameters parameters =
            AWBaseRequest.parametersFromUrlEncodedString(formValuesString);
        if (parameters != null) {
            String characterEncodingName =
                parameters.getParameter(AWBaseRequest.CharacterEncodingKey);
            AWCharacterEncoding characterEncoding = null;
            if (!StringUtil.nullOrEmptyOrBlankString(characterEncodingName)) {
                characterEncoding =
                    AWCharacterEncoding.characterEncodingNamed(characterEncodingName);
            }
            int elementCount = parameters.getParameterCount();
            newHashtable = new AWStringKeyHashtable(
                (elementCount == 0) ? 1 : elementCount);
            Iterator keyEnumerator = parameters.getParameterNames();
            while (keyEnumerator.hasNext()) {
                String keyString = (String)keyEnumerator.next();
                String[] formValuesArray = parameters.getParameterValues(keyString);
                if (characterEncoding != null &&
                    !characterEncoding.equals(AWCharacterEncoding.ISO8859_1)) {
                    AWBaseRequest.convertStrings(formValuesArray, characterEncoding);
                }
                newHashtable.put(keyString, formValuesArray);
View Full Code Here

TOP

Related Classes of ariba.ui.aribaweb.util.Parameters

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.