Class EntryStore
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of the various server manager events. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringPath to local server binaries.private final StringPath to local server data.private final String"Root" local server directory.private final StringPath to mcservl.private final StringPath to the user's "RESOLV.SRV".private static final String"Userpath" not writable error message.private static final String"Userpath" not writable error message.private final IdvObjectStoreMcIDAS-V preferences store.LastAddeEntriesadded to the manager.private static StringWhich port is this particular manager operating onprivate static final org.slf4j.LoggerLogging object.private static final StringPreference key for ADDE entries.private static final StringProperty that allows users to control debug output from ADDE requests.private static final StringProperty that allows users to supply arbitrary paths to McIDAS-X binaries used by mcservl.private static AddeThreadThread that monitors the mcservl process.private final org.apache.commons.collections4.trie.PatriciaTrie<AddeEntry> The ADDE servers known to McIDAS-V.private final StringPath to the user's "userpath" directory.private static final StringSLF4J-style formatting string for use whenRESOLV.SRVcan not be found. . -
Constructor Summary
ConstructorsConstructorDescriptionEntryStore(IdvObjectStore store, IdvResourceManager rscManager) Constructs a server manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntries(Collection<? extends AddeEntry> newEntries) voidbooleanCheck to see if the thread is running.Returns theAddeEntriesstored in the user's preferences.extractResourceEntries(AddeEntry.EntrySource source, XmlResourceCollection xmlResources) Process all of the "IDV-style" XML resources for a given "source".extractUserEntries(XmlResourceCollection xmlResources) Process all of the "user" XML resources.private Set<LocalAddeEntry> filterLocalEntriesByTemporaryStatus(boolean getTemporaryEntries) Filters the local entries by whether or not they are set as "temporary".getAccountingFor(String address, String group, AddeEntry.EntryType type) Searches the set of servers in an attempt to locate the accounting information for the matching server.getAccountingFor(AddeServer idvServer, String typeAsStr) Returns the accounting for the givenidvServerandtypeAsStr.protected String[]Returns command line used to launch mcservl.static StringReturns the path to where the root directory of the user's McIDAS-X binaries should be.Returns the completeSetofAddeEntries.Returns theSetof "groups" associated with the givenaddress.getGroupsFor(String address, AddeEntry.EntryType type) Returns theIdvObjectStoreused to save user preferences.Returns a list of all available ADDE datasets, converted to IDVAddeServerobjects.Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType, converted to IDVAddeServerobjects.getIdvStyleEntries(String typeAsStr) Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType, converted to IDVAddeServerobjects.Returns all enabled, validLocalAddeEntriesas a collection of "IDV style"AddeServer.Groupobjects.getIdvStyleRemoteGroups(String server, AddeEntry.EntryType type) Returns the entries matching the givenserverandtypeparameters as a collection ofAddeServer.Groupobjects.getIdvStyleRemoteGroups(String server, String typeAsStr) Returns the entries matching the givenserverandtypeAsStrparameters as a collection ofAddeServer.Groupobjects.Returns theAddeEntriesthat were added last.Searches the newest entries for the entries of the givenAddeEntry.EntryType.Returns theAddeEntriesthat were added last, filtered by the givenEntryTypes.Returns the completeSetofLocalAddeEntries.static StringAsk for the port we are listening on.Returns all non-temporaryAddeEntries.Returns theSetofLocalAddeEntriesthat will be saved between McIDAS-V sessions.Returns the completeSetofRemoteAddeEntries.Returns anyLocalAddeEntriesthat will be removed at the end of the current McIDAS-V session.protected String[]Returns environment variables that allow mcservl to run on "unix-like" systems.Returns the availableAddeEntries, grouped byAddeEntry.EntryType.protected String[]Returns environment variables that allow mcservl to run on Windows.static booleanisAddeDebugEnabled(boolean defValue) Checks the value of thedebug.adde.reqssystem property to determine whether or not the user has requested ADDE URL debugging output.static booleanisInvalidEntry(AddeEntry entry) Determine the validity of a givenAddeEntry.protected static StringGet the next port by incrementing current port.voidonEvent(EntryStore.Event evt) Responds to server manager events being passed with the event bus.private static voidputEntries(org.apache.commons.collections4.trie.PatriciaTrie<AddeEntry> trie, Collection<? extends AddeEntry> newEntries) AddsAddeEntryobjects to a givenPatriciaTrie.removeDeletedSystemEntries(Collection<? extends AddeEntry> entries, Collection<? extends AddeEntry> systemEntries) SearchesentriesforAddeEntryobjects with two characteristics: the object source isAddeEntry.EntrySource.SYSTEMthe object is not insystemEntriesbooleanremoveEntries(Collection<? extends AddeEntry> removedEntries) Removes the givenAddeEntries.booleanremoveEntry(AddeEntry entry) Removes a singleAddeEntryfrom the set of available entries.voidreplaceEntries(Collection<? extends AddeEntry> oldEntries, Collection<? extends AddeEntry> newEntries) voidSaves the current set of ADDE servers to the user's preferences andADDE_RESOLV.voidSaves the list of ADDE entries to both the user's preferences andADDE_RESOLV.searchWithPrefix(String prefix) Search the server manager for entries that matchprefix.static booleansetAddeDebugEnabled(boolean value) Sets the value of thedebug.adde.reqssystem property so that debugging output can be controlled without restarting McIDAS-V.static voidsetLocalPort(String port) Change the port we are listening on.voidStarts the local server thread (if it isn't already running).voidStops the local server thread if it is running.booleanTest to see if the thread can access userpath
-
Field Details
-
PROP_DEBUG_LOCALROOT
Property that allows users to supply arbitrary paths to McIDAS-X binaries used by mcservl.- See Also:
-
PROP_DEBUG_ADDEURL
Property that allows users to control debug output from ADDE requests.- See Also:
-
ERROR_LOGUTIL_USERPATH
"Userpath" not writable error message. This is the one that is shown in the GUI viaLogUtil.userErrorMessage(String).- See Also:
-
ERROR_USERPATH
"Userpath" not writable error message. This one is used by the logging system.- See Also:
-
WARN_NO_RESOLVSRV
SLF4J-style formatting string for use whenRESOLV.SRVcan not be found. .- See Also:
-
logger
Logging object. -
PREF_ADDE_ENTRIES
Preference key for ADDE entries.- See Also:
-
trie
The ADDE servers known to McIDAS-V. -
ADDE_DIRECTORY
"Root" local server directory. -
ADDE_BIN
Path to local server binaries. -
ADDE_DATA
Path to local server data. -
ADDE_MCSERVL
Path to mcservl. -
USER_DIRECTORY
Path to the user's "userpath" directory. -
ADDE_RESOLV
Path to the user's "RESOLV.SRV". -
localPort
Which port is this particular manager operating on -
thread
Thread that monitors the mcservl process. -
lastAdded
LastAddeEntriesadded to the manager. -
idvStore
McIDAS-V preferences store.
-
-
Constructor Details
-
EntryStore
Constructs a server manager.- Parameters:
store- McIDAS-V's preferences store. Cannot benull.rscManager- McIDAS-V's resource manager. Cannot benull.- Throws:
NullPointerException- if either ofstoreorrscManagerisnull.
-
-
Method Details
-
removeDeletedSystemEntries
private static Set<AddeEntry> removeDeletedSystemEntries(Collection<? extends AddeEntry> entries, Collection<? extends AddeEntry> systemEntries) SearchesentriesforAddeEntryobjects with two characteristics:- the object source is
AddeEntry.EntrySource.SYSTEM - the object is not in
systemEntries
The intent behind this method is to safely remove "system" entries that have been stored to a user's preferences.
entriescan be generated from anywhere you like, butsystemEntriesshould almost always be created from "addeservers.xml".- Parameters:
entries- Cannot benull.systemEntries- Cannot benull.- Returns:
Setof entries that are not system resources that have been removed, or an emptySet.
- the object source is
-
putEntries
private static void putEntries(org.apache.commons.collections4.trie.PatriciaTrie<AddeEntry> trie, Collection<? extends AddeEntry> newEntries) AddsAddeEntryobjects to a givenPatriciaTrie.- Parameters:
trie- Cannot benull.newEntries- Cannot benull.
-
getIdvStore
Returns theIdvObjectStoreused to save user preferences.- Returns:
IdvObjectStoreused by the rest of McIDAS-V.
-
getWindowsAddeEnv
Returns environment variables that allow mcservl to run on Windows.- Returns:
Stringarray containing mcservl's environment variables.
-
getUnixAddeEnv
Returns environment variables that allow mcservl to run on "unix-like" systems.- Returns:
Stringarray containing mcservl's environment variables.
-
getAddeCommands
Returns command line used to launch mcservl.- Returns:
Stringarray that represents an invocation of mcservl.
-
isInvalidEntry
Determine the validity of a givenAddeEntry.- Parameters:
entry- Entry to check. Cannot benull.- Returns:
trueifentryis invalid orfalseotherwise.- Throws:
NullPointerException- ifentryisnull.AssertionError- ifentryis somehow neither aRemoteAddeEntryorLocalAddeEntry.- See Also:
-
extractPreferencesEntries
Returns theAddeEntriesstored in the user's preferences.- Parameters:
store- Object store that represents the user's preferences. Cannot benull.- Returns:
- Either the
AddeEntrysstored in the prefs or an emptySet.
-
onEvent
Responds to server manager events being passed with the event bus.- Parameters:
evt- Event to which this method is responding. Cannot benull.- Throws:
NullPointerException- ifevtisnull.
-
saveEntries
Saves the current set of ADDE servers to the user's preferences andADDE_RESOLV. -
saveForShutdown
Saves the list of ADDE entries to both the user's preferences andADDE_RESOLV. -
getLastAddedByType
Searches the newest entries for the entries of the givenAddeEntry.EntryType.- Parameters:
type- Look for entries matching thisEntryType. Cannot benull.- Returns:
- Either a
Listof entries or an emptyList. - Throws:
NullPointerException- iftypeisnull.
-
getLastAddedByTypes
Returns theAddeEntriesthat were added last, filtered by the givenEntryTypes.- Parameters:
types- Filter the last added entries by these entry type. Cannot benull.- Returns:
Listof the last added entries, filtered bytypes.- Throws:
NullPointerException- iftypesisnull.
-
getLastAdded
Returns theAddeEntriesthat were added last. Note that this value is not preserved between sessions.- Returns:
Listof the last ADDE entries that were added. May be empty.
-
getVerifiedEntries
- Parameters:
type- TheEntryTypeyou are interested in. Cannot benull.- Returns:
- A
Setof matching remote ADDE entries. If there were no matches, an emptySetis returned. - Throws:
NullPointerException- iftypeisnull.
-
getVerifiedEntriesByTypes
Returns the availableAddeEntries, grouped byAddeEntry.EntryType. -
getGroupsFor
- Parameters:
address- ADDE server address whose groups are needed. Cannot benull.type- Only include groups that matchAddeEntry.EntryType. Cannot benull.- Returns:
- Either a set containing the desired groups, or an empty set if there were no matches.
- Throws:
NullPointerException- if eitheraddressortypeisnull.
-
searchWithPrefix
Search the server manager for entries that matchprefix.- Parameters:
prefix-Stringto match. Cannot benull.- Returns:
Listcontaining matching entries. If there were no matches theListwill be empty.- Throws:
NullPointerException- ifprefixisnull.- See Also:
-
getAddresses
- Returns:
Setcontaining all of the stored addresses. If no addresses are stored, an emptySetis returned.
-
getRemoteEntryTexts
- Returns:
- The "entry text" representations of each
RemoteAddeEntry. - See Also:
-
getGroups
Returns theSetof "groups" associated with the givenaddress.- Parameters:
address- Address of a server.- Returns:
- Either all of the "groups" on
addressor an emptySet.
-
getTypes
- Parameters:
address- Address of a server.group- Group whose "types" you want.- Returns:
- Either of all the types for a given
addressandgroupor an emptySetif there were no matches.
-
getAccountingFor
Searches the set of servers in an attempt to locate the accounting information for the matching server. Note that because the data structure is aSet, there cannot be duplicate entries, so there is no need to worry about our criteria finding multiple matches.Also note that none of the given parameters accept
nullvalues.- Parameters:
address- Address of the server.group- Dataset.type- Group type.- Returns:
- Either the
AddeAccountfor the given criteria, orAddeEntry.DEFAULT_ACCOUNTif there was no match. - See Also:
-
getAccountingFor
Returns the accounting for the givenidvServerandtypeAsStr.- Parameters:
idvServer- Server to search for.typeAsStr- One of "IMAGE", "POINT", "GRID", "TEXT", "NAV", "RADAR", "UNKNOWN", or "INVALID".- Returns:
AddeAccountassociated withidvServerandtypeAsStr.
-
getEntrySet
Returns the completeSetofAddeEntries.- Returns:
- All of the managed ADDE entries.
-
getPersistedEntrySet
Returns all non-temporaryAddeEntries.- Returns:
Setof ADDE entries that stick around between McIDAS-V sessions.
-
getRemoteEntries
Returns the completeSetofRemoteAddeEntries.- Returns:
Setof remote ADDE entries stored within the available entries.
-
getLocalEntries
Returns the completeSetofLocalAddeEntries.- Returns:
Setof local ADDE entries stored within the available entries.
-
getPersistedLocalEntries
Returns theSetofLocalAddeEntriesthat will be saved between McIDAS-V sessions.Note: all this does is check
LocalAddeEntry.isEntryTemporary().- Returns:
- Local ADDE entries that will be saved for the next session.
-
getTemporaryLocalEntries
Returns anyLocalAddeEntriesthat will be removed at the end of the current McIDAS-V session.- Returns:
Setof all the temporary local ADDE entries.
-
filterLocalEntriesByTemporaryStatus
Filters the local entries by whether or not they are set as "temporary".- Parameters:
getTemporaryEntries-truereturns temporary local entries;falsereturns local entries that are permanent.- Returns:
Setof filtered local ADDE entries.
-
removeEntries
Removes the givenAddeEntries.- Parameters:
removedEntries-AddeEntryobjects to remove. Cannot benull.- Returns:
- Whether or not
removeEntrieswere removed. - Throws:
NullPointerException- ifremovedEntriesisnull.
-
removeEntry
Removes a singleAddeEntryfrom the set of available entries.- Parameters:
entry- Entry to remove. Cannot benull.- Returns:
trueif something was removed,falseotherwise.- Throws:
NullPointerException- ifentryisnull.
-
addEntry
- Parameters:
entry- Entry to add. Cannot benull.- Throws:
NullPointerException- ifentryisnull.
-
addEntries
- Parameters:
newEntries- New entries to add to the server manager. Cannot benull.- Throws:
NullPointerException- ifnewEntriesisnull.
-
replaceEntries
public void replaceEntries(Collection<? extends AddeEntry> oldEntries, Collection<? extends AddeEntry> newEntries) - Parameters:
oldEntries- Entries to be replaced. Cannot benull.newEntries- Entries to use as replacements. Cannot benull.- Throws:
NullPointerException- if either ofoldEntriesornewEntriesisnull.
-
getIdvStyleLocalGroups
Returns all enabled, validLocalAddeEntriesas a collection of "IDV style"AddeServer.Groupobjects.- Returns:
SetofAddeServer.Groupobjects that corresponds with the enabled, valid local ADDE entries.
-
getIdvStyleRemoteGroups
Returns the entries matching the givenserverandtypeAsStrparameters as a collection ofAddeServer.Groupobjects.- Parameters:
server- Remote ADDE server. Should not benull.typeAsStr- Entry type. One of "IMAGE", "POINT", "GRID", "TEXT", "NAV", "RADAR", "UNKNOWN", or "INVALID". Should not benull.- Returns:
SetofAddeServer.Groupobjects that corresponds to the entries associated withserverandtypeAsStr.
-
getIdvStyleRemoteGroups
Returns the entries matching the givenserverandtypeparameters as a collection ofAddeServer.Groupobjects.- Parameters:
server- Remote ADDE server. Should not benull.type- Entry type. Should not benull.- Returns:
SetofAddeServer.Groupobjects that corresponds to the entries associated withserverandtype.
-
getIdvStyleEntries
Returns a list of all available ADDE datasets, converted to IDVAddeServerobjects.- Returns:
- List of
AddeServerobjects for each ADDE entry.
-
getIdvStyleEntries
Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType, converted to IDVAddeServerobjects.- Parameters:
type- Only add entries with this type to the returned list. Cannot benull.- Returns:
AddeServerobjects for each ADDE entry of the given type.
-
getIdvStyleEntries
Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType, converted to IDVAddeServerobjects.- Parameters:
typeAsStr- Only add entries with this type to the returned list. Cannot benulland must be a value that works withEntryTransforms.strToEntryType(String).- Returns:
AddeServerobjects for each ADDE entry of the given type.- See Also:
-
extractResourceEntries
private Set<AddeEntry> extractResourceEntries(AddeEntry.EntrySource source, XmlResourceCollection xmlResources) Process all of the "IDV-style" XML resources for a given "source".- Parameters:
source- Origin of the XML resources.xmlResources- Actual XML resources.- Returns:
Setof theAddeEntrysextracted fromxmlResources.
-
extractUserEntries
Process all of the "user" XML resources.- Parameters:
xmlResources- Resource collection. Cannot benull.- Returns:
SetofRemoteAddeEntriescontained withinresource.
-
getAddeRootDirectory
Returns the path to where the root directory of the user's McIDAS-X binaries should be. The path may be invalid.The default path is determined like so:
System.getProperty("user.dir") + File.separatorChar + "adde"Users can provide an arbitrary path at runtime by setting the
debug.localadde.rootdirsystem property.- Returns:
Stringcontaining the path to the McIDAS-X root directory.- See Also:
-
isAddeDebugEnabled
Checks the value of thedebug.adde.reqssystem property to determine whether or not the user has requested ADDE URL debugging output. Output is sent toSystem.out.Please keep in mind that the
debug.adde.reqscan not force debugging for all ADDE requests. To do so will require updates to the VisAD ADDE library.- Parameters:
defValue- Value to return ifdebug.adde.reqshas not been set.- Returns:
- If it exists, the value of
debug.adde.reqs. Otherwisedebug.adde.reqs. - See Also:
-
setAddeDebugEnabled
Sets the value of thedebug.adde.reqssystem property so that debugging output can be controlled without restarting McIDAS-V.Please keep in mind that the
debug.adde.reqscan not force debugging for all ADDE requests. To do so will require updates to the VisAD ADDE library.- Parameters:
value- New value ofdebug.adde.reqs.- Returns:
- Previous value of
debug.adde.reqs. - See Also:
-
setLocalPort
Change the port we are listening on.- Parameters:
port- New port number.
-
getLocalPort
Ask for the port we are listening on.- Returns:
- String representation of the listening port.
-
nextLocalPort
Get the next port by incrementing current port.- Returns:
- The next port that will be tried.
-
startLocalServer
Starts the local server thread (if it isn't already running). -
stopLocalServer
Stops the local server thread if it is running. -
testLocalServer
Test to see if the thread can access userpath- Returns:
trueif the local server can access userpath,falseotherwise.
-
checkLocalServer
Check to see if the thread is running.- Returns:
trueif the local server thread is running;falseotherwise.
-