edu.wisc.ssec.mcidasv
Class ResourceManager

java.lang.Object
  extended by ucar.unidata.ui.WindowHolder
      extended by ucar.unidata.idv.IdvManager
          extended by ucar.unidata.idv.IdvResourceManager
              extended by edu.wisc.ssec.mcidasv.ResourceManager
All Implemented Interfaces:
ActionListener, EventListener, HyperlinkListener, IdvConstants

public class ResourceManager
extends IdvResourceManager

Version:
$Id$
Author:
McIDAS-V Team

Nested Class Summary
 
Nested classes/interfaces inherited from class ucar.unidata.idv.IdvResourceManager
IdvResourceManager.IdvResource, IdvResourceManager.XmlIdvResource
 
Field Summary
private static org.slf4j.Logger logger
           
static IdvResourceManager.IdvResource RSC_NEW_USERSERVERS
           
static IdvResourceManager.IdvResource RSC_OLD_USERSERVERS
           
static IdvResourceManager.XmlIdvResource RSC_PARAMETERSETS
          Points to the adde image defaults
static IdvResourceManager.IdvResource RSC_SITESERVERS
           
 
Fields inherited from class ucar.unidata.idv.IdvResourceManager
ATTR_ID, ATTR_LABEL, ATTR_LOADMORE, ATTR_LOCATION, ATTR_NAME, ATTR_REMOVEPREVIOUS, ATTR_RESOURCETYPE, ATTR_VALUE, hasInitializedTranslations, resources, RSC_ACTIONS, RSC_ADDESERVER, RSC_ALIASES, RSC_AUTODISPLAYS, RSC_BACKGROUNDWMS, RSC_BUNDLES, RSC_BUNDLEXML, RSC_CHOOSERS, RSC_COLORPAIRS, RSC_COLORTABLES, RSC_CONTROLS, RSC_DATASOURCE, RSC_DERIVED, RSC_DISPLAYSETTINGS, RSC_GEMPAKGRIDPARAMTABLES, RSC_GLOBEMAPS, RSC_GRIB1LOOKUPTABLES, RSC_GRIB2LOOKUPTABLES, RSC_HELPTIPS, RSC_IMAGEDEFAULTS, RSC_IMAGESETS, RSC_JYTHON, RSC_JYTHONTOCOPY, RSC_LOCATIONS, RSC_MAPS, RSC_MENUBAR, RSC_MESSAGES, RSC_NJCONFIG, RSC_PARAMDEFAULTS, RSC_PARAMGROUPS, RSC_PLUGININDEX, RSC_PLUGINS, RSC_PREFERENCES, RSC_PROJECTIONS, RSC_PROTOTYPES, RSC_PUBLISHERS, RSC_PUBLISHERTYPES, RSC_QUICKLINKS, RSC_SKIN, RSC_STATIONMODELS, RSC_STATIONSYMBOLS, RSC_TOOLBAR, RSC_TRANSECTS, RSC_TRANSLATIONS, RSC_URLMAPS, RSC_USERCHOOSER, RSC_VARIABLERENAMER, RSC_VIEWPOINTS, TAG_PROPERTY, TAG_RESOURCE, TAG_RESOURCEBUNDLE, TAG_RESOURCES, translationTables
 
Fields inherited from class ucar.unidata.ui.WindowHolder
contents, dialog, frame, window
 
Fields inherited from interface ucar.unidata.idv.IdvConstants
ARG_B64BUNDLE, ARG_B64ISL, ARG_BUNDLE, ARG_CATALOG, ARG_CHOOSER, ARG_CLEARDEFAULT, ARG_CODE, ARG_CONNECT, ARG_CURRENTTIME, ARG_DATA, ARG_DEBUG, ARG_DEFAULT, ARG_DISPLAY, ARG_DXML, ARG_FIXEDTIME, ARG_HELP, ARG_IMAGE, ARG_IMAGESERVER, ARG_INSTALLPLUGIN, ARG_ISLFILE, ARG_ISLINTERACTIVE, ARG_LISTRESOURCES, ARG_MAINCLASS, ARG_MOVIE, ARG_MSG_DEBUG, ARG_MSG_RECORD, ARG_NODEFAULT, ARG_NOERRORSINGUI, ARG_NOGUI, ARG_NOONEINSTANCE, ARG_NOPLUGINS, ARG_NOPREF, ARG_ONEINSTANCEPORT, ARG_PLUGIN, ARG_PORT, ARG_PRINTJNLP, ARG_PROPERTIES, ARG_SCRIPT, ARG_SERVER, ARG_SETFILES, ARG_SITEPATH, ARG_TEMPLATE, ARG_TEST, ARG_TESTEVAL, ARG_TRACE, ARG_TRACEONLY, ARG_USERPATH, DEFAULT_DATE_FORMAT, DEFAULT_DOCPATH, DEFAULT_MAX_PERMGENSIZE, DEFAULT_TIMEZONE, FILTER_CPT, FILTER_ISL, FILTER_JNLP, FILTER_XIDV, FILTER_XIDVZIDV, FILTER_XML, FILTER_ZIDV, ID_COMMANDSTORUN, ID_DATASOURCES, ID_DISPLAYCONTROLS, ID_IDV, ID_JYTHON, ID_MESSAGE, ID_MISCHASHTABLE, ID_NCIDV_VERSION, ID_VERSION, ID_VIEWMANAGERS, ID_WINDOWS, INITIAL_PROBE_EARTHLOCATION, NULL_DATA_SELECTION, NULL_STRING, PREF_ARCHIVEDIR, PREF_ARCHIVENAME, PREF_AUTODISPLAYS_ENABLE, PREF_AUTODISPLAYS_SHOWGUI, PREF_AUTOSELECTDATA, PREF_CACHESIZE, PREF_CONTROLSINTABS, PREF_DATAPREFIX, PREF_DATE_FORMAT, PREF_DISTANCEUNIT, PREF_DOCACHE, PREF_EMBEDDATACHOOSERINDASHBOARD, PREF_EMBEDFIELDSELECTORINDASHBOARD, PREF_EMBEDLEGENDINDASHBOARD, PREF_EMBEDQUICKLINKSINDASHBOARD, PREF_EVENT_KEYBOARDMAP, PREF_EVENT_MOUSEMAP, PREF_EVENT_WHEELMAP, PREF_FAST_RENDER, PREF_FIELD_CACHETHRESHOLD, PREF_FILEREADDIR, PREF_FILEWRITEDIR, PREF_GEOMETRY_BY_REF, PREF_HISTORY, PREF_IMAGE_BY_REF, PREF_LARGE_REMOTE_DATA_WARN, PREF_LASTVERSION, PREF_LATLON_FORMAT, PREF_LEGEND_SHOWICONS, PREF_LOCALE, PREF_LOOKANDFEEL, PREF_MAX_PERMGENSIZE, PREF_MAXIMAGESIZE, PREF_MEMORY, PREF_NPOT_IMAGE, PREF_OPEN_ASK, PREF_OPEN_MERGE, PREF_OPEN_REMOVE, PREF_PROJ_LIST, PREF_SAMPLINGMODE, PREF_SHOWCONTROLWINDOW, PREF_SHOWDASHBOARD, PREF_SHOWDECODEDIALOG, PREF_SHOWHIDDENFILES, PREF_SHOWQUITCONFIRM, PREF_SITEPATH, PREF_THREADS_DATA, PREF_THREADS_RENDER, PREF_TIMEZONE, PREF_VERTICALCS, PREF_VERTICALUNIT, PREF_WINDOW_SHOWTOOLBAR, PREF_ZIDV_ASK, PREF_ZIDV_DIRECTORY, PREF_ZIDV_SAVETOTMP, PROP_3DMODE, PROP_ABOUTTEXT, PROP_APPRESOURCEPATH, PROP_CHOOSERS, PROP_CHOOSERS_ALL, PROP_CONTROLDESCRIPTORS, PROP_CONTROLDESCRIPTORS_ALL, PROP_DATAHOLDERBOUNDS, PROP_DEFAULTLOCATIONS, PROP_DISPLAYLIST_GROUP, PROP_FIXFILELOCKUP, PROP_JNLPCODEBASE, PROP_JNLPTEMPLATE, PROP_JNLPTITLE, PROP_LOADINGXML, PROP_MAP_GLOBE_LEVEL, PROP_MAP_MAP_LEVEL, PROP_MINIMUMFRAMECYCLETIME, PROP_MONITORPORT, PROP_OLDCONTROLDESCRIPTORS, PROP_ONEINSTANCEPORT, PROP_PREFERENCES, PROP_PROJ_NAME, PROP_RESOURCEFILES, PROP_SHOWCLOCK, PROP_SHOWDASHBOARD, PROP_SHOWDATATREE, PROP_SHOWFORMULAS, PROP_SHOWSPLASH, PROP_SPLASHICON, PROP_UI_DESKTOP, PROP_USE_TIMEDRIVER, PROP_VERSIONFILE, PROP_WINDOW_SCREENSIZEOFFSET, PROP_WINDOW_SIZEHEIGHT, PROP_WINDOW_SIZEWIDTH, PROP_WINDOW_USESCREENSIZE, SUFFIX_BAT, SUFFIX_CPT, SUFFIX_ISL, SUFFIX_JNLP, SUFFIX_RBI, SUFFIX_SH, SUFFIX_XIDV, SUFFIX_XML, SUFFIX_ZIDV
 
Constructor Summary
ResourceManager(IntegratedDataViewer idv)
           
 
Method Summary
private  void checkMoveOutdatedDefaultBundle()
          Look for existing "default.mcv" and "default.xidv" bundles in root userpath If they exist, move them to the "bundles" directory, preferring "default.mcv"
private static String fixId(Element resource)
          Utility method that calls StateManager.fixIds(String).
private  ResourceCollection getCollection(Element rsrc, String name)
          Returns either a "normal" ResourceCollection or a XmlResourceCollection, based upon rsrc.
private  List<String> getInvalidMapsInResource(String path)
          Checks an individual map resource (typically from RSC_MAPS) to verify that all of the specified maps exist?
private  Map<String,String> getNodeAttributes(Element resourceNode)
          Builds an attribute:value Map based upon the contents of resourceNode.
private  Map<String,String> getNodeProperties(Element resourceNode)
          "Resource" elements within a RBI file are allowed to have an arbitrary number of "property" child elements (or none at all).
private  List<String> getPaths(String origPath, Map<String,String> props)
          Expands origPath (if needed) and builds a List of paths.
 String getResourcePath(String path)
          Adds support for McIDAS-V macros.
protected  void init(List rbiFiles)
          Overridden so that McIDAS-V can attempt to verify "critical" resources without causing crashes.
private  boolean isPathValid(String path)
          Pretty much relies upon IOUtil.getInputStream(String, Class) to determine if path exists.
protected  void processRbi(Element root, boolean observeLoadMore)
          Processes the top-level "root" of a RBI XML file.
protected  void verifyResources()
          Loops through all of the ResourceCollections that the IDV knows about.
 
Methods inherited from class ucar.unidata.idv.IdvResourceManager
addDisplaySetting, clearDefaultBundles, clearResourceMacros, createMapInfo, createResourceCollection, createXmlResourceCollection, displaySettingChanged, findDisplaySetting, findLocations, findLocationsByType, getAppResourcePath, getDataResourcePath, getDefaultStations, getDisplaySettings, getDisplaySettingsTimestamp, getHtmlView, getIdvResourcePath, getLocationList, getMacroMap, getMapResources, getMaps, getResourceList, getResourcePaths, getResources, getResources, getResources, getResourcesForUser, getResourceUrlBase, getSitePath, getTransects, getTranslationsHashtable, getUserHome, getUserPath, getXmlResources, getXmlResources, hyperlinkUpdate, processRbi, removeDisplaySetting, removeDisplaySettings, removeLocalMaps, removeResources, showHtmlView, writeMapState, writeTransects
 
Methods inherited from class ucar.unidata.idv.IdvManager
getArgsManager, getCollabManager, getColorTableManager, getDataManager, getIdv, getIdvChooserManager, getIdvClass, getIdvProjectionManager, getIdvUIManager, getImageGenerator, getInstallManager, getJythonManager, getPersistenceManager, getPreferenceManager, getProperty, getProperty, getProperty, getPublishManager, getResourceManager, getStateManager, getStationModelManager, getStore, getVMManager, logException, showNormalCursor, showWaitCursor, waitUntilDisplaysAreDone, waitUntilDisplaysAreDone
 
Methods inherited from class ucar.unidata.ui.WindowHolder
actionPerformed, close, doMakeContents, getContents, getDialog, getFrame, getWindow, getWindowTitle, isShowing, removeAll, setMenuBar, setWindowTitle, shouldMakeDialog, show, show, showModal, toFront, windowIsClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.slf4j.Logger logger

RSC_PARAMETERSETS

public static final IdvResourceManager.XmlIdvResource RSC_PARAMETERSETS
Points to the adde image defaults


RSC_SITESERVERS

public static final IdvResourceManager.IdvResource RSC_SITESERVERS

RSC_NEW_USERSERVERS

public static final IdvResourceManager.IdvResource RSC_NEW_USERSERVERS

RSC_OLD_USERSERVERS

public static final IdvResourceManager.IdvResource RSC_OLD_USERSERVERS
Constructor Detail

ResourceManager

public ResourceManager(IntegratedDataViewer idv)
Method Detail

init

protected void init(List rbiFiles)
Overridden so that McIDAS-V can attempt to verify "critical" resources without causing crashes.

Currently doesn't do a whole lot.

Overrides:
init in class IdvResourceManager
See Also:
verifyResources()

verifyResources

protected void verifyResources()
Loops through all of the ResourceCollections that the IDV knows about.

I realize that this could balloon into a really tedious thing... there could potentially be verification steps for each type of resource collection! the better approach is probably to identify a few key collections (like the (default?) maps).


isPathValid

private boolean isPathValid(String path)
Pretty much relies upon IOUtil.getInputStream(String, Class) to determine if path exists.

Parameters:
path - Path to an arbitrary file. It can be a remote URL, normal file on disk, or a file included in a JAR. Just so long as it's not null!
Returns:
true iff there were no problems. false otherwise.

getResourcePath

public String getResourcePath(String path)
Adds support for McIDAS-V macros. Specifically:

Overrides:
getResourcePath in class IdvResourceManager
Parameters:
path - Path that contains a macro to be translated.
Returns:
Resource with our macros applied.
See Also:
IdvResourceManager.getResourcePath(String)

checkMoveOutdatedDefaultBundle

private void checkMoveOutdatedDefaultBundle()
Look for existing "default.mcv" and "default.xidv" bundles in root userpath If they exist, move them to the "bundles" directory, preferring "default.mcv"


getInvalidMapsInResource

private List<String> getInvalidMapsInResource(String path)
Checks an individual map resource (typically from RSC_MAPS) to verify that all of the specified maps exist?

Currently a no-op. The intention is to return a List so that the set of missing resources can eventually be sent off in a support request...

We could also decide to allow the user to search the list of plugins or ignore any missing resources (simply remove the bad stuff from the list of available xml).

Parameters:
path - Path to a map resource. URLs are allowed, but null is not.
Returns:
List of map paths that could not be read. If there were no errors the list is merely empty.
See Also:
IdvResourceManager.RSC_MAPS

getCollection

private ResourceCollection getCollection(Element rsrc,
                                         String name)
Returns either a "normal" ResourceCollection or a XmlResourceCollection, based upon rsrc.

Parameters:
rsrc - XML representation of a resource collection. Should not be null.
name - The "name" to associate with the returned ResourceCollection. Should not be null.

getNodeProperties

private Map<String,String> getNodeProperties(Element resourceNode)
"Resource" elements within a RBI file are allowed to have an arbitrary number of "property" child elements (or none at all). The property elements must have "name" and "value" attributes.

This method iterates through any property elements and creates a Map of name:value pairs.

Parameters:
resourceNode - The "resource" element to examine. Should not be null. Resources without propertys are permitted.
Returns:
Either a Map of name:value pairs or an empty Map.

getNodeAttributes

private Map<String,String> getNodeAttributes(Element resourceNode)
Builds an attribute:value Map based upon the contents of resourceNode.

Be aware that "location" and "id" attributes are ignored, as the IDV apparently considers them to be special.

Parameters:
resourceNode - The XML element to examine. Should not be null.
Returns:
Either a Map of attribute:value pairs or an empty Map.

getPaths

private List<String> getPaths(String origPath,
                              Map<String,String> props)
Expands origPath (if needed) and builds a List of paths. Paths beginning with "index:" or "http:" may be in need of expansion.

"Index" files contain a list of paths. These paths should be used instead of origPath.

Files that reside on a webserver (these begin with "http:") may be inaccessible for a variety of reasons. McIDAS-V allows a RBI file to specify a "property" named "default" whose "value" is a path to use as a backup. For example:

 <resources name="idv.resource.pluginindex">
   <resource label="Plugin Index" location="https://www.ssec.wisc.edu/mcidas/software/v/resources/plugins/plugins.xml">
     <property name="default" value="%APPPATH%/plugins.xml"/>
   </resource>
 </resources>
 
The origPath parameter will be the value of the "location" attribute. If origPath is inaccessible, then the path given by the "default" property will be used.

Parameters:
origPath - Typically the value of the "location" attribute associated with a given resource. Cannot be null.
props - Contains the property name:value pairs associated with the resource whose path is being examined. Cannot be null.
Returns:
List of paths associated with a given resource.
See Also:
isPathValid(String)

fixId

private static String fixId(Element resource)
Utility method that calls StateManager.fixIds(String).


processRbi

protected void processRbi(Element root,
                          boolean observeLoadMore)
Processes the top-level "root" of a RBI XML file. Overridden in McIDAS-V so that remote resources can have a backup location.

Overrides:
processRbi in class IdvResourceManager
Parameters:
root - The "root" element. Should not be null.
observeLoadMore - Whether or not processing should continue if a "loadmore" tag is encountered.
See Also:
getPaths(String, Map)