Example usage for com.liferay.portal.kernel.util ServerDetector isWebSphere

List of usage examples for com.liferay.portal.kernel.util ServerDetector isWebSphere

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ServerDetector isWebSphere.

Prototype

public static boolean isWebSphere() 

Source Link

Usage

From source file:com.liferay.opensocial.shindig.servlet.AuthenticationServletFilter.java

License:Open Source License

@Override
public void init(FilterConfig filterConfig) throws ServletException {

    // LPS-23577// w  ww  .j  ava  2  s  . c  o m

    if (ServerDetector.isWebSphere()) {
        injector = null;
    } else {
        super.init(filterConfig);
    }
}

From source file:com.liferay.rtl.servlet.filters.ComboServletFilter.java

License:Open Source License

@Override
protected void processFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
        throws Exception {

    Set<String> modulePathsSet = new LinkedHashSet<String>();

    Enumeration<String> enu = request.getParameterNames();

    if (ServerDetector.isWebSphere()) {
        Map<String, String[]> parameterMap = HttpUtil.getParameterMap(request.getQueryString());

        enu = Collections.enumeration(parameterMap.keySet());
    }//from www  .  ja  v  a2  s .  c  om

    while (enu.hasMoreElements()) {
        String name = enu.nextElement();

        if (_protectedParameters.contains(name)) {
            continue;
        }

        modulePathsSet.add(name);
    }

    if (modulePathsSet.size() == 0) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Modules paths set is empty");

        return;
    }

    String[] modulePaths = modulePathsSet.toArray(new String[modulePathsSet.size()]);

    String firstModulePath = modulePaths[0];

    String extension = FileUtil.getExtension(firstModulePath);

    String minifierType = ParamUtil.getString(request, "minifierType");

    if (Validator.isNull(minifierType)) {
        minifierType = "js";

        if (StringUtil.equalsIgnoreCase(extension, _CSS_EXTENSION)) {
            minifierType = "css";
        }
    }

    if (!minifierType.equals("css") && !minifierType.equals("js")) {
        minifierType = "js";
    }

    String modulePathsString = null;

    byte[][] bytesArray = null;

    if (!PropsValues.COMBO_CHECK_TIMESTAMP) {
        modulePathsString = Arrays.toString(modulePaths);

        if (minifierType.equals("css") && DynamicCSSUtil.isRightToLeft(request)) {

            modulePathsString += ".rtl";
        }

        bytesArray = _bytesArrayPortalCache.get(modulePathsString);
    }

    if (bytesArray == null) {
        String rootPath = ServletContextUtil.getRootPath(_servletContext);

        bytesArray = new byte[modulePaths.length][];

        for (int i = 0; i < modulePaths.length; i++) {
            String modulePath = modulePaths[i];

            if (!validateModuleExtension(modulePath)) {
                response.setHeader(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_NO_CACHE_VALUE);
                response.setStatus(HttpServletResponse.SC_NOT_FOUND);

                return;
            }

            byte[] bytes = new byte[0];

            if (Validator.isNotNull(modulePath)) {
                modulePath = StringUtil.replaceFirst(modulePath, PortalUtil.getPathContext(), StringPool.BLANK);

                URL url = getResourceURL(_servletContext, rootPath, modulePath);

                if (url == null) {
                    response.setHeader(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_NO_CACHE_VALUE);
                    response.setStatus(HttpServletResponse.SC_NOT_FOUND);

                    return;
                }

                bytes = getResourceContent(request, response, url, modulePath, minifierType);
            }

            bytesArray[i] = bytes;
        }

        if ((modulePathsString != null) && !PropsValues.COMBO_CHECK_TIMESTAMP) {

            _bytesArrayPortalCache.put(modulePathsString, bytesArray);
        }
    }

    String contentType = ContentTypes.TEXT_JAVASCRIPT;

    if (StringUtil.equalsIgnoreCase(extension, _CSS_EXTENSION)) {
        contentType = ContentTypes.TEXT_CSS;
    }

    response.setContentType(contentType);

    ServletResponseUtil.write(response, bytesArray);
}

From source file:com.liferay.testpacl.util.TestPACLUtil.java

License:Open Source License

public static String translateFileName(String fileName) {
    if (fileName.startsWith("../webapps")) {
        String installedDir = StringPool.BLANK;

        try {/*from  ww w.j  a  v  a2  s  .c om*/
            installedDir = DeployManagerUtil.getInstalledDir();
        } catch (Exception e) {
            _log.error(e, e);
        }

        fileName = StringUtil.replace(fileName, "../webapps", installedDir);

        if (ServerDetector.isGeronimo()) {
            String geronimoHome = System.getProperty("org.apache.geronimo.home.dir");
            String version = ReleaseInfo.getVersion();

            fileName = StringUtil.replace(fileName, installedDir + "/chat-portlet/", geronimoHome
                    + "/repository/liferay/chat-portlet/" + version + ".1/chat-portlet-" + version + ".1.car/");
        } else if (ServerDetector.isGlassfish()) {
            fileName = StringUtil.replace(fileName, "autodeploy", "applications");
        } else if (ServerDetector.isJBoss()) {
            fileName = StringUtil.replace(fileName, "/chat-portlet/", "/chat-portlet.war/");
        } else if (ServerDetector.isWebSphere()) {
            String serverRoot = System.getProperty("server.root");
            String cellName = System.getenv("WAS_CELL");

            fileName = StringUtil.replace(fileName, installedDir + "/chat-portlet/",
                    serverRoot + "/installedApps/" + cellName + "/chat-portlet.ear/chat-portlet.war/");
        }
    }

    return fileName;
}

From source file:com.liferay.util.aspectj.AspectJUtil.java

License:Open Source License

public static Method getMethod(MethodSignature methodSignature) throws NoSuchMethodException {

    Method method = null;/*from w  w  w.ja v  a  2  s . c  o  m*/

    if (ServerDetector.isWebSphere()) {
        Class<?> declaringType = methodSignature.getDeclaringType();
        String name = methodSignature.getName();
        Class<?>[] parameterTypes = methodSignature.getParameterTypes();

        method = declaringType.getMethod(name, parameterTypes);
    } else {
        method = methodSignature.getMethod();
    }

    return method;
}

From source file:com.liferay.util.Encryptor.java

License:Open Source License

public static Provider getProvider()
        throws ClassNotFoundException, IllegalAccessException, InstantiationException {

    Class<?> providerClass = null;

    try {/* w w  w. j  a va  2  s .co m*/
        providerClass = Class.forName(PROVIDER_CLASS);
    } catch (ClassNotFoundException cnfe) {
        if ((ServerDetector.isWebSphere()) && (PROVIDER_CLASS.equals(SUN_PROVIDER_CLASS))) {

            if (_log.isWarnEnabled()) {
                _log.warn("WebSphere does not have " + SUN_PROVIDER_CLASS + ", using " + IBM_PROVIDER_CLASS
                        + " instead");
            }

            providerClass = Class.forName(IBM_PROVIDER_CLASS);
        } else if (System.getProperty("java.vm.vendor").equals("IBM Corporation")) {

            if (_log.isWarnEnabled()) {
                _log.warn("IBM JVM does not have " + SUN_PROVIDER_CLASS + ", using " + IBM_PROVIDER_CLASS
                        + " instead");
            }

            providerClass = Class.forName(IBM_PROVIDER_CLASS);
        } else {
            throw cnfe;
        }
    }

    return (Provider) providerClass.newInstance();
}