Example usage for com.liferay.portal.kernel.util PropsUtil get

List of usage examples for com.liferay.portal.kernel.util PropsUtil get

Introduction

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

Prototype

public static String get(String key) 

Source Link

Usage

From source file:com.virtusa.icd.service.builder.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from   w  ww.  ja  v  a  2  s.  co  m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "icd-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("icd-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "icd-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.vportal.portal.servlet.PortalSessionListener.java

License:Open Source License

public void sessionCreated(HttpSessionEvent event) {

    /*if (PropsValues.SESSION_DISABLED) {
       return;/*  ww w  .  j a va2 s .  c o m*/
    }*/
    //hoan
    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.SESSION_DISABLED))) {
        return;
    }
    //hoan
    HttpSession ses = event.getSession();

    MethodKey method = new MethodKey("com.liferay.portal.kernel.util.Validator.PortalSessionContext", "put",
            String.class, HttpSession.class);
    Object[] args = new Object[] { ses.getId(), ses };
    //PortalSessionContext.put(ses.getId(), ses);
    try {
        PortalClassInvoker.invoke(false, method, args);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    // Process session created events

    try {
        /*EventsProcessor.process(
        PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
        PropsValues.SERVLET_SESSION_CREATE_EVENTS, ses);*/
        //hoan
        MethodKey methodProcess = new MethodKey("com.liferay.portal.events.EventsProcessorUtil", "process",
                String.class, String.class, HttpSession.class);
        Object[] argsProcess = new Object[] { PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
                PropsUtil.getArray("SERVLET_SESSION_CREATE_EVENTS"), ses };
        PortalClassInvoker.invoke(false, methodProcess, argsProcess);
        /*EventsProcessorUtil.process(
              PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
              PropsValues.SERVLET_SESSION_CREATE_EVENTS, ses);*/
        //hoan      
    } catch (ActionException ae) {
        _log.error(ae, ae);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.vportal.portal.servlet.PortalSessionListener.java

License:Open Source License

public void sessionDestroyed(HttpSessionEvent event) {
    /*if (PropsValues.SESSION_DISABLED) {
    return;/*w w w .j a  v  a  2 s .  c  om*/
    }*/
    //hoan
    if (GetterUtil.getBoolean(PropsUtil.get("SESSION_DISABLED"))) {
        return;
    }
    //hoan

    HttpSession ses = event.getSession();

    MethodKey method = new MethodKey("com.liferay.portal.kernel.util.Validator.PortalSessionContext", "remove",
            String.class);
    Object[] args = new Object[] { ses.getId() };
    try {
        PortalClassInvoker.invoke(false, method, args);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    //PortalSessionContext.remove(ses.getId());

    try {
        Long userIdObj = (Long) ses.getAttribute(WebKeys.USER_ID);

        if (userIdObj == null) {
            _log.warn("User id is not in the session");
        } else {
            long userId = userIdObj.longValue();

            if (CompanyThreadLocal.getCompanyId() == 0) {
                setCompanyId(userId);
            }

            //MailSessionLock.cleanUp(ses);
            MethodKey methodSignOut = new MethodKey("com.liferay.portal.liveusers.LiveUsers", "signOut",
                    long.class, String.class, String.class);
            Object[] argsSignOut = new Object[] { CompanyThreadLocal.getCompanyId(), userId, ses.getId() };
            PortalClassInvoker.invoke(false, methodSignOut, argsSignOut);
            //LiveUsers.signOut(CompanyThreadLocal.getCompanyId(), userId, ses.getId());
        }

    } catch (IllegalStateException ise) {
        _log.warn("Please upgrade to a servlet 2.4 compliant container");
    } catch (Exception e) {
        _log.error(e, e);
    }
    //ses.removeAttribute(WebKeys.PORTLET_SESSION_TRACKER);
    //ses.removeAttribute(WebKeys.REVERSE_AJAX);

    //MessagingUtil.closeXMPPConnection(ses);

    // Process session destroyed events

    try {
        /*EventsProcessor.process(
        PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
        PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/
        //hoan
        MethodKey methodProcess = new MethodKey("com.liferay.portal.events.EventsProcessorUtil", "process",
                String.class, String.class, HttpSession.class);
        Object[] argsProcess = new Object[] { PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
                PropsUtil.getArray(PropsKeys.SERVLET_SESSION_DESTROY_EVENTS), ses };
        PortalClassInvoker.invoke(false, methodProcess, argsProcess);

        /*EventsProcessorUtil.process(
              PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
              PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/
        //hoan

    } catch (ActionException ae) {
        _log.error(ae, ae);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.vportal.portlet.edirectory.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from  www  .  j a  v a  2s.com

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "EDirectory-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("EDirectory-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "EDirectory-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.vportal.portlet.vcalendar.util.CalUtil.java

License:Open Source License

public static String getEmailFromAddress(PortletPreferences preferences) {
    String emailFromAddress = PropsUtil.get(PropsKeys.CALENDAR_EMAIL_FROM_ADDRESS);

    return preferences.getValue("email-from-address", emailFromAddress);
}

From source file:com.vportal.portlet.vcalendar.util.CalUtil.java

License:Open Source License

public static String getEmailFromName(PortletPreferences preferences) {
    String emailFromName = PropsUtil.get(PropsKeys.CALENDAR_EMAIL_FROM_NAME);

    return preferences.getValue("email-from-name", emailFromName);
}

From source file:com.vportal.portlet.vcalendar.util.CalUtil.java

License:Open Source License

public static boolean getEmailEventReminderEnabled(PortletPreferences preferences) {

    String emailEventReminderEnabled = preferences.getValue("email-event-reminder-enabled", StringPool.BLANK);

    if (Validator.isNotNull(emailEventReminderEnabled)) {
        return GetterUtil.getBoolean(emailEventReminderEnabled);
    } else {//from   ww w.  j  a v a2  s .c o  m
        return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.CALENDAR_EMAIL_EVENT_REMINDER_ENABLED));
    }
}

From source file:com.vportal.portlet.vclip.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from  www. j  av  a 2  s . c om

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "vclip-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("vclip-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "vclip-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.vportal.portlet.vdoc.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }// w  ww . ja  v  a 2s  .  co m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "VDoc-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("VDoc-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "VDoc-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.vportal.portlet.vimagegallery.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from  w  w w.  j  ava 2 s . c  o m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "vimagegallery-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("vimagegallery-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "vimagegallery-portlet";
        }

        return _servletContextName;
    }
}