de.mid.innovator.srv
Class RepositoryServer

java.lang.Object
  extended by de.mid.innovator.client.InoProgram
      extended by de.mid.innovator.srv.InoServerProgram
          extended by de.mid.innovator.srv.RepositoryServer
All Implemented Interfaces:
SrvContext

public class RepositoryServer
extends InoServerProgram
implements SrvContext

This class represents the Innovator repository server. A repository server recognizes its own license server and keeps an up-to-date list of the models contained in it. Note: an instance of this class is different from the server proxy element of the ADRepository type. To obtain this instance, call getADRepository() if connected to the server.

A repository server extends a general purpose server program class that provides different kinds of data through the license server requests. The implementation of the interface SrvContext is needed to realize a uniform way to call helper methods, either using a connected server instance or an object of the class model.

Author:
borschet
See Also:
ADRepository

Nested Class Summary
 
Nested classes/interfaces inherited from class de.mid.innovator.client.InoProgram
InoProgram.Type
 
Constructor Summary
RepositoryServer(LicenseServer aLicenseServer, int pid, int procStatus, String vers, String host, String user, LicSrvGetSrvPrjListReplyTelegram.SrvConData srvConData, List<Model> modelLst)
           
 
Method Summary
 void connect()
          Connects to a running Innovator repository server if not yet connected.
 Model createModel(String name, K_ADMODEL modelType, String newAdminPwd, String userCfg, String modelCfg, List<String> addOnList)
          Creates a new Model in the actual repository server and refreshes the list of models.
 void disconnect()
          Disconnects from the repository server.
 boolean equals(SrvContext obj)
          Compares this server object to an SrvContext implementer.
 ADRepository getADRepository()
          Gets the repository server proxy element.
 ExcellenceModel getExcellenceModel(String aModelName, K_ADMODEL aModelType)
          Gets a model with the given name and type from the list of currently known models.
 String getFullName()
          Gets the name of the repository server (which is equal to the directory name where the server stores all data).
 LicenseServer getLicenseServer()
          Gets the license server object which the repository server periodically contacts.
 SrvLogin getLogin()
          Implements the method from SrvContext
 Model getModel(String aModelName, K_ADMODEL aModelType)
          Gets a model with the given name and type from the list of currently known models.
 List<Model> getModels()
          Gets the complete list of known models.
 List<Model> getModels(K_ADMODEL aModelType)
          Searches the list of currently known models in this server for models of the given type.
 String getName()
          Gets the name of the repository server (which is equal to the directory name where the server stores all data).
 SrvConnection getSrvConnection()
          Implements the method from SrvContext
 EnumSet<ServerStatus> getStatus()
           
 boolean hasLogin()
          Checks whether a previous successful administrator login was performed.
 void logout()
          Logs out from the repository server if still logged-in, otherwise nothing will be done.
 void modifyPassword(String oldPass, String newPass)
          Modifies the repository server's administration password.
 void refresh()
          Synchronizes this server object's model list with the actual state known by the license server.
 void repositoryAdminLogin(String pwd)
          Authenticates the user credentials for administration purposes; this is carried out by the repository server.
 String toString()
           
 boolean userHasAdminPrivileges()
           
 
Methods inherited from class de.mid.innovator.srv.InoServerProgram
getStatusFlags
 
Methods inherited from class de.mid.innovator.client.InoProgram
getHost, getPid, getProgramType, getUser, getVers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RepositoryServer

public RepositoryServer(LicenseServer aLicenseServer,
                        int pid,
                        int procStatus,
                        String vers,
                        String host,
                        String user,
                        LicSrvGetSrvPrjListReplyTelegram.SrvConData srvConData,
                        List<Model> modelLst)
Method Detail

connect

public void connect()
             throws InoNetException
Connects to a running Innovator repository server if not yet connected. As a side effect, the repository server proxy object is received; this provides direct server access. The service is carried out by a contained object of the SrvConnection type that handles all TCP/IP network information.

Throws:
InoNetException - if a network error occurs.
See Also:
SrvConnection

createModel

public Model createModel(String name,
                         K_ADMODEL modelType,
                         String newAdminPwd,
                         String userCfg,
                         String modelCfg,
                         List<String> addOnList)
                  throws InoNetException,
                         SrvErrorException
Creates a new Model in the actual repository server and refreshes the list of models.

Parameters:
name - the name of the new model
modelType - the kind of model
newAdminPwd - the administrator's password for the new model or null
userCfg - the name of a valid user configuration or null
modelCfg - the name of a valid model configuration or null
addOnList - a list of add-ons which need to be loaded or null
Returns:
the created model object
Throws:
InoNetException - if a network error occurs.
SrvErrorException - if invalid data has been sent to this server.
IllegalArgumentException - if the given model type is different to K_ADMODEL.UML

disconnect

public void disconnect()
                throws InoNetException
Disconnects from the repository server. The method should be called once for every call made to connect(). This enables the repository server to finish the corresponding connection.

Throws:
InoNetException - if a network error occurs.

equals

public boolean equals(SrvContext obj)
Compares this server object to an SrvContext implementer. If the object to be compared with is an instance of the RepositoryServer class, the two server instances are declared to be equal if they point to the same Innovator server. Otherwise the objects are not equal.

This method implements SrvContext.equals(SrvContext)

Specified by:
equals in interface SrvContext
See Also:
SrvContext, Model.equals(SrvContext)

getADRepository

public ADRepository getADRepository()
Gets the repository server proxy element.

Returns:
an ADRepository object, if connected to the server, otherwise null.

getExcellenceModel

public ExcellenceModel getExcellenceModel(String aModelName,
                                          K_ADMODEL aModelType)
Gets a model with the given name and type from the list of currently known models. This is done without any server communication and may not be up-to-date. Use the refresh() method to synchronize this server object with the current state.

Parameters:
aModelName - the name of the Innovator eXcellence model
aModelType - the type of eXcellence model
Returns:
a model object if found, otherwise null.

getFullName

public String getFullName()
Gets the name of the repository server (which is equal to the directory name where the server stores all data).


getLicenseServer

public LicenseServer getLicenseServer()
Gets the license server object which the repository server periodically contacts.

Returns:
the server's license server object

getLogin

public SrvLogin getLogin()
Implements the method from SrvContext

Specified by:
getLogin in interface SrvContext
Returns:
the current login or null if not logged-in

getModel

public Model getModel(String aModelName,
                      K_ADMODEL aModelType)
Gets a model with the given name and type from the list of currently known models. This is done without any server communication and may not be up-to-date. Use the refresh() method to synchronize this server object with the current state.

Parameters:
aModelName - the name of the Innovator model
aModelType - the type of model
Returns:
a model object if found, otherwise null.

getModels

public List<Model> getModels()
Gets the complete list of known models. The model list may not be synchronized. Use refresh() to keep it up-to-date.

Returns:
a list of model objects or an empty list if this server has no models

getModels

public List<Model> getModels(K_ADMODEL aModelType)
Searches the list of currently known models in this server for models of the given type. The model list may not be synchronized. Use refresh() to keep it up-to-date.

Parameters:
aModelType - the type of model
Returns:
a list of models or an empty list if none are found
See Also:
getModel(String, K_ADMODEL)

getName

public String getName()
Gets the name of the repository server (which is equal to the directory name where the server stores all data).


getSrvConnection

public SrvConnection getSrvConnection()
Implements the method from SrvContext

Specified by:
getSrvConnection in interface SrvContext
Returns:
information needed to connect to a repository server

getStatus

public EnumSet<ServerStatus> getStatus()
                                throws InoNetException
Throws:
InoNetException

hasLogin

public boolean hasLogin()
Checks whether a previous successful administrator login was performed.

Returns:
true, if there is an ADLogin to be queried with getLogin(), otherwise false

logout

public void logout()
            throws InoNetException,
                   SrvErrorException
Logs out from the repository server if still logged-in, otherwise nothing will be done.

Throws:
InoNetException - if a network error occurs.
SrvErrorException - if invalid data has been sent to this server.
See Also:
repositoryAdminLogin(String)

modifyPassword

public void modifyPassword(String oldPass,
                           String newPass)
                    throws InoNetException,
                           SrvErrorException
Modifies the repository server's administration password.

Parameters:
oldPass - old password (plain text)
newPass - new password (plain text)
Throws:
InoNetException - if a network error occurs.
SrvErrorException - if invalid data has been sent to this server.

refresh

public void refresh()
             throws InoNetException
Synchronizes this server object's model list with the actual state known by the license server. The Innovator license server needs to be communicated with to get the correct data.

Throws:
InoNetException - if a network error occurs.
SrvErrorException

repositoryAdminLogin

public void repositoryAdminLogin(String pwd)
                          throws InoNetException,
                                 SrvErrorException
Authenticates the user credentials for administration purposes; this is carried out by the repository server.

Parameters:
pwd - the repository server's administration password
Throws:
InoNetException - if a network error occurs.
SrvErrorException - if invalid data has been sent to this server.
See Also:
logout()

toString

public String toString()
Overrides:
toString in class InoServerProgram

userHasAdminPrivileges

public boolean userHasAdminPrivileges()
                               throws InoNetException
Throws:
InoNetException