Package ariba.ui.aribaweb.util

Examples of ariba.ui.aribaweb.util.AWStringKeyHashtable


    }

    protected AWStringKeyHashtable parseMultipartEncodedRequest ()
    {
        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.
                    Locale locale = preferredLocale();
                    // get max size for this request
                    int maxLength = AWMimeReader.maxBytesPerChunk();
                    boolean encrypted = false;
                    HttpSession httpSession = getSession(false);
                    if (httpSession != null) {
                        Integer length = (Integer)httpSession.getAttribute(name);
                        if (length != null) {
                            maxLength = length.intValue();
                        }
                        Boolean enc = (Boolean)httpSession.getAttribute(BindingNames.encrypt +"."+name);
                        if (enc != null) {
                            encrypted = enc;
                        }
                        locale = (Locale)httpSession.getAttribute(Locale.class.getName());
                    }

                    String sessionId = initSessionId();
                    ProgressMonitor.register(sessionId);

                    // Message for file upload status panel
                    String msg = localizedJavaString(ComponentName, 1, "Uploaded %s KB of %s KB...",
                                        AWConcreteServerApplication.sharedInstance().resourceManager(locale));

                    ProgressMonitor.instance().prepare(msg, contentLength()/1024);

                    AWFileData fileData =
                        mimeReader.nextChunk(fileName, headerContentType, maxLength, encrypted);

                    if (fileData != null) {
                        newHashtable.put(name, fileData);
                    }
                }
                else {
                    byte[] nextChunk = mimeReader.nextChunk();
                    int nextChunkLength = nextChunk.length;
                    if (nextChunkLength > 0) {
                        if (nextChunk[nextChunkLength - 1] == '\n') {
                            nextChunkLength--;
                            if (nextChunk[nextChunkLength - 1] == '\r') {
                                nextChunkLength--;
                            }
                        }
                    }
                    // Todo: This shouldn't be hard coded to UTF8
                    String nextChunkString = new String(nextChunk, 0,
                        nextChunkLength, AWCharacterEncoding.UTF8.name);
                    String[] nextChunkArray = (String[])newHashtable.get(name);

                    if (nextChunkArray != null) {
                        nextChunkArray = (String[])AWUtil.addElement(
                            nextChunkArray, nextChunkString);
                    }
                    else {
                        nextChunkArray = new String[1];
                        nextChunkArray[0] = nextChunkString;
                    }

                    newHashtable.put(name, nextChunkArray);
                }
            }
            return newHashtable;
        }
        catch (UnsupportedEncodingException unsupportedEncodingException) {
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++) {
                            filter = debugFilterKeys[i].equals(keyString);
                        }
                    }

                    Log.aribaweb_request.debug("name: %s,  value: %s",
                        keyString, filter ? "**** filtered ****" :
                        formValuesArray.length == 1 ? formValuesArray[0] :
                            ArrayUtil.formatArray("",formValuesArray));
                }
                if (characterEncoding != null &&
                    !characterEncoding.equals(AWCharacterEncoding.ISO8859_1)) {
                    AWBaseRequest.convertStrings(formValuesArray, characterEncoding);
                }
                newHashtable.put(keyString, formValuesArray);
            }
        }
        else {
            newHashtable = new AWStringKeyHashtable(1);
        }
        return newHashtable;
    }
View Full Code Here

        stuff to be more efficient, and at that time,
        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);
            }
        }
        else {
            newHashtable = new AWStringKeyHashtable(1);
        }
        return newHashtable;
    }
View Full Code Here

TOP

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

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.