Class EntryTransforms
java.lang.Object
edu.wisc.ssec.mcidasv.servermanager.EntryTransforms
Useful methods for doing things like converting a
AddeServer to a
RemoteAddeEntry.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Function<AddeServer, RemoteAddeEntry> private static final Stringprivate static final intprivate static final MatcherNo sense in rebuilding things that don't need to be rebuilt.private static final PatternMatches "host" declarations in a MCTABLE file.private static final org.slf4j.LoggerLogger object.private static final MatcherNo sense in rebuilding things that don't need to be rebuilt.private static final PatternMatches dataset routing information in a MCTABLE file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic voidappendResolvFile(String filename, Collection<LocalAddeEntry> entries) Writes aCollectionofLocalAddeEntriesto a "RESOLV.SRV" file.asResolvEntries(Collection<LocalAddeEntry> entries) static StringasResolvEntry(LocalAddeEntry entry) Converts a givenLocalAddeEntryinto aStringthat is suitable for including in a "RESOLV.SRV" file.convertAddeServerXml(Element root, AddeEntry.EntrySource source) static Set<RemoteAddeEntry> convertIdvServers(List<AddeServer> idvServers) Converts givenidvServersto aRemoteAddeEntries.static Set<AddeServer> convertMcvServers(Collection<AddeEntry> entries) Converts givenAddeEntriestoAddeServers.protected static Set<RemoteAddeEntry> convertUserXml(Element root) static Set<RemoteAddeEntry> createEntriesFrom(RemoteAddeEntry entry) static StringdemungeFileMask(String path) De-munges file mask strings.static StringConverts a givenAddeEntry.EntryTypeto itsStringrepresentation.protected static Set<RemoteAddeEntry> extractMctableEntries(String path, String username, String project) static Set<AddeEntry.EntryType> findEntryTypes(Collection<? extends AddeEntry> entries) private static List<RemoteAddeEntry> mapDatasetsToName(Map<String, String> datasetToHost, Map<String, String> hostToIp, String username, String project) This method is slightly confusing, sorry!mapIpToName(Map<String, Set<String>> map) static StringmungeFileMask(String mask) Munges a file maskStringinto something "RESOLV.SRV" expects.static Set<LocalAddeEntry> readResolvFile(String filename) Reads a "RESOLV.SRV" file and converts the contents into aSetofLocalAddeEntries.static LocalAddeEntryreadResolvLine(String line) Converts aStringcontaining a "RESOLV.SRV" entry into aLocalAddeEntry.static Set<LocalAddeEntry> removeTemporaryEntriesFromResolvFile(String filename, Collection<LocalAddeEntry> entries) static StringserverNameToStr(LocalAddeEntry.ServerName serverName) Converts a givenLocalAddeEntry.ServerNameto itsStringrepresentation.static LocalAddeEntry.AddeFormatAttempts to convert aStringinto a member ofLocalAddeEntry.AddeFormat.static AddeEntry.EntrySourceAttempts to convert aStringto anAddeEntry.EntrySource.static AddeEntry.EntryStatusAttempts to convert aStringinto anAddeEntry.EntryStatus.static AddeEntry.EntryTypeAttempts to convert aStringto aAddeEntry.EntryType.static AddeEntry.EntryValidityAttempts to convert aStringto anAddeEntry.EntryValidity.static LocalAddeEntry.ServerNameAttempts to convert aStringto aLocalAddeEntry.ServerName.private static voidwriteResolvFile(String filename, boolean append, Collection<LocalAddeEntry> entries) Writes aCollectionofLocalAddeEntriesto a "RESOLV.SRV" file.static voidwriteResolvFile(String filename, Collection<LocalAddeEntry> entries) Writes aCollectionofLocalAddeEntriesto a "RESOLV.SRV" file.
-
Field Details
-
logger
Logger object. -
routePattern
Matches dataset routing information in a MCTABLE file. -
hostPattern
Matches "host" declarations in a MCTABLE file. -
routeMatcher
No sense in rebuilding things that don't need to be rebuilt. -
hostMatcher
No sense in rebuilding things that don't need to be rebuilt. -
cygwinPrefix
- See Also:
-
cygwinPrefixLength
-
convertIdvServer
-
-
Constructor Details
-
EntryTransforms
private EntryTransforms()This is a utility class. Don't create it!
-
-
Method Details
-
findEntryTypes
-
convertIdvServers
Converts givenidvServersto aRemoteAddeEntries.- Parameters:
idvServers- "IDV-style" ADDE servers to convert.- Returns:
Setof remote ADDE entries that corresponds to the unique objects inidvServers.
-
convertMcvServers
Converts givenAddeEntriestoAddeServers.- Parameters:
entries- "McIDAS-V style" ADDE entries to convert.- Returns:
SetofAddeServerobjects that corresponds to the ones found inentries.
-
convertUserXml
- Parameters:
root- "Root" of the XML to convert.- Returns:
Setof remote ADDE entries described byroot.
-
createEntriesFrom
-
convertAddeServerXml
- Parameters:
root- XML to convert.source- Used to "bulk set" the origin of whatever remote ADDE entries get created.- Returns:
Setof remote ADDE entries contained withinroot.
-
serverNameToStr
Converts a givenLocalAddeEntry.ServerNameto itsStringrepresentation. Note that the resultingStringis lowercase.- Parameters:
serverName- The server name to convert. Cannot benull.- Returns:
serverNameconverted to a lowercaseString.- Throws:
NullPointerException- ifserverNameisnull.
-
strToServerName
Attempts to convert aStringto aLocalAddeEntry.ServerName.- Parameters:
s- Value whoseServerNameis wanted. Cannot benull.- Returns:
- One of
ServerName. If there was no "sensible" conversion, the method returnsLocalAddeEntry.ServerName.INVALID. - Throws:
NullPointerException- ifsisnull.
-
entryTypeToStr
Converts a givenAddeEntry.EntryTypeto itsStringrepresentation. Note that the resultingStringis lowercase.- Parameters:
type- The type to convert. Cannot benull.- Returns:
typeconverted to a lowercaseString.- Throws:
NullPointerException- iftypeisnull.
-
strToEntryType
Attempts to convert aStringto aAddeEntry.EntryType.- Parameters:
s- Value whoseEntryTypeis wanted. Cannot benull.- Returns:
- One of
EntryType. If there was no "sensible" conversion, the method returnsAddeEntry.EntryType.UNKNOWN. - Throws:
NullPointerException- ifsisnull.
-
strToEntrySource
Attempts to convert aStringto anAddeEntry.EntrySource.- Parameters:
s-Stringrepresentation of anEntrySource. Cannot benull.- Returns:
- Uses
AddeEntry.EntrySource.valueOf(String)to convertsto anEntrySourceand returns. If no conversion was possible, returnsAddeEntry.EntrySource.USER. - Throws:
NullPointerException- ifsisnull.
-
strToEntryValidity
Attempts to convert aStringto anAddeEntry.EntryValidity.- Parameters:
s-Stringrepresentation of anEntryValidity. Cannot benull.- Returns:
- Uses
AddeEntry.EntryValidity.valueOf(String)to convertsto anEntryValidityand returns. If no conversion was possible, returnsAddeEntry.EntryValidity.UNVERIFIED. - Throws:
NullPointerException- ifsisnull.
-
strToEntryStatus
Attempts to convert aStringinto anAddeEntry.EntryStatus.- Parameters:
s-Stringrepresentation of anEntryStatus. Cannot benull.- Returns:
- Uses
AddeEntry.EntryStatus.valueOf(String)to convertsinto anEntryStatusand returns. If no conversion was possible, returnsAddeEntry.EntryStatus.DISABLED. - Throws:
NullPointerException- ifsisnull.
-
strToAddeFormat
Attempts to convert aStringinto a member ofLocalAddeEntry.AddeFormat. This method does a little bit of magic with the incomingString:- spaces are replaced with underscores
- dashes ("-") are removed
- Parameters:
s-Stringrepresentation of anAddeFormat. Cannot benull.- Returns:
- Uses
LocalAddeEntry.AddeFormat.valueOf(String)to convert the modifiedStringinto anAddeFormatand returns. If no conversion was possible, returnsLocalAddeEntry.AddeFormat.INVALID. - Throws:
NullPointerException- ifsisnull.
-
addeFormatToStr
-
extractMctableEntries
protected static Set<RemoteAddeEntry> extractMctableEntries(String path, String username, String project) -
mapDatasetsToName
private static List<RemoteAddeEntry> mapDatasetsToName(Map<String, String> datasetToHost, Map<String, String> hostToIp, String username, String project) This method is slightly confusing, sorry! Think of it kind of like a "SQL JOIN"...Basically create
RemoteAddeEntriesby using a hostname to determine which dataset belongs to which IP.- Parameters:
datasetToHost-Mapof ADDE groups to host names.hostToIp-Mapof host names to IP addresses.username- ADDE username.project- ADDE project number (as aString).- Returns:
ListofRemoteAddeEntryinstances. Each hostname will have a value fromdatasetToHostand the accounting information is formed fromusernameandproject.
-
mapIpToName
-
mapDatasetsToIp
-
readResolvFile
Reads a "RESOLV.SRV" file and converts the contents into aSetofLocalAddeEntries.- Parameters:
filename- Filename containing desired local ADDE entries. Cannot benull.- Returns:
Setof local ADDE entries contained withinfilename.- Throws:
IOException- if there was a problem reading fromfilename.- See Also:
-
readResolvLine
Converts aStringcontaining a "RESOLV.SRV" entry into aLocalAddeEntry.- Parameters:
line- Line fromRESOLV.SRV.- Returns:
LocalAddeEntrythat represents the givenlinefromRESOLV.SRV.
-
writeResolvFile
public static void writeResolvFile(String filename, Collection<LocalAddeEntry> entries) throws IOException Writes aCollectionofLocalAddeEntriesto a "RESOLV.SRV" file. This method discards the current contents offilename!- Parameters:
filename- Filename that will contain the local ADDE entries withinentries. Cannot benull.entries-Setof entries to be written tofilename. Cannot benull.- Throws:
IOException- if there was a problem writing tofilename.- See Also:
-
appendResolvFile
public static void appendResolvFile(String filename, Collection<LocalAddeEntry> entries) throws IOException Writes aCollectionofLocalAddeEntriesto a "RESOLV.SRV" file. This method will append the contents ofentriestofilename.- Parameters:
filename- Filename that will contain the local ADDE entries withinentries. Cannot benull.entries-Collectionof entries to be written tofilename. Cannot benull.- Throws:
IOException- if there was a problem writing tofilename.- See Also:
-
writeResolvFile
private static void writeResolvFile(String filename, boolean append, Collection<LocalAddeEntry> entries) throws IOException Writes aCollectionofLocalAddeEntriesto a "RESOLV.SRV" file.- Parameters:
filename- Filename that will contain the local ADDE entries withinentries. Cannot benull.append- Iftrue, appendentriestofilename. Otherwise discards contents offilename.entries-Collectionof entries to be written tofilename. Cannot benull.- Throws:
IOException- if there was a problem writing tofilename.- See Also:
-
removeTemporaryEntriesFromResolvFile
public static Set<LocalAddeEntry> removeTemporaryEntriesFromResolvFile(String filename, Collection<LocalAddeEntry> entries) throws IOException - Throws:
IOException
-
demungeFileMask
De-munges file mask strings.This process is largely used to generate "Windows-friendly" masks.
- Parameters:
path- File path to fix.- Returns:
pathwith Windows fixes applied.- Throws:
NullPointerException- ifpathisnull.
-
mungeFileMask
Munges a file maskStringinto something "RESOLV.SRV" expects.Munging is only needed for Windows users--the process converts back slashes into forward slashes and prefixes with "/cygdrive/".
- Parameters:
mask- File mask that may need to be fixed before storing inRESOLV.SRV.- Returns:
- Path suitable for storing in
RESOLV.SRV. - Throws:
NullPointerException- ifmaskisnull.
-
asResolvEntries
- Parameters:
entries-Collectionof entries to convert. Should not benull.- Returns:
entriesrepresented as strings.- See Also:
-
asResolvEntry
Converts a givenLocalAddeEntryinto aStringthat is suitable for including in a "RESOLV.SRV" file. This method does not append a newline to the end of theString.- Parameters:
entry- TheLocalAddeEntryto convert. Should not benull.- Returns:
entryas a "RESOLV.SRV" entry.
-