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.smoketurner.pipeline.application.aws.AmazonSNSNotification.java
License:Apache License
@JsonIgnore public Duration getDelayDuration() { final Interval interval = new Interval(timestamp, DateTime.now(DateTimeZone.UTC)); return interval.toDuration(); }
From source file:com.solidfire.core.serialization.DateTimeAdapter.java
License:Open Source License
/** * Writes a DateTime object.// ww w . j a v a 2 s . c om * * @param writer the JSON writer to write to. * @param value the DateTime object to write. * @throws IOException */ @Override public void write(JsonWriter writer, DateTime value) throws IOException { if (value == null) { writer.nullValue(); } else { DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); writer.value(fmt.print(value.withZone(DateTimeZone.UTC))); } }
From source file:com.sonicle.webtop.calendar.bol.model.ReminderGenId.java
License:Open Source License
public static String buildId(DateTime remindOn) { return Hex.encodeHexString(remindOn.withZone(DateTimeZone.UTC).toString().getBytes()); }
From source file:com.sonicle.webtop.calendar.bol.ORecurrence.java
License:Open Source License
public void set(Recur recur, LocalDate recurStartDate, DateTime eventStartDate, DateTime eventEndDate, DateTimeZone eventTimezone) {/* w w w . j a va 2 s.com*/ DateTime newStart = (recurStartDate != null) ? recurStartDate.toDateTimeAtStartOfDay(eventTimezone) : eventStartDate; setStartDate(newStart); if (ICal4jUtils.recurHasCount(recur)) { DateTime untilDate = ICal4jUtils.calculateRecurrenceEnd(recur, newStart, eventTimezone); setUntilDate(untilDate.withTimeAtStartOfDay().plusDays(1)); } else if (ICal4jUtils.recurHasUntilDate(recur)) { DateTime untilDate = ICal4jUtils.toJodaDateTime(recur.getUntil(), DateTimeZone.UTC) .withZone(eventTimezone); setUntilDate(untilDate.withTimeAtStartOfDay().plusDays(1)); } else { setUntilDate(ICal4jUtils.ifiniteDate(eventTimezone)); } setRule(recur.toString()); }
From source file:com.sonicle.webtop.calendar.bol.ORecurrence.java
License:Open Source License
@Deprecated public RRule __applyEndRepeat(int repeatTimes, DateTime eventStartDate, DateTime eventEndDate, DateTimeZone etz, boolean setRule) { RRule rr = null;//w w w. j a va 2 s. com setRepeat(repeatTimes); setPermanent(false); rr = buildRRule(etz); setUntilDate(ICal4jUtils.calculateRecurrenceEnd(eventStartDate, eventEndDate, rr, DateTimeZone.UTC)); rr = buildRRule(etz); if (setRule) setRule(rr.getValue()); return rr; }
From source file:com.sonicle.webtop.calendar.CalendarManager.java
License:Open Source License
@Override public void updateEventFromICal(net.fortuna.ical4j.model.Calendar ical) throws WTException { Connection con = null;/*from ww w . j a v a2 s . c o m*/ VEvent ve = ICalendarUtils.getVEvent(ical); if (ve == null) throw new WTException("iCalendar object does not contain any events"); String uid = ICalendarUtils.getUidValue(ve); if (StringUtils.isBlank(uid)) throw new WTException("Event does not provide a valid Uid"); try { con = WT.getConnection(SERVICE_ID, false); if (ical.getMethod().equals(Method.REQUEST)) { // Organizer -> Attendee // The organizer after updating the event details send a mail message // to all attendees telling to update their saved information // Gets the event... Event evt = doEventGet(con, GetEventScope.PERSONAL_AND_INCOMING, uid); if (evt == null) throw new WTException("Event not found [{}]", uid); EventDAO edao = EventDAO.getInstance(); final UserProfile.Data udata = WT.getUserData(getTargetProfileId()); // Parse the ical using the code used in import ArrayList<EventInput> parsed = new ICalendarInput(udata.getTimeZone()).fromICalendarFile(ical, null); if (parsed.isEmpty()) throw new WTException("iCal must contain at least one event"); Event parsedEvent = parsed.get(0).event; parsedEvent.setCalendarId(evt.getCalendarId()); checkRightsOnCalendarElements(evt.getCalendarId(), "UPDATE"); OEvent original = edao.selectById(con, evt.getEventId()); // Set into parsed all fields that can't be changed by the iCal // update otherwise data can be lost inside doEventUpdate parsedEvent.setEventId(original.getEventId()); parsedEvent.setCalendarId(original.getCalendarId()); parsedEvent.setReadOnly(original.getReadOnly()); parsedEvent.setReminder(Event.Reminder.valueOf(original.getReminder())); parsedEvent.setEtag(original.getEtag()); parsedEvent.setActivityId(original.getActivityId()); parsedEvent.setMasterDataId(original.getMasterDataId()); parsedEvent.setStatMasterDataId(original.getStatMasterDataId()); parsedEvent.setCausalId(original.getCausalId()); doEventUpdate(con, original, parsedEvent, true, false); DbUtils.commitQuietly(con); writeLog("EVENT_UPDATE", String.valueOf(original.getEventId())); } else if (ical.getMethod().equals(Method.REPLY)) { // Attendee -> Organizer // The attendee replies to an event sending to the organizer a mail // message with an attached ical (the above param), properly configured. // The ical should be kept untouched in the reply except for the // attendee list: it should contains only the references of the // attendee that replies to the invitation. Attendee att = ICalendarUtils.getAttendee(ve); if (att == null) throw new WTException("Event does not provide any attendees"); // Gets the event looking also into incoming calendars... // (i can be the organizer of a meeting created for my boss that // share his calendar with me; all received replies must be bringed // back to the event in the shared calendar) //Event evt = getEvent(uid); // Previous impl. forced (forceOriginal == true) Event evt = doEventGet(con, GetEventScope.PERSONAL_AND_INCOMING, uid); if (evt == null) throw new WTException("Event not found [{0}]", uid); // Extract response info... PartStat partStat = (PartStat) att.getParameter(Parameter.PARTSTAT); ICalendarInput inWithDummyTz = new ICalendarInput(DateTimeZone.UTC); List<String> updatedAttIds = doEventAttendeeUpdateResponseByRecipient(con, evt, att.getCalAddress().getSchemeSpecificPart(), inWithDummyTz.partStatToResponseStatus(partStat)); //List<String> updatedAttIds = updateEventAttendeeResponseByRecipient(evt, att.getCalAddress().getSchemeSpecificPart(), responseStatus); DbUtils.commitQuietly(con); // Commented to not send notification email in this case: // the organizer already knows this info, he updated 'manually' the // event by clicking the "Update event" button on the preview! /* if (!updatedAttIds.isEmpty()) { evt = getEvent(evt.getEventId()); for(String attId : updatedAttIds) notifyOrganizer(getLocale(), evt, attId); } */ } else if (ical.getMethod().equals(Method.CANCEL)) { // Organizer -> Attendee // The organizer after cancelling the event send a mail message // to all attendees telling to update their saved information // Gets the event... //Event evt = getEventForICalUpdate(uid); Event evt = doEventGet(con, GetEventScope.PERSONAL_AND_INCOMING, uid); if (evt == null) throw new WTException("Event not found [{0}]", uid); doEventDelete(con, evt.getEventId(), true); DbUtils.commitQuietly(con); writeLog("EVENT_DELETE", String.valueOf(evt.getEventId())); } else { throw new WTException("Unsupported Calendar's method [{0}]", ical.getMethod().toString()); } } catch (SQLException | DAOException | IOException | WTException ex) { DbUtils.rollbackQuietly(con); throw wrapException(ex); } finally { DbUtils.closeQuietly(con); } }
From source file:com.sonicle.webtop.calendar.CalendarManager.java
License:Open Source License
public List<BaseReminder> getRemindersToBeNotified(DateTime now) { EventDAO evtDao = EventDAO.getInstance(); Connection con = null;/*from w w w. j a v a2 s. c o m*/ ensureSysAdmin(); ArrayList<VExpEventInstance> evtInstCandidates = new ArrayList<>(); logger.trace("Analyzing event instances..."); try { final DateTime from = now.withTimeAtStartOfDay(); con = WT.getConnection(SERVICE_ID, false); for (VExpEventInstance evtInst : doEventGetExpiredForUpdate(con, from, from.plusDays(7 * 2 + 1))) { final DateTime remindOn = evtInst.getStartDate().withZone(DateTimeZone.UTC) .minusMinutes(evtInst.getReminder()); if (now.compareTo(remindOn) < 0) continue; // If instance should have been reminded in past... if (evtInst.getRemindedOn() != null) { // Only recurring event instances should pass here, classic events are already excluded by the db query if (evtInst.getRecurrenceId() == null) throw new WTException("This should never happen (famous last words)"); final DateTime lastRemindedOn = evtInst.getRemindedOn().withZone(DateTimeZone.UTC); if (remindOn.compareTo(lastRemindedOn) <= 0) continue; // If instance should have been reminded after last remind... } int ret = evtDao.updateRemindedOn(con, evtInst.getEventId(), now); evtInstCandidates.add(evtInst); } DbUtils.commitQuietly(con); } catch (SQLException | DAOException | WTException ex) { DbUtils.rollbackQuietly(con); logger.error("Error collecting instances", ex); } finally { DbUtils.closeQuietly(con); } logger.debug("Found {} instances to be reminded", evtInstCandidates.size()); ArrayList<BaseReminder> alerts = new ArrayList<>(); HashMap<UserProfileId, Boolean> byEmailCache = new HashMap<>(); logger.trace("Preparing alerts..."); for (VExpEventInstance evtInst : evtInstCandidates) { logger.debug("Working on instance [{}, {}]", evtInst.getEventId(), evtInst.getStartDate()); if (!byEmailCache.containsKey(evtInst.getCalendarProfileId())) { CalendarUserSettings cus = new CalendarUserSettings(SERVICE_ID, evtInst.getCalendarProfileId()); boolean bool = cus.getEventReminderDelivery() .equals(CalendarSettings.EVENT_REMINDER_DELIVERY_EMAIL); byEmailCache.put(evtInst.getCalendarProfileId(), bool); } if (byEmailCache.get(evtInst.getCalendarProfileId())) { UserProfile.Data ud = WT.getUserData(evtInst.getCalendarProfileId()); CoreUserSettings cus = new CoreUserSettings(evtInst.getCalendarProfileId()); try { EventInstance eventInstance = getEventInstance(evtInst.getKey()); alerts.add(createEventReminderAlertEmail(ud.getLocale(), cus.getShortDateFormat(), cus.getShortTimeFormat(), ud.getPersonalEmailAddress(), evtInst.getCalendarProfileId(), eventInstance)); } catch (WTException ex) { logger.error("Error preparing email", ex); } } else { alerts.add(createEventReminderAlertWeb(evtInst)); } } //FIXME: remove this when zpush is using manager methods sendInvitationForZPushEvents(); // ---------------------------- return alerts; }
From source file:com.sonicle.webtop.calendar.CalendarManager.java
License:Open Source License
private List<VExpEventInstance> doEventGetExpiredForUpdate(Connection con, DateTime fromDate, DateTime toDate) throws WTException { EventDAO evtDao = EventDAO.getInstance(); final ArrayList<VExpEventInstance> instances = new ArrayList<>(); for (VExpEvent vee : evtDao.viewExpiredForUpdateByFromTo(con, fromDate, toDate)) { VExpEventInstance item = new VExpEventInstance(); Cloner.standard().copyPropertiesOfInheritedClass(vee, item); item.setKey(EventKey.buildKey(vee.getEventId(), vee.getSeriesEventId())); instances.add(item);/* w w w . j av a2 s . c o m*/ } for (VExpEvent vee : evtDao.viewRecurringExpiredForUpdateByFromTo(con, fromDate, toDate)) { // Returns 15 instances only, this should be enough for serving max day range from underlying reminder instances.addAll(calculateRecurringInstances(con, new VExpEventInstanceMapper(vee), fromDate, toDate, DateTimeZone.UTC, 14 + 1)); } return instances; }
From source file:com.sonicle.webtop.calendar.kettle.Migration.java
License:Open Source License
public static ORecurrence buildRecurrence(Date eventStart, Date eventEnd, String eventTimezone, Date startDate, Date untilDate, Integer repeat, Boolean permanent, String type, Integer dailyFreq, Integer weeklyFreq, Boolean weeklyDay1, Boolean weeklyDay2, Boolean weeklyDay3, Boolean weeklyDay4, Boolean weeklyDay5, Boolean weeklyDay6, Boolean weeklyDay7, Integer monthlyFreq, Integer monthlyDay, Integer yearlyFreq, Integer yearlyDay) {//from w ww . j a va 2 s . c o m DateTime dtEventStart = new DateTime(eventStart, DateTimeZone.UTC); DateTime dtEventEnd = new DateTime(eventEnd, DateTimeZone.UTC); DateTime dtUntilDate = (untilDate != null) ? new DateTime(untilDate, DateTimeZone.UTC) : null; // Emulates the orec object coming from wt5 db ORecurrence orec = new ORecurrence(); orec.setStartDate(dtEventStart); orec.setUntilDate(dtUntilDate); orec.setRepeat(repeat); orec.setPermanent(permanent); orec.setType(type); orec.setDailyFreq(dailyFreq); orec.setWeeklyFreq(weeklyFreq); orec.setWeeklyDay_1(weeklyDay1); orec.setWeeklyDay_2(weeklyDay2); orec.setWeeklyDay_3(weeklyDay3); orec.setWeeklyDay_4(weeklyDay4); orec.setWeeklyDay_5(weeklyDay5); orec.setWeeklyDay_6(weeklyDay6); orec.setWeeklyDay_7(weeklyDay7); orec.setMonthlyFreq(monthlyFreq); orec.setMonthlyDay(monthlyDay); orec.setYearlyFreq(yearlyFreq); orec.setYearlyDay(yearlyDay); EventRecurrence rec = createEventRecurrence(orec); orec.__fillFrom(true, rec, dtEventStart, dtEventEnd, eventTimezone); return orec; }
From source file:com.sonicle.webtop.calendar.rest.v1.CalDav.java
License:Open Source License
private CalObject createCalObject(EventObjectWithICalendar calObject) { return new CalObject().id(calObject.getEventId()).uid(calObject.getPublicUid()).href(calObject.getHref()) .lastModified(calObject.getRevisionTimestamp().withZone(DateTimeZone.UTC).getMillis() / 1000) .etag(buildEtag(calObject.getRevisionTimestamp())).size(calObject.getSize()); }