use of org.bedework.calfacade.BwAttendee in project bw-calendar-engine by Bedework.
the class BwFreeBusyUtil method toFreeBusy.
/**
* @param cb
* @param val
* @return BwFreeBusy
* @throws CalFacadeException
*/
public static EventInfo toFreeBusy(final IcalCallback cb, final VFreeBusy val) throws CalFacadeException {
if (val == null) {
return null;
}
boolean debug = getLog().isDebugEnabled();
try {
PropertyList pl = val.getProperties();
if (pl == null) {
// Empty VEvent
return null;
}
BwEvent fb = new BwEventObj();
EventInfo ei = new EventInfo(fb);
ChangeTable chg = ei.getChangeset(cb.getPrincipal().getPrincipalRef());
fb.setEntityType(IcalDefs.entityTypeFreeAndBusy);
setDates(cb.getPrincipal().getPrincipalRef(), ei, (DtStart) pl.getProperty(Property.DTSTART), (DtEnd) pl.getProperty(Property.DTEND), (Duration) pl.getProperty(Property.DURATION));
Iterator it = pl.iterator();
while (it.hasNext()) {
Property prop = (Property) it.next();
String pval = prop.getValue();
if ((pval != null) && (pval.length() == 0)) {
pval = null;
}
PropertyInfoIndex pi = PropertyInfoIndex.fromName(prop.getName());
if (pi == null) {
debugMsg("Unknown property with name " + prop.getName() + " class " + prop.getClass() + " and value " + pval);
continue;
}
switch(pi) {
case ATTENDEE:
/* ------------------- Attendee -------------------- */
BwAttendee att = getAttendee(cb, (Attendee) prop);
fb.addAttendee(att);
chg.addValue(pi, att);
break;
case COMMENT:
/* ------------------- Comment -------------------- */
// LANG
fb.addComment(null, pval);
chg.addValue(pi, pval);
case DTEND:
break;
case DTSTAMP:
/* ------------------- DtStamp -------------------- */
chg.changed(pi, fb.getDtstamp(), pval);
fb.setDtstamp(pval);
case DTSTART:
break;
case FREEBUSY:
/* ------------------- freebusy -------------------- */
FreeBusy fbusy = (FreeBusy) prop;
PeriodList perpl = fbusy.getPeriods();
Parameter par = getParameter(fbusy, "FBTYPE");
int fbtype;
if (par == null) {
fbtype = BwFreeBusyComponent.typeBusy;
} else if (par.equals(FbType.BUSY)) {
fbtype = BwFreeBusyComponent.typeBusy;
} else if (par.equals(FbType.BUSY_TENTATIVE)) {
fbtype = BwFreeBusyComponent.typeBusyTentative;
} else if (par.equals(FbType.BUSY_UNAVAILABLE)) {
fbtype = BwFreeBusyComponent.typeBusyUnavailable;
} else if (par.equals(FbType.FREE)) {
fbtype = BwFreeBusyComponent.typeFree;
} else {
if (debug) {
debugMsg("Unsupported parameter " + par.getName());
}
throw new IcalMalformedException("parameter " + par.getName());
}
BwFreeBusyComponent fbc = new BwFreeBusyComponent();
fbc.setType(fbtype);
Iterator perit = perpl.iterator();
while (perit.hasNext()) {
Period per = (Period) perit.next();
fbc.addPeriod(per);
}
fb.addFreeBusyPeriod(fbc);
chg.addValue(pi, fbc);
break;
case ORGANIZER:
/* ------------------- Organizer -------------------- */
BwOrganizer org = getOrganizer(cb, (Organizer) prop);
fb.setOrganizer(org);
chg.addValue(pi, org);
break;
case UID:
/* ------------------- Uid -------------------- */
chg.changed(pi, fb.getUid(), pval);
fb.setUid(pval);
break;
default:
if (debug) {
debugMsg("Unsupported property with class " + prop.getClass() + " and value " + pval);
}
}
}
return ei;
} catch (CalFacadeException cfe) {
throw cfe;
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
use of org.bedework.calfacade.BwAttendee in project bw-calendar-engine by Bedework.
the class DocBuilder method indexAttendees.
private void indexAttendees(final Set<BwAttendee> atts, final boolean vpoll) throws CalFacadeException {
try {
if (Util.isEmpty(atts)) {
return;
}
if (vpoll) {
startArray(getJname(PropertyInfoIndex.VOTER));
} else {
startArray(getJname(PropertyInfoIndex.ATTENDEE));
}
for (final BwAttendee val : atts) {
startObject();
startObject("pars");
if (val.getRsvp()) {
makeField(ParameterInfoIndex.RSVP.getJname(), val.getRsvp());
}
if (vpoll && val.getStayInformed()) {
makeField(ParameterInfoIndex.STAY_INFORMED.getJname(), val.getStayInformed());
}
makeField(ParameterInfoIndex.CN.getJname(), val.getCn());
String temp = val.getPartstat();
if (temp == null) {
temp = IcalDefs.partstatValNeedsAction;
}
makeField(ParameterInfoIndex.PARTSTAT.getJname(), temp);
makeField(ParameterInfoIndex.SCHEDULE_STATUS.getJname(), val.getScheduleStatus());
makeField(ParameterInfoIndex.CUTYPE.getJname(), val.getCuType());
makeField(ParameterInfoIndex.DELEGATED_FROM.getJname(), val.getDelegatedFrom());
makeField(ParameterInfoIndex.DELEGATED_TO.getJname(), val.getDelegatedTo());
makeField(ParameterInfoIndex.DIR.getJname(), val.getDir());
makeField(ParameterInfoIndex.LANGUAGE.getJname(), val.getLanguage());
makeField(ParameterInfoIndex.MEMBER.getJname(), val.getMember());
makeField(ParameterInfoIndex.ROLE.getJname(), val.getRole());
makeField(ParameterInfoIndex.SENT_BY.getJname(), val.getSentBy());
endObject();
makeField("uri", val.getAttendeeUri());
endObject();
}
endArray();
} catch (final IndexException e) {
throw new CalFacadeException(e);
}
}
use of org.bedework.calfacade.BwAttendee in project bw-calendar-engine by Bedework.
the class EntityBuilder method restoreAttendees.
private Set<BwAttendee> restoreAttendees(final boolean vpoll) throws CalFacadeException {
final PropertyInfoIndex pi;
if (vpoll) {
pi = PropertyInfoIndex.VOTER;
} else {
pi = PropertyInfoIndex.ATTENDEE;
}
final List<Object> vals = getFieldValues(pi);
if (Util.isEmpty(vals)) {
return null;
}
final Set<BwAttendee> atts = new TreeSet<>();
for (final Object o : vals) {
try {
pushFields(o);
final BwAttendee att = new BwAttendee();
if (pushFields(PropertyInfoIndex.PARAMETERS)) {
try {
att.setRsvp(getBool(ParameterInfoIndex.RSVP));
att.setCn(getString(ParameterInfoIndex.CN));
att.setPartstat(getString(ParameterInfoIndex.PARTSTAT));
att.setScheduleStatus(getString(ParameterInfoIndex.SCHEDULE_STATUS));
att.setCuType(getString(ParameterInfoIndex.CUTYPE));
att.setDelegatedFrom(getString(ParameterInfoIndex.DELEGATED_FROM));
att.setDelegatedTo(getString(ParameterInfoIndex.DELEGATED_TO));
att.setDir(getString(ParameterInfoIndex.DIR));
att.setLanguage(getString(ParameterInfoIndex.LANGUAGE));
att.setMember(getString(ParameterInfoIndex.MEMBER));
att.setRole(getString(ParameterInfoIndex.ROLE));
att.setSentBy(getString(ParameterInfoIndex.SENT_BY));
if (vpoll) {
att.setStayInformed(getBool(ParameterInfoIndex.STAY_INFORMED));
}
} finally {
popFields();
}
}
att.setAttendeeUri(getString(PropertyInfoIndex.URI));
atts.add(att);
} catch (final IndexException ie) {
throw new CalFacadeException(ie);
} finally {
popFields();
}
}
return atts;
}
use of org.bedework.calfacade.BwAttendee in project bw-calendar-engine by Bedework.
the class AttendeeFieldRule method field.
@Override
public void field(final String name) throws Throwable {
BwAttendee ent = (BwAttendee) top();
if (name.equals("id") || name.equals("seq")) {
// pre 3.5 - won't work
return;
}
if (name.equals("cn")) {
ent.setCn(stringFld());
return;
}
if (name.equals("dir")) {
ent.setDir(stringFld());
return;
}
if (name.equals("member")) {
ent.setMember(stringFld());
return;
}
if (name.equals("reinvite")) {
return;
}
if (name.equals("rsvp")) {
ent.setRsvp(booleanFld());
return;
}
if (name.equals("role")) {
ent.setRole(stringFld());
return;
}
if (name.equals("sequence")) {
ent.setSequence(intFld());
return;
}
if (name.equals("dtstamp")) {
ent.setDtstamp(stringFld());
return;
}
if (name.equals("partstat")) {
ent.setPartstat(stringFld());
return;
}
if (name.equals("cuType")) {
ent.setCuType(stringFld());
return;
}
if (name.equals("delegatedFrom")) {
ent.setDelegatedFrom(stringFld());
return;
}
if (name.equals("delegatedTo")) {
ent.setDelegatedTo(stringFld());
return;
}
if (name.equals("language")) {
ent.setLanguage(stringFld());
return;
}
if (name.equals("scheduleAgent")) {
ent.setScheduleAgent(intFld());
return;
}
if (name.equals("scheduleStatus")) {
ent.setScheduleStatus(stringFld());
return;
}
if (name.equals("sentBy")) {
ent.setSentBy(stringFld());
return;
}
if (name.equals("attendeeUri")) {
ent.setAttendeeUri(stringFld());
return;
}
if (name.equals("byteSize")) {
ent.setByteSize(intFld());
return;
}
unknownTag(name);
}
use of org.bedework.calfacade.BwAttendee in project bw-calendar-engine by Bedework.
the class InReply method process.
@Override
public ProcessResult process(final EventInfo ei) throws CalFacadeException {
/* Process a response we as the organizer, or their proxy, received from
* an attendee
*/
final ProcessResult pr = new ProcessResult();
final SchedulingI sched = getSvc().getScheduler();
BwEvent ev = ei.getEvent();
final EventInfo colEi = sched.getStoredMeeting(ev);
/* The event should have a calendar set to the inbox it came from.
* That inbox may be owned by somebody other than the current user if a
* calendar user has delegated control of their inbox to some other user
* e.g. secretary.
*/
pr.attendeeAccepting = true;
check: {
if (colEi == null) {
// No corresponding stored meeting
break check;
}
if (ev.getOriginator() == null) {
pr.sr.errorCode = CalFacadeException.schedulingNoOriginator;
break check;
}
String attUri = null;
/* Should be exactly one attendee */
if (!ev.getSuppressed()) {
final Collection<BwAttendee> atts = ev.getAttendees();
if ((atts == null) || (atts.size() != 1)) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
final BwAttendee att = atts.iterator().next();
if (!att.getPartstat().equals(acceptPartstat)) {
pr.attendeeAccepting = false;
}
attUri = att.getAttendeeUri();
}
if (ei.getNumOverrides() > 0) {
for (final EventInfo oei : ei.getOverrides()) {
ev = oei.getEvent();
final Collection<BwAttendee> atts = ev.getAttendees();
if ((atts == null) || (atts.size() != 1)) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
final BwAttendee att = atts.iterator().next();
if (!att.getPartstat().equals(acceptPartstat)) {
pr.attendeeAccepting = false;
}
if (attUri == null) {
attUri = att.getAttendeeUri();
} else if (!attUri.equals(att.getAttendeeUri())) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
}
}
if (attUri == null) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
/*TODO If the sequence of the incoming event is lower than the sequence on the
* calendar event we ignore it.
*/
final boolean vpoll = colEi.getEvent().getEntityType() == IcalDefs.entityTypeVpoll;
if (vpoll) {
if (!updateOrganizerPollCopy(colEi, ei, attUri, pr.sr)) {
break check;
}
} else if (!updateOrganizerCopy(colEi, ei, attUri, pr.sr)) {
break check;
}
pr.removeInboxEntry = false;
}
return pr;
}
Aggregations