List of usage examples for org.joda.time DateTimeZone UTC
DateTimeZone UTC
To view the source code for org.joda.time DateTimeZone UTC.
Click Source Link
From source file:com.sonicle.webtop.contacts.ContactsManager.java
License:Open Source License
public List<BaseReminder> getRemindersToBeNotified(DateTime now) { ArrayList<BaseReminder> alerts = new ArrayList<>(); HashMap<UserProfileId, Boolean> okCache = new HashMap<>(); HashMap<UserProfileId, DateTime> dateTimeCache = new HashMap<>(); HashMap<UserProfileId, String> deliveryCache = new HashMap<>(); ContactDAO cdao = ContactDAO.getInstance(); Connection con = null;/* w w w . j a va 2 s.c o m*/ // Valid reminder times (see getAnniversaryReminderTime in options) // are only at 0 and 30 min of each hour. So skip unuseful runs... if ((now.getMinuteOfHour() == 0) || (now.getMinuteOfHour() == 30)) { try { con = WT.getConnection(SERVICE_ID); LocalDate date = now.toLocalDate(); List<VContact> bdays = cdao.viewOnBirthdayByDate(con, date); for (VContact cont : bdays) { boolean ok = false; if (!okCache.containsKey(cont.getCategoryProfileId())) { ok = getAnniversaryReminderTime(dateTimeCache, cont.getCategoryProfileId(), date) .withZone(DateTimeZone.UTC).equals(now); okCache.put(cont.getCategoryProfileId(), ok); } if (ok) { DateTime dateTime = getAnniversaryReminderTime(dateTimeCache, cont.getCategoryProfileId(), date); String delivery = getAnniversaryReminderDelivery(deliveryCache, cont.getCategoryProfileId()); UserProfile.Data ud = WT.getUserData(cont.getCategoryProfileId()); if (delivery.equals(ContactsSettings.ANNIVERSARY_REMINDER_DELIVERY_EMAIL)) { alerts.add(createAnniversaryEmailReminder(ud.getLocale(), ud.getEmail(), true, cont, dateTime)); } else if (delivery.equals(ContactsSettings.ANNIVERSARY_REMINDER_DELIVERY_APP)) { alerts.add(createAnniversaryInAppReminder(ud.getLocale(), true, cont, dateTime)); } } } List<VContact> anns = cdao.viewOnAnniversaryByDate(con, date); for (VContact cont : anns) { boolean ok = false; if (!okCache.containsKey(cont.getCategoryProfileId())) { ok = getAnniversaryReminderTime(dateTimeCache, cont.getCategoryProfileId(), date) .withZone(DateTimeZone.UTC).equals(now); okCache.put(cont.getCategoryProfileId(), ok); } if (ok) { DateTime dateTime = getAnniversaryReminderTime(dateTimeCache, cont.getCategoryProfileId(), date); String delivery = getAnniversaryReminderDelivery(deliveryCache, cont.getCategoryProfileId()); UserProfile.Data ud = WT.getUserData(cont.getCategoryProfileId()); if (delivery.equals(ContactsSettings.ANNIVERSARY_REMINDER_DELIVERY_EMAIL)) { alerts.add(createAnniversaryEmailReminder(ud.getLocale(), ud.getEmail(), false, cont, dateTime)); } else if (delivery.equals(ContactsSettings.ANNIVERSARY_REMINDER_DELIVERY_APP)) { alerts.add(createAnniversaryInAppReminder(ud.getLocale(), false, cont, dateTime)); } } } } catch (Exception ex) { logger.error("Error collecting reminder alerts", ex); } finally { DbUtils.closeQuietly(con); } } return alerts; }
From source file:com.sonicle.webtop.contacts.rest.v1.CardDav.java
License:Open Source License
private Card createCard(ContactObjectWithVCard card) { return new Card().id(card.getContactId()).uid(card.getPublicUid()).href(card.getHref()) .lastModified(card.getRevisionTimestamp().withZone(DateTimeZone.UTC).getMillis() / 1000) .etag(buildEtag(card.getRevisionTimestamp())).size(card.getSize()); }
From source file:com.sonicle.webtop.core.app.LogManager.java
License:Open Source License
public boolean write(UserProfileId profileId, String serviceId, String action, String softwareName, String remoteIp, String userAgent, String sessionId, String data) { Connection con = null;/*from ww w .j a v a2s. com*/ if (!initialized) return false; if (!isEnabled(profileId.getDomain(), serviceId)) return false; try { con = WT.getCoreConnection(); SysLogDAO dao = SysLogDAO.getInstance(); OSysLog item = new OSysLog(); item.setSyslogId(dao.getSequence(con)); item.setTimestamp(DateTime.now(DateTimeZone.UTC)); item.setDomainId(profileId.getDomain()); item.setUserId(profileId.getUserId()); item.setServiceId(serviceId); item.setAction(action); item.setSwName(StringUtils.defaultIfBlank(softwareName, wta.getPlatformName())); item.setIpAddress(remoteIp); item.setUserAgent(userAgent); item.setSessionId(sessionId); item.setData(data); dao.insert(con, item); return true; } catch (SQLException ex) { logger.error("DB error", ex); return false; } finally { DbUtils.closeQuietly(con); } }
From source file:com.sonicle.webtop.core.app.SessionManager.java
License:Open Source License
private void enqueueMessages(UserProfileId profileId, Collection<ServiceMessage> messages) { MessageQueueDAO mqDao = MessageQueueDAO.getInstance(); Connection con = null;// ww w. ja v a 2 s .c o m try { con = WT.getCoreConnection(false); OMessageQueue queued = null; for (ServiceMessage message : messages) { queued = new OMessageQueue(); queued.setQueueId(mqDao.getSequence(con).intValue()); queued.setDomainId(profileId.getDomainId()); queued.setUserId(profileId.getUserId()); queued.setMessageType(message.getClass().getName()); queued.setMessageRaw(JsonResult.gson.toJson(message)); queued.setQueuedOn(DateTime.now(DateTimeZone.UTC)); mqDao.insert(con, queued); } DbUtils.commitQuietly(con); } catch (Throwable t) { DbUtils.rollbackQuietly(con); logger.error("Error enqueuing messages", t); } finally { DbUtils.closeQuietly(con); } }
From source file:com.sonicle.webtop.core.CoreManager.java
License:Open Source License
private DateTime createRevisionTimestamp() { return DateTime.now(DateTimeZone.UTC); }
From source file:com.sonicle.webtop.core.dal.BaseDAO.java
License:Open Source License
public static DateTime createRevisionTimestamp() { return DateTime.now(DateTimeZone.UTC); }
From source file:com.sonicle.webtop.core.dal.SysLogDAO.java
License:Open Source License
public int deleteByAge(Connection con, int days) throws DAOException { DateTime boundaryDate = DateTime.now(DateTimeZone.UTC).withTimeAtStartOfDay().minusDays(days); DSLContext dsl = getDSL(con);/* w w w . j a va 2 s.c o m*/ return dsl.delete(SYSLOG).where(SYSLOG.TIMESTAMP.lessThan(boundaryDate)).execute(); }
From source file:com.sonicle.webtop.core.sdk.BaseSettings.java
License:Open Source License
public DateTime getDateTime(String key, DateTime defaultValue) { return getDateTime(key, defaultValue, DateTimeZone.UTC); }
From source file:com.sonicle.webtop.core.sdk.BaseSettings.java
License:Open Source License
public boolean setDateTime(String key, DateTime value) { return setDateTime(key, value, DateTimeZone.UTC); }
From source file:com.sonicle.webtop.core.xmpp.ChatMessage.java
License:Open Source License
public static DateTime nowTimestamp() { return DateTime.now(DateTimeZone.UTC); }