use of org.bedework.calfacade.BwXproperty in project bw-calendar-engine by Bedework.
the class DocBuilder method indexXprops.
private void indexXprops(final XpropsEntity ent) throws CalFacadeException {
try {
if (Util.isEmpty(ent.getXproperties())) {
return;
}
/* First output ones we know about with our own name */
for (final String nm : interestingXprops.keySet()) {
final List<BwXproperty> props = ent.getXproperties(nm);
if (Util.isEmpty(props)) {
continue;
}
startArray(interestingXprops.get(nm));
for (final BwXproperty xp : props) {
if (xp.getName().equals(BwXproperty.bedeworkSuggestedTo)) {
final String val = xp.getValue();
// Find the second ":" delimiter
final int pos = val.indexOf(":", 2);
if (pos < 0) {
// Bad value
continue;
}
value(val.substring(0, pos));
continue;
}
String pars = xp.getPars();
if (pars == null) {
pars = "";
}
value(pars + "\t" + xp.getValue());
}
endArray();
}
/* Now ones we don't know or care about */
startArray(getJname(PropertyInfoIndex.XPROP));
for (final BwXproperty xp : ent.getXproperties()) {
final String nm = interestingXprops.get(xp.getName());
if (nm != null) {
continue;
}
startObject();
makeField(PropertyInfoIndex.NAME, xp.getName());
if (xp.getPars() != null) {
makeField(getJname(PropertyInfoIndex.PARAMETERS), xp.getPars());
}
makeField(getJname(PropertyInfoIndex.VALUE), xp.getValue());
endObject();
}
endArray();
} catch (final IndexException e) {
throw new CalFacadeException(e);
}
}
use of org.bedework.calfacade.BwXproperty in project bw-calendar-engine by Bedework.
the class BwStringRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
if (name.equals("bwstring")) {
// 3.5 onwards we wrapped with a tag. Do nothing
return;
}
BwString entity = (BwString) pop();
if (top() instanceof BwRequestStatus) {
BwRequestStatus rs = (BwRequestStatus) top();
rs.setDescription(entity);
return;
}
if (top() instanceof BwCategory) {
BwCategory cat = (BwCategory) top();
if (name.equals("keyword")) {
cat.setWord(entity);
} else if (name.equals("desc")) {
cat.setDescription(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwContact) {
BwContact ent = (BwContact) top();
if (name.equals("value")) {
ent.setCn(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwLocation) {
BwLocation loc = (BwLocation) top();
if (name.equals("addr")) {
loc.setAddress(entity);
} else if (name.equals("subaddr")) {
loc.setSubaddress(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwFilterDef) {
BwFilterDef f = (BwFilterDef) top();
if (name.equals("display-name")) {
f.addDisplayName(entity);
} else if (name.equals("subaddr")) {
f.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwAlarm) {
BwAlarm a = (BwAlarm) top();
if (name.equals("description")) {
a.addDescription(entity);
if (entity.getLang() != null) {
a.addXproperty(new BwXproperty(entity.getLang(), null, entity.getValue()));
} else {
a.addDescription(entity);
}
return;
}
if (name.equals("summary")) {
a.addSummary(entity);
} else {
unknownTag(name);
}
return;
}
EventInfo ei = (EventInfo) top();
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
e = ((BwEventProxy) e).getRef();
}
if (name.equals("comment")) {
e.addComment(entity);
} else if (name.equals("description")) {
e.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else if (name.equals("resource")) {
e.addResource(entity);
} else if (name.equals("summary")) {
e.addSummary(entity);
} else {
unknownTag(name);
}
}
use of org.bedework.calfacade.BwXproperty in project bw-calendar-engine by Bedework.
the class InRequest method updateAttendeeFields.
private boolean updateAttendeeFields(final EventInfo ourCopy, final EventInfo inBoxEi, final String attUri) throws CalFacadeException {
BwEvent ourEv = ourCopy.getEvent();
BwEvent inEv = inBoxEi.getEvent();
boolean flagNeedsReply = false;
ChangeTable chg = ourCopy.getChangeset(getPrincipalHref());
for (PropertyInfoIndex ipi : PropertyInfoIndex.values()) {
BwIcalPropertyInfoEntry bipie = BwIcalPropertyInfo.getPinfo(ipi);
if (bipie == null) {
continue;
}
if ((ourEv.getEntityType() == IcalDefs.entityTypeEvent) && !bipie.getEventProperty()) {
continue;
}
if ((ourEv.getEntityType() == IcalDefs.entityTypeTodo) && !bipie.getTodoProperty()) {
continue;
}
switch(ipi) {
case UNKNOWN_PROPERTY:
break;
case CLASS:
if (chg.changed(ipi, ourEv.getClassification(), inEv.getClassification())) {
ourEv.setClassification(inEv.getClassification());
}
break;
case COMPLETED:
/* Todo only */
if (chg.changed(ipi, ourEv.getCompleted(), inEv.getCompleted())) {
ourEv.setCompleted(inEv.getCompleted());
}
break;
case CREATED:
break;
case DESCRIPTION:
/*
for (BwLongString s: inEv.getDescriptions()) {
chg.addValue(Property.DESCRIPTION, s);
}
*/
if (chg.changed(ipi, ourEv.getDescription(), inEv.getDescription())) {
ourEv.setDescription(inEv.getDescription());
}
break;
case DTEND:
/* Event only */
case DUE:
/* Todo only */
BwDateTime dt = inEv.getDtend();
if (!CalFacadeUtil.eqObjval(ourEv.getDtend(), dt)) {
ourEv.setDtend(dt);
chg.changed(ipi, ourEv.getDtend(), dt);
}
char c = inEv.getEndType();
if (c != ourEv.getEndType()) {
ourEv.setEndType(c);
chg.changed(PropertyInfoIndex.END_TYPE, ourEv.getEndType(), c);
}
break;
case DTSTAMP:
break;
case DTSTART:
dt = inEv.getDtstart();
if (!CalFacadeUtil.eqObjval(ourEv.getDtstart(), dt)) {
ourEv.setDtstart(dt);
chg.changed(ipi, ourEv.getDtstart(), dt);
}
break;
case DURATION:
if (chg.changed(ipi, ourEv.getDuration(), inEv.getDuration())) {
ourEv.setDuration(inEv.getDuration());
}
break;
case GEO:
if (chg.changed(ipi, ourEv.getGeo(), inEv.getGeo())) {
ourEv.setGeo(inEv.getGeo());
}
break;
case LAST_MODIFIED:
break;
case LOCATION:
if (chg.changed(ipi, ourEv.getLocation(), inEv.getLocation())) {
ourEv.setLocation((BwLocation) inEv.getLocation().clone());
}
break;
case ORGANIZER:
if (chg.changed(ipi, ourEv.getOrganizer(), inEv.getOrganizer())) {
ourEv.setOrganizer((BwOrganizer) inEv.getOrganizer().clone());
}
break;
case PRIORITY:
if (chg.changed(ipi, ourEv.getPriority(), inEv.getPriority())) {
ourEv.setPriority(inEv.getPriority());
}
break;
case RECURRENCE_ID:
break;
case SEQUENCE:
if (chg.changed(ipi, ourEv.getSequence(), inEv.getSequence())) {
ourEv.setSequence(inEv.getSequence());
}
break;
case STATUS:
if (chg.changed(ipi, ourEv.getStatus(), inEv.getStatus())) {
ourEv.setStatus(inEv.getStatus());
}
break;
case SUMMARY:
/*
for (BwString s: inEv.getSummaries()) {
chg.addValue(Property.SUMMARY, s);
}
*/
if (chg.changed(ipi, ourEv.getSummary(), inEv.getSummary())) {
ourEv.setSummary(inEv.getSummary());
}
break;
case PERCENT_COMPLETE:
/* Todo only */
if (chg.changed(ipi, ourEv.getPercentComplete(), inEv.getPercentComplete())) {
ourEv.setPercentComplete(inEv.getPercentComplete());
}
break;
case UID:
break;
case URL:
if (chg.changed(ipi, ourEv.getLink(), inEv.getLink())) {
ourEv.setLink(inEv.getLink());
}
break;
case TRANSP:
/* Event only - done with attendee */
break;
case ATTACH:
break;
case ATTENDEE:
String transparency = ourEv.getTransparency();
BwAttendee ourAtt = null;
for (BwAttendee inAtt : inEv.getAttendees()) {
BwAttendee att = (BwAttendee) inAtt.clone();
att.setScheduleStatus(null);
String inAttUri = att.getAttendeeUri();
BwAttendee evAtt = ourEv.findAttendee(inAttUri);
if (inAttUri.equals(attUri)) {
// It's ours
ourAtt = att;
if ((att.getPartstat() == null) || att.getPartstat().equals(IcalDefs.partstatValNeedsAction)) {
transparency = IcalDefs.transparencyTransparent;
// Apple ical seems to expect an x-prop.
flagNeedsReply = true;
}
// att.setScheduleStatus(IcalDefs.deliveryStatusSuccess);
}
/* See if it's in the current set and if anything significant changed
for (BwAttendee calAtt: ourEv.getAttendees()) {
if (calAtt.getAttendeeUri().equals(inAttUri)) {
if (calAtt.changedBy(inAtt, false)) {
ourEv.setSignificantChange(true);
}
}
}*/
final ChangeTableEntry cte = chg.getEntry(PropertyInfoIndex.ATTENDEE);
if (evAtt != null) {
cte.addChangedValue(att);
} else {
cte.addAddedValue(att);
}
}
if (ourAtt == null) {
// Error?
if (debug) {
trace("InSchedule - no attendee for " + ourEv.getOwnerHref());
}
return false;
}
if (chg.changed(PropertyInfoIndex.TRANSP, ourEv.getTransparency(), transparency)) {
ourEv.setTransparency(transparency);
}
break;
case CATEGORIES:
if (!Util.isEmpty(inEv.getCategories())) {
for (BwCategory cat : inEv.getCategories()) {
chg.addValue(ipi, cat);
}
}
break;
case COMMENT:
for (BwString s : inEv.getComments()) {
chg.addValue(ipi, s);
}
break;
case CONTACT:
for (final BwContact ct : inEv.getContacts()) {
chg.addValue(ipi, ct.clone());
}
break;
case EXDATE:
// Don't updaye exdate - we add cancelled overrides
break;
case EXRULE:
// Only for master events
if (ourEv instanceof BwEventProxy) {
break;
}
for (final String s : inEv.getExrules()) {
chg.addValue(ipi, s);
}
break;
case REQUEST_STATUS:
break;
case RELATED_TO:
if (chg.changed(ipi, ourEv.getRelatedTo(), inEv.getRelatedTo())) {
ourEv.setRelatedTo(inEv.getRelatedTo());
}
break;
case RESOURCES:
for (BwString bs : inEv.getResources()) {
chg.addValue(ipi, bs);
}
break;
case RDATE:
// Only for master events
if (ourEv instanceof BwEventProxy) {
break;
}
for (BwDateTime bdt : inEv.getRdates()) {
chg.addValue(ipi, bdt);
}
break;
case RRULE:
// Only for master events
if (ourEv instanceof BwEventProxy) {
break;
}
for (String s : inEv.getRrules()) {
chg.addValue(ipi, s);
}
break;
case XPROP:
for (BwXproperty x : inEv.getXproperties()) {
chg.addValue(ipi, x);
}
break;
case FREEBUSY:
case TZID:
case TZNAME:
case TZOFFSETFROM:
case TZOFFSETTO:
case TZURL:
case ACTION:
case REPEAT:
case TRIGGER:
break;
// non ical
case COLLECTION:
// non ical
case COST:
// non ical
case CREATOR:
// non ical
case OWNER:
case // non ical
ENTITY_TYPE:
break;
case // Component
VALARM:
break;
// Param
case LANG:
case // Param
TZIDPAR:
break;
case PUBLISH_URL:
case POLL_ITEM_ID:
case END_TYPE:
case ETAG:
case HREF:
case XBEDEWORK_COST:
case CALSCALE:
case METHOD:
case PRODID:
case VERSION:
case ACL:
case AFFECTS_FREE_BUSY:
case ALIAS_URI:
case ATTENDEE_SCHEDULING_OBJECT:
case CALTYPE:
case COL_PROPERTIES:
case COLPATH:
case CTOKEN:
case DISPLAY:
case DOCTYPE:
case EVENTREG_END:
case EVENTREG_MAX_TICKETS:
case EVENTREG_MAX_TICKETS_PER_USER:
case EVENTREG_START:
case EVENTREG_WAIT_LIST_LIMIT:
case FILTER_EXPR:
case IGNORE_TRANSP:
case IMAGE:
case INDEX_END:
case INDEX_START:
case INSTANCE:
case LAST_REFRESH:
case LAST_REFRESH_STATUS:
case LOCATION_UID:
case LOCATION_STR:
break;
default:
warn("Not handling icalendar property " + ipi);
}
// switch
}
if (chg.changed(PropertyInfoIndex.COST, ourEv.getCost(), inEv.getCost())) {
ourEv.setCost(inEv.getCost());
}
/* Now see if we need to flag a schedule-tag change. We do so only if
* a. A property other than the attendee changed
* b. An attendee was added or removed
*/
Collection<ChangeTableEntry> changes = chg.getEntries();
ChangeTableEntry attChanges = null;
ourEv.setSignificantChange(false);
for (ChangeTableEntry cte : changes) {
if (!cte.getChanged()) {
continue;
}
if (cte.getIndex() == PropertyInfoIndex.ATTENDEE) {
attChanges = cte;
continue;
}
ourEv.setSignificantChange(true);
}
if (debug) {
trace("After change check getSignificantChange=" + ourEv.getSignificantChange());
}
if (flagNeedsReply) {
// Apple ical seems to expect an x-prop.
// chg.addValue(PropertyInfoIndex.XPROP,
// new BwXproperty(BwXproperty.appleNeedsReply,
// null, "TRUE"));
}
chg.processChanges(ourEv, true);
if (debug) {
trace(chg.toString());
}
/* The attendee change entry will now reflect the changes made to the
* attendee list. See if any significant change was made there.
*/
if (attChanges != null) {
if (!Util.isEmpty(attChanges.getAddedValues()) || !Util.isEmpty(attChanges.getRemovedValues())) {
ourEv.setSignificantChange(true);
} else {
/* TODO - go through the changed entries and look for our entry. See
* if we are being asked to reply - this can probably be done earlier.
*/
}
}
if (debug) {
trace("After attendee change check getSignificantChange=" + ourEv.getSignificantChange());
}
return true;
}
use of org.bedework.calfacade.BwXproperty in project bw-calendar-engine by Bedework.
the class OutboundSchedulingHandler method addToInbox.
/**
* Add a copy of senderEi to the users inbox and add to the autoschedule queue.
* The 'sender' may be the organizer of a meeting, if it's REQUEST etc, or the
* attendee replying.
*
* @param inboxPath - eventual destination
* @param attPrincipal - attendees principal
* @param senderEi the event
* @param fromOrganizer - true if it's coming from the organizer
* @return null for ok, errorcode otherwise
* @throws CalFacadeException
*/
private String addToInbox(final String inboxPath, final BwPrincipal attPrincipal, final EventInfo senderEi, final boolean fromOrganizer) throws CalFacadeException {
final EventInfo ei = copyEventInfo(senderEi, fromOrganizer, attPrincipal);
final BwEvent ev = ei.getEvent();
if (senderEi.getReplyUpdate()) {
// Flag as a trivial update to attendee status
ev.addXproperty(new BwXproperty(BwXproperty.bedeworkSchedulingReplyUpdate, null, "true"));
}
if (!Util.isEmpty(ev.getRecipients())) {
ev.getRecipients().clear();
}
ev.addRecipient(getSvc().getDirectories().principalToCaladdr(attPrincipal));
/*
if (destAtt != null) {
String attPartStat = destAtt.getPartstat();
if ((attPartStat == null) || // default - needs-action
(!attPartStat.equalsIgnoreCase(IcalDefs.partstatValAccepted) &&
!attPartStat.equalsIgnoreCase(IcalDefs.partstatValCompleted) &&
!attPartStat.equalsIgnoreCase(IcalDefs.partstatValDelegated))) {
ev.setTransparency(IcalDefs.transparencyTransparent);
}
}*/
final String evDtstamp = ev.getDtstamp();
ev.setScheduleState(BwEvent.scheduleStateNotProcessed);
ev.setColPath(inboxPath);
if (ei.getNumContainedItems() > 0) {
for (final EventInfo cei : ei.getContainedItems()) {
cei.getEvent().setColPath(inboxPath);
}
}
/* Before we add this we should see if there is an earlier one we can
* discard. As attendees update their status we get many requests sent to
* each attendee.
*
* Also this current message may be earlier than one already in the inbox.
*
* TODO - fix recurrences
*
* We could get separate messages for the same uid but with different
* recurrence ids if we are an attendee to some instances only.
*
* In the inbox these will be separate events with the same uid -
* possibly, They probably need to be combined in the users
* calendar as a single recurring event.
*/
final int smethod = ev.getScheduleMethod();
if (Icalendar.itipRequestMethodType(smethod)) {
final Collection<EventInfo> inevs = getEventsByUid(inboxPath, ev.getUid());
for (final EventInfo inei : inevs) {
final BwEvent inev = inei.getEvent();
final int cres = evDtstamp.compareTo(inev.getDtstamp());
if (cres <= 0) {
// Discard the new one
return null;
}
/* Discard the earlier message */
/* XXX What if this message is currently being processed by the inbox
* handler process? Does it matter - will it reappear?
*
* Probably need to handle stale-state exceptions at the other end.
*/
deleteEvent(inei, true, false);
}
}
/* Add it and post to the autoscheduler */
final String ecode = addEvent(ei, "In-" + Uid.getUid() + "-" + evDtstamp, BwCalendar.calTypePendingInbox, true);
if (ecode != null) {
return ecode;
}
if (debug) {
trace("Add event with name " + ev.getName() + " and summary " + ev.getSummary() + " to " + ev.getColPath());
}
addAutoScheduleMessage(true, attPrincipal.getPrincipalRef(), ev.getName());
return null;
}
use of org.bedework.calfacade.BwXproperty in project bw-calendar-engine by Bedework.
the class ProcessMove method moveEvent.
private void moveEvent(final String fromPath, final String toPath, final String name, final Collection<BwCategory> cats, final Collection<String> aliases, final boolean setname) throws Throwable {
final EventInfo ei = getEvent(fromPath, name);
final BwEvent ev = ei.getEvent();
if (debug) {
final StringBuilder sb = new StringBuilder("Moving event ");
sb.append(ev.getUid());
if (ev.getRecurring()) {
sb.append(" recurring");
}
sb.append(" from ");
sb.append(fromPath);
sb.append(" to ");
sb.append(toPath);
debug(sb.toString());
}
ev.setColPath(toPath);
for (final BwCategory cat : cats) {
ev.addCategory(cat);
}
for (final String alias : aliases) {
final BwXproperty x = new BwXproperty();
x.setName(BwXproperty.bedeworkAlias);
x.setValue(alias);
ev.addXproperty(x);
}
if (setname) {
final String nm = ev.getName();
final String nnm = ev.getUid() + ".ics";
if (!nm.equals(nnm)) {
ev.setName(nnm);
}
}
if (ei.getOverrideProxies() != null) {
for (final BwEvent oev : ei.getOverrideProxies()) {
oev.setColPath(toPath);
}
}
try {
getSvci().getEventsHandler().update(ei, false, null);
} catch (final CalFacadeDupNameException cdne) {
pstate.addError("Duplicate name " + ev.getName() + " uid: " + ev.getUid() + " from: " + fromPath);
}
}
Aggregations