Search in sources :

Example 1 with BwFilterDef

use of org.bedework.calfacade.BwFilterDef in project bw-calendar-engine by Bedework.

the class FilterRule method end.

public void end(String ns, String name) throws Exception {
    BwFilterDef entity = (BwFilterDef) pop();
    globals.counts[globals.filters]++;
    try {
        if (globals.rintf != null) {
            trace("About to restore filter " + entity);
            globals.rintf.restoreFilter(entity);
        }
    } catch (Throwable t) {
        throw new Exception(t);
    }
}
Also used : BwFilterDef(org.bedework.calfacade.BwFilterDef)

Example 2 with BwFilterDef

use of org.bedework.calfacade.BwFilterDef in project bw-calendar-engine by Bedework.

the class Filters method get.

@Override
public GetFilterDefResponse get(final String name) {
    final GetFilterDefResponse gfdr = new GetFilterDefResponse();
    try {
        final BwFilterDef fdef = getCal().getFilterDef(name, getEntityOwner(getPrincipal()));
        if (fdef == null) {
            gfdr.setStatus(Response.Status.notFound);
        } else {
            gfdr.setStatus(Response.Status.ok);
            gfdr.setFilterDef(fdef);
        }
    } catch (final CalFacadeException cfe) {
        gfdr.setStatus(Response.Status.failed);
        gfdr.setMessage(cfe.getLocalizedMessage());
    }
    return gfdr;
}
Also used : GetFilterDefResponse(org.bedework.calfacade.responses.GetFilterDefResponse) BwFilterDef(org.bedework.calfacade.BwFilterDef) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 3 with BwFilterDef

use of org.bedework.calfacade.BwFilterDef in project bw-calendar-engine by Bedework.

the class CalintfImpl method save.

/* ====================================================================
   *                       filter defs
   * ==================================================================== */
@Override
public void save(final BwFilterDef val, final BwPrincipal owner) throws CalFacadeException {
    final BwFilterDef fd = filterDefs.fetch(val.getName(), owner);
    if (fd != null) {
        throw new CalFacadeException(CalFacadeException.duplicateFilter, val.getName());
    }
    entityDao.save(val);
}
Also used : BwFilterDef(org.bedework.calfacade.BwFilterDef) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 4 with BwFilterDef

use of org.bedework.calfacade.BwFilterDef in project bw-calendar-engine by Bedework.

the class CalintfImpl method deleteFilterDef.

@Override
public void deleteFilterDef(final String name, final BwPrincipal owner) throws CalFacadeException {
    final BwFilterDef fd = filterDefs.fetch(name, owner);
    if (fd == null) {
        throw new CalFacadeException(CalFacadeException.unknownFilter, name);
    }
    entityDao.delete(fd);
}
Also used : BwFilterDef(org.bedework.calfacade.BwFilterDef) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 5 with BwFilterDef

use of org.bedework.calfacade.BwFilterDef 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);
    }
}
Also used : BwLongString(org.bedework.calfacade.BwLongString) BwLocation(org.bedework.calfacade.BwLocation) BwRequestStatus(org.bedework.calfacade.BwRequestStatus) EventInfo(org.bedework.calfacade.svc.EventInfo) BwXproperty(org.bedework.calfacade.BwXproperty) BwCategory(org.bedework.calfacade.BwCategory) BwFilterDef(org.bedework.calfacade.BwFilterDef) BwEvent(org.bedework.calfacade.BwEvent) BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAlarm(org.bedework.calfacade.BwAlarm)

Aggregations

BwFilterDef (org.bedework.calfacade.BwFilterDef)8 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)3 BwEvent (org.bedework.calfacade.BwEvent)2 BwEventProxy (org.bedework.calfacade.BwEventProxy)2 BwLongString (org.bedework.calfacade.BwLongString)2 BwString (org.bedework.calfacade.BwString)2 EventInfo (org.bedework.calfacade.svc.EventInfo)2 HibSession (org.bedework.calcorei.HibSession)1 BwAlarm (org.bedework.calfacade.BwAlarm)1 BwCategory (org.bedework.calfacade.BwCategory)1 BwContact (org.bedework.calfacade.BwContact)1 BwLocation (org.bedework.calfacade.BwLocation)1 BwRequestStatus (org.bedework.calfacade.BwRequestStatus)1 BwXproperty (org.bedework.calfacade.BwXproperty)1 BwStringBase (org.bedework.calfacade.base.BwStringBase)1 GetFilterDefResponse (org.bedework.calfacade.responses.GetFilterDefResponse)1