|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.wisc.ssec.mcidasv.servermanager.EntryTransforms
public class EntryTransforms
Useful methods for doing things like converting a
AddeServer
to a
RemoteAddeEntry
.
Field Summary | |
---|---|
static Function<AddeServer,RemoteAddeEntry> |
convertIdvServer
Function that transforms an AddeServer into a RemoteAddeEntry . |
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. |
Constructor Summary | |
---|---|
private |
EntryTransforms()
This is a utility class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Function
that transforms an AddeServer
into a RemoteAddeEntry
.
Constructor Detail |
---|
private EntryTransforms()
Method Detail |
---|
public static Set<AddeEntry.EntryType> findEntryTypes(Collection<? extends AddeEntry> entries)
public static Set<RemoteAddeEntry> convertIdvServers(List<AddeServer> idvServers)
public static Set<AddeServer> convertMcvServers(Collection<AddeEntry> entries)
protected static Set<RemoteAddeEntry> convertUserXml(Element root)
ResourceManager.RSC_NEW_USERSERVERS
to a Set
of RemoteAddeEntry
s.
root
- "Root" of the XML to convert.
Set
of RemoteAddeEntry
s described by
root
.public static Set<RemoteAddeEntry> createEntriesFrom(RemoteAddeEntry entry)
protected static Set<AddeEntry> convertAddeServerXml(Element root, AddeEntry.EntrySource source)
IdvResourceManager.RSC_ADDESERVER
to a Set
of RemoteAddeEntry
s.
root
- XML to convert.source
- Used to "bulk set" the origin of whatever
RemoteAddeEntry
s get created.
Set
of RemoteAddeEntry
s 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 RemoteAddeEntry
s 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> mapIpToName(Map<String,Set<String>> map)
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 LocalAddeEntry
s.
filename
- Filename containing desired LocalAddeEntry
s.
Cannot be null
.
Set
of LocalAddeEntry
s 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 LocalAddeEntry
s to a "RESOLV.SRV"
file. This method discards the current contents of filename
!
filename
- Filename that will contain the LocalAddeEntry
s 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 LocalAddeEntry
s to a "RESOLV.SRV"
file. This method will append the contents of entries
to
filename
.
filename
- Filename that will contain the LocalAddeEntry
s 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 LocalAddeEntry
s to a "RESOLV.SRV"
file.
filename
- Filename that will contain the LocalAddeEntry
s 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
IOException
public 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)
Collection
of LocalAddeEntry
s into a List
of String
s.
entries
- Collection
of entries to convert. Should not be null
.
entries
represented as String
s.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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |