info.aduna.gee.publication.net
Class InputHandler

java.lang.Object
  extended by info.aduna.gee.publication.net.InputHandler
All Implemented Interfaces:
LocalNames, FileNames, IOListener

public class InputHandler
extends Object
implements IOListener, LocalNames, FileNames

Central point for loading the files.
These are the files that are of particular importance to content extractors (i.e. Session).
In addition sharing of downloaded files is supported. Note: InputHandler's MUST be closed in order to enable GC.


Field Summary
protected  Vector _listeners
          The interested audience.
 Cache cache
          The cache
 WURL location
          The location this input handler operates on
static long maxZPadTimesAge
          The maximum delay of ZPadTimes for the current server.
 Random random
          My random generator, used by associated outputHandlers too.
static WProperties redirections
          the session wide known lists of redirections.
static Hashtable theZPadTimes
          The shared times of all files of all locations
static Vector zpadsVisited
          the list of all ZPad's ever visited.
 
Fields inherited from interface info.aduna.gee.publication.net.IOListener
CACHE_UPDATE, LOGIN_ADDED, PASSWORD_ERROR, QUEUE_UPDATE, SHOW_OBJECT, STORE_DONE, STORE_STARTED
 
Fields inherited from interface info.aduna.gee.publication.LocalNames
AM, APRIL, AUGUST, BUTTON_ADD, BUTTON_ASSOCIATES_MAY_NOT_EDIT, BUTTON_BACKUP, BUTTON_BOTTOM, BUTTON_CLEAR, BUTTON_CLEAR_CART, BUTTON_DELETE, BUTTON_DESCRIPTION, BUTTON_DOWN, BUTTON_EDIT, BUTTON_EDIT_CLABELS, BUTTON_EDIT_SUBSCRIPTION, BUTTON_EDIT_SUBSCRIPTIONS, BUTTON_ENTRY_FROM_CLIPBOARD, BUTTON_ENTRY_TO_CLIPBOARD, BUTTON_EXIT_EDIT_MODE, BUTTON_FAST_BACKWARD, BUTTON_FAST_FORWARD, BUTTON_FIND_FUTURE, BUTTON_FIND_PAST, BUTTON_INTERNALIZE_ENTRY, BUTTON_LINK, BUTTON_LINK_IN_FRAME, BUTTON_LOCK_ZPAD, BUTTON_MORE_TEXT, BUTTON_NEXTCONTENT, BUTTON_PERSONALIZE, BUTTON_PL0, BUTTON_PL1, BUTTON_PL2, BUTTON_PL3, BUTTON_PL4, BUTTON_PREVIOUSCONTENT, BUTTON_PROVIDE_ENTRY, BUTTON_RE_EXPORT, BUTTON_RE_MANUAL, BUTTON_REPEAT, BUTTON_REPEAT_TODAY, BUTTON_RESTORE, BUTTON_SEND_ORDER, BUTTON_SUGGESTED_DESTINATION, BUTTON_SUMMARY, BUTTON_SYNCHRONIZE, BUTTON_TIME, BUTTON_TODAY, BUTTON_TOMORROW, BUTTON_TOOLS, BUTTON_TOP, BUTTON_UNDO, BUTTON_UP, BUTTON_UPLOAD_IMAGE, BUTTON_YESTERDAY, CONFIRM_BACKUP_ERROR, CONFIRM_CHANGE_ALL_REPEATING, CONFIRM_CLABEL_DEFINITION_FORMAT, CONFIRM_COULD_NOT_SAVE, CONFIRM_DELETE_ALL_REPEATING, CONFIRM_DELETE_EXPIRED, CONFIRM_ERROR, CONFIRM_FILE_CHANGED, CONFIRM_FILE_CHANGED_TITLE, CONFIRM_FILE_REALLY_CHANGED, CONFIRM_FIND_CONTENT, CONFIRM_FIRST_SECTION, CONFIRM_HAS_THEMES_FRAME, CONFIRM_MIXED_TODAY, CONFIRM_NO_MORE_CONTENT, CONFIRM_NOT_A_ZPAD, CONFIRM_NOT_REMOVE_SECTION, CONFIRM_QUESTION, CONFIRM_READONLY_BROWSER, CONFIRM_SURE, CONFIRM_THIS_ZPAD, CONFIRM_TODAY_IS_AT_STARTUP, CONFIRM_TODAY_IS_AT_TRANSFER, CONFIRM_UNDO, DECEMBER, ENTRY_TYPE_APPLET, ENTRY_TYPE_HTML, ENTRY_TYPE_IMAGE, ENTRY_TYPE_OBJECT, ENTRY_TYPE_TEXT, ENTRY_TYPE_TMPLD, ERROR_CONFIG_LOAD, ERROR_DATABASE_LOAD, ERROR_IMAGE_LOAD, ERROR_RESOLVE_LOCATION, ERROR_ZPAD_LOAD, EXC_INVALID_PORT_NUMBER, EXC_NO_GZIP_SUPPORT, EXC_NO_HOSTNAME_SPECIFIED, EXC_UNKNOWN_COMPR, EXC_UNKNOWN_ENCODING, EXC_VELOCITY_NOT_SHOWN, FEBRUARY, FRIDAY, FROM, GETTING_BUTTONS, GETTING_CONTENT, HTML_EDIT_ENTRY, HTML_ENTRY_EXPIRED, HTML_ENTRY_NOT_YET_INSPIRED, HTML_ENTRY_WILL_EXPIRE, HTML_MOVE_ENTRY, HTML_ZPAD_GET_ENTRY, INVALID_USER_LOCATION, JANUARY, JULY, JUNE, LABEL_ACCEPT_BATCH, LABEL_ADD_TO_CART, LABEL_ALL_CLABELS, LABEL_ALLSUB_SECTIONS, LABEL_APPLET_CODE, LABEL_APPLET_CODEBASE, LABEL_AT_STARTUP, LABEL_AT_STARTUP_BRIEF, LABEL_BACKGROUND, LABEL_BATCH_IS_MULTIPLE, LABEL_BATCH_NEW_SECTION, LABEL_BLUE, LABEL_BOTTOMUP_SUBSCRIPTION, LABEL_CART_EMPTY, LABEL_CASE_SENSITIVE, LABEL_CHOOSE_SECTION, LABEL_CHOOSE_TMPL, LABEL_CLABEL_IMAGE, LABEL_CLABEL_OVER_IMAGE, LABEL_CLABEL_RULE, LABEL_CLABELS, LABEL_CLABELS_SELECTED, LABEL_COUNT, LABEL_COVER_SECTIONS, LABEL_COVER_SPECIFIC_BUTTONS, LABEL_COVER_SPECIFIC_ENTRY_BUTTONS, LABEL_COVER_USES_HIERMENU, LABEL_COVER_USES_HIERMENU_ALL_OPTION, LABEL_COVER_USES_INPAGE, LABEL_COVER_USES_JOUST, LABEL_CURRENT_SECTIONS, LABEL_DAILY, LABEL_DATE, LABEL_DAYOFWEEK, LABEL_DESCR, LABEL_DESCRIPTION, LABEL_DESTINATION, LABEL_DONT_INHERIT, LABEL_EDIT_BATCH, LABEL_EMBED_SOURCE, LABEL_ENTRY_HTML, LABEL_ENTRY_IS_TMPL, LABEL_FOREGROUND, LABEL_GREEN, LABEL_HEIGHT, LABEL_HTML_STYLE, LABEL_ID, LABEL_IMAGE_LOCATION, LABEL_IMPORT_CLASSNAME, LABEL_IMPORT_SERVERNAME, LABEL_INHERIT_CLABELS, LABEL_INHERIT_PRIVACY_GROUPS, LABEL_INLINE_DESCRIPTION, LABEL_INPAGE_ALT_TEMPLATE_ID, LABEL_INPAGE_ALT_TEMPLATE_SOURCE, LABEL_INPAGE_SUB_TEMPLATE_ID, LABEL_INPAGE_SUB_TEMPLATE_SOURCE, LABEL_INPAGE_SUBSUB_TEMPLATE_ID, LABEL_INPAGE_SUBSUB_TEMPLATE_SOURCE, LABEL_INPAGE_TEMPLATE_ID, LABEL_INPAGE_TEMPLATE_SOURCE, LABEL_LOADED_FRAMES, LABEL_LOADED_TEMPLATES, LABEL_MONTH, LABEL_MONTHLY, LABEL_MOUNTPOINT, LABEL_MULTISUB_SECTIONS, LABEL_NEVER_EXPIRES, LABEL_NEVER_INSPIRES, LABEL_NEW_CLABEL, LABEL_NEW_FRAME, LABEL_NEW_PL_MEMBER, LABEL_NEW_SECTION, LABEL_NEW_SUBSCRIPTION, LABEL_NEW_TEMPLATE, LABEL_NEW_ZPAD_NAME, LABEL_NO_COLOR, LABEL_NO_ENTRY_SPECIFIC_PROPERTIES, LABEL_NO_FRAME, LABEL_NO_TEMPLATE_PREFERENCE, LABEL_NOT_AT_THIS_PL, LABEL_NOT_IN_CLIENTMODE, LABEL_OBJECT_LOCATION, LABEL_OCCURRING_SUBSCRIPTION, LABEL_OPTIONS, LABEL_ORDER_PRICE, LABEL_OWN_CONTENTS_ONLY, LABEL_OWN_SECTIONS, LABEL_OWNER_VERSION, LABEL_PASSWORD, LABEL_PASSWORD_ERROR, LABEL_PL_MEMBERS, LABEL_PLUS_ASSOCIATES, LABEL_PRICE, LABEL_PRICE_PER_ITEM, LABEL_PRO_VERSION, LABEL_RECURSIVE_SUBSCRIPTION, LABEL_RED, LABEL_REPEAT_1, LABEL_REPEAT_2, LABEL_REPEAT_3, LABEL_REQUIRED, LABEL_RGB, LABEL_SELECT_ZPAD, LABEL_SELECTED_ZPAD, LABEL_SHARED_SUBSCRIPTION, LABEL_SHOWING_RESULT, LABEL_STARTPOINT, LABEL_SUBSCRIPTIONS, LABEL_SYSTEM_SUBSCRIPTIONS, LABEL_THIS_IS_HTML, LABEL_THIS_ZPAD, LABEL_TMPL_DESCRIPTOR, LABEL_TMPL_ID, LABEL_TMPL_LOOP, LABEL_TMPL_NOT_AVAILABLE, LABEL_TMPL_STUBCHARS, LABEL_TODAY, LABEL_TOPDOWN_SUBSCRIPTION, LABEL_TOTAL_PRICE, LABEL_TRANSLATION_URL, LABEL_UNCLASSIFIED, LABEL_UP_TO_USER, LABEL_USE_RANGE, LABEL_USER_NAME, LABEL_VOLUME_DISCOUNT, LABEL_WEEKLY, LABEL_WIDTH, LABEL_YEAR, LABEL_YEARLY, MARCH, MAY, MONDAY, MORE, NO_CONTENT_IN_PAGE, NOVEMBER, OCTOBER, PM, PRESSED_DATE_POPUP, PRESSED_EDIT_POPUP, PRESSED_FIND_POPUP, PRESSED_META_POPUP, PRESSED_PERSONALIZE_POPUP, PRESSED_PRIVL_POPUP, PRESSED_SECTION_POPUP, PRESSED_TOOLS_POPUP, QUESTION_ENTRY_TO_CLIPBOARD, QUESTION_OVERWRITE_BACKUP, QUESTION_REPLACE_WITH_BACKUP, QUESTION_SELECT_ADVANCED_VERSION, REMOVE, SATURDAY, SAVING_CONTENT, SEARCH_FOR_MANUAL, SEARCH_FOR_PRIVACY_LEVEL, SEARCH_FOR_PROVIDE_PL, SEARCH_FOR_RE_EXPORT, SEARCH_FOR_RE_MANUAL, SEARCH_FOR_SUBSCRIPTION, SEARCH_FOR_TIME, SEARCH_FOR_TYPE, SEPTEMBER, SHOULD_SYNC, SUNDAY, TEMPLATE_NOT_AVAILABLE, THURSDAY, TITLE_ADD_ALIAS, TITLE_ADD_APPLET, TITLE_ADD_EMBED, TITLE_ADD_HTML, TITLE_ADD_IMAGE, TITLE_ADD_IMPORT, TITLE_ADD_OBJECT, TITLE_ADD_TEXT, TITLE_ADD_TMPLD, TITLE_ADVANCED_ZPAD, TITLE_CHANGE_COVER, TITLE_CLABEL_DEFINITIONS, TITLE_CLABEL_SELECTION, TITLE_COPY_TO, TITLE_COVER_OPTIONS, TITLE_COVER_SECTIONS, TITLE_DATE_OFFSET, TITLE_DATE_SECTIONS, TITLE_DATE_SPEC, TITLE_DESTINATION, TITLE_EDIT_CATEGORIES, TITLE_EDIT_PRIVACY_GROUPS, TITLE_EDIT_SHEET, TITLE_ENTRY_ATTRIBS, TITLE_ENTRY_EXPIRATION, TITLE_ENTRY_INSPIRATION, TITLE_ENTRY_PARAMS, TITLE_ENTRY_PROPS, TITLE_EXPIRED_HANDLING, TITLE_EXTERNAL_SECTIONS, TITLE_FIND_ENTRY, TITLE_FIRST_SECTION, TITLE_IDENTIFY_YOURSELF, TITLE_INSTANT_COVER, TITLE_LAST_SECTION, TITLE_LOGIN_DIALOG, TITLE_MANIPULATE_SECTION, TITLE_MOVE_ENTRY, TITLE_MOVE_TO, TITLE_NAVIGATOR, TITLE_PERSONALIZE_SHEET, TITLE_PL_GROUPS, TITLE_REMOVE_ALIAS, TITLE_REMOVE_FILE, TITLE_REMOVE_IMAGE, TITLE_SELECT_DATE, TITLE_SELECT_PL, TITLE_SELECT_SECTION, TITLE_SELECT_TMPL, TITLE_SET_CLABEL_IMAGES, TITLE_SET_COLOR, TITLE_SET_COLORS, TITLE_SET_FRAME, TITLE_SET_HTML, TITLE_SET_PL, TITLE_START_SECTION, TITLE_STATISTICS, TITLE_SUBSCRIPTIONS, TITLE_TEMPLATE_PREFERENCE, TITLE_TOOLS_SHEET, TITLE_TRANSFER, TITLE_UPLOAD_FILE, TITLE_USER_SECTIONS, TO, TUESDAY, WEDNESDAY, ZPAD
 
Fields inherited from interface info.aduna.gee.publication.net.FileNames
ASA_FILE_NAME, BAK_FILE_NAME, CAT_FILE_NAME, CFG_FILE_NAME, CHS_FILE_NAME, DAT_FILE_NAME, HLP_FILE_NAME, LOCAL_FILE_PREFIX, SBS_FILE_NAME, SSS_FILE_NAME, WIF_FILE_NAME
 
Constructor Summary
InputHandler(WURL location)
          Creates a new InputHandler.
 
Method Summary
protected  void _load(WStorable object, String filename, boolean checkCaches, boolean reload)
           
protected  void _loadZpadTimes(long maxDelay)
          Load the file time information.
 void addListener(IOListener listener)
          Add a listener to the audience.
 void close()
          Remove this InputHandler completely.
 boolean fileExists(String fileName)
          This a generic function to check the existence of a file, without actually loading its full contents.
 boolean fileExists(String filename, long maxDelay, boolean allowDefaultHandling, boolean ifUnknown)
          Knowledge based on the ZpadTimes.html, therefore this file can be used ONLY for user's files.
 CLabelDefinitions getCLabelDefinitions()
          Get the CLabelDefinitions from the Cache.
 Config getConfig()
          Get the Config file from the cache.
 URLConnection getConnection(String filename)
          Get a connection to a file.
 Database getDatabase(String filename)
          Get a content database from the cache.
 InputStream getInputStream(String filename)
          Get an inputstream on a file.
 long getModificationTime(String filename, long maxDelay)
          Get the modification time of a file or 0 if not known.
 SubscriptionDefinitions getSubscriptionDefinitions(String filename)
          Get the SubscriptionDefinitions from the Cache.
 void ioStateChanged(WURL cacheLocation, int info, String filename, Object arg)
          Implements listener interface IOListener.
 CLabelDefinitions loadCLabelDefinitions()
          Loads the CLabelDefinitions.
 Config loadConfig()
          Loads the configuration.
 Database loadDatabase(String filename)
          Loads a content database from file filename
 String loadFile(String fileName, boolean doCache)
          A generic function to load a text file.
static InputStream loadFrom(InputStream input, WStorable object)
           
 Generator loadGenerator(InputHandler shareInput)
          Loads the wif file.
 ZContainer loadImport(Entry entry)
          Load the Entries represented by the IMPORT entry.
 Local loadLocal(String language)
          Load the localized string database.
 SubscriptionDefinitions loadSubscriptionDefinitions(String filename)
          Loads the SubscriptionDefinitions.
 void onException(WURL location, Exception e, String filename)
          Called when the store requested encountered an io exception.
 void reload(String fileName)
          Reloads an already loaded storable object.
 void removeListener(IOListener listener)
          Remove a listener from the audience.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxZPadTimesAge

public static long maxZPadTimesAge
The maximum delay of ZPadTimes for the current server.


theZPadTimes

public static Hashtable theZPadTimes
The shared times of all files of all locations


redirections

public static WProperties redirections
the session wide known lists of redirections.


zpadsVisited

public static Vector zpadsVisited
the list of all ZPad's ever visited.


location

public WURL location
The location this input handler operates on


cache

public Cache cache
The cache


_listeners

protected Vector _listeners
The interested audience.


random

public Random random
My random generator, used by associated outputHandlers too.

Constructor Detail

InputHandler

public InputHandler(WURL location)
Creates a new InputHandler.

Parameters:
location - The ZPad location to transfer from.
Method Detail

getInputStream

public InputStream getInputStream(String filename)
                           throws IOException
Get an inputstream on a file.

Parameters:
filename - the name of the file to open the input stream on.
Throws:
IOException

getConnection

public URLConnection getConnection(String filename)
                            throws IOException
Get a connection to a file.

Parameters:
filename - the file's name
Throws:
IOException

reload

public void reload(String fileName)
            throws IOException
Reloads an already loaded storable object. Method is called from the navigator to reload file that were stored from another location on for example group accounts.

Parameters:
fileName - the name of the file to reload.
Throws:
IOException

_load

protected void _load(WStorable object,
                     String filename,
                     boolean checkCaches,
                     boolean reload)
              throws IOException
Parameters:
checkCaches - whether or not to check the ZPad, Browser and Proxy caches. Note: we only forceLoad once and don't check again (and again).
reload - do a forced reload
Throws:
IOException

loadConfig

public Config loadConfig()
                  throws IOException
Loads the configuration.

Returns:
The loaded configuration of this user or null if not found.
Throws:
IOException - when an I/O error occurrs while reading the configuration.

getCLabelDefinitions

public CLabelDefinitions getCLabelDefinitions()
Get the CLabelDefinitions from the Cache.


loadCLabelDefinitions

public CLabelDefinitions loadCLabelDefinitions()
                                        throws IOException
Loads the CLabelDefinitions.

Throws:
IOException

getSubscriptionDefinitions

public SubscriptionDefinitions getSubscriptionDefinitions(String filename)
Get the SubscriptionDefinitions from the Cache.


loadSubscriptionDefinitions

public SubscriptionDefinitions loadSubscriptionDefinitions(String filename)
Loads the SubscriptionDefinitions.


loadLocal

public Local loadLocal(String language)
                throws IOException
Load the localized string database.

Returns:
The load localized data, null on errors.
Throws:
IOException - when an I/O error occurrs while loading.

getConfig

public Config getConfig()
Get the Config file from the cache. This function may be used only after the Config has been loaded.

Returns:
the loaded configuration, null if not found.

loadGenerator

public Generator loadGenerator(InputHandler shareInput)
                        throws IOException
Loads the wif file.

Returns:
The loaded wif of this cover or null if not found.
Throws:
IOException - when an I/O error occurrs.

loadDatabase

public Database loadDatabase(String filename)
                      throws IOException
Loads a content database from file filename

Parameters:
filename - the name of the file to load.
Returns:
the loaded content database or null if not found.
Throws:
IOException - when an I/O error occurrs while reading the database.
See Also:
#storeDatabase

getDatabase

public Database getDatabase(String filename)
Get a content database from the cache.

Parameters:
filename - the name of the file to get
Returns:
the content database or null if not cached

addListener

public void addListener(IOListener listener)
Add a listener to the audience.

Parameters:
listener - a new io listener.

removeListener

public void removeListener(IOListener listener)
Remove a listener from the audience.

Parameters:
listener - the listener to remove.

close

public void close()
Remove this InputHandler completely. The only operation allowed is another close() ... which won't have effect.


ioStateChanged

public void ioStateChanged(WURL cacheLocation,
                           int info,
                           String filename,
                           Object arg)
Implements listener interface IOListener.

Specified by:
ioStateChanged in interface IOListener
Parameters:
info - the info being given.
filename - the name of the file the info is about.
arg - an optional argument
cacheLocation - the location

onException

public void onException(WURL location,
                        Exception e,
                        String filename)
Description copied from interface: IOListener
Called when the store requested encountered an io exception.

Specified by:
onException in interface IOListener
Parameters:
location - the location
e - the encountered exception.
filename - the name of the file the info is about.

_loadZpadTimes

protected void _loadZpadTimes(long maxDelay)
Load the file time information.


getModificationTime

public long getModificationTime(String filename,
                                long maxDelay)
Get the modification time of a file or 0 if not known.

Parameters:
filename - the name of the file for which to get the Modification Time
maxDelay - the max age in seconds (!) of the Modification Time. If older, get new ones first.

fileExists

public boolean fileExists(String filename,
                          long maxDelay,
                          boolean allowDefaultHandling,
                          boolean ifUnknown)
Knowledge based on the ZpadTimes.html, therefore this file can be used ONLY for user's files.

Parameters:
allowDefaultHandling - if true, interpret handling by the Zpad's server default behaviour as existing if false, the file should physically exist
ifUnknown - the result in case the existence of the file is unknown (based on ZPadTimes.html).

loadFile

public String loadFile(String fileName,
                       boolean doCache)
A generic function to load a text file.

Parameters:
fileName - the name (relative URL with respect to the current InputHandler's location) of the text file to load
doCache - if true cache the result, if false don't
Returns:
a null result indicates troubles loading the file.

loadImport

public ZContainer loadImport(Entry entry)
Load the Entries represented by the IMPORT entry. NOTE: this method was designed for the Zpad "client" code, so it ignores IMPORT_SERVER_NAME.


fileExists

public boolean fileExists(String fileName)
This a generic function to check the existence of a file, without actually loading its full contents. The results of this function are always cached. Warning: DO NOT USE THIS METHOD FOR ZPAD FILES! Only for external files (like "/share/edit.gif" or "/cover/.../edit.gif")


loadFrom

public static InputStream loadFrom(InputStream input,
                                   WStorable object)
                            throws IOException
Throws:
IOException


Copyright © 1997-2008 Aduna. All Rights Reserved.