de.cau.cs.kieler.kwebs.client
Class ServerConfigs

java.lang.Object
  extended by de.cau.cs.kieler.kwebs.client.ServerConfigs

public final class ServerConfigs
extends Object

This utility class provides convenient access to the list of server configuration configurable by the user.

Rating proposed yellow
(2011-08-02) reviewed by ckru, mri, msp

Nested Class Summary
static class ServerConfigs.ServerConfigError
          Error constants for the validity test on a server configuration.
 
Method Summary
 void addServerConfig(ServerConfigData serverConfig)
          Adds a server configuration to the server configuration list.
 void clear()
          Clears the server configuration list.
 boolean containsServerConfig(ServerConfigData serverConfig)
          Returns whether a given server configuration is already contained in the server configuration list.
 int countConfigs()
          Returns the number of server configurations contained.
 ServerConfigData createServerConfig(String name, URI address)
          Creates a new server configuration.
 ServerConfigData createServerConfig(String name, URI address, String truststore, String truststorepass)
          Creates a new server configuration.
 ServerConfigData createServerConfig(String name, URI address, String truststore, String truststorepass, boolean isFixed, boolean isActive, boolean isStandard)
          Creates a new server configuration.
 ServerConfigData findServerConfig(ServerConfigData serverConfig)
          Returns a server configuration equal to the given server configuration.
 ServerConfigData getActiveServerConfig()
          Returns the currently active server configuration.
 int getIndexByServerConfig(ServerConfigData serverConfig)
          Returns the index of a given server configuration in the server configuration list.
static ServerConfigs getInstance()
          Get the singleton instance.
 ServerConfigData getServerConfigByIndex(int index)
          Returns a server configuration from the server configuration list by the given index.
 ServerConfigData getStandardServerConfig()
          Returns the standard server configuration.
 boolean isDirty()
          Returns whether the list of server configuration or any of the contained server configuration have been changed.
 ServerConfigs.ServerConfigError isValidServerConfig(ServerConfigData serverConfig)
          Checks whether the given server configuration is valid, e.g.
 void read()
          This method uses a registered storage manager to read a server configuration list.
 void registerStorageManager(IServerConfigsStorageManager manager)
          Registers a storage manager.
 void removeServerConfig(ServerConfigData serverConfig)
          Removes a server configuration from the server configuration list.
 void setActiveServerConfig(ServerConfigData activeServerConfig)
          Sets the currently active server configuration.
 void setDirty(boolean theisDirty)
          Sets the dirty state of this server configuration list.
 void setStandardServerConfig(ServerConfigData standardServerConfig)
          Sets the standard server configuration.
 void store()
          This method uses a registered storage manager to store a server configuration list.
 Object[] toObjectArray()
          Returns an object array consisting of the server configuration.
 void unregisterStorageManager()
          Unregisters the storage manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ServerConfigs getInstance()
Get the singleton instance.

Returns:
the singleton instance

registerStorageManager

public void registerStorageManager(IServerConfigsStorageManager manager)
Registers a storage manager.

Parameters:
manager - the storage manager to be registered

unregisterStorageManager

public void unregisterStorageManager()
Unregisters the storage manager.


clear

public void clear()
Clears the server configuration list.


read

public void read()
This method uses a registered storage manager to read a server configuration list.


store

public void store()
This method uses a registered storage manager to store a server configuration list.


isValidServerConfig

public ServerConfigs.ServerConfigError isValidServerConfig(ServerConfigData serverConfig)
Checks whether the given server configuration is valid, e.g. name and URI is valid and if the URI is HTTPS based whether the trust store parameters are valid.

Parameters:
serverConfig - the server configuration to be tested
Returns:
whether the server configuration is valid

createServerConfig

public ServerConfigData createServerConfig(String name,
                                           URI address)
Creates a new server configuration.

Parameters:
name - the name of the server configuration
address - the address of the layout service
Returns:
the newly created server configuration or null if the provided data is not valid

createServerConfig

public ServerConfigData createServerConfig(String name,
                                           URI address,
                                           String truststore,
                                           String truststorepass)
Creates a new server configuration.

Parameters:
name - the name of the server configuration
address - the address of the layout service
truststore - path to the trust store when using HTTPS
truststorepass - password for the trust store
Returns:
the newly created server configuration or null if the provided data is not valid

createServerConfig

public ServerConfigData createServerConfig(String name,
                                           URI address,
                                           String truststore,
                                           String truststorepass,
                                           boolean isFixed,
                                           boolean isActive,
                                           boolean isStandard)
Creates a new server configuration.

Parameters:
name - the name of the server configuration
address - the address of the layout service
truststore - path to the trust store when using HTTPS
truststorepass - password for the trust store
isFixed - whether this server configuration can be altered or deleted from the server configuration list
isActive - whether this server configuration shall be the currently active server configuration for doing remote layout
isStandard - whether this server configuration shall be the standard server configuration for doing remote layout
Returns:
the newly created server configuration or null if the provided data is not valid

addServerConfig

public void addServerConfig(ServerConfigData serverConfig)
Adds a server configuration to the server configuration list.

Parameters:
serverConfig - the server configuration to be added

removeServerConfig

public void removeServerConfig(ServerConfigData serverConfig)
Removes a server configuration from the server configuration list.

Parameters:
serverConfig - the server configuration to be removed

findServerConfig

public ServerConfigData findServerConfig(ServerConfigData serverConfig)
Returns a server configuration equal to the given server configuration.

Parameters:
serverConfig - the server configuration to be compared
Returns:
a server configuration equal to the given server configuration or null if no equal server configuration is in the server configuration list

containsServerConfig

public boolean containsServerConfig(ServerConfigData serverConfig)
Returns whether a given server configuration is already contained in the server configuration list.

Parameters:
serverConfig - the server configuration to be searched for
Returns:
whether a given server configuration is already contained in the server configuration list

getIndexByServerConfig

public int getIndexByServerConfig(ServerConfigData serverConfig)
Returns the index of a given server configuration in the server configuration list.

Parameters:
serverConfig - the server configuration to determine the index for
Returns:
the index or -1 if the server configuration is not contained in the server configuration list

getServerConfigByIndex

public ServerConfigData getServerConfigByIndex(int index)
Returns a server configuration from the server configuration list by the given index.

Parameters:
index - the index of the server configuration
Returns:
the server configuration or null if the index is invalid

getActiveServerConfig

public ServerConfigData getActiveServerConfig()
Returns the currently active server configuration.

Returns:
the currently active server configuration or null if no server configuration is currently active

setActiveServerConfig

public void setActiveServerConfig(ServerConfigData activeServerConfig)
Sets the currently active server configuration.

Parameters:
activeServerConfig - the server configuration which shall be the actively used server configuration for remote layout

getStandardServerConfig

public ServerConfigData getStandardServerConfig()
Returns the standard server configuration.

Returns:
the standard server configuration or null if no server configuration is currently defined as standard

setStandardServerConfig

public void setStandardServerConfig(ServerConfigData standardServerConfig)
Sets the standard server configuration.

Parameters:
standardServerConfig - the server configuration which shall be the standard server configuration for remote layout

isDirty

public boolean isDirty()
Returns whether the list of server configuration or any of the contained server configuration have been changed.

Returns:
whether the list of server configuration or any of the contained server configuration have been changed

countConfigs

public int countConfigs()
Returns the number of server configurations contained.

Returns:
the number of server configurations contained

setDirty

public void setDirty(boolean theisDirty)
Sets the dirty state of this server configuration list.

Parameters:
theisDirty - the new dirty state

toObjectArray

public Object[] toObjectArray()
Returns an object array consisting of the server configuration.

Returns:
an object array consisting of the server configuration