Changeset 369

Show
Ignore:
Timestamp:
04/13/06 09:35:10
Author:
douglm
Message:

Code to support lucene indexing. Nothing being used yet but builds OK

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/bldfiles/defjars.properties

    r312 r369  
    6161ical4j.jar.name=ical4j-0.9.19-pre.jar 
    6262ical4j.jar=${org.bedework.default.lib}/${ical4j.jar.name} 
     63 
     64#      lucene.jar           Used for indexing and searching 
     65lucene.jar.name=lucene-core-1.9.1.jar 
     66lucene.jar=${org.bedework.default.lib}/${lucene.jar.name} 
    6367 
    6468#      regexp.jar           Handles regular expressions 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java

    r360 r369  
    222222 
    223223  public BwCalendar getCalendars() throws CalFacadeException { 
     224    return getCalendars(getUser()); 
     225  } 
     226 
     227  public BwCalendar getCalendars(BwUser user) throws CalFacadeException { 
    224228    HibSession sess = getSess(); 
    225229 
    226230    sess.namedQuery("getCalendarByPath"); 
    227     sess.setString("path", userCalendarRootPath + "/" + getUser().getAccount()); 
     231    sess.setString("path", userCalendarRootPath + "/" + user.getAccount()); 
    228232    sess.cacheableQuery(); 
    229233 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r360 r369  
    817817  } 
    818818 
     819  public BwCalendar getCalendars(BwUser user) throws CalFacadeException { 
     820    checkOpen(); 
     821 
     822    return calendars.getCalendars(user); 
     823  } 
     824 
    819825  public Collection getCalendarCollections() throws CalFacadeException { 
    820826    checkOpen(); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwFreeBusy.java

    r366 r369  
    7272  private BwDateTime end; 
    7373 
    74   /** Collection of FreeBusyComponentVO 
     74  /** Collection of BwFreeBusyComponent 
    7575   */ 
    7676  private Collection times; 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java

    r360 r369  
    426426  } 
    427427 
     428  public BwCalendar getCalendars(BwUser user) throws CalFacadeException { 
     429    throw new CalFacadeUnimplementedException(); 
     430  } 
     431 
    428432  public Collection getCalendarCollections() throws CalFacadeException { 
    429433    checkOpen(); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java

    r360 r369  
     1/* 
     2 Copyright (c) 2000-2005 University of Washington.  All rights reserved. 
     3 
     4 Redistribution and use of this distribution in source and binary forms, 
     5 with or without modification, are permitted provided that: 
     6 
     7   The above copyright notice and this permission notice appear in 
     8   all copies and supporting documentation; 
     9 
     10   The name, identifiers, and trademarks of the University of Washington 
     11   are not used in advertising or publicity without the express prior 
     12   written permission of the University of Washington; 
     13 
     14   Recipients acknowledge that this distribution is made available as a 
     15   research courtesy, "as is", potentially with defects, without 
     16   any obligation on the part of the University of Washington to 
     17   provide support, services, or repair; 
     18 
     19   THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR 
     20   IMPLIED, WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION 
     21   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
     22   PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF 
     23   WASHINGTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
     24   DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 
     25   PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING 
     26   NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION WITH 
     27   THE USE OR PERFORMANCE OF THIS SOFTWARE. 
     28 */ 
     29/* ********************************************************************** 
     30    Copyright 2005 Rensselaer Polytechnic Institute. All worldwide rights reserved. 
     31 
     32    Redistribution and use of this distribution in source and binary forms, 
     33    with or without modification, are permitted provided that: 
     34       The above copyright notice and this permission notice appear in all 
     35        copies and supporting documentation; 
     36 
     37        The name, identifiers, and trademarks of Rensselaer Polytechnic 
     38        Institute are not used in advertising or publicity without the 
     39        express prior written permission of Rensselaer Polytechnic Institute; 
     40 
     41    DISCLAIMER: The software is distributed" AS IS" without any express or 
     42    implied warranty, including but not limited to, any implied warranties 
     43    of merchantability or fitness for a particular purpose or any warrant)' 
     44    of non-infringement of any current or pending patent rights. The authors 
     45    of the software make no representations about the suitability of this 
     46    software for any particular purpose. The entire risk as to the quality 
     47    and performance of the software is with the user. Should the software 
     48    prove defective, the user assumes the cost of all necessary servicing, 
     49    repair or correction. In particular, neither Rensselaer Polytechnic 
     50    Institute, nor the authors of the software are liable for any indirect, 
     51    special, consequential, or incidental damages related to the software, 
     52    to the maximum extent the law permits. 
     53*/ 
    154package org.bedework.calfacade.ifs; 
    255 
     
    4194  /** Returns calendars owned by the current user. 
    4295   * 
    43    * <p>For anonymous (public events) access, this method returns the same 
    44    * as getPublicCalendars(). 
     96   * <p>For authenticated, personal access this always returns the user 
     97   * entry in the /user calendar tree, e.g. for user smithj it would return 
     98   * an entry /user/smithj 
     99   * 
     100   * @return BwCalendar   root with all children attached 
     101   * @throws CalFacadeException 
     102   */ 
     103  public BwCalendar getCalendars() throws CalFacadeException; 
     104 
     105  /** Returns calendars owned by the given user. 
    45106   * 
    46107   * <p>For authenticated, personal access this always returns the user 
     
    51112   * @throws CalFacadeException 
    52113   */ 
    53   public BwCalendar getCalendars() throws CalFacadeException; 
     114  public BwCalendar getCalendars(BwUser user) throws CalFacadeException; 
    54115 
    55116  /** Return a list of user calendars in which calendar objects can be 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/calquery/FreeBusyQuery.java

    r366 r369  
    147147      try { 
    148148        BwFreeBusy fb = svci.getFreeBusy(null, new BwUser(user), 
    149                                          tr.getStart(), tr.getEnd(), null); 
     149                                         tr.getStart(), tr.getEnd(), null, 
     150                                         false); 
    150151 
    151152        if (debug) { 
  • trunk/calendar3/calsvc/build.xml

    r2 r369  
    3131      <pathelement location="${ical4j.jar}"/> 
    3232      <pathelement location="${log4j.jar}"/> 
     33      <pathelement location="${lucene.jar}"/> 
    3334      <pathelement location="${org.bedework.calsvci.jar}"/> 
    3435      <pathelement location="${org.bedework.calcore.jar}"/> 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r366 r369  
    100100//import org.bedework.mail.MailerIntf; 
    101101 
     102import edu.rpi.cct.misc.indexing.Index; 
    102103import edu.rpi.cct.uwcal.access.PrivilegeDefs; 
    103104import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 
     
    128129  private CalSvcIPars pars; 
    129130 
     131  private Index indexer; 
     132 
    130133  private boolean debug; 
    131134 
     
    10151018  public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, 
    10161019                                BwDateTime start, BwDateTime end, 
    1017                                 BwDuration granularity) 
     1020                                BwDuration granularity, 
     1021                                boolean returnAll) 
    10181022          throws CalFacadeException { 
    10191023    if (!(who instanceof BwUser)) { 
     
    10211025    } 
    10221026 
    1023     if (isGuest() || (!currentUser().equals(who))) { 
    1024       // No access for the moment 
    1025       throw new CalFacadeAccessException(); 
    1026     } 
    1027  
    10281027    BwUser u = (BwUser)who; 
    10291028    Collection subs; 
    10301029 
    10311030    if (cal != null) { 
     1031      getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); 
     1032 
    10321033      BwSubscription sub = BwSubscription.makeSubscription(cal); 
    10331034 
     
    10371038      subs = getSubscriptions(); 
    10381039    } else { 
     1040      getCal().checkAccess(getCal().getCalendars(u), 
     1041                           PrivilegeDefs.privReadFreeBusy, false); 
     1042 
    10391043      subs = dbi.fetchPreferences(u).getSubscriptions(); 
    10401044    } 
     
    10801084        gpp.tzcache = getTimezones(); 
    10811085 
    1082         /* For the moment just build a single BwFreeBusyComponent 
    1083          */ 
    1084         BwFreeBusyComponent fbc = new BwFreeBusyComponent(); 
     1086        BwFreeBusyComponent fbc = null; 
     1087 
     1088        if (!returnAll) { 
     1089          // One component 
     1090          fbc = new BwFreeBusyComponent(); 
     1091          fb.addTime(fbc); 
     1092        } 
    10851093 
    10861094        int limit = 10000; // XXX do this better 
    10871095        while (gpp.startDt.before(end)) { 
    1088           if (debug) { 
    1089             trace("gpp.startDt=" + gpp.startDt + " end=" + end); 
    1090          
     1096          //if (debug) { 
     1097          //  trace("gpp.startDt=" + gpp.startDt + " end=" + end); 
     1098          //
    10911099          if (limit < 0) { 
    10921100            throw new CalFacadeException("org.bedework.svci.limit.exceeded"); 
     
    10961104          Collection periodEvents = CalFacadeUtil.getPeriodsEvents(gpp); 
    10971105 
    1098           if (periodEvents.size() != 0) { 
     1106          if (returnAll) { 
     1107            fbc = new BwFreeBusyComponent(); 
     1108            fb.addTime(fbc); 
     1109            fbc.addPeriod(new Period(new DateTime(gpp.startDt.getDtval()), 
     1110                                     new DateTime(gpp.endDt.getDtval()))); 
     1111            if (periodEvents.size() == 0) { 
     1112              fbc.setType(BwFreeBusyComponent.typeFree); 
     1113            } 
     1114          } else if (periodEvents.size() != 0) { 
    10991115            // Some events fall in the period. Add an entry. 
    11001116 
     
    11031119          } 
    11041120        } 
    1105         fb.addTime(fbc); 
    11061121 
    11071122        return fb; 
     
    23742389  } 
    23752390 
     2391  /* ==================================================================== 
     2392   *                   Private indexing methods 
     2393   * ==================================================================== */ 
     2394 
     2395  private Index getIndexer() throws CalFacadeException { 
     2396    try { 
     2397      if (indexer == null) { 
     2398        indexer = new BwIndexLuceneImpl(this, 
     2399                                        // XXX Schema change - in syspars 
     2400                                        "/temp/bedeworkindex", 
     2401                                        isPublicAdmin(), 
     2402                                        debug); 
     2403      } 
     2404 
     2405      return indexer; 
     2406    } catch (Throwable t) { 
     2407      throw new CalFacadeException(t); 
     2408    } 
     2409  } 
     2410 
     2411  /* Call to (re)index an event 
     2412   */ 
     2413  private void indexEvent(BwEvent ev) throws CalFacadeException { 
     2414    try { 
     2415      getIndexer().indexRec(ev); 
     2416    } catch (Throwable t) { 
     2417      throw new CalFacadeException(t); 
     2418    } 
     2419  } 
     2420 
     2421  private void unindexEvent(BwEvent ev) throws CalFacadeException { 
     2422    try { 
     2423      getIndexer().unindexRec(ev); 
     2424    } catch (Throwable t) { 
     2425      throw new CalFacadeException(t); 
     2426    } 
     2427  } 
     2428 
     2429  /* Call to (re)index a calendar 
     2430   */ 
     2431  private void indexCalendar(BwCalendar cal) throws CalFacadeException { 
     2432    try { 
     2433      getIndexer().indexRec(cal); 
     2434    } catch (Throwable t) { 
     2435      throw new CalFacadeException(t); 
     2436    } 
     2437  } 
     2438 
     2439  private void unindexCalendar(BwCalendar cal) throws CalFacadeException { 
     2440    try { 
     2441      getIndexer().unindexRec(cal); 
     2442 
     2443      // And all the children 
     2444      Iterator it = cal.iterateChildren(); 
     2445      while (it.hasNext()) { 
     2446        BwCalendar ch = (BwCalendar)it.next(); 
     2447 
     2448        unindexCalendar(ch); 
     2449      } 
     2450    } catch (Throwable t) { 
     2451      throw new CalFacadeException(t); 
     2452    } 
     2453  } 
     2454 
    23762455  /* Get a logger for messages 
    23772456   */ 
  • trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java

    r366 r369  
    810810   *                    null for one big glob. or set to e.g. 1 hour for 
    811811   *                    hourly chunks. 
     812   * @param returnAll   if true return entries for free time otherwise just for busy 
     813   *                    (only for granularity not null) 
    812814   * @return BwFreeBusy 
    813815   * @throws CalFacadeException 
     
    815817  public abstract BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, 
    816818                                         BwDateTime start, BwDateTime end, 
    817                                          BwDuration granularity) 
     819                                         BwDuration granularity, 
     820                                         boolean returnAll) 
    818821          throws CalFacadeException; 
    819822 
  • trunk/calendar3/common/build.xml

    r310 r369  
    1717 
    1818    <fileset id="base.java.sources" dir="${source.home}" > 
    19      <include name="edu/rpi/sss/util/**/*.java"/> 
    20       <include name="edu/rpi/cct/uwcal/**/*.java"/> 
     19     <include name="edu/rpi/**/*.java"/> 
    2120    </fileset> 
    2221 
    2322    <patternset id="base.class.patternset"> 
    24       <include name="edu/rpi/sss/util/**/*.class"/> 
    25       <include name="edu/rpi/cct/uwcal/**/*.class"/> 
     23      <include name="edu/rpi/**/*.class"/> 
    2624    </patternset> 
    2725 
     
    3432      <pathelement location="${avalon.jar}"/> 
    3533      <pathelement location="${log4j.jar}"/> 
    36       <pathelement location="${logkit.jar}"/> 
     34      <pathelement location="${log4j.jar}"/> 
     35      <pathelement location="${lucene.jar}"/> 
    3736      <pathelement location="${jtidy.jar}"/> 
    3837    </path> 
  • trunk/calendar3/webclient/src/org/bedework/webclient/BwFreeBusyAction.java

    r366 r369  
    158158                                     CalFacadeUtil.getDateTime(sdt, false, false, tzs), 
    159159                                     CalFacadeUtil.getDateTime(edt, false, false, tzs), 
    160                                      dur); 
     160                                     dur, true); 
    161161 
    162162    form.assignFreeBusy(fb); 
  • trunk/calendar3/webclient/war/docs/freeBusy.jsp

    r313 r369  
    22<%@ taglib uri='struts-logic' prefix='logic' %> 
    33<%@ taglib uri='struts-genurl' prefix='genurl' %> 
     4<%@ taglib uri='bedework' prefix='bw' %> 
    45 
    56<%@ include file="/docs/header.jsp" %> 
     
    1718 
    1819<freebusy> 
    19   <who><bean:write name="freeBusyObj" property="who.account" /></who
    20   <start><bean:write name="freeBusyObj" property="start" /></start
    21   <end><bean:write name="freeBusyObj" property="end" /></end
     20  <bw:emitText name="freeBusyObj" property="who.account" tagName="who" /
     21  <bw:emitText name="freeBusyObj" property="start.dtval" tagName="start" /
     22  <bw:emitText name="freeBusyObj" property="end.dtval" tagName="end" /
    2223  <logic:iterate id="freeBusyComponent"  name="freeBusyObj" property="times" > 
    2324    <freeBusyComponent>