use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class MessageProcessor method getIndexer.
@SuppressWarnings("rawtypes")
private BwIndexer getIndexer(final CalSvcI svci, final Object val) throws CalFacadeException {
boolean publick = false;
String principal = null;
final BwOwnedDbentity ent;
if (val instanceof BwOwnedDbentity) {
ent = (BwOwnedDbentity) val;
} else if (val instanceof EventInfo) {
ent = ((EventInfo) val).getEvent();
} else {
error("Cannot index class: " + val.getClass());
throw new CalFacadeException("org.bedework.index.unexpected.class");
}
if (ent != null) {
if (ent.getPublick() == null) {
debug("This is wrong");
}
publick = ent.getPublick();
principal = ent.getOwnerHref();
}
return getIndexer(svci, publick, principal);
}
use of org.bedework.calfacade.svc.EventInfo 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);
}
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class ProcessRealias method realiasEvents.
private boolean realiasEvents() throws Throwable {
boolean add = false;
boolean remove = false;
BwXproperty xp = null;
/* Expect from (possibly quoted)
* to (possibly quoted)
*/
try {
open();
final String fromHref = getAliasPath();
if (fromHref == null) {
return false;
}
final String wd = word();
if (wd == null) {
return false;
}
if ("remove".equals(wd)) {
remove = true;
} else {
if ("add".equals(wd)) {
add = true;
} else if ("replace".equals(wd)) {
remove = true;
} else {
error("Expect add | remove | replace");
return false;
}
final BwCalendar col = getCal();
if (col == null) {
return false;
}
/* At the moment an alias is represented by an x-property with
the form:
X-BEDEWORK-ALIAS; \
X-BEDEWORK-PARAM-DISPLAYNAME=Jobs;\
X-BEDEWORK-PARAM-PATH=/public/aliases/Browse By Topic/Jobs;\
X-BEDEWORK-PARAM-ALIASPATH=/public/cals/MainCal:\
/user/agrp_calsuite-MainCampus/Browse By Topic/Jobs"
That is - it appears the displayname comes from the top level
the path is what it points to
the aliaspath is the path of the final target
the value is the path of the alias itself.
*/
final BwCalendar aliasTarget = getAliasTarget(col);
xp = new BwXproperty();
xp.setName("X-BEDEWORK-ALIAS");
xp.setPars("X-BEDEWORK-PARAM-DISPLAYNAME=" + col.getName() + ";X-BEDEWORK-PARAM-PATH=" + col.getAliasUri().substring(BwCalendar.internalAliasUriPrefix.length()) + ";X-BEDEWORK-PARAM-ALIASPATH=" + aliasTarget.getPath());
xp.setValue(col.getPath());
}
final FilterBase fltr = parseQuery("topical_area=\"\t" + fromHref + "\"");
if (fltr == null) {
return false;
}
close();
/* Now we need to process the stuff in batches */
open();
final BwIndexer idx = getIndexer();
final SearchResult sr = idx.search(null, false, fltr, null, null, null, null, batchSize, includeDeleted, RecurringRetrievalMode.entityOnly);
if (sr.getFound() == 0) {
warn("No events found");
return false;
}
for (; ; ) {
final List<SearchResultEntry> sres = idx.getSearchResult(sr, BwIndexer.Position.next, PrivilegeDefs.privAny);
if (Util.isEmpty(sres)) {
break;
}
int updated = 0;
for (final SearchResultEntry sre : sres) {
final Object o = sre.getEntity();
if (!(o instanceof EventInfo)) {
warn("Unhandled entity " + o.getClass());
continue;
}
EventInfo ei = (EventInfo) o;
/* Fetch the persistent version
*/
final String colPath = ei.getEvent().getColPath();
final String name = ei.getEvent().getName();
ei = getEvents().get(colPath, name);
if (ei == null) {
warn("Unable to retrieve persistent copy of " + colPath + " " + name);
continue;
}
updated += doRealias(ei, fromHref, xp, add, remove);
if ((updated % 10) == 0) {
info("done " + updated);
}
}
info("Total updated: " + updated);
}
return true;
} finally {
close();
}
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method checkStatus.
/**
* @param sr schedule result
* @return recipient results
* @throws WebdavException
*/
private Collection<SchedRecipientResult> checkStatus(final ScheduleResult sr) throws WebdavException {
if ((sr.errorCode == null) || (sr.errorCode.equals(CalFacadeException.schedulingNoRecipients))) {
final Collection<SchedRecipientResult> srrs = new ArrayList<>();
for (final ScheduleRecipientResult bwsrr : sr.recipientResults.values()) {
final SchedRecipientResult srr = new SchedRecipientResult();
srr.recipient = bwsrr.recipient;
srr.status = bwsrr.getStatus();
if (bwsrr.freeBusy != null) {
srr.freeBusy = new BwCalDAVEvent(this, new EventInfo(bwsrr.freeBusy));
}
srrs.add(srr);
}
return srrs;
}
if (sr.errorCode.equals(CalFacadeException.schedulingBadMethod)) {
throw new WebdavForbidden(CaldavTags.validCalendarData, "Bad METHOD");
}
if (sr.errorCode.equals(CalFacadeException.schedulingBadAttendees)) {
throw new WebdavForbidden(CaldavTags.attendeeAllowed, "Bad attendees");
}
if (sr.errorCode.equals(CalFacadeException.schedulingAttendeeAccessDisallowed)) {
throw new WebdavForbidden(CaldavTags.attendeeAllowed, "attendeeAccessDisallowed");
}
throw new WebdavForbidden(sr.errorCode);
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getSpecialFreeBusy.
/* (non-Javadoc)
* @see org.bedework.caldav.server.sysinterface.SysIntf#getSpecialFreeBusy(java.lang.String, java.util.Set, java.lang.String, org.bedework.caldav.util.TimeRange, java.io.Writer)
*/
@Override
public void getSpecialFreeBusy(final String cua, final Set<String> recipients, final String originator, final TimeRange tr, final Writer wtr) throws WebdavException {
BwOrganizer org = new BwOrganizer();
org.setOrganizerUri(cua);
BwEvent ev = new BwEventObj();
ev.setDtstart(getBwDt(tr.getStart()));
ev.setDtend(getBwDt(tr.getEnd()));
ev.setEntityType(IcalDefs.entityTypeFreeAndBusy);
ev.setScheduleMethod(ScheduleMethods.methodTypeRequest);
ev.setRecipients(recipients);
ev.setOriginator(originator);
ev.setOrganizer(org);
Collection<SchedRecipientResult> srrs = requestFreeBusy(new BwCalDAVEvent(this, new EventInfo(ev)), false);
for (SchedRecipientResult srr : srrs) {
// We expect one only
BwCalDAVEvent rfb = (BwCalDAVEvent) srr.freeBusy;
if (rfb != null) {
rfb.getEv().setOrganizer(org);
try {
VFreeBusy vfreeBusy = VFreeUtil.toVFreeBusy(rfb.getEv());
net.fortuna.ical4j.model.Calendar ical = IcalTranslator.newIcal(ScheduleMethods.methodTypeReply);
ical.getComponents().add(vfreeBusy);
IcalTranslator.writeCalendar(ical, wtr);
} catch (Throwable t) {
if (debug) {
error(t);
}
throw new WebdavException(t);
}
}
}
}
Aggregations