All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openl.rules.webstudio.util.WebTool Maven / Gradle / Ivy

There is a newer version: 5.27.9
Show newest version
package org.openl.rules.webstudio.util;

import java.util.Map;
import javax.servlet.ServletRequest;

import org.apache.commons.lang3.ArrayUtils;

import org.openl.util.StringTool;

/**
 * DOCUMENT ME!
 *
 * @author Stanislav Shor
 */
public final class WebTool {
    private WebTool() {
    }

    public static String listRequestParams(ServletRequest request, String[] exceptParams) {
        StringBuilder buf = new StringBuilder();

        for (Map.Entry entry : request.getParameterMap().entrySet()) {
            String paramName = entry.getKey();
            if (ArrayUtils.contains(exceptParams, paramName)) {
                continue;
            }
            if (buf.length() != 0) {
                buf.append('&');
            }
            String[] paramValues = entry.getValue();
            buf.append(paramName).append('=').append(StringTool.encodeURL(paramValues[0]));
        }

        return buf.toString();
    }

    public static String getContentDispositionValue(String fileName) {
        String encodedFileName = StringTool.encodeURL(fileName);
        return "attachment; filename=" + encodedFileName + "; filename*=UTF-8''" + encodedFileName;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy