Public Member Functions | Private Member Functions | Private Attributes

com::nmt::mgp::ConnHandler Class Reference

Manage a connection to an EMG server. More...

List of all members.

Public Member Functions

 ConnHandler (String theHost, String theUser, String thePassword, int thePort, boolean withSsl)
 Normal constructor.
void init (String str)
 Sets the systemtype to be sent to the server.
void sessionInvalidate ()
 Close the connection to the server.
OptionHolder getLoginOptions ()
 Gets the MGP options from the current MgpSession.
boolean isAdmin () throws MgpException
 Returns true if and only if the current user has full administration rights.
int getAdminFlags () throws MgpException
String getClientConfig () throws MgpException
 Returns the MGP option client_config.
String getRemoteIp () throws MgpException
 Returns the MGP option remoteip.
void sendOperation (int operand, OptionHolder oph) throws MgpException
 Sends an operation with parameters to the server.
void sendOperation (int operand, OptionHolder oph, boolean doFlush) throws MgpException
 Sends an operation with parameters to the server.
void readOperation (OptionHolder oph) throws MgpException
 Reads the reply from the EMG server from the previous operation.
int sendMess (Message msg) throws MgpException
 Send an MGP Message to the server.
java.sql.ResultSet dbexec (String profile, String sql) throws MgpException
 Sends an SQL string to the server, to be executed by the given database profile.
OptionHolder execute (int operation, OptionHolder options) throws MgpException
boolean havePermission (int mask, boolean all) throws MgpException
 Checks the permission of the currently logged in user.
boolean test () throws MgpException, java.io.IOException, Exception
 Fetches the connection parameters from Setting, and calls test(String,int,String,String,boolean).
boolean test (String host, int port, String user, String pwd, boolean ssl) throws MgpException
 Close the current session, and reconnect.
void setEmgDebug (boolean inBool)
 Sets the debug level for the MgpSession, if any.
final String getHost ()
final String getPassword ()
final int getPort ()
final boolean isSsl ()
final String getUser ()

Private Member Functions

void checkConn (String theHost, int thePort, String theUser, String thePassword, boolean withSsl) throws MgpException
void checkConn () throws MgpException

Private Attributes

String syncer = ""
MgpSession session = null
String systemtype = null
String sClientConfig = null
OptionHolder loginOptions = null
String host = ""
String user = ""
String password = ""
int port = 0
boolean ssl = false

Detailed Description

Manage a connection to an EMG server.

Connection parameters are taken from the Settings class, using the following parameters.


Constructor & Destructor Documentation

com::nmt::mgp::ConnHandler::ConnHandler ( String  theHost,
String  theUser,
String  thePassword,
int  thePort,
boolean  withSsl 
) [inline]

Normal constructor.

References host, password, port, ssl, and user.


Member Function Documentation

void com::nmt::mgp::ConnHandler::checkConn ( String  theHost,
int  thePort,
String  theUser,
String  thePassword,
boolean  withSsl 
) throws MgpException [inline, private]
void com::nmt::mgp::ConnHandler::checkConn (  )  throws MgpException [inline, private]
java.sql.ResultSet com::nmt::mgp::ConnHandler::dbexec ( String  profile,
String  sql 
) throws MgpException [inline]

Sends an SQL string to the server, to be executed by the given database profile.

The connection to the server is restored if necessary.

Parameters:
profile the database profile name
sql the sql string
Returns:
the ResultSet read by the server
Exceptions:
MgpException if the connection failes, or there is something wrong with the sql statement

References checkConn(), com::nmt::mgp::MgpSession::dbexec(), com::nmt::mgp::MgpException::getErrno(), session, sessionInvalidate(), and syncer.

OptionHolder com::nmt::mgp::ConnHandler::execute ( int  operation,
OptionHolder  options 
) throws MgpException [inline]
int com::nmt::mgp::ConnHandler::getAdminFlags (  )  throws MgpException [inline]
String com::nmt::mgp::ConnHandler::getClientConfig (  )  throws MgpException [inline]

Returns the MGP option client_config.

A connection to the server is made if necessary.

Exceptions:
MgpException If a connection can't be made.

References checkConn(), com::nmt::mgp::MgpSession::getClientConfig(), session, and syncer.

final String com::nmt::mgp::ConnHandler::getHost (  )  [inline]

References host.

OptionHolder com::nmt::mgp::ConnHandler::getLoginOptions (  )  [inline]

Gets the MGP options from the current MgpSession.

References loginOptions.

final String com::nmt::mgp::ConnHandler::getPassword (  )  [inline]

References password.

final int com::nmt::mgp::ConnHandler::getPort (  )  [inline]

References port.

String com::nmt::mgp::ConnHandler::getRemoteIp (  )  throws MgpException [inline]

Returns the MGP option remoteip.

A connection to the server is made if necessary.

Exceptions:
MgpException If a connection can't be made.

References checkConn(), com::nmt::mgp::MgpSession::getRemoteIp(), session, and syncer.

final String com::nmt::mgp::ConnHandler::getUser (  )  [inline]

References user.

boolean com::nmt::mgp::ConnHandler::havePermission ( int  mask,
boolean  all 
) throws MgpException [inline]

Checks the permission of the currently logged in user.

The connection to the server is restored if necessary.

Parameters:
mask the bitmask of permissions
all if all bits must match
Returns:
true if and only if the user has all the required permissions
Exceptions:
MgpException if the connection failes

References checkConn(), com::nmt::mgp::MgpException::getErrno(), com::nmt::mgp::MgpSession::havePermission(), session, sessionInvalidate(), and syncer.

void com::nmt::mgp::ConnHandler::init ( String  str  )  [inline]

Sets the systemtype to be sent to the server.

Parameters:
str the systemtype

References systemtype.

boolean com::nmt::mgp::ConnHandler::isAdmin (  )  throws MgpException [inline]

Returns true if and only if the current user has full administration rights.

A connection to the server is made if necessary.

Exceptions:
MgpException If a connection can't be made.

References getAdminFlags().

final boolean com::nmt::mgp::ConnHandler::isSsl (  )  [inline]

References ssl.

void com::nmt::mgp::ConnHandler::readOperation ( OptionHolder  oph  )  throws MgpException [inline]

Reads the reply from the EMG server from the previous operation.

If readOperation() is called before sendOperation(), the application will hang waiting for the non-existent reply.

Parameters:
oph the container to store the replies in
Exceptions:
MgpException the connection fails
Deprecated:
Use com.nmt.mgp.MgpSessionI#execute instead.

References checkConn(), com::nmt::mgp::MgpException::getErrno(), com::nmt::mgp::MgpSession::readOperation(), session, and sessionInvalidate().

int com::nmt::mgp::ConnHandler::sendMess ( Message  msg  )  throws MgpException [inline]

Send an MGP Message to the server.

If an MgpException is caught, the connection is closed, reopened, and a second attempt is made. No third attempt is made.

Parameters:
msg the message to send
Returns:
the message id returned from the server
Exceptions:
MgpException if anything is wrong with the message or the connection can't be established.

References checkConn(), com::nmt::mgp::MgpException::getErrno(), com::nmt::mgp::MgpSession::sendMessage(), session, and sessionInvalidate().

void com::nmt::mgp::ConnHandler::sendOperation ( int  operand,
OptionHolder  oph 
) throws MgpException [inline]

Sends an operation with parameters to the server.

A connection to the server is made if necessary.

Parameters:
operand the operation number
oph the parameters
Exceptions:
MgpException If a connection can't be made.
void com::nmt::mgp::ConnHandler::sendOperation ( int  operand,
OptionHolder  oph,
boolean  doFlush 
) throws MgpException [inline]

Sends an operation with parameters to the server.

A connection to the server is made if necessary.

Parameters:
operand the operation number
oph the parameters
doFlush if the data should be flushed
Exceptions:
MgpException If a connection can't be made.
Deprecated:
Use com.nmt.mgp.MgpSessionI#execute instead.

References checkConn(), com::nmt::mgp::MgpException::getErrno(), com::nmt::mgp::MgpSession::sendOperation(), session, sessionInvalidate(), and com::nmt::mgp::MgpSession::setDebug().

void com::nmt::mgp::ConnHandler::sessionInvalidate (  )  [inline]
void com::nmt::mgp::ConnHandler::setEmgDebug ( boolean  inBool  )  [inline]

Sets the debug level for the MgpSession, if any.

References session, and com::nmt::mgp::MgpSession::setDebug().

boolean com::nmt::mgp::ConnHandler::test (  )  throws MgpException, java.io.IOException, Exception [inline]

Fetches the connection parameters from Setting, and calls test(String,int,String,String,boolean).

boolean com::nmt::mgp::ConnHandler::test ( String  host,
int  port,
String  user,
String  pwd,
boolean  ssl 
) throws MgpException [inline]

Close the current session, and reconnect.

References checkConn(), com::nmt::mgp::MgpException::getErrno(), host, port, session, sessionInvalidate(), ssl, and user.


Member Data Documentation

String com::nmt::mgp::ConnHandler::host = "" [private]

Referenced by checkConn(), ConnHandler(), getHost(), and test().

Referenced by checkConn(), and getLoginOptions().

String com::nmt::mgp::ConnHandler::password = "" [private]

Referenced by checkConn(), ConnHandler(), and getPassword().

Referenced by checkConn(), ConnHandler(), getPort(), and test().

Referenced by checkConn().

boolean com::nmt::mgp::ConnHandler::ssl = false [private]

Referenced by checkConn(), ConnHandler(), isSsl(), and test().

String com::nmt::mgp::ConnHandler::syncer = "" [private]
String com::nmt::mgp::ConnHandler::systemtype = null [private]

Referenced by checkConn(), and init().

String com::nmt::mgp::ConnHandler::user = "" [private]

Referenced by checkConn(), ConnHandler(), getUser(), and test().


The documentation for this class was generated from the following file: