EMGJavaAPI
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.
String sendMess (Message msg) throws MgpException
 Send an MGP Message to the server.
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]
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:
MgpExceptionIf a connection can't be made.

References checkConn(), com::nmt::mgp::MgpSession::getClientConfig(), com::nmt::mgp::Mgp::MGP_ERR_UNKNOWN, 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:
MgpExceptionIf a connection can't be made.

References checkConn(), com::nmt::mgp::MgpSession::getRemoteIp(), com::nmt::mgp::Mgp::MGP_ERR_UNKNOWN, 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:
maskthe bitmask of permissions
allif all bits must match
Returns:
true if and only if the user has all the required permissions
Exceptions:
MgpExceptionif the connection failes

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

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

Sets the systemtype to be sent to the server.

Parameters:
strthe 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:
MgpExceptionIf a connection can't be made.

References getAdminFlags(), and com::nmt::mgp::Mgp::MGP_GROUP_ADMIN.

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:
ophthe container to store the replies in
Exceptions:
MgpExceptionthe connection fails
Deprecated:
Use com.nmt.mgp.MgpSessionI#execute instead.

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

String 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:
msgthe message to send
Returns:
the message id returned from the server
Exceptions:
MgpExceptionif anything is wrong with the message or the connection can't be established.

References checkConn(), com::nmt::mgp::MgpException::getErrno(), com::nmt::mgp::Mgp::MGP_ERR_COMM, com::nmt::mgp::Mgp::MGP_ERR_UNKNOWN, 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:
operandthe operation number
ophthe parameters
Exceptions:
MgpExceptionIf 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:
operandthe operation number
ophthe parameters
doFlushif the data should be flushed
Exceptions:
MgpExceptionIf a connection can't be made.
Deprecated:
Use com.nmt.mgp.MgpSessionI#execute instead.

References checkConn(), com::nmt::mgp::MgpException::getErrno(), com::nmt::mgp::Mgp::MGP_ERR_COMM, com::nmt::mgp::Mgp::MGP_ERR_UNKNOWN, 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]

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: