use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class EntityProcessor method process.
/* (non-Javadoc)
* @see java.lang.Thread#run()
*/
@Override
public void process() throws CalFacadeException {
try {
try (BwSvc bw = getBw()) {
final CalSvcI svci = bw.getSvci();
final BwIndexer indexer = svci.getIndexer(principal, indexRootPath);
for (final String name : entityNames) {
try {
if (debug) {
debug("Indexing collection " + path + " entity " + name);
}
status.stats.inc(IndexedType.events);
final EventInfo ent = svci.getEventsHandler().get(path, name);
if (ent == null) {
status.stats.inc(IndexedType.unreachableEntities);
continue;
}
indexer.indexEntity(ent);
} catch (final Throwable t) {
Logger.getLogger(this.getClass()).error(this, t);
errors++;
if (errors > maxErrors) {
error("Too many errors (" + errors + "): terminating");
break;
}
}
}
}
} catch (final Throwable t) {
Logger.getLogger(this.getClass()).error(t);
}
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class PublicProcessor method process.
@Override
public void process() throws CalFacadeException {
try (BwSvc bw = getBw()) {
final CalSvcI svc = bw.getSvci();
/* First index the public collection(s) */
indexCollection(svc, Util.buildPath(false, "/", getPublicCalendarRoot()));
final BwIndexer indexer = svc.getIndexer(principal, indexRootPath);
status.stats.inc(IndexedType.categories, svc.getCategoriesHandler().reindex(indexer));
status.stats.inc(IndexedType.contacts, svc.getContactsHandler().reindex(indexer));
status.stats.inc(IndexedType.locations, svc.getLocationsHandler().reindex(indexer));
}
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class NotificationConf method sendInvite.
/* ========================================================================
* Operations
* ======================================================================== */
@Override
public String sendInvite(final String cua, final String href) {
try {
final ShareType share = new ShareType();
final SetType set = new SetType();
set.setHref(cua);
set.setSummary("Test Collection");
final AccessType at = new AccessType();
at.setRead(true);
set.setAccess(at);
share.getSet().add(set);
try (CalSvcI svci = getSvci(getNotifierId())) {
final BwCalendar col = svci.getCalendarsHandler().get(href);
if (col == null) {
return "No such collection";
}
svci.getSharingHandler().share(col, share);
}
svci.endTransaction();
return "ok";
} catch (final Throwable t) {
error(t);
return t.getLocalizedMessage();
}
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class InScheduler method processEntityQueuedEvent.
private ProcessMessageResult processEntityQueuedEvent(final EntityQueuedEvent msg) {
/* These are events that are placed in the inbox.
*/
EventInfo ei = null;
try (final CalSvcI svci = getSvci(msg.getOwnerHref())) {
if (debug) {
trace("InSchedule inbox entry for principal " + msg.getOwnerHref());
}
ei = getInboxEvent(svci, msg.getName());
if (ei == null) {
// Event deleted from inbox.
if (debug) {
trace("InSchedule event deleted from inbox");
}
return ProcessMessageResult.NO_ACTION;
}
final BwEvent ev = ei.getEvent();
final int method = ev.getScheduleMethod();
if (debug) {
trace("InSchedule event for " + msg.getOwnerHref() + " " + msg.getName() + " with method " + ScheduleMethods.methods[method] + "\n" + ev);
if (ev.getSuppressed()) {
for (final EventInfo oei : ei.getOverrides()) {
trace("Override: " + oei.getEvent());
}
}
}
InProcessor proc = null;
switch(method) {
case Icalendar.methodTypeCancel:
proc = new InCancel(svci);
break;
case Icalendar.methodTypeRequest:
case Icalendar.methodTypePollStatus:
proc = new InRequest(svci);
break;
case Icalendar.methodTypeReply:
proc = new InReply(svci);
break;
case Icalendar.methodTypeRefresh:
proc = new InRefresh(svci);
break;
default:
warn("InSchedule: unhandled method for " + ev.getOwnerHref() + " " + method);
}
if (proc == null) {
deleteEvent(ei, false, false);
return ProcessMessageResult.PROCESSED;
}
final ProcessResult pr = proc.process(ei);
if (debug) {
trace("InSchedule " + pr.sr);
}
if (!pr.noInboxChange) {
proc.pendingToInbox(ei, ev.getOwnerHref(), pr.attendeeAccepting, pr.removeInboxEntry);
}
deleteEvent(ei, false, false);
return ProcessMessageResult.PROCESSED;
} catch (final CalFacadeForbidden cff) {
if (debug) {
trace("Forbidden exception" + cff);
}
if (ei != null) {
try {
deleteEvent(ei, false, false);
} catch (final Throwable ignored) {
}
}
return ProcessMessageResult.FAILED_NORETRIES;
} catch (final CalFacadeStaleStateException csse) {
if (debug) {
trace("Stale state exception");
}
rollback(getSvc());
return ProcessMessageResult.STALE_STATE;
} catch (final Throwable t) {
rollback(getSvc());
error(t);
}
return ProcessMessageResult.FAILED;
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class CmdUtilHelper method close.
protected void close() {
try {
final CalSvcI svci = getSvci();
if (svci == null) {
return;
}
svci.endTransaction();
svci.close();
} catch (final Throwable t) {
error(t);
}
}
Aggregations