bootstrapP
Class SafeMSForBSInterface

java.lang.Object
  extended by bootstrapP.SafeMSForBSInterface
All Implemented Interfaces:
MSForBSInterface, java.io.Serializable, java.rmi.Remote

public class SafeMSForBSInterface
extends java.lang.Object
implements MSForBSInterface, java.io.Serializable

A Safe Message Server to Bootstrap interface.
Normally, when a Bootstrap losts its RMI reference to the Message Server, for example for a MS shutdown, any call to the message server interface throws a RemoteException, even if the server got back on-line.
Using this class, any method calls the interface method, but when the interface is down, it tries to bring it up once again.

Author:
Marco Cornolti
See Also:
Serialized Form

Field Summary
private  MSForBSInterface interf
           
(package private)  java.net.InetAddress ip
           
(package private)  int RMIPort
           
private static long serialVersionUID
           
 
Constructor Summary
SafeMSForBSInterface(java.net.InetAddress ip, int RMIPort)
          Safe MS for BS Interface constructor.
 
Method Summary
 void assign(java.lang.String MSPw, User user, java.lang.String userPw)
          Assigns a new user to the message server.
 void blockAssignation(java.lang.String MSPw, boolean status)
          Puts the MS in the 'blocked' or 'unblocked' status, depending on the boolean status given by argument.
 void deleteUserAdmin(User nick, java.lang.String MSpw)
          Deletes a user.
 Statistics getStatistics(java.lang.String globalpw)
          Returns the statistics of the message server.
 java.util.Vector<User> getUsersList(java.lang.String globalpw)
          Returns the list of users managed by the Message Server.
 void moveUser(java.lang.String MSPw, User user, MessageServer ms)
          Moves a user assignation from the message server to the specified one.
private  void refreshInterface()
          Refreshes the interface.
 void shutdown(java.lang.String MSPw)
          Shuts down the MS server.
 boolean testPassword(java.lang.String pw)
          Tests a message server administration password.
 void testPresence()
          Tests the presence of a Message Server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

interf

private MSForBSInterface interf

RMIPort

int RMIPort

ip

java.net.InetAddress ip
Constructor Detail

SafeMSForBSInterface

public SafeMSForBSInterface(java.net.InetAddress ip,
                            int RMIPort)
                     throws java.rmi.RemoteException
Safe MS for BS Interface constructor.

Parameters:
ip - the MS ip address.
RMIPort - the MS RMI port.
Throws:
java.rmi.RemoteException - if the server could not be reached.
Method Detail

assign

public void assign(java.lang.String MSPw,
                   User user,
                   java.lang.String userPw)
            throws java.rmi.RemoteException,
                   BlockedException,
                   WrongPasswordException
Description copied from interface: MSForBSInterface
Assigns a new user to the message server.

Specified by:
assign in interface MSForBSInterface
Parameters:
MSPw - the MS password.
user - the user to add
userPw - the user password
Throws:
java.rmi.RemoteException - if a communication problem occurs.
BlockedException - if the server is blocked and does not accept new users.
WrongPasswordException - if the Message Server Password is wrong.

blockAssignation

public void blockAssignation(java.lang.String MSPw,
                             boolean status)
                      throws java.rmi.RemoteException,
                             WrongPasswordException
Description copied from interface: MSForBSInterface
Puts the MS in the 'blocked' or 'unblocked' status, depending on the boolean status given by argument. If the MS is blocked, no new assignations are accepted. The MS must be put in bloked status when their users have to be transferred to another MS before shutting down.

Specified by:
blockAssignation in interface MSForBSInterface
Parameters:
MSPw - the MS administration password.
status - true if the status must be set to 'blocked', false if the status must be set to 'unblocked'.
Throws:
java.rmi.RemoteException - if a communication problem occurs.
WrongPasswordException - if the password is wrong.

deleteUserAdmin

public void deleteUserAdmin(User nick,
                            java.lang.String MSpw)
                     throws java.rmi.RemoteException,
                            WrongPasswordException,
                            BlockedException,
                            UserNotManagedException
Description copied from interface: MSForBSInterface
Deletes a user. This method is invoked by the global administrator.

Specified by:
deleteUserAdmin in interface MSForBSInterface
Parameters:
nick - the user to delete.
MSpw - the Message Server administration password.
Throws:
java.rmi.RemoteException - if a communication problem with the server occurred.
WrongPasswordException - if the password is not right.
BlockedException - if the MS is currently blocked.
UserNotManagedException - if the specified user is not managed by the Message server.

getStatistics

public Statistics getStatistics(java.lang.String globalpw)
                         throws java.rmi.RemoteException,
                                WrongPasswordException
Description copied from interface: MSForBSInterface
Returns the statistics of the message server.

Specified by:
getStatistics in interface MSForBSInterface
Parameters:
globalpw - the MS password
Returns:
an object containing the statistics of the message server.
Throws:
java.rmi.RemoteException - if a communcation problem occurs.
WrongPasswordException - if the administration password is wrong.

getUsersList

public java.util.Vector<User> getUsersList(java.lang.String globalpw)
                                    throws java.rmi.RemoteException,
                                           WrongPasswordException
Description copied from interface: MSForBSInterface
Returns the list of users managed by the Message Server. (Used only for debug purposals?)

Specified by:
getUsersList in interface MSForBSInterface
Parameters:
globalpw - the MS password
Returns:
a vector containing the managed users or null if the password is wrong.
Throws:
java.rmi.RemoteException - if a communication problem occurs.
WrongPasswordException - if the password is wrong.

moveUser

public void moveUser(java.lang.String MSPw,
                     User user,
                     MessageServer ms)
              throws java.rmi.RemoteException,
                     WrongPasswordException,
                     UserNotManagedException,
                     AssignationNotAcceptedException,
                     GenericErrorException
Description copied from interface: MSForBSInterface
Moves a user assignation from the message server to the specified one.

Specified by:
moveUser in interface MSForBSInterface
Parameters:
MSPw - the message server password.
user - the user to move.
ms - the message server to move the user to.
Throws:
java.rmi.RemoteException - if a communication problem occurs.
WrongPasswordException - id the MS admin password is wrong.
UserNotManagedException - if the user is not managed by this MS (or does not exists).
AssignationNotAcceptedException - if the MS the user was wanted to be moved to refused the assignation (i.e. is blocked).
GenericErrorException - if a communication problem with the second MS occurred.

shutdown

public void shutdown(java.lang.String MSPw)
              throws java.rmi.RemoteException,
                     WrongPasswordException,
                     UsersStillPresentException,
                     BlockedException
Description copied from interface: MSForBSInterface
Shuts down the MS server. Must be invoked when no users are managed by the MS and the MS is blocked.

Specified by:
shutdown in interface MSForBSInterface
Parameters:
MSPw - the Message Server password.
Throws:
java.rmi.RemoteException - if there was a communication error or the MS was correctly shutdown.
WrongPasswordException - if the password is wrong.
UsersStillPresentException - if the Message Server still manages some users.
BlockedException - if the Message Server is not blocked.

testPassword

public boolean testPassword(java.lang.String pw)
                     throws java.rmi.RemoteException
Description copied from interface: MSForBSInterface
Tests a message server administration password.

Specified by:
testPassword in interface MSForBSInterface
Parameters:
pw - the password to check
Returns:
true if the password is right, false otherwise.
Throws:
java.rmi.RemoteException

testPresence

public void testPresence()
                  throws java.rmi.RemoteException
Description copied from interface: MSForBSInterface
Tests the presence of a Message Server

Specified by:
testPresence in interface MSForBSInterface
Throws:
java.rmi.RemoteException - if the server could not be reached.

refreshInterface

private void refreshInterface()
                       throws java.rmi.RemoteException
Refreshes the interface.

Throws:
java.rmi.RemoteException - if the interface could not be refreshed (the server is still down).