Search in sources :

Example 1 with CalFacadeException

use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.

the class BwAlarm method getTriggerDate.

/**
 * Get the trigger Date value. This is the earliest time for the
 * alarm.
 *
 *  @return Date   trigger time as a date object
 *  @throws CalFacadeException on error
 */
@NoDump
public Date getTriggerDate(final BwDateTime start) throws CalFacadeException {
    try {
        if (triggerDate != null) {
            return triggerDate;
        }
        final Trigger tr = new Trigger();
        tr.setValue(getTrigger());
        /* if dt is null then it's a duration????
       */
        Date dt = tr.getDateTime();
        if (dt == null) {
            final Dur dur = tr.getDuration();
            if (start == null) {
                throw new CalFacadeException("No start date for alarm " + this);
            }
            dt = dur.getTime(BwDateTimeUtil.getDate(start));
        }
        triggerDate = dt;
        return dt;
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : Dur(net.fortuna.ical4j.model.Dur) Trigger(net.fortuna.ical4j.model.property.Trigger) Date(java.util.Date) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 2 with CalFacadeException

use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.

the class BwCategory method toJson.

public void toJson(final JsonGenerator jgen) throws CalFacadeException {
    try {
        jgen.writeStartObject();
        outJsonField("name", getName(), jgen);
        outJsonField("href", getHref(), jgen);
        outJsonField("colPath", getColPath(), jgen);
        outJsonField("uid", getUid(), jgen);
        outJsonBwString("word", getWord(), jgen);
        outJsonBwString("description", getDescription(), jgen);
        // category
        jgen.writeEndObject();
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 3 with CalFacadeException

use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.

the class BwDateTime method makeBwDateTime.

/**
 * Constructor
 *
 * @param dateType
 * @param date
 * @param tzid
 * @return initialised BwDateTime
 * @throws CalFacadeException
 */
public static BwDateTime makeBwDateTime(final boolean dateType, final String date, final String tzid) throws CalFacadeException {
    try {
        if (dateType) {
            if (!DateTimeUtil.isISODate(date)) {
                throw new CalFacadeException("org.bedework.datetime.expect.dateonly");
            }
        }
        BwDateTime bwd = new BwDateTime();
        bwd.setDateType(dateType);
        bwd.setDtval(date);
        bwd.setTzid(tzid);
        if (tzid == null) {
            if (DateTimeUtil.isISODateTime(date)) {
                bwd.setFloatFlag(true);
                bwd.setDate(date + "Z");
            }
        }
        if (!bwd.getFloating()) {
            bwd.setDate(Timezones.getUtc(date, tzid));
        }
        return bwd;
    } catch (TimezonesException tze) {
        if (tze.getMessage().equals(TimezonesException.unknownTimezone)) {
            throw new CalFacadeException(CalFacadeException.unknownTimezone, tze.getExtra());
        } else {
            throw new CalFacadeBadDateException();
        }
    } catch (Throwable t) {
        throw new CalFacadeBadDateException();
    }
}
Also used : TimezonesException(org.bedework.util.timezones.TimezonesException) CalFacadeBadDateException(org.bedework.calfacade.exc.CalFacadeBadDateException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 4 with CalFacadeException

use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.

the class BwDuration method populate.

/**
 * Populate the bean from the given String value.
 *
 * @param db    BwDuration
 * @param val   String value
 * @throws CalFacadeException
 */
public static void populate(final BwDuration db, final String val) throws CalFacadeException {
    try {
        if (val == null) {
            return;
        }
        Dur d = new Dur(val);
        if (d.getWeeks() != 0) {
            db.setWeeks(d.getWeeks());
            return;
        }
        db.setDays(d.getDays());
        db.setHours(d.getHours());
        db.setMinutes(d.getMinutes());
        db.setSeconds(d.getSeconds());
        db.setNegative(d.isNegative());
    } catch (Throwable t) {
        throw new CalFacadeException("Invalid duration");
    }
}
Also used : Dur(net.fortuna.ical4j.model.Dur) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 5 with CalFacadeException

use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.

the class BwDateTime method makeDtEnd.

/**
 * Make a DtEnd from this object
 *
 * @param tzreg
 * @return DtEnd
 * @throws CalFacadeException
 */
public DtEnd makeDtEnd(final TimeZoneRegistry tzreg) throws CalFacadeException {
    try {
        DtEnd dt = new DtEnd();
        initDateProp(dt, tzreg);
        return dt;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) DtEnd(net.fortuna.ical4j.model.property.DtEnd)

Aggregations

CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)298 BwCalendar (org.bedework.calfacade.BwCalendar)55 BwEvent (org.bedework.calfacade.BwEvent)55 EventInfo (org.bedework.calfacade.svc.EventInfo)37 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)32 ArrayList (java.util.ArrayList)28 BwString (org.bedework.calfacade.BwString)26 BwDateTime (org.bedework.calfacade.BwDateTime)24 IndexException (org.bedework.util.indexing.IndexException)23 BwPrincipal (org.bedework.calfacade.BwPrincipal)22 TreeSet (java.util.TreeSet)19 BwAttendee (org.bedework.calfacade.BwAttendee)18 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)16 Calendar (net.fortuna.ical4j.model.Calendar)15 DateTime (net.fortuna.ical4j.model.DateTime)15 Period (net.fortuna.ical4j.model.Period)13 BwCategory (org.bedework.calfacade.BwCategory)13 StringReader (java.io.StringReader)12 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)12 BwEventProxy (org.bedework.calfacade.BwEventProxy)12