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.liferay.book.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from  w w w.  j  a 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,
                    "book-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("book-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 = "book-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.calendar.hook.upgrade.v1_0_1.UpgradeCalendar.java

License:Open Source License

@Override
protected void doUpgrade() throws Exception {
    Connection con = null;/*  w w  w.j  a  v  a  2s.  com*/
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        con = DataAccess.getUpgradeOptimizedConnection();

        StringBundler sb = new StringBundler(6);

        sb.append("select Calendar.calendarId, CalendarResource.");
        sb.append("classNameId, User_.timeZoneId from Calendar ");
        sb.append("inner join CalendarResource on Calendar.");
        sb.append("calendarResourceId = CalendarResource.");
        sb.append("calendarResourceId inner join User_ on ");
        sb.append("CalendarResource.userId = User_.userId");

        ps = con.prepareStatement(sb.toString());

        rs = ps.executeQuery();

        long userClassNameId = PortalUtil.getClassNameId(User.class);

        while (rs.next()) {
            long calendarId = rs.getLong(1);
            long classNameId = rs.getLong(2);

            String timeZoneId = null;

            if (classNameId == userClassNameId) {
                timeZoneId = rs.getString(3);
            } else {
                timeZoneId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE);
            }

            updateCalendarTimeZoneId(con, calendarId, timeZoneId);
        }
    } finally {
        DataAccess.cleanUp(con);
    }
}

From source file:com.liferay.calendar.hook.upgrade.v1_0_1.UpgradeCalendarTest.java

License:Open Source License

@Test
public void testUpgradeSetsSiteCalendarTimeZoneId() throws Exception {
    CalendarResource calendarResource = CalendarResourceUtil.getGroupCalendarResource(_group.getGroupId(),
            new ServiceContext());

    UpgradeCalendar upgradeCalendar = new UpgradeCalendar();

    upgradeCalendar.doUpgrade();//w  w w  .  j  a v a  2  s.  c o  m

    List<Calendar> calendars = CalendarLocalServiceUtil.getCalendarResourceCalendars(_group.getGroupId(),
            calendarResource.getCalendarResourceId());

    Calendar calendar = calendars.get(0);

    Assert.assertEquals(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE), calendar.getTimeZoneId());
}

From source file:com.liferay.calendar.internal.upgrade.v1_0_2.UpgradeCalendar.java

License:Open Source License

public void updateCalendarTimeZoneIds() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        StringBundler sb = new StringBundler(5);

        sb.append("select Calendar.calendarId, CalendarResource.");
        sb.append("classNameId, User_.timeZoneId from Calendar inner ");
        sb.append("join CalendarResource on Calendar.calendarResourceId ");
        sb.append("= CalendarResource.calendarResourceId inner join ");
        sb.append("User_ on CalendarResource.userId = User_.userId");

        try (PreparedStatement ps = connection.prepareStatement(sb.toString());
                ResultSet rs = ps.executeQuery()) {

            long userClassNameId = PortalUtil.getClassNameId(User.class);

            while (rs.next()) {
                long calendarId = rs.getLong(1);
                long classNameId = rs.getLong(2);

                String timeZoneId = null;

                if (classNameId == userClassNameId) {
                    timeZoneId = rs.getString(3);
                } else {
                    timeZoneId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE);
                }//from   w  ww  . ja  va 2  s  .c o m

                updateCalendarTimeZoneId(calendarId, timeZoneId);
            }
        }
    }
}

From source file:com.liferay.calendar.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }// w  ww .jav 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,
                    "calendar-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("calendar-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 = "calendar-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.calendar.upgrade.test.UpgradeCalendarTest.java

License:Open Source License

@Test
public void testUpgradeSetsSiteCalendarTimeZoneId() throws Exception {
    CalendarResource calendarResource = CalendarResourceUtil.getGroupCalendarResource(_group.getGroupId(),
            new ServiceContext());

    upgrade();/* ww  w  .j  a  v a2s.c om*/

    List<Calendar> calendars = CalendarLocalServiceUtil.getCalendarResourceCalendars(_group.getGroupId(),
            calendarResource.getCalendarResourceId());

    Calendar calendar = calendars.get(0);

    Assert.assertEquals(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE), calendar.getTimeZoneId());
}

From source file:com.liferay.calendar.upgrade.v1_0_2.test.UpgradeCalendarTest.java

License:Open Source License

@Test
public void testUpgradeSetsSiteCalendarTimeZoneId() throws Exception {
    Calendar calendar = CalendarTestUtil.addCalendar(_group);

    _upgradeProcess.upgrade();//www .j  av  a2  s  .co m

    assertCalendarTimeZoneId(calendar, PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE));
}

From source file:com.liferay.calendar.upgrade.v1_0_2.UpgradeCalendar.java

License:Open Source License

protected void updateCalendarTimeZoneIds() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        StringBundler sb = new StringBundler(5);

        sb.append("select Calendar.calendarId, CalendarResource.");
        sb.append("classNameId, User_.timeZoneId from Calendar inner ");
        sb.append("join CalendarResource on Calendar.calendarResourceId ");
        sb.append("= CalendarResource.calendarResourceId inner join ");
        sb.append("User_ on CalendarResource.userId = User_.userId");

        try (PreparedStatement ps = connection.prepareStatement(sb.toString());
                ResultSet rs = ps.executeQuery()) {

            long userClassNameId = PortalUtil.getClassNameId(User.class);

            while (rs.next()) {
                long calendarId = rs.getLong(1);
                long classNameId = rs.getLong(2);

                String timeZoneId = null;

                if (classNameId == userClassNameId) {
                    timeZoneId = rs.getString(3);
                } else {
                    timeZoneId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE);
                }// w w  w  .  ja  va  2 s  .c  om

                updateCalendarTimeZoneId(calendarId, timeZoneId);
            }
        }
    }
}

From source file:com.liferay.calendarimporter.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/* w  ww .  ja va  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,
                    "calendar-importer-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("calendar-importer-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 = "calendar-importer-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.chat.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. 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,
                    "chat-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("chat-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 = "chat-portlet";
        }

        return _servletContextName;
    }
}