Class TzServerUtil

java.lang.Object
org.bedework.timezones.common.TzServerUtil

public class TzServerUtil extends Object
Common code for the timezone service.
Author:
Mike Douglass
  • Field Details

    • errorNodata

      public static final String errorNodata
      Unable to retrieve the data
      See Also:
    • lastDataFetch

      public static long lastDataFetch
      Time we last fetched the data
  • Method Details

    • getInstance

      public static TzServerUtil getInstance()
      Returns:
      a singleton instance
    • getAppname

      public static String getAppname()
      Returns:
      appname
    • setTzConfigHolder

      public static void setTzConfigHolder(org.bedework.util.jmx.ConfigHolder<TzConfigImpl> val)
      Parameters:
      val - config holder
    • getTzConfig

      public static TzConfig getTzConfig()
      Returns:
      current state of the configuration
    • saveConfig

      public static void saveConfig()
    • printableTime

      public static String printableTime(long millis)
      Parameters:
      millis - long
      Returns:
      String minutes:seconds
    • fireRefresh

      public static void fireRefresh(boolean clear) throws TzException
      Cause a refresh of the data
      Throws:
      TzException - on fatal error
    • setProdid

      public static void setProdid(String val)
      Parameters:
      val - prodid for generated calendar data
    • fireCheck

      public static void fireCheck() throws TzException
      Cause data to be checked against primary
      Throws:
      TzException - on fatal error
    • updateData

      public static List<String> updateData(String tzdataUrl) throws TzException
      Compare data pointed to by tzdataUrl with the given data then update.
      Parameters:
      tzdataUrl - - references source
      Returns:
      info lines.
      Throws:
      TzException - on fatal error
    • compareData

      public static List<String> compareData(String tzdataUrl) throws TzException
      Compare data pointed to by tzdataUrl with the given data.
      Parameters:
      tzdataUrl - - reference to data
      Returns:
      info lines.
      Throws:
      TzException - on fatal error
    • getDataSource

      public static CachedData getDataSource(TzConfig config) throws TzException
      Throws:
      TzException
    • getStats

      public static List<Stat> getStats() throws TzException
      Returns:
      stats for the service
      Throws:
      TzException - on fatal error
    • stop

      public void stop() throws TzException
      Stop any running threads.
      Throws:
      TzException - on fatal error
    • getDtstamp

      public String getDtstamp() throws TzException
      Returns:
      the data dtstamp
      Throws:
      TzException - on fatal error
    • getNames

      public SortedSet<String> getNames() throws TzException
      Returns:
      names from the zip file.
      Throws:
      TzException - on fatal error
    • getTz

      public String getTz(String name) throws TzException
      Parameters:
      name - of tz
      Returns:
      spec
      Throws:
      TzException - on fatal error
    • getAllTzs

      public Collection<String> getAllTzs() throws TzException
      Returns:
      all specs
      Throws:
      TzException - on fatal error
    • getAliasedTz

      public String getAliasedTz(String name) throws TzException
      Parameters:
      name - alias
      Returns:
      spec
      Throws:
      TzException - on fatal error
    • getAliasesStr

      public String getAliasesStr() throws TzException
      Returns:
      String value of aliases file.
      Throws:
      TzException - on fatal error
    • findAliases

      public SortedSet<String> findAliases(String tzid) throws TzException
      Parameters:
      tzid - timezone id
      Returns:
      list of aliases or null
      Throws:
      TzException - on fatal error
    • getUtc

      public String getUtc(String time, String tzid) throws Throwable
      Parameters:
      time - to convert to UTC
      tzid - timezone id
      Returns:
      String utc date
      Throws:
      Throwable - on date error
    • convertDateTime

      public String convertDateTime(String dateTime, String fromTzid, String toTzid) throws Throwable
      Convert from local time in fromTzid to local time in toTzid. If dateTime is already an iso utc date time fromTzid may be null.
      Parameters:
      dateTime - local time
      fromTzid - tz converting from
      toTzid - tz converting to
      Returns:
      String time in given timezone
      Throws:
      Throwable - on date error
    • getTimezones

      public List<org.bedework.util.timezones.model.TimezoneType> getTimezones(String[] tzids) throws TzException
      Parameters:
      tzids - - to fetch
      Returns:
      list of summary info
      Throws:
      TzException - on fatal error
    • getTimezones

      public List<org.bedework.util.timezones.model.TimezoneType> getTimezones(String changedSince) throws TzException
      Parameters:
      changedSince - - null or dtstamp value
      Returns:
      list of summary info
      Throws:
      TzException - on fatal error
    • findTimezones

      public List<org.bedework.util.timezones.model.TimezoneType> findTimezones(String name) throws TzException
      Parameters:
      name - - non null name for partial match
      Returns:
      list of summary info
      Throws:
      TzException - on fatal error
    • getExpanded

      public ExpandedMapEntry getExpanded(String tzid, String start, String end, boolean oldForm) throws Throwable
      Parameters:
      tzid - for expansion
      start - of range
      end - of range
      Returns:
      expansion or null
      Throws:
      TzException - on fatal error
      Throwable
    • fetchTimeZone

      public net.fortuna.ical4j.model.TimeZone fetchTimeZone(String tzid) throws TzException
      Get a timezone object from the server given the id.
      Parameters:
      tzid - to fetch
      Returns:
      TimeZone with id or null
      Throws:
      TzException - on fatal error
    • getCalHdr

      public static String getCalHdr()
      Returns:
      an ical Calendar prefix
    • getCalTlr

      public static String getCalTlr()
      Returns:
      an ical Calendar trailer
    • getEtag

      public String getEtag() throws TzException
      Returns:
      an etag based on when we refreshed data
      Throws:
      TzException - on fatal error