Changeset 298

Show
Ignore:
Timestamp:
03/23/06 00:17:08
Author:
douglm
Message:

Improve personal calendar upload error reporting
Handle TRANSP in ical
Add System properties to enable Microsoft tolerant parsing in ical

Files:

Legend:

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

    r2 r298  
    6363   */ 
    6464  public CalFacadeBadDateException() { 
    65     super(); 
     65    super(badDate); 
    6666  } 
    6767 
     
    7979   */ 
    8080  public CalFacadeBadDateException(String s) { 
    81     super(s); 
     81    super(badDate, s); 
    8282  } 
    8383} 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeException.java

    r285 r298  
    6262   * retrieve a localized message and can also be used to identify the 
    6363   * cause of the exception. 
     64   *  
     65   * Every CalFacadeException should have one of these as the getMessage() 
     66   * value. 
    6467   */ 
    6568   
     
    117120  public static final String timezonesReadError = 
    118121      "org.bedework.error.timezones.readerror"; 
     122   
     123  /** Unknown timezones */ 
     124  public static final String unknownTimezone = 
     125      "org.bedework.error.unknown.timezone"; 
     126   
     127  /** Bad date */ 
     128  public static final String badDate = 
     129      "org.bedework.error.bad.date"; 
    119130 
    120131  /* ****************** Misc ****************************** */ 
     
    126137  private String extra; 
    127138 
    128   /** Constrictor 
     139  /** Constructor 
    129140   * 
    130141   */ 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java

    r278 r298  
    300300    HashMap cache = null; 
    301301     
    302     if (CalFacadeUtil.isISODate(time)) { 
     302    if ((time.length() == 8) && CalFacadeUtil.isISODate(time)) { 
    303303      /* See if we have it cached */ 
    304304       
     
    328328      time += "T000000"; 
    329329    } else if (!CalFacadeUtil.isISODateTime(time)) { 
    330       throw new CalFacadeBadDateException(); 
     330      throw new CalFacadeBadDateException(time); 
    331331    } 
    332332     
     
    359359          if (lasttz == null) { 
    360360            lasttzid = null; 
    361             throw new CalFacadeBadDateException(); 
     361            throw new CalFacadeException(CalFacadeException.unknownTimezone, tzid); 
    362362          } 
    363363          tzchanged = true; 
     
    406406       
    407407      return utc; 
     408    } catch (CalFacadeException cfe) { 
     409      throw cfe; 
    408410    } catch (Throwable t) { 
    409411      t.printStackTrace(); 
    410       throw new CalFacadeBadDateException(); 
     412      throw new CalFacadeBadDateException(time); 
    411413    } 
    412414  } 
  • trunk/calendar3/deployment/webuser/webapp/resources/demoskins/default/default/errors.xsl

    r2 r298  
    2727          You must supply a recipient. 
    2828      </xsl:when> 
     29      <xsl:when test="id='org.bedework.error.unknown.timezone'"> 
     30          Unknown timezone <xsl:value-of select="param"/> 
     31      </xsl:when> 
    2932      <xsl:otherwise> 
    3033        <xsl:value-of select="id"/> = <xsl:value-of select="param"/> 
  • trunk/calendar3/icalendar/src/org/bedework/icalendar/BwEventUtil.java

    r207 r298  
    9999import net.fortuna.ical4j.model.property.Status; 
    100100import net.fortuna.ical4j.model.property.Summary; 
     101import net.fortuna.ical4j.model.property.Transp; 
    101102import net.fortuna.ical4j.model.property.Uid; 
    102103import net.fortuna.ical4j.model.property.Url; 
     
    498499 
    499500          ev.setSummary(pval); 
     501        } else if (prop instanceof Transp) { 
     502          /* ------------------- Transp -------------------- */ 
     503 
     504          ev.setTransparency(pval); 
    500505        } else if (prop instanceof Uid) { 
    501506          /* ------------------- Uid -------------------- */ 
  • trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalTranslator.java

    r295 r298  
    271271   */ 
    272272  public Collection fromIcal(BwCalendar cal, String val) throws CalFacadeException { 
     273    return fromIcal(cal, new StringReader(val)); 
     274    /* 
    273275    try { 
    274276      CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl()); 
     
    287289    } catch (Throwable t) { 
    288290      throw new CalFacadeException(t); 
    289     } 
     291    }*/ 
    290292  } 
    291293 
     
    299301  public Collection fromIcal(BwCalendar cal, Reader rdr) throws CalFacadeException { 
    300302    try { 
    301       //System.setProperty("ical4j.unfolding.relaxed", "true"); 
     303      setSystemProperties(); 
    302304      CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl()); 
    303305 
     
    360362  public static Calendar getCalendar(String val) throws CalFacadeException { 
    361363    try { 
     364      setSystemProperties(); 
    362365      CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl()); 
    363366 
     
    365368       
    366369      return bldr.build(ufrdr); 
     370    } catch (CalFacadeException cfe) { 
     371      throw cfe; 
    367372    } catch (Throwable t) { 
    368373      throw new CalFacadeException(t); 
     
    382387  public Collection toVEvent(String val) throws CalFacadeException { 
    383388    try { 
     389      setSystemProperties(); 
    384390      CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl()); 
    385391 
     
    406412 
    407413      return evs; 
     414    } catch (CalFacadeException cfe) { 
     415      throw cfe; 
    408416    } catch (Throwable t) { 
    409417      throw new CalFacadeException(t); 
     
    538546    added.put(tzid, null); 
    539547  } 
     548   
     549  private static void setSystemProperties() throws CalFacadeException { 
     550    try { 
     551      System.setProperty("ical4j.unfolding.relaxed", "true"); 
     552      System.setProperty("ical4j.parsing.relaxed", "true"); 
     553      System.setProperty("ical4j.compatibility.outlook", "true"); 
     554    } catch (Throwable t) { 
     555      throw new CalFacadeException(t); 
     556    } 
     557  } 
    540558 
    541559  private Logger getLog() { 
  • trunk/calendar3/webclient/war/WEB-INF/struts-config.xml

    r272 r298  
    276276               scope="session" 
    277277               validate="false"> 
     278    <forward name="baddata" path="/showMain.rdo" redirect="true" /> 
    278279    </action> 
    279280 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/UploadAction.java

    r261 r298  
    5757import org.bedework.calfacade.BwCalendar; 
    5858import org.bedework.calfacade.BwEvent; 
     59import org.bedework.calfacade.CalFacadeException; 
    5960import org.bedework.calfacade.svc.EventInfo; 
    6061import org.bedework.calsvci.CalSvcI; 
     
    123124    } 
    124125 
    125     InputStream is = upFile.getInputStream(); 
     126    try { 
     127      // To catch some of the parser errors 
    126128 
    127     IcalTranslator trans = new IcalTranslator(svci.getIcalCallback(), debug); 
    128  
    129     Collection objs = trans.fromIcal(cal, new InputStreamReader(is)); 
    130  
    131     Iterator it = objs.iterator(); 
    132  
    133     while (it.hasNext()) { 
    134       Object o = it.next(); 
    135  
    136       if (o instanceof EventInfo) { 
    137         EventInfo ei = (EventInfo)o; 
    138         BwEvent ev = ei.getEvent(); 
    139  
    140         if (ei.getNewEvent()) { 
    141           svci.addEvent(cal, ev, ei.getOverrides()); 
    142         } else { 
    143           svci.updateEvent(ev); 
     129      InputStream is = upFile.getInputStream(); 
     130       
     131      IcalTranslator trans = new IcalTranslator(svci.getIcalCallback(), debug); 
     132       
     133      Collection objs = trans.fromIcal(cal, new InputStreamReader(is)); 
     134       
     135      Iterator it = objs.iterator(); 
     136       
     137      while (it.hasNext()) { 
     138        Object o = it.next(); 
     139         
     140        if (o instanceof EventInfo) { 
     141          EventInfo ei = (EventInfo)o; 
     142          BwEvent ev = ei.getEvent(); 
     143           
     144          if (ei.getNewEvent()) { 
     145            svci.addEvent(cal, ev, ei.getOverrides()); 
     146          } else { 
     147            svci.updateEvent(ev); 
     148          } 
    144149        } 
    145150      } 
     151    } catch (CalFacadeException cfe) { 
     152      form.getErr().emit(cfe.getMessage(), cfe.getExtra()); 
     153      return "baddata"; 
    146154    } 
    147155 
    148     form.getMsg().emit("org.bedework.client.message.event.added"); 
     156    form.getMsg().emit("org.bedework.message.added.events", 1); 
    149157 
    150158    return "success";