User.v1_1
Class VisitorAgent

java.lang.Object
  |
  +--PaP.Actor
        |
        +--PaP.ApplicationActor
              |
              +--User.v1_1.VisitorAgent
All Implemented Interfaces:
ActorInterface, ControlInterface, java.rmi.Remote, java.io.Serializable

public class VisitorAgent
extends ApplicationActor

A VisitorAgent is the actor working on behalf of a user that has logged into a PaP domain as visitor. The VisitorAgent has unlike the UserAgent not a Session object for the user. This way no session can be either suspended or resumed by a VisitorAgent. The VisitorAgent is used when a user loggs into a domain other than his home domain. He then gets certain default rights and capabilities. In order for a user to get his userprofile, his session and his actual rights and capabilities he needs to login to his Director from the VisitorAgent. The VisitorAgent will then be plugged out and a UserAgent will be plugged in.

Every VisitorAgent has an reference to a VisitorWindow which acts as the Graphical User Interface (GUI) of the VisitorAgent. The VisitorWindow contains to tables; the plugin table and the plugout table. The VisitorAgent reads the file RoleList_Visitor.xml for a list of plays and roles that the user can select to plugin and this list is shown in the plugin table. Everytime a user plugs in an actor to play the specified role, the GAI of the actor is added to the plugout table. This table contains a list of actors that the user can select to plugout.

Version:
1.0
Author:
Lars Erik Liljebäck
See Also:
Session, VisitorWindow, Serialized Form

Inner Class Summary
 class VisitorAgent.CloseWindowThread
          This thread is started when an ActorPlugOut request is received.
 
Field Summary
private  java.lang.String codebase
          URL used as codebase when actors are plugged in.
private  boolean initiated
          Indicates wether initial ActorPlugIn has been performed or not
private  java.util.Hashtable pluggedInActors
          Hashtable containing plugged in actors
private  int unique
          Increasing number used for naming of actors
private  VisitorWindow window
          The reference to the VisitorWindow, the GUI of the VisitorAgent.
private  XMLFileUtil xfu
          Reference to the XMLFileUtil used for reading the file ActorList_Visitor.xml.
 
Fields inherited from class PaP.Actor
bf, context, fh
 
Constructor Summary
VisitorAgent()
          Creates a new VisitorAgent.
 
Method Summary
 RequestResult applicationActorEntry(RequestPars rpars)
          This method is the common entry point for all external requests to this actor.
 void closeApplication()
          This method is used by the GUI to notify that the user wants to close the application.
private  void dbg(java.lang.String dbg)
          Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities.
 java.lang.String getCodebase()
          Returns the current URL used as codebase.
 java.lang.String[] getPluggedInActors()
          Returns a string array with the GAI of all the actors that have been plugged in by this VisitorAgent.
private  int getUnique()
          Returns a unigue number that is used to name the actors being plugged in by the VisitorAgent.
 void loginUserRemotely(java.lang.String directorGAI, java.lang.String username, java.lang.String password, boolean resumeSession)
          Sends a configured LoginRequest of type REMOTE to the Director.
static void main(java.lang.String[] args)
          Used for debugging.
 void pluginActor(java.lang.String playName, java.lang.String version, java.lang.String roleName, java.lang.String plugInLocation)
          Plugs in an actor with the specified role.
 void plugOutActor(java.lang.String gai)
          Plugs out the actor with the specified GAI.
 void plugOutAllActors()
          Pluggs out all the actors plugged in by this VisitorAgent.
 void setCodebase(java.lang.String url)
          Sets the URL to use as codebase when actors are plugged in.
 void windowDebug(java.lang.String dbg)
          Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities.
 
Methods inherited from class PaP.ApplicationActor
actorBehaviourPlugIn, actorBehaviourPlugOut, actorCapabilities, actorChangeBehaviour, actorEntry, actorPlay, actorPlugIn, actorPlugOut, anyOtherRequestType, callActorChangeBehaviour, control, init, loginUser, logoutUser, playChangesPlugIn, playPlugIn, playPlugOut, requestToActor, roleFigurePlugIn, roleFigurePlugOut, roleSessionAction, sessionResume, sessionSuspend, sessionUpdate, subscribeCancel, subscribeReport, subscribeRequest
 
Methods inherited from class PaP.Actor
findRoleSession, getGAI, start, status, term
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

initiated

private boolean initiated
Indicates wether initial ActorPlugIn has been performed or not

window

private VisitorWindow window
The reference to the VisitorWindow, the GUI of the VisitorAgent.

xfu

private XMLFileUtil xfu
Reference to the XMLFileUtil used for reading the file ActorList_Visitor.xml.

codebase

private java.lang.String codebase
URL used as codebase when actors are plugged in.

unique

private int unique
Increasing number used for naming of actors

pluggedInActors

private java.util.Hashtable pluggedInActors
Hashtable containing plugged in actors
Constructor Detail

VisitorAgent

public VisitorAgent()
Creates a new VisitorAgent.
Method Detail

applicationActorEntry

public RequestResult applicationActorEntry(RequestPars rpars)
                                    throws java.lang.Exception
This method is the common entry point for all external requests to this actor. Checks which type of request was received and performs the appropriate actions based on the type.
Overrides:
applicationActorEntry in class ApplicationActor
Parameters:
rpars - Instance of RequestPars which specifies type of request and additional parametres to the request.
Returns:
An instance of RequestResult which indicates success or failure in treatment of the request.
Throws:
java.lang.Exception -  

closeApplication

public void closeApplication()
                      throws java.lang.Exception
This method is used by the GUI to notify that the user wants to close the application. It tries to plug out the actor.

getCodebase

public java.lang.String getCodebase()
Returns the current URL used as codebase.
Returns:
The current codebase.

getPluggedInActors

public java.lang.String[] getPluggedInActors()
Returns a string array with the GAI of all the actors that have been plugged in by this VisitorAgent.
Returns:
String array with the GAI of the plugged in actors.

loginUserRemotely

public void loginUserRemotely(java.lang.String directorGAI,
                              java.lang.String username,
                              java.lang.String password,
                              boolean resumeSession)
                       throws java.lang.Exception
Sends a configured LoginRequest of type REMOTE to the Director. This is sent because a user logged in as a visitor wants to login to his home PaP domain. The domain is specified by the GAI of the Director of the domain. The request is sent to the VisitorAgent's Director who forwards the request to the specified Director who loggs in the user.
The LoginRequest contains the specified username and password and indicates wether a stored session is to be resumed or not.
Parameters:
directorGAI - The GAI of the Director of the user's home domain.
username - The username of the user logging in.
password - The password of the user logging in.
resumeSession - If true the user's stored session is resumed, else a new session is created.
Throws:
java.lang.Exception - if something goes wrong.

pluginActor

public void pluginActor(java.lang.String playName,
                        java.lang.String version,
                        java.lang.String roleName,
                        java.lang.String plugInLocation)
                 throws java.lang.Exception
Plugs in an actor with the specified role. It first tries to plugin the specified Version of the specified Play. If it was already plugged in, it disregards the result indicating FAIL. Then it sends an ActorPlugIn request of plugging in an actor with the specified role. The node where the actor is plugged in is specified by plugInLocation. If it equals Local is is plugged in on the user's node. If it equals Director it is plugged in on the Director's node.
Parameters:
playname - The name of the Play the specified role belongs to.
version - The version of the Play wanted.
role - The name of the role of the actor to be plugged in.
plugInLocation - Specifies the node where the actor is plugged in.
Throws:
java.lang.Exception - if something goes wrong.

plugOutActor

public void plugOutActor(java.lang.String gai)
                  throws java.lang.Exception
Plugs out the actor with the specified GAI. Gets the RoleSession from the hashtable with a key equal to the specified GAI. Then sends a request to the Director to plugout the specified RoleSession, meaning the cooperator of the RoleSession. If the request succeeds the RoleSession is removed from the hashtable, else an Exception is thrown to notify the UserWindow that the request failed.
Parameters:
gai - Specifies which RoleSession in the hashtable to plugout.
Throws:
An - Exception is thrown if something goes wrong or if the request fails.

plugOutAllActors

public void plugOutAllActors()
Pluggs out all the actors plugged in by this VisitorAgent. This method is called when the user chooses to logout. Repeatedly follows the same procedure used in plugOutActor().
See Also:
plugOutActor(java.lang.String)

setCodebase

public void setCodebase(java.lang.String url)
Sets the URL to use as codebase when actors are plugged in. The codebase indicates the location of the class files to load.
Parameters:
url - The new codebase.

windowDebug

public void windowDebug(java.lang.String dbg)
Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities. This method is used by the VisitorWindow.
Parameters:
dbg - The debug information to be sent.

dbg

private void dbg(java.lang.String dbg)
Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities.
Overrides:
dbg in class ApplicationActor
Parameters:
dbg - The debug information to be sent.

getUnique

private int getUnique()
Returns a unigue number that is used to name the actors being plugged in by the VisitorAgent. The number is a counter that is incremented every time this method is called.
Returns:
The current value of the unique variable.

main

public static void main(java.lang.String[] args)
Used for debugging.