Changeset 321

Show
Ignore:
Timestamp:
04/03/06 14:27:37
Author:
douglm
Message:

Further changes to make access information visible to clients.
Added new class returned by CalIntf? methods containing event and CurrentAccess?

Deprecated getEvent(id)
Updated client jsp to write access information on detailed view.

Further work needed to straighten out displayed information

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r314 r321  
    7676import org.bedework.calfacade.CalFacadeDefs; 
    7777import org.bedework.calfacade.CalFacadeException; 
     78import org.bedework.calfacade.CoreEventInfo; 
    7879import org.bedework.calfacade.base.BwShareableDbentity; 
    7980import org.bedework.calfacade.filter.BwFilter; 
     
    10621063  } 
    10631064 
    1064   public BwEvent getEvent(int id) throws CalFacadeException { 
     1065  public CoreEventInfo getEvent(int id) throws CalFacadeException { 
    10651066    checkOpen(); 
    10661067    return events.getEvent(id); 
     
    10891090  } 
    10901091 
    1091   public boolean editable(BwEvent val) throws CalFacadeException { 
     1092  /*public boolean editable(BwEvent val) throws CalFacadeException { 
    10921093    checkOpen(); 
    10931094 
    10941095    return events.editable(val); 
    1095   } 
     1096  }*/ 
    10961097 
    10971098  public Collection getEventsByName(BwCalendar cal, String val) 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java

    r301 r321  
    6464import org.bedework.calfacade.CalFacadeDefs; 
    6565import org.bedework.calfacade.CalFacadeUtil; 
     66import org.bedework.calfacade.CoreEventInfo; 
    6667import org.bedework.calfacade.filter.BwFilter; 
    6768import org.bedework.calfacade.ifs.CalTimezones; 
     
    7071import org.bedework.calfacade.CalFacadeException; 
    7172import org.bedework.icalendar.VEventUtil; 
     73 
     74import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 
    7275 
    7376import net.fortuna.ical4j.model.component.VEvent; 
     
    111114  public Collection getEvent(BwCalendar calendar, String guid, String rid, 
    112115                             int recurRetrieval) throws CalFacadeException { 
    113     BwEvent ev = null; 
     116    CoreEventInfo cei = null; 
    114117    BwEvent master = null; 
    115118    TreeSet ts = new TreeSet(); 
     
    133136      /* There should be one only */ 
    134137 
    135       ev = postGetEvent((BwEvent)sess.getUnique(), privRead, noAccessReturnsNull); 
    136  
    137       if (ev == null) { 
     138      cei = postGetEvent((BwEvent)sess.getUnique(), privRead, noAccessReturnsNull); 
     139 
     140      if (cei == null) { 
    138141        /* Look for an annotation to that event by the current user. 
    139142         */ 
    140143        eventQuery(BwEventAnnotation.class, calendar, guid, rid, true); 
    141         BwEventAnnotation ann = (BwEventAnnotation)postGetEvent((BwEvent)sess.getUnique(), 
    142                                                             privRead, noAccessReturnsNull); 
    143  
    144         if (ann != null) { 
    145           ev = new BwEventProxy(ann); 
     144        cei = postGetEvent((BwEvent)sess.getUnique(), 
     145                           privRead, noAccessReturnsNull); 
     146 
     147        if (cei != null) { 
     148          cei.setEvent(new BwEventProxy((BwEventAnnotation)cei.getEvent())); 
    146149        } 
    147150      } 
    148151       
    149       if (ev == null) { 
     152      if (cei == null) { 
    150153        return ts; 
    151154      } 
    152155       
    153       master = ev
    154  
    155       ts.add(ev); 
     156      master = cei.getEvent()
     157 
     158      ts.add(cei); 
    156159      if ((recurRetrieval == CalFacadeDefs.retrieveRecurMaster) || 
    157           (!ev.getRecurring())) { 
     160          (!master.getRecurring())) { 
    158161        return ts; 
    159162      } 
     
    200203        while (it.hasNext()) { 
    201204          BwEventAnnotation override = (BwEventAnnotation)it.next(); 
    202           BwEventProxy proxy = (BwEventProxy)postGetEvent( 
    203                                makeProxy(null, override, null, 
    204                                          CalFacadeDefs.retrieveRecurExpanded), 
    205                            privRead, noAccessReturnsNull); 
    206           if (proxy != null) { 
    207             overrides.add(proxy); 
     205          cei = makeProxy(null, override, null, 
     206                          CalFacadeDefs.retrieveRecurExpanded); 
     207          if (cei != null) { 
     208            overrides.add(cei); 
    208209          } 
    209210        } 
     
    232233      while (it.hasNext()) { 
    233234        BwRecurrenceInstance instance = (BwRecurrenceInstance)it.next(); 
    234         BwEventProxy proxy = makeProxy(instance, null, null, 
    235                                        CalFacadeDefs.retrieveRecurExpanded); 
    236         ts.add(proxy); 
     235        ts.add(makeProxy(instance, null, null, 
     236                         CalFacadeDefs.retrieveRecurExpanded)); 
    237237      } 
    238238 
     
    245245    BwEventAnnotation override = (BwEventAnnotation)sess.getUnique(); 
    246246 
    247     BwEventProxy proxy; 
    248  
    249247    if (override != null) { 
    250       proxy = makeProxy(null, override, null, CalFacadeDefs.retrieveRecurExpanded); 
     248      cei = makeProxy(null, override, null, CalFacadeDefs.retrieveRecurExpanded); 
    251249    } else { 
    252250      // Look in the recurrences table 
     
    271269      } 
    272270 
    273       proxy = makeProxy(inst, null, null, CalFacadeDefs.retrieveRecurExpanded); 
    274     } 
    275  
    276     if ((proxy != null) && 
    277         (access.accessible(proxy, privRead, noAccessReturnsNull))) { 
    278       ts.add(proxy); 
     271      cei = makeProxy(inst, null, null, CalFacadeDefs.retrieveRecurExpanded); 
     272    } 
     273 
     274    if (cei != null) { 
     275      ts.add(cei); 
    279276    } 
    280277 
     
    282279  } 
    283280 
    284   public BwEvent getEvent(int id) throws CalFacadeException { 
     281  public CoreEventInfo getEvent(int id) throws CalFacadeException { 
    285282    HibSession sess = getSess(); 
    286283    Criteria cr = sess.createCriteria(BwEventObj.class); 
     
    290287    BwEvent ev = (BwEvent)sess.getUnique(); 
    291288 
    292     if (!access.accessible(ev, privRead, noAccessReturnsNull)) { 
    293       return null; 
    294     } 
    295  
    296     return ev; 
     289    return postGetEvent(ev, privRead, noAccessReturnsNull); 
    297290  } 
    298291 
     
    637630    } 
    638631 
    639     Collection es = sess.getList(); 
     632    Collection ceis = sess.getList(); 
    640633 
    641634    if (debug) { 
    642       trace("Found " + es.size() + " events"); 
    643     } 
    644  
    645     es = postGetEvents(es, privRead, noAccessReturnsNull); 
     635      trace("Found " + ceis.size() + " events"); 
     636    } 
     637 
     638    ceis = postGetEvents(ceis, privRead, noAccessReturnsNull); 
    646639 
    647640    /** Run the events we got through the filters 
    648641     */ 
    649     es = flt.postExec(es); 
    650  
    651     Collection rs = getLimitedRecurrences(calendar, filter, startDate, endDate, 
    652                                           currentMode, cal.getSuperUser(), 
    653                                           recurRetrieval); 
    654     if (rs != null) { 
    655       es.addAll(rs); 
    656     } 
    657  
    658     return es; 
     642    ceis = flt.postExec(ceis); 
     643 
     644    Collection rceis = getLimitedRecurrences(calendar, filter, startDate, endDate, 
     645                                             currentMode, cal.getSuperUser(), 
     646                                             recurRetrieval); 
     647    if (rceis != null) { 
     648      ceis.addAll(rceis); 
     649    } 
     650 
     651    return ceis; 
    659652  } 
    660653 
     
    860853   * @param currentMode 
    861854   * @param ignoreCreator 
    862    * @return Collection  populated event value objects 
     855   * @return Collection  of CoreEventInfo objects 
    863856   * @throws CalFacadeException 
    864857   */ 
     
    941934 
    942935    CheckMap checked = new CheckMap(); 
    943     TreeSet evs = new TreeSet(); 
     936    TreeSet ceis = new TreeSet(); 
    944937 
    945938    Iterator it = rs.iterator(); 
     
    949942      /* XXX should have a list of overrides that cover 
    950943       */ 
    951       BwEventProxy proxy = makeProxy(inst, null, checked, recurRetrieval); 
    952       if (proxy != null) { 
     944      CoreEventInfo cei = makeProxy(inst, null, checked, recurRetrieval); 
     945      if (cei != null) { 
    953946        //if (debug) { 
    954947        //  debugMsg("Ev: " + proxy); 
    955948        //} 
    956         evs.add(proxy); 
     949        ceis.add(cei); 
    957950      } 
    958951    } 
     
    964957    /** Run the events we got through the filters 
    965958     */ 
    966     return flt.postExec(evs); 
     959    return flt.postExec(ceis); 
    967960  } 
    968961 
     
    10611054   * @param override    May be null if we retrieved the instance 
    10621055   * @param checked 
    1063    * @return BwEventProxy 
     1056   * @return CoreEventInfo 
    10641057   * @throws CalFacadeException 
    10651058   */ 
    1066   private BwEventProxy makeProxy(BwRecurrenceInstance inst, 
    1067                                  BwEventAnnotation override, 
    1068                                  CheckMap checked, 
    1069                                  int recurRetrieval) throws CalFacadeException { 
     1059  private CoreEventInfo makeProxy(BwRecurrenceInstance inst, 
     1060                                  BwEventAnnotation override, 
     1061                                  CheckMap checked, 
     1062                                  int recurRetrieval) throws CalFacadeException { 
    10701063    BwEvent mstr; 
    10711064    if (inst != null) { 
     
    10751068    } 
    10761069 
    1077     int res = 0; 
     1070    //int res = 0; 
     1071    CurrentAccess ca = null; 
    10781072 
    10791073    if (checked != null) { 
    1080       res = checked.test(mstr); 
    1081       if (res < 0) { 
     1074      ca = checked.getca(mstr); 
     1075      if ((ca != null) && !ca.accessAllowed) { 
    10821076        // failed 
    10831077        return null; 
     
    10861080 
    10871081    if ((recurRetrieval == CalFacadeDefs.retrieveRecurMaster) && 
    1088         (checked != null) && (res != 0)) { 
    1089       // Master only and we've already seen it 
     1082        (checked != null) && (ca != null)) { 
     1083      // Master only and we've already seen it - we don't want it again 
    10901084      return null; 
    10911085    } 
    10921086 
    1093     if ((checked == null) || (res == 0)) { 
     1087    if ((checked == null) || (ca == null)) { 
    10941088      // untested 
    1095       if (!access.accessible(mstr, privRead, noAccessReturnsNull)) { 
    1096         if (checked != null) { 
    1097           checked.setChecked(mstr, false); 
    1098         } 
     1089      ca = access.checkAccess(mstr, privRead, noAccessReturnsNull); 
     1090      if (checked != null) { 
     1091        checked.setChecked(mstr, ca); 
     1092      } 
     1093       
     1094      if (!ca.accessAllowed) { 
    10991095        return null; 
    11001096      } 
    1101     } 
    1102  
    1103     if (checked != null) { 
    1104       checked.setChecked(mstr, true); 
    11051097    } 
    11061098 
     
    11241116      override.setOwner(getUser()); 
    11251117 
    1126       return new BwEventProxy(override); 
     1118      return new CoreEventInfo(new BwEventProxy(override), ca); 
    11271119    } 
    11281120 
     
    11761168    } 
    11771169 
    1178     return new BwEventProxy(override); 
     1170    return new CoreEventInfo(new BwEventProxy(override), ca); 
    11791171  } 
    11801172 
    11811173  private static class CheckMap extends HashMap { 
    1182     void setChecked(BwEvent ev, boolean ok) { 
    1183       put(new Integer(ev.getId()), new Boolean(ok)); 
    1184     } 
    1185  
    1186     /* Return 0 for not found, 1 for OK, -1 for not allowed. 
    1187      */ 
    1188     int test(BwEvent ev) { 
    1189       Boolean b = (Boolean)get(new Integer(ev.getId())); 
    1190  
    1191       if (b == null) { 
    1192         return 0; 
    1193       } 
    1194  
    1195       if (b.booleanValue()) { 
    1196         return 1; 
    1197       } 
    1198  
    1199       return -1; 
     1174    void setChecked(BwEvent ev, CurrentAccess ca) { 
     1175      put(new Integer(ev.getId()), ca); 
     1176    } 
     1177 
     1178    /* Return null for not found. 
     1179     */ 
     1180    CurrentAccess getca(BwEvent ev) { 
     1181      return (CurrentAccess)get(new Integer(ev.getId())); 
    12001182    } 
    12011183  } 
     
    13001282 
    13011283    while (it.hasNext()) { 
    1302       BwEvent ev = (BwEvent)it.next(); 
    1303  
    1304       if (access.accessible(ev, desiredAccess,  nullForNoAccess)) { 
    1305         outevs.add(ev); 
     1284      CoreEventInfo cei = postGetEvent((BwEvent)it.next(),  
     1285                                       desiredAccess, nullForNoAccess); 
     1286       
     1287      if (cei != null) { 
     1288        outevs.add(cei); 
    13061289      } 
    13071290    } 
     
    13101293  } 
    13111294 
    1312   /* Post processing of event. Return null for no access 
     1295  /* Post processing of event. Return null or throw exception for no access 
    13131296   */ 
    1314   private BwEvent postGetEvent(BwEvent ev, int desiredAccess, 
    1315                                boolean nullForNoAccess) throws CalFacadeException { 
     1297  private CoreEventInfo postGetEvent(BwEvent ev, int desiredAccess, 
     1298                                     boolean nullForNoAccess) throws CalFacadeException { 
    13161299    if (ev == null) { 
    13171300      return null; 
    13181301    } 
    13191302 
    1320     if (!access.accessible(ev, desiredAccess, nullForNoAccess)) { 
     1303    CurrentAccess ca = access.checkAccess(ev, desiredAccess, nullForNoAccess); 
     1304     
     1305    if (!ca.accessAllowed) { 
    13211306      return null; 
    13221307    } 
     
    13281313    */ 
    13291314 
    1330     return ev; 
     1315    CoreEventInfo cei = new CoreEventInfo(ev, ca); 
     1316     
     1317    return cei; 
    13311318  } 
    13321319 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Filters.java

    r2 r321  
    5656import org.bedework.calfacade.BwEvent; 
    5757import org.bedework.calfacade.CalFacadeException; 
     58import org.bedework.calfacade.CoreEventInfo; 
    5859import org.bedework.calfacade.filter.BwAndFilter; 
    5960import org.bedework.calfacade.filter.BwCategoryFilter; 
     
    246247   * result and handle any filters that could not be handled by the query. 
    247248   * 
    248    * @param val         Collection to be filtered 
     249   * @param val         Collection of CoreEventInfo to be filtered 
    249250   * @return Collection filtered 
    250251   * @throws CalFacadeException 
     
    259260 
    260261    while (it.hasNext()) { 
    261       BwEvent ev = (BwEvent)it.next(); 
     262      CoreEventInfo cei = (CoreEventInfo)it.next(); 
     263      BwEvent ev = cei.getEvent(); 
    262264 
    263265      if (matches(filter, ev)) { 
    264         l.add(ev); 
     266        l.add(cei); 
    265267      } 
    266268    } 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java

    r314 r321  
    7171import org.bedework.calfacade.CalFacadeException; 
    7272import org.bedework.calfacade.CalintfDefs; 
     73import org.bedework.calfacade.CoreEventInfo; 
    7374import org.bedework.calfacade.filter.BwFilter; 
    7475import org.bedework.calfacade.ifs.CalTimezones; 
     
    689690   * ==================================================================== */ 
    690691 
    691   public BwEvent getEvent(int id) throws CalFacadeException { 
     692  public CoreEventInfo getEvent(int id) throws CalFacadeException { 
    692693    checkOpen(); 
    693694    throw new CalFacadeUnimplementedException(); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/EventsI.java

    r207 r321  
    55import org.bedework.calfacade.BwEvent; 
    66import org.bedework.calfacade.CalFacadeException; 
     7import org.bedework.calfacade.CoreEventInfo; 
    78import org.bedework.calfacade.filter.BwFilter; 
    89 
     
    4142   *                    master or non-null-valued for particular occurrence. 
    4243   * @param recurRetrieval Takes value defined in CalFacadeDefs. 
    43    * @return  Collection of EventInfo objects representing event(s). 
     44   * @return  Collection of CoreEventInfo objects representing event(s). 
    4445   * @throws CalFacadeException 
    4546   */ 
     
    4950  /** Return a single event for the current user 
    5051   * 
    51    * @param   eventId   int id of the event 
    52    * @return  EventVO   value object representing event. 
     52   * @param   eventId       int id of the event 
     53   * @return  CoreEventInfo object representing event. 
    5354   * @throws CalFacadeException 
     55   *  
     56   * @deprecated - other calendar systems won't support this. Doesn't make sense 
     57   *               for recurring events. 
    5458   */ 
    55   public BwEvent getEvent(int eventId) throws CalFacadeException; 
     59  public CoreEventInfo getEvent(int eventId) throws CalFacadeException; 
    5660 
    5761  /** Add an event to the database. The id and uid will be set in the parameter 
     
    124128   * @param endDate      DateTimeVO end - may be null. 
    125129   * @param recurRetrieval Takes value defined in CalFacadeDefs 
    126    * @return Collection  populated event value objects 
     130   * @return Collection  of CoreEventInfo objects 
    127131   * @throws CalFacadeException 
    128132   */ 
     
    132136          throws CalFacadeException; 
    133137 
    134   /** Return true if this event is editable by the current user 
     138  /* * Return true if this event is editable by the current user 
    135139   * 
    136140   * @param val                EventVO object to be tested 
    137141   * @return boolean 
    138142   * @throws CalFacadeException 
    139    *
    140   public boolean editable(BwEvent val) throws CalFacadeException; 
     143   *
     144  public boolean editable(BwEvent val) throws CalFacadeException;*/ 
    141145 
    142146  /* ==================================================================== 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/EventInfo.java

    r151 r321  
    5858import org.bedework.calfacade.BwEventAnnotation; 
    5959 
     60import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 
     61 
    6062import java.io.Serializable; 
    6163import java.util.Collection; 
     
    6971 * <p>This class allows us to handle thread, or user, specific information. 
    7072 * 
    71  * @author Mike Douglass       douglm@rpi.edu 
     73 * @author Mike Douglass       douglm @ rpi.edu 
    7274 */ 
    7375public class EventInfo implements Comparable, Comparator, Serializable { 
     
    127129   */ 
    128130  private String recurrenceId; 
     131   
     132  /* This object contains information giving the current users access rights to 
     133   * the entity. 
     134   */ 
     135  private CurrentAccess currentAccess; 
    129136 
    130137  /** 
     
    303310  public String getRecurrenceId() { 
    304311    return recurrenceId; 
     312  } 
     313   
     314  /* Set the current users access rights. 
     315   *  
     316   * @param val  CurrentAccess 
     317   */ 
     318  public void setCurrentAccess(CurrentAccess val) { 
     319    currentAccess = val; 
     320  } 
     321   
     322  /* Get the current users access rights. 
     323   *  
     324   * @return  CurrentAccess 
     325   */ 
     326  public CurrentAccess getCurrentAccess() { 
     327    return currentAccess; 
    305328  } 
    306329 
  • trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/CalintfCaldavImpl.java

    r301 r321  
    6363import org.bedework.calfacade.BwSponsor; 
    6464import org.bedework.calfacade.BwStats; 
     65import org.bedework.calfacade.CoreEventInfo; 
    6566//import org.bedework.calfacade.BwSynchData; 
    6667import org.bedework.calfacade.BwSynchInfo; 
     
    577578   * ==================================================================== */ 
    578579 
    579   public BwEvent getEvent(int id) throws CalFacadeException { 
     580  public CoreEventInfo getEvent(int id) throws CalFacadeException { 
    580581    checkOpen(); 
    581582    throw new CalFacadeUnimplementedException(); 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r314 r321  
    8080import org.bedework.calfacade.CalFacadeException; 
    8181import org.bedework.calfacade.CalFacadeUtil; 
     82import org.bedework.calfacade.CoreEventInfo; 
    8283import org.bedework.calfacade.filter.BwFilter; 
    8384import org.bedework.calfacade.ifs.CalTimezones; 
     
    19291930  }*/ 
    19301931 
    1931   private EventInfo postProcess(BwEvent ev, BwSubscription sub,  
     1932  private EventInfo postProcess(CoreEventInfo cei, BwSubscription sub,  
    19321933                                HashMap sublookup) 
    19331934          throws CalFacadeException { 
    1934     if (ev == null) { 
     1935    if (cei == null) { 
    19351936      return null; 
    19361937    } 
     
    19411942     * proxy and return that object. 
    19421943     */ 
     1944    BwEvent ev = cei.getEvent(); 
     1945     
    19431946    if (ev instanceof BwEventAnnotation) { 
    19441947      ev = new BwEventProxy((BwEventAnnotation)ev); 
     
    19541957    } 
    19551958    ei.setRecurrenceId(ev.getRecurrence().getRecurrenceId()); 
     1959    ei.setCurrentAccess(cei.getCurrentAccess()); 
    19561960 
    19571961    return ei; 
    19581962  } 
    19591963 
    1960   private Collection postProcess(Collection evs, BwSubscription sub) 
     1964  private Collection postProcess(Collection ceis, BwSubscription sub) 
    19611965          throws CalFacadeException { 
    19621966    ArrayList al = new ArrayList(); 
    19631967 
    1964     Iterator it = evs.iterator(); 
     1968    Iterator it = ceis.iterator(); 
    19651969 
    19661970    while (it.hasNext()) { 
    1967       BwEvent ev = (BwEvent)it.next(); 
    1968       EventInfo ei = postProcess(ev, sub, null); 
     1971      EventInfo ei = postProcess((CoreEventInfo)it.next(), sub, null); 
    19691972      al.add(ei); 
    19701973    } 
     
    19731976  } 
    19741977 
    1975   private Collection postProcess(Collection evs, HashMap sublookup) 
     1978  private Collection postProcess(Collection ceis, HashMap sublookup) 
    19761979          throws CalFacadeException { 
    19771980    ArrayList al = new ArrayList(); 
    19781981 
    1979     Iterator it = evs.iterator(); 
     1982    Iterator it = ceis.iterator(); 
    19801983 
    19811984    while (it.hasNext()) { 
    1982       BwEvent ev = (BwEvent)it.next(); 
    1983       EventInfo ei = postProcess(ev, null, sublookup); 
     1985      EventInfo ei = postProcess((CoreEventInfo)it.next(), null, sublookup); 
    19841986      al.add(ei); 
    19851987    } 
  • trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java

    r314 r321  
    10891089   * @return  EventInfo   value object representing event. 
    10901090   * @throws CalFacadeException 
     1091   *  
     1092   * @deprecated - other calendar systems won't support this. Doesn't make sense 
     1093   *               for recurring events. 
    10911094   */ 
    10921095  public abstract EventInfo getEvent(int eventId) throws CalFacadeException; 
  • trunk/calendar3/webclient/war/docs/event/emitEventDetail.jsp

    r312 r321  
    7070      </sponsor> 
    7171    </logic:present> 
     72    <bw:emitCurrentPrivs name="eventInfo" property="currentAccess" /> 
    7273