public class EntryTransforms extends Object
AddeServer to a
RemoteAddeEntry.| Modifier and Type | Field and Description |
|---|---|
static Function<AddeServer,RemoteAddeEntry> |
convertIdvServer
|
private static String |
cygwinPrefix |
private static int |
cygwinPrefixLength |
private static Matcher |
hostMatcher
No sense in rebuilding things that don't need to be rebuilt.
|
private static Pattern |
hostPattern
Matches "host" declarations in a MCTABLE file.
|
private static org.slf4j.Logger |
logger
Logger object.
|
private static Matcher |
routeMatcher
No sense in rebuilding things that don't need to be rebuilt.
|
private static Pattern |
routePattern
Matches dataset routing information in a MCTABLE file.
|
| Modifier | Constructor and Description |
|---|---|
private |
EntryTransforms()
This is a utility class.
|
private static final org.slf4j.Logger logger
private static final Pattern routePattern
private static final Pattern hostPattern
private static final Matcher routeMatcher
private static final Matcher hostMatcher
private static final String cygwinPrefix
private static final int cygwinPrefixLength
public static final Function<AddeServer,RemoteAddeEntry> convertIdvServer
private EntryTransforms()
public static Set<AddeEntry.EntryType> findEntryTypes(Collection<? extends AddeEntry> entries)
public static Set<RemoteAddeEntry> convertIdvServers(List<AddeServer> idvServers)
idvServers to a
RemoteAddeEntries.idvServers - "IDV-style" ADDE servers to convert.Set of remote ADDE entries that corresponds to the unique
objects in idvServers.public static Set<AddeServer> convertMcvServers(Collection<AddeEntry> entries)
AddeEntries to
AddeServers.entries - "McIDAS-V style" ADDE entries to convert.Set of AddeServer objects that corresponds to
the ones found in entries.protected static Set<RemoteAddeEntry> convertUserXml(Element root)
root - "Root" of the XML to convert.Set of remote ADDE entries described by
root.public static Set<RemoteAddeEntry> createEntriesFrom(RemoteAddeEntry entry)
protected static Set<AddeEntry> convertAddeServerXml(Element root, AddeEntry.EntrySource source)
root - XML to convert.source - Used to "bulk set" the origin of whatever
remote ADDE entries get created.Set of remote ADDE entries contained within root.public static String serverNameToStr(LocalAddeEntry.ServerName serverName)
LocalAddeEntry.ServerName to its String representation.
Note that the resulting String is lowercase.serverName - The server name to convert. Cannot be null.serverName converted to a lowercase String representation.NullPointerException - if serverName is null.public static LocalAddeEntry.ServerName strToServerName(String s)
String to a LocalAddeEntry.ServerName.s - Value whose ServerName is wanted. Cannot be null.ServerName. If there was no "sensible"
conversion, the method returns LocalAddeEntry.ServerName.INVALID.NullPointerException - if s is null.public static String entryTypeToStr(AddeEntry.EntryType type)
AddeEntry.EntryType to its String representation.
Note that the resulting String is lowercase.type - The type to convert. Cannot be null.type converted to a lowercase String representation.NullPointerException - if type is null.public static AddeEntry.EntryType strToEntryType(String s)
String to a AddeEntry.EntryType.s - Value whose EntryType is wanted. Cannot be null.EntryType. If there was no "sensible"
conversion, the method returns AddeEntry.EntryType.UNKNOWN.NullPointerException - if s is null.public static AddeEntry.EntrySource strToEntrySource(String s)
String to an AddeEntry.EntrySource.s - String representation of an EntrySource.
Cannot be null.AddeEntry.EntrySource.valueOf(String) to convert s
to an EntrySource and returns. If no conversion was possible,
returns AddeEntry.EntrySource.USER.NullPointerException - if s is null.public static AddeEntry.EntryValidity strToEntryValidity(String s)
String to an AddeEntry.EntryValidity.s - String representation of an EntryValidity.
Cannot be null.AddeEntry.EntryValidity.valueOf(String) to convert
s to an EntryValidity and returns. If no conversion
was possible, returns AddeEntry.EntryValidity.UNVERIFIED.NullPointerException - if s is null.public static AddeEntry.EntryStatus strToEntryStatus(String s)
String into an AddeEntry.EntryStatus.s - String representation of an EntryStatus.
Cannot be null.AddeEntry.EntryStatus.valueOf(String) to convert s
into an EntryStatus and returns. If no conversion was possible,
returns AddeEntry.EntryStatus.DISABLED.NullPointerException - if s is null.public static LocalAddeEntry.AddeFormat strToAddeFormat(String s)
String into a member of LocalAddeEntry.AddeFormat.
This method does a little bit of magic with the incoming String:
s - String representation of an AddeFormat. Cannot
be null.LocalAddeEntry.AddeFormat.valueOf(String) to convert the modified
String into an AddeFormat and returns. If no conversion
was possible, returns LocalAddeEntry.AddeFormat.INVALID.NullPointerException - if s is null.public static String addeFormatToStr(LocalAddeEntry.AddeFormat format)
protected static Set<RemoteAddeEntry> extractMctableEntries(String path, String username, String project)
private static List<RemoteAddeEntry> mapDatasetsToName(Map<String,String> datasetToHost, Map<String,String> hostToIp, String username, String project)
Basically create RemoteAddeEntries by using
a hostname to determine which dataset belongs to which IP.
datasetToHost - Map of ADDE groups to host names.hostToIp - Map of host names to IP addresses.username - ADDE username.project - ADDE project number (as a String).List of RemoteAddeEntry instances. Each hostname
will have a value from datasetToHost and the accounting information
is formed from username and project.private static Map<String,String> mapDatasetsToIp(Map<String,String> datasets, Map<String,String> hostMap)
public static Set<LocalAddeEntry> readResolvFile(String filename) throws IOException
Set of LocalAddeEntries.filename - Filename containing desired local ADDE entries.
Cannot be null.Set of local ADDE entries contained within
filename.IOException - if there was a problem reading from filename.readResolvLine(String)public static LocalAddeEntry readResolvLine(String line)
String containing a "RESOLV.SRV" entry into
a LocalAddeEntry.public static void writeResolvFile(String filename, Collection<LocalAddeEntry> entries) throws IOException
Collection of LocalAddeEntries
to a "RESOLV.SRV" file. This method discards the current
contents of filename!filename - Filename that will contain the local ADDE entries
within entries. Cannot be null.entries - Set of entries to be written to filename.
Cannot be null.IOException - if there was a problem writing to filename.appendResolvFile(String, Collection)public static void appendResolvFile(String filename, Collection<LocalAddeEntry> entries) throws IOException
Collection of LocalAddeEntries
to a "RESOLV.SRV" file. This method will append the
contents of entries to filename.filename - Filename that will contain the local ADDE entries within
entries. Cannot be null.entries - Collection of entries to be written to filename.
Cannot be null.IOException - if there was a problem writing to filename.writeResolvFile(String, Collection)private static void writeResolvFile(String filename, boolean append, Collection<LocalAddeEntry> entries) throws IOException
Collection of LocalAddeEntries
to a "RESOLV.SRV" file.filename - Filename that will contain the local ADDE entries within
entries. Cannot be null.append - If true, append entries to
filename. Otherwise discards contents of filename.entries - Collection of entries to be written to
filename. Cannot be null.IOException - if there was a problem writing to filename.appendResolvFile(String, Collection),
asResolvEntry(LocalAddeEntry)public static Set<LocalAddeEntry> removeTemporaryEntriesFromResolvFile(String filename, Collection<LocalAddeEntry> entries) throws IOException
IOExceptionpublic static String demungeFileMask(String path)
NullPointerException - if path is null.public static String mungeFileMask(String mask)
String into something "RESOLV.SRV"
expects.
Munging is only needed for Windows users--the process converts back slashes into forward slashes and prefixes with "/cygdrive/".
NullPointerException - if mask is null.public static List<String> asResolvEntries(Collection<LocalAddeEntry> entries)
entries - Collection of entries to convert. Should not be
null.entries represented as strings.asResolvEntry(LocalAddeEntry)public static String asResolvEntry(LocalAddeEntry entry)
LocalAddeEntry into a String that is
suitable for including in a "RESOLV.SRV" file. This method
does not append a newline to the end of the String.entry - The LocalAddeEntry to convert. Should not be
null.entry as a "RESOLV.SRV" entry.