Changeset 532

Show
Ignore:
Timestamp:
06/05/06 10:23:17
Author:
douglm
Message:

Small fix to event validation.
Use syspar length to limit description length

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEvent.java

    r507 r532  
    159159  private String summary; 
    160160 
    161   /** This should be set by the back end code. 
    162    */ 
    163   public static final int maxDescriptionLength = 500; 
    164  
    165161  private String description; 
    166162 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/PEActionForm.java

    r161 r532  
    207207   */ 
    208208  public int getMaxDescriptionLength() { 
    209     return BwEvent.maxDescriptionLength; 
     209    try { 
     210      return fetchSvci().getSyspars().getMaxPublicDescriptionLength(); 
     211    } catch (Throwable t) { 
     212      err.emit(t); 
     213      return 0; 
     214    } 
    210215  } 
    211216 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEUpdateEventAction.java

    r519 r532  
    207207    if (!form.getEventDates().updateEvent(event, svci.getTimezones())) { 
    208208      ok = false; 
    209     } else if (!BwWebUtil.validateEvent(svci, event, true, // ENUM  descriptionRequired 
     209    } else if (!BwWebUtil.validateEvent(svci, event, true, // public 
    210210                                        err)) { 
    211211      ok = false; 
  • trunk/calendar3/webclient/src/org/bedework/webclient/BwAddEventAction.java

    r419 r532  
    101101 
    102102    if (!form.getEventDates().updateEvent(ev, svci.getTimezones()) || 
    103         !BwWebUtil.validateEvent(svci, ev, false, //  descriptionRequired 
     103        !BwWebUtil.validateEvent(svci, ev, false, //  public 
    104104                                 form.getErr())) { 
    105105      return "doNothing"; 
  • trunk/calendar3/webclient/src/org/bedework/webclient/BwEditEventAction.java

    r421 r532  
    161161 
    162162    if (!form.getEventDates().updateEvent(ev, svci.getTimezones()) || 
    163         !BwWebUtil.validateEvent(svci, ev, false, //  descriptionRequired 
     163        !BwWebUtil.validateEvent(svci, ev, false, //  public 
    164164                                 form.getErr())) { 
    165165      return "doNothing"; 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwWebUtil.java

    r519 r532  
    5959import org.bedework.calfacade.BwLocation; 
    6060import org.bedework.calfacade.BwSponsor; 
     61import org.bedework.calfacade.BwSystem; 
    6162import org.bedework.calfacade.CalFacadeException; 
    6263import org.bedework.calsvci.CalSvcI; 
     
    166167   * @param svci 
    167168   * @param ev 
    168    * @param descriptionRequired 
     169   * @param publicEvent    requirements will differ 
    169170   * @param err 
    170171   * @return boolean true for ok 
    171172   * @throws CalFacadeException 
    172173   */ 
    173   public static boolean validateEvent(CalSvcI svci, BwEvent ev, boolean descriptionRequired, 
     174  public static boolean validateEvent(CalSvcI svci, BwEvent ev, 
     175                                      boolean publicEvent, 
    174176                                      MessageEmit err) throws CalFacadeException { 
    175177    boolean ok = true; 
     
    177179    ev.setSummary(checkNull(ev.getSummary())); 
    178180    ev.setDescription(checkNull(ev.getDescription())); 
     181    ev.setLink(checkNull(ev.getLink())); 
    179182 
    180183    if (ev.getCalendar() == null) { 
     
    183186    } 
    184187 
     188    BwSystem syspars = svci.getSyspars(); 
     189    int maxDescLen; 
     190    if (publicEvent) { 
     191      maxDescLen = syspars.getMaxPublicDescriptionLength(); 
     192    } else { 
     193      maxDescLen = syspars.getMaxUserDescriptionLength(); 
     194    } 
     195 
    185196    if (ev.getSummary() == null) { 
    186197      err.emit("org.bedework.validation.error.notitle"); 
    187198      ok = false; 
     199    } else if (ev.getSummary().length() > maxDescLen) { 
     200      // Use the description length here 
     201      err.emit("org.bedework.validation.error.toolong.summary", 
     202               String.valueOf(maxDescLen)); 
     203      ok = false; 
    188204    } 
    189205 
    190206    if (ev.getDescription() == null) { 
    191       if (descriptionRequired) { 
     207      if (publicEvent) { 
    192208        err.emit("org.bedework.validation.error.nodescription"); 
    193209        ok = false; 
    194210      } 
    195     } else if (ev.getDescription().length() > BwEvent.maxDescriptionLength) { 
    196       err.emit("org.bedework.validation.error.toolong.description", String.valueOf(BwEvent.maxDescriptionLength)); 
     211    } else if (ev.getDescription().length() > maxDescLen) { 
     212      err.emit("org.bedework.validation.error.toolong.description", 
     213               String.valueOf(maxDescLen)); 
    197214      ok = false; 
    198215    }