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);
}
}
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);
}
}
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();
}
}
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");
}
}
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);
}
}
Aggregations