@Override public void setTimeZoneId(String timeZoneId) { if (Validator.isNull(timeZoneId)) { timeZoneId = TimeZoneUtil.getDefault().getID(); } _timeZone = TimeZoneUtil.getTimeZone(timeZoneId); super.setTimeZoneId(timeZoneId); }
protected void importEvent( PortletDataContext portletDataContext, Element eventElement, CalEvent event) throws Exception { long userId = portletDataContext.getUserId(event.getUserUuid()); Date startDate = event.getStartDate(); int startDateMonth = 0; int startDateDay = 0; int startDateYear = 0; int startDateHour = 0; int startDateMinute = 0; if (startDate != null) { Locale locale = null; TimeZone timeZone = null; if (event.getTimeZoneSensitive()) { User user = UserLocalServiceUtil.getUser(userId); locale = user.getLocale(); timeZone = user.getTimeZone(); } else { locale = LocaleUtil.getDefault(); timeZone = TimeZoneUtil.getTimeZone(StringPool.UTC); } Calendar startCal = CalendarFactoryUtil.getCalendar(timeZone, locale); startCal.setTime(startDate); startDateMonth = startCal.get(Calendar.MONTH); startDateDay = startCal.get(Calendar.DATE); startDateYear = startCal.get(Calendar.YEAR); startDateHour = startCal.get(Calendar.HOUR); startDateMinute = startCal.get(Calendar.MINUTE); if (startCal.get(Calendar.AM_PM) == Calendar.PM) { startDateHour += 12; } } ServiceContext serviceContext = portletDataContext.createServiceContext(eventElement, event, NAMESPACE); CalEvent importedEvent = null; if (portletDataContext.isDataStrategyMirror()) { CalEvent existingEvent = CalEventUtil.fetchByUUID_G(event.getUuid(), portletDataContext.getScopeGroupId()); if (existingEvent == null) { serviceContext.setUuid(event.getUuid()); importedEvent = CalEventLocalServiceUtil.addEvent( userId, event.getTitle(), event.getDescription(), event.getLocation(), startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, event.getDurationHour(), event.getDurationMinute(), event.isAllDay(), event.isTimeZoneSensitive(), event.getType(), event.getRepeating(), event.getRecurrenceObj(), event.getRemindBy(), event.getFirstReminder(), event.getSecondReminder(), serviceContext); } else { importedEvent = CalEventLocalServiceUtil.updateEvent( userId, existingEvent.getEventId(), event.getTitle(), event.getDescription(), event.getLocation(), startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, event.getDurationHour(), event.getDurationMinute(), event.isAllDay(), event.isTimeZoneSensitive(), event.getType(), event.getRepeating(), event.getRecurrenceObj(), event.getRemindBy(), event.getFirstReminder(), event.getSecondReminder(), serviceContext); } } else { importedEvent = CalEventLocalServiceUtil.addEvent( userId, event.getTitle(), event.getDescription(), event.getLocation(), startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, event.getDurationHour(), event.getDurationMinute(), event.isAllDay(), event.isTimeZoneSensitive(), event.getType(), event.getRepeating(), event.getRecurrenceObj(), event.getRemindBy(), event.getFirstReminder(), event.getSecondReminder(), serviceContext); } portletDataContext.importClassedModel(event, importedEvent, NAMESPACE); }
public static synchronized void init() { if (_initialized) { return; } StopWatch stopWatch = new StopWatch(); stopWatch.start(); // Set the default locale used by Liferay. This locale is no longer set // at the VM level. See LEP-2584. String userLanguage = SystemProperties.get("user.language"); String userCountry = SystemProperties.get("user.country"); String userVariant = SystemProperties.get("user.variant"); LocaleUtil.setDefault(userLanguage, userCountry, userVariant); // Set the default time zone used by Liferay. This time zone is no // longer set at the VM level. See LEP-2584. String userTimeZone = SystemProperties.get("user.timezone"); TimeZoneUtil.setDefault(userTimeZone); // Shared class loader try { PortalClassLoaderUtil.setClassLoader(ClassLoaderUtil.getContextClassLoader()); } catch (Exception e) { e.printStackTrace(); } // Properties com.liferay.portal.kernel.util.PropsUtil.setProps(new PropsImpl()); // Log4J if (GetterUtil.getBoolean(SystemProperties.get("log4j.configure.on.startup"), true)) { ClassLoader classLoader = InitUtil.class.getClassLoader(); Log4JUtil.configureLog4J(classLoader); } // Shared log try { LogFactoryUtil.setLogFactory(new Log4jLogFactoryImpl()); } catch (Exception e) { e.printStackTrace(); } // Log sanitizer SanitizerLogWrapper.init(); // Java properties JavaDetector.isJDK5(); // Security manager SecurityManagerUtil.init(); if (SecurityManagerUtil.ENABLED) { com.liferay.portal.kernel.util.PropsUtil.setProps( DoPrivilegedUtil.wrap(com.liferay.portal.kernel.util.PropsUtil.getProps())); LogFactoryUtil.setLogFactory(DoPrivilegedUtil.wrap(LogFactoryUtil.getLogFactory())); } // Cache registry CacheRegistryUtil.setCacheRegistry(DoPrivilegedUtil.wrap(new CacheRegistryImpl())); // Configuration factory ConfigurationFactoryUtil.setConfigurationFactory( DoPrivilegedUtil.wrap(new ConfigurationFactoryImpl())); // Data source factory DataSourceFactoryUtil.setDataSourceFactory(DoPrivilegedUtil.wrap(new DataSourceFactoryImpl())); // DB factory DBFactoryUtil.setDBFactory(DoPrivilegedUtil.wrap(new DBFactoryImpl())); // ROME XmlReader.setDefaultEncoding(StringPool.UTF8); if (_PRINT_TIME) { System.out.println("InitAction takes " + stopWatch.getTime() + " ms"); } _initialized = true; }