Changeset 42

Show
Ignore:
Timestamp:
01/26/06 16:08:11
Author:
douglm
Message:

Fix events validation

Files:

Legend:

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

    r2 r42  
    6969import org.apache.log4j.Logger; 
    7070 
    71 /** Implementation of UserAuth that handles UW DB tables for authorisation. 
     71/** Implementation of UserAuth that handles Bedwork DB tables for authorisation. 
    7272 * 
    7373 * @author Mike Douglass    douglm@rpi.edu 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwPrincipal.java

    r2 r42  
    8484public abstract class BwPrincipal extends BwDbentity 
    8585                                  implements AccessPrincipal, Comparator { 
    86   /** The kind of Principal returned by getKind() */ 
    87  
    88   /** user */ 
    89   public static final int principalUser = 0; 
    90  
    91   /** group */ 
    92   public static final int principalGroup = 1; 
    93  
    94   /** host */ 
    95   public static final int principalHost = 2; 
    96  
    97   /** Used for db version checks 
    98    */ 
    99   protected int seq; 
    100  
    10186  /** The internal name by which this principal is identified, unique within 
    10287   * its class 
     
    170155   */ 
    171156  public abstract int getKind(); 
    172  
    173   /** Set the db version 
    174    * 
    175    * @param val   db version number 
    176    */ 
    177   public void setSeq(int val) { 
    178     seq = val; 
    179   } 
    180  
    181   /** Get the db version 
    182    * 
    183    * @return int    the db version 
    184    */ 
    185   public int getSeq() { 
    186     return seq; 
    187   } 
    188157 
    189158  /** Set the unauthenticated state. 
     
    466435    BwPrincipal p2 = (BwPrincipal)o2; 
    467436 
    468     if (p1.account == null) { 
    469       // Should not happen 
    470       throw new RuntimeException("Null account for UserVO object id=" + 
    471                                  p1.getId()); 
    472     } 
    473  
    474     if (p2.account == null) { 
    475       // Should not happen 
    476       throw new RuntimeException("Null account for UserVO object id=" + 
    477                                  p2.getId()); 
    478     } 
    479  
    480     return p1.account.compareTo(p2.account); 
     437    if (p1.getKind() < p2.getKind()) { 
     438      return -1; 
     439    } 
     440 
     441    if (p1.getKind() > p2.getKind()) { 
     442      return 1; 
     443    } 
     444 
     445    return CalFacadeUtil.compareStrings(p1.getAccount(), p2.getAccount()); 
    481446  } 
    482447 
  • trunk/calendar3/deployment/webadmin/webapp/resources/en_US/default/errors.xsl

    r40 r42  
    7171        You must supply a title<br/> 
    7272      </xsl:when> 
     73      <xsl:when test="id='org.bedework.validation.error.nocalendar'"> 
     74        You must supply the calendar<br/> 
     75      </xsl:when> 
    7376      <xsl:when test="id='org.bedework.validation.error.nodescription'"> 
    7477        You must supply a description<br/> 
  • trunk/calendar3/docs/todo.txt

    r36 r42  
    33-------------------------------------------------------------------------------- 
    44-------------------------------------------------------------------------------- 
    5 -------------------------------------------------------------------------------- 
     5Unremovable subscriptions 
     6-------------------------------------------------------------------------------- 
     7Personal users need default subscriptions and views 
    68-------------------------------------------------------------------------------- 
    79Finish off moving calendar labelling stuff out of TimeDateComponents 
     
    101103Fix the add event link in calendar gui 
    102104-------------------------------------------------------------------------------- 
    103 Remove target from BwEvent? 
    104105-------------------------------------------------------------------------------- 
    105106We probably need the equivalent of an event info object at the Calintf level to 
     
    322323Delete in user calendar doesn't work 
    323324-------------------------------------------------------------------------------- 
    324 Caused by: java.io.NotSerializableException: org.apache.log4j.Logger 
    325325-------------------------------------------------------------------------------- 
    326326Event_Attendees table has wrong column name 
     
    420420Manage calendars. 
    421421 
    422 Use /calendar/initAdd to specify parent 
    423 http://localhost:8080/caladmin/calendar/initAdd.do?calId=123 
    424  
    425 Then 
    426 http://localhost:8080/caladmin/calendar/update.do?... 
    427 with calendar fields. 
    428  
    429 To update go to 
    430 http://localhost:8080/caladmin/calendar/fetchForUpdate.do?calId=123 
    431 then on to update 
    432  
    433 Deletion should start off as update then on to 
    434 http://localhost:8080/caladmin/calendar/delete.do?... 
    435  
    436 ********************************** 
    437422Check that access is limited to calendars to which auth user has at least 
    438423write-content access 
  • trunk/calendar3/tools/dumprestore/build.xml

    r18 r42  
    238238      <arg line="${org.bedework.restore.arg.admingroupsClass}" /> 
    239239      <arg line="${org.bedework.restore.arg.usergroupsClass}" /> 
     240      <!-- 
    240241      <jvmarg value="-Xrunyjpagent:cpu=times,onexit=cpu" /> 
     242      --> 
    241243      <!-- 
    242244      <arg value="-Djava.endorsed.dir=${org.bedework.default.lib}/endorsed"/>--> 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/PEActionForm.java

    r24 r42  
    145145  /** Set if we appear to be changing the event category. 
    146146   */ 
    147 //  private CategoryVO oldCategory; 
    148  
    149   private IntSelectId keyId; 
     147 
     148  private IntSelectId categoryId; 
    150149 
    151150  /* .................................................................... 
     
    397396 
    398397    /* A is the All box, B is the user preferred values. */ 
    399     keyId = new IntSelectId(id, IntSelectId.AHasPrecedence); 
     398    categoryId = new IntSelectId(id, IntSelectId.AHasPrecedence); 
    400399 
    401400    BwSponsor s = event.getSponsor(); 
     
    526525  public void setCategoryId(int val) { 
    527526    if (val >= 0) { 
    528       keyId.setA(val); 
     527      categoryId.setA(val); 
    529528    } 
    530529  } 
     
    538537   */ 
    539538  public int getOriginalCategoryId() { 
    540     if (keyId == null) { 
     539    if (categoryId == null) { 
    541540      return 0; 
    542541    } 
    543542 
    544     return keyId.getOriginalVal(); 
     543    return categoryId.getOriginalVal(); 
    545544  } 
    546545 
     
    550549  public void setPrefCategoryId(int val) { 
    551550    if (val >= 0) { 
    552       keyId.setB(val); 
     551      categoryId.setB(val); 
    553552    } 
    554553  } 
     
    10891088   * ==================================================================== */ 
    10901089 
    1091   /** Ensure the event has all required fields and all are valid. 
    1092    * 
    1093    * <p>This method will retrieve any selected contacts, locations and 
    1094    * categories and embed them in the form and event. 
    1095    * 
    1096    * @return boolean   true   event looks OK 
    1097    * @throws Throwable 
    1098    */ 
    1099   public boolean validateEvent() throws Throwable { 
    1100     boolean ok = validateEventCategory(); 
    1101     BwEvent ev = getEvent(); 
    1102  
    1103     if (!validateEventSponsor()) { 
    1104       ok = false; 
    1105     } 
    1106  
    1107     if (!validateEventLocation()) { 
    1108       ok = false; 
    1109     } 
    1110  
    1111     if (!validateEventCalendar()) { 
    1112       ok = false; 
    1113     } 
    1114  
    1115     if (!getEventDates().updateEvent(ev, getCalSvcI().getTimezones())) { 
    1116       ok = false; 
    1117     } else { 
    1118       ok = BwWebUtil.validateEvent(this.getCalSvcI(), ev, true, //  descriptionRequired 
    1119                                    err); 
    1120     } 
    1121  
    1122     return ok; 
    1123   } 
    1124  
    11251090  /** 
    11261091   * 
     
    11291094   */ 
    11301095  public boolean validateEventCategory() throws Throwable { 
    1131     int id = keyId.getVal(); 
     1096    int id = categoryId.getVal(); 
    11321097 
    11331098    if (id <= 0) { 
     
    11481113      } 
    11491114 
    1150       if (!keyId.getChanged()) { 
     1115      if (!categoryId.getChanged()) { 
    11511116        return true; 
    11521117      } 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEUpdateEventAction.java

    r24 r42  
    6262import org.bedework.webadmin.PEActionForm; 
    6363import org.bedework.webcommon.BwSession; 
     64import org.bedework.webcommon.BwWebUtil; 
    6465 
    6566 
     
    121122 
    122123    CalSvcI svci = form.getCalSvcI(); 
    123     if (!form.validateEvent()) { 
     124    if (!validateEvent(form)) { 
    124125      return "retry"; 
    125126    } 
     
    155156    return "continue"; 
    156157  } 
     158 
     159  /* Ensure the event has all required fields and all are valid. 
     160   * 
     161   * <p>This method will retrieve any selected contacts, locations and 
     162   * categories and embed them in the form and event. 
     163   */ 
     164  private boolean validateEvent(PEActionForm form) throws Throwable { 
     165    boolean ok = form.validateEventCategory(); 
     166    BwEvent ev = form.getEvent(); 
     167    CalSvcI svci = form.getCalSvcI(); 
     168 
     169    if (!form.validateEventSponsor()) { 
     170      ok = false; 
     171    } 
     172 
     173    if (!form.validateEventLocation()) { 
     174      ok = false; 
     175    } 
     176 
     177    if (!form.validateEventCalendar()) { 
     178      ok = false; 
     179    } 
     180 
     181    if (!form.getEventDates().updateEvent(ev, svci.getTimezones())) { 
     182      ok = false; 
     183    } else { 
     184      ok = BwWebUtil.validateEvent(svci, ev, true, //  descriptionRequired 
     185                                   form.getErr()); 
     186    } 
     187 
     188    return ok; 
     189  } 
    157190} 
    158191 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwWebUtil.java

    r2 r42  
    178178    ev.setDescription(checkNull(ev.getDescription())); 
    179179 
     180    if (ev.getCalendar() == null) { 
     181      err.emit("org.bedework.validation.error.nocalendar"); 
     182      ok = false; 
     183    } 
     184 
    180185    if (ev.getSummary() == null) { 
    181186      err.emit("org.bedework.validation.error.notitle");