Changeset 96

Show
Ignore:
Timestamp:
02/06/06 17:11:41
Author:
douglm
Message:

Missing class - broke select view in user client

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java

    r48 r96  
    5656 
    5757import org.bedework.calfacade.BwUser; 
    58 //import org.bedework.calfacade.BwTimeZone; 
    5958import org.bedework.calfacade.BwTimeZone; 
    6059import org.bedework.calfacade.CalFacadeBadDateException; 
     
    6261import org.bedework.calfacade.CalFacadeUtil; 
    6362import org.bedework.calfacade.ifs.CalTimezones; 
    64 //import org.bedework.icalendar.IcalTranslator; 
    65  
    66 //import net.fortuna.ical4j.model.Calendar; 
    67 //import net.fortuna.ical4j.model.Component; 
     63 
    6864import net.fortuna.ical4j.model.component.VTimeZone; 
    69 import net.fortuna.ical4j.model.parameter.TzId; 
    70 import net.fortuna.ical4j.model.property.DtEnd; 
    7165import net.fortuna.ical4j.model.TimeZone; 
    72  
    73 //import java.util.Collection; 
     66import net.fortuna.ical4j.util.TimeZones; 
     67 
     68import java.text.DateFormat; 
     69import java.text.SimpleDateFormat; 
     70import java.util.Calendar; 
    7471import java.util.HashMap; 
    75 //import java.util.Iterator; 
    7672 
    7773import org.apache.log4j.Logger; 
     
    275271  } 
    276272 
    277   public String getUtc(String time, String tzid, TimeZone tz) throws CalFacadeException { 
     273  private static DateFormat formatTd  = new SimpleDateFormat("yyyyMMdd'T'HHmmss"); 
     274  private static Calendar cal = Calendar.getInstance(); 
     275  private static java.util.TimeZone utctz; 
     276  private static java.util.TimeZone lasttz; 
     277  private static String lasttzid; 
     278  static { 
     279    try { 
     280      utctz = TimeZone.getTimeZone(TimeZones.UTC_ID); 
     281    } catch (Throwable t) { 
     282      throw new RuntimeException("Unable to initialise UTC timezone"); 
     283    } 
     284  } 
     285 
     286  public synchronized String getUtc(String time, String tzid, TimeZone tz) throws CalFacadeException { 
     287    /* XXX We probably need the ownerid to determine exactly which timezone 
     288     */ 
    278289    //if (debug) { 
    279290    //  trace("Get utc for " + time + " tzid=" + tzid + " tz =" + tz); 
     
    286297    if (CalFacadeUtil.isISODateTime(time)) { 
    287298      try { 
    288         DtEnd dte = new DtEnd(); 
    289  
    290         if ((tz == null) && (tzid != null)) { 
    291           tz = getTimeZone(tzid); 
    292  
    293           //if (debug) { 
    294           //  trace("--------Got timezone " + tz); 
    295           //} 
    296  
    297           if (tz == null) { 
    298             throw new CalFacadeBadDateException(); 
     299        boolean tzchanged = false; 
     300 
     301        if (tz == null) { 
     302          if (tzid == null) { 
     303            if ((lasttzid != null) || (lasttz == null)) { 
     304              lasttz = TimeZone.getDefault(); 
     305              tzchanged = true; 
     306            } 
     307          } else { 
     308            if ((lasttzid == null) || (!lasttzid.equals(tzid))) { 
     309              lasttz = getTimeZone(tzid); 
     310              if (lasttz == null) { 
     311                lasttzid = null; 
     312                throw new CalFacadeBadDateException(); 
     313              } 
     314              tzchanged = true; 
     315            } 
    299316          } 
    300  
    301           dte.getParameters().add(new TzId(tzid)); 
    302           dte.setTimeZone(tz); 
     317        } else { 
     318          // tz supplied 
     319          if (tz != lasttz) { 
     320            /* Yes, that's a !=. I'm looking for it being the same object. 
     321             * If I were sure that equals were correct and fast I'd use 
     322             * that. 
     323             */ 
     324            tzchanged = true; 
     325            tzid = tz.getID(); 
     326            lasttz = tz; 
     327          } 
    303328        } 
    304329 
    305         dte.setValue(time); 
    306         dte.setUtc(true); 
    307  
    308         return dte.getValue(); 
     330 
     331        if (tzchanged) { 
     332          if (debug) { 
     333            trace("**********tzchanged"); 
     334          } 
     335          formatTd.setTimeZone(lasttz); 
     336          lasttzid = tzid; 
     337        } 
     338 
     339        cal.setTimeZone(utctz); 
     340        cal.setTime(formatTd.parse(time)); 
     341 
     342        StringBuffer sb = new StringBuffer(); 
     343        digit4(sb, cal.get(Calendar.YEAR)); 
     344        digit2(sb, cal.get(Calendar.MONTH) + 1); // Month starts at 0 
     345        digit2(sb, cal.get(Calendar.DAY_OF_MONTH)); 
     346        sb.append('T'); 
     347        digit2(sb, cal.get(Calendar.HOUR_OF_DAY)); 
     348        digit2(sb, cal.get(Calendar.MINUTE)); 
     349        digit2(sb, cal.get(Calendar.SECOND)); 
     350        sb.append('Z'); 
     351        return sb.toString(); 
    309352      } catch (Throwable t) { 
    310353        t.printStackTrace(); 
     
    323366   *                   Private methods 
    324367   * ==================================================================== */ 
     368 
     369  private void digit2(StringBuffer sb, int val) throws CalFacadeException { 
     370    if (val > 99) { 
     371      throw new CalFacadeBadDateException(); 
     372    } 
     373    if (val < 10) { 
     374      sb.append("0"); 
     375    } 
     376    sb.append(val); 
     377  } 
     378 
     379  private void digit4(StringBuffer sb, int val) throws CalFacadeException { 
     380    if (val > 9999) { 
     381      throw new CalFacadeBadDateException(); 
     382    } 
     383    if (val < 10) { 
     384      sb.append("000"); 
     385    } else if (val < 100) { 
     386      sb.append("00"); 
     387    } else if (val < 1000) { 
     388      sb.append("0"); 
     389    } 
     390    sb.append(val); 
     391  } 
    325392 
    326393  private TimezoneInfo lookup(String id) throws CalFacadeException { 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwSvciFilter.java

    r2 r96  
    6868import org.apache.log4j.Logger; 
    6969 
    70 /** This class must be installed as a filter for a UWCal web application. 
     70/** This class must be installed as a filter for a Bedework web application. 
    7171 * 
    7272 * <p>We assume that any CalSvci object must remain open until after the jsp