com.anabas.sharedlet
Interface CapabilitiesManager


public interface CapabilitiesManager
extends SharedletService

This SharedletService provides moderation capability to the sharedlet. It manages what capabilities a local sharedlet has and allows moderator/hosts to remotely set other client's capabilities via its interfaces.

All sharedlet that decide to support moderation must do the following in its SharedletInfo implementation.

  1. Define the raw list of capabilities it supports
    This is done once for the application when the application is written.
  2. Define the roles this application may have
    Roles define the set of capabilites a sharedlet has when it is invoked.
  3. Define the set of moderatable elements the sharedlet has This is the set of host/moderator changeable capability sets. This can be define what capabilities are moderatable during the session and what are not.
  4. Within each sharedlet, check with the CapabilitiesManager to see if a capability is enabled before allowing the user to use that feature.
Definition of Capabilities/Roles/ModeratableElement:

Capabilities A capability is a feature the sharedlet supports and want it to be made enablable or disablable. For example, in a whiteboard, capabilities could be "can draw circle", "can draw filled circle", "can draw text", ...

Sharedlet Roles A role is a defined set of capabilities. Whenever a sharedlet is launched, it will be set to one of its defined roles by the management system. This will in turn define the initial set of capabilities that the user has in this invocation of a sharedlet. For example, a instructor role for the whiteboard sharedlet allows the instructor to use all of the capabilities. A student role will only allow the student to place pointers on the whiteboard.

ModeratableElement A moderatable element is a set of capabilities as well. All defined moderatable elements are those that a moderator or a host can change during the class/meeting. For example, the "Draw" moderatable element is a list of all draw capabilities. If it is defined, the host/moderator will be able to remotely enable the "Draw" moderatable element (which will enable all of the capabilities defined within the element) for a particular user.

This set of elements convenience packages all possible capabilities into a set of moderation commands for the moderator/host.

Master/Slave/Moderator Modes

The CapabilitiesManager can take on three modes.

Location In GXO

A sharedlet can find the Capabilities Manager under:

/services/CapabilitiesManager


Field Summary
static short MASTER_MODE
          All methods are allowed.
static short MODERATOR_MODE
          The setRemoteMode() method is disallowed.
static short SLAVE_MODE
          All remote functionality are disallowed.
 
Method Summary
 void addCapabilityListener(CapabilityListener l)
          Listener to monitor changes in capabilities.
 void disableCapability(java.lang.String sharedletMIME, java.lang.String capability)
          Used to disable capability of a local user.
 void disableRemoteModeratable(java.lang.String sharedletMIME, java.lang.String modertable, com.anabas.concepts.UserID user)
          Used by sharedlet to remotely enable capabilities in a different user's capability manager.
 void enableCapability(java.lang.String sharedletMIME, java.lang.String capability)
          Used to enable capability of a local user.
 void enableRemoteModeratable(java.lang.String sharedletMIME, java.lang.String moderatable, com.anabas.concepts.UserID user)
          Used by sharedlet to remotely enable capabilities in a different user's capability manager.
 java.util.Vector getApplicationRoles()
          Get the list of application roles.
 java.lang.String getCurrentApplicationRole()
          Get the current application role for this instance of the capabilities manager.
 java.util.Vector getModeratableElements(java.lang.String sharedletMIME)
          Returns the list of moderatoratable element that this instance of the capabilitymanager has access to.
 java.lang.String getRemoteApplicationRole(com.anabas.concepts.UserID user)
          Gets a remote application role.
 java.lang.String getRole(java.lang.String sharedletMIME)
          Find out what role a sharedlet is currently set in.
 boolean isCapable(java.lang.String sharedletMIME, java.lang.String capability)
          Used by sharedlets to determine whether they have the capability to do certain actions.
 boolean isLocalModeratable(java.lang.String sharedletMIME, java.lang.String moderatable)
           
 boolean isRemoteCapable(java.lang.String sharedletMIME, java.lang.String capability, com.anabas.concepts.UserID user)
          Query wether a capability is enabled in a remote capabilities manager for another user.
 boolean isRemoteModeratable(java.lang.String sharedletMIME, java.lang.String moderatable, com.anabas.concepts.UserID user)
          Find out if another client's capability manager has a particular modertable element enabled.
 void removeCapabilityListener(CapabilityListener l)
          Listener to monitor changes in capabilities.
 void setRemoteApplicationRole(com.anabas.concepts.UserID user, java.lang.String appRole)
          Set a remote application role.
 void setRemoteMode(short mode, com.anabas.concepts.UserID user)
          Sets a remote capability manager's mode.
 
Methods inherited from interface com.anabas.sharedlet.SharedletService
init, resume, shutdown, suspend
 

Field Detail

SLAVE_MODE

public static final short SLAVE_MODE
All remote functionality are disallowed. Invoking any of the functions will cause a PermissionDeniedException.

MODERATOR_MODE

public static final short MODERATOR_MODE
The setRemoteMode() method is disallowed. Invoking that function will result in a PermissionDeniedException

MASTER_MODE

public static final short MASTER_MODE
All methods are allowed.
Method Detail

addCapabilityListener

public void addCapabilityListener(CapabilityListener l)
Listener to monitor changes in capabilities.
Parameters:
l - The listener to add.

removeCapabilityListener

public void removeCapabilityListener(CapabilityListener l)
Listener to monitor changes in capabilities.
Parameters:
l - The listener to remove.

getRole

public java.lang.String getRole(java.lang.String sharedletMIME)
Find out what role a sharedlet is currently set in.
Parameters:
sharedletMIME - The mime type of the sharedlet to get the role for.
Returns:
The role set for a particular sharedlet within this session.

getApplicationRoles

public java.util.Vector getApplicationRoles()
Get the list of application roles. Each application role is a set of sharedlet roles.

getCurrentApplicationRole

public java.lang.String getCurrentApplicationRole()
Get the current application role for this instance of the capabilities manager. It is one of the possible application roles returned by getApplicationRoles();

setRemoteApplicationRole

public void setRemoteApplicationRole(com.anabas.concepts.UserID user,
                                     java.lang.String appRole)
                              throws PermissionDeniedException
Set a remote application role.
Throws:
PermissionDeniedException - If the current instance is not in. MASTER_MODE.

getRemoteApplicationRole

public java.lang.String getRemoteApplicationRole(com.anabas.concepts.UserID user)
                                          throws PermissionDeniedException
Gets a remote application role.
Throws:
PermissionDeniedException - If the user is in SLAVE_MODE.

isCapable

public boolean isCapable(java.lang.String sharedletMIME,
                         java.lang.String capability)
Used by sharedlets to determine whether they have the capability to do certain actions.
Parameters:
sharedletMIME - The MIME type of the sharedlet to lookup.
capability - The name of the capability to lookup.

isRemoteCapable

public boolean isRemoteCapable(java.lang.String sharedletMIME,
                               java.lang.String capability,
                               com.anabas.concepts.UserID user)
                        throws PermissionDeniedException
Query wether a capability is enabled in a remote capabilities manager for another user. Typically used by the moderator or host to find out if a particular capability has already been enabled/disabled or not.
Parameters:
sharedletMIME - The MIME type of the sharedlet to enable a capability for.
capability - The name of the capability to enable
user - The user to perform the capability change on. This object can be retrived from the SessionManager service.
Throws:
PermissionDeniedException - If the capability manager is in the SLAVE_MODE.

isLocalModeratable

public boolean isLocalModeratable(java.lang.String sharedletMIME,
                                  java.lang.String moderatable)
Returns:
true If the moderatable element specified for a particular sharedlet in the local instance is enabled.

isRemoteModeratable

public boolean isRemoteModeratable(java.lang.String sharedletMIME,
                                   java.lang.String moderatable,
                                   com.anabas.concepts.UserID user)
                            throws PermissionDeniedException
Find out if another client's capability manager has a particular modertable element enabled. Useful for displaying the moderation status of another user.
Parameters:
sharedletMIME - The MIME type of the sharedlet to enable a capability for.
modertable - The name of the moderatable element to query.
user - The user id of the person to perform the capability change on. This object can be retrived from the SessionManager service.
Returns:
true If the remote user's modertable element is enabled. false otherwise.
Throws:
PermissionDeniedException - If the capability manager is in the SLAVE_MODE.

setRemoteMode

public void setRemoteMode(short mode,
                          com.anabas.concepts.UserID user)
                   throws PermissionDeniedException
Sets a remote capability manager's mode. Only doable in MASTER_MODE.
Parameters:
mode - one of MASTER_MODE, SLAVE_MODE, MODERATOR_MODER
user - The user id of the person whose capability manager to set. This object can be retrived from the SessionManager service.
Throws:
PermissionDeniedException - If the capability manager is not in MASTER_MODE

enableRemoteModeratable

public void enableRemoteModeratable(java.lang.String sharedletMIME,
                                    java.lang.String moderatable,
                                    com.anabas.concepts.UserID user)
                             throws PermissionDeniedException
Used by sharedlet to remotely enable capabilities in a different user's capability manager.
Parameters:
sharedletMIME - The MIME type of the sharedlet to enable a capability for.
modertable - The name of the moderatable element to enable.
user - The user to perform the capability change on. This object can be retrived from the SessionManager service.
Throws:
PermissionDeniedException - The the capability manager is in the SLAVE_MODE or if the role the sharedlet is in can not see the moderatable element as defined by the role definition.

disableRemoteModeratable

public void disableRemoteModeratable(java.lang.String sharedletMIME,
                                     java.lang.String modertable,
                                     com.anabas.concepts.UserID user)
                              throws PermissionDeniedException
Used by sharedlet to remotely enable capabilities in a different user's capability manager.
Parameters:
sharedletMIME - The MIME type of the sharedlet to enable a capability for.
modertable - The name of the moderatable element to disable.
user - The user to perform the capability change on. This object can be retrived from the SessionManager service.
Throws:
PermissionDeniedException - The the capability manager is in the SLAVE_MODE or if the role the sharedlet is in can not see the moderatable element as defined by the role definition.

getModeratableElements

public java.util.Vector getModeratableElements(java.lang.String sharedletMIME)
Returns the list of moderatoratable element that this instance of the capabilitymanager has access to.
Returns:
A vector of ModeratableElementInfo structures.

enableCapability

public void enableCapability(java.lang.String sharedletMIME,
                             java.lang.String capability)
                      throws PermissionDeniedException
Used to enable capability of a local user. This method is enabled in Host/ Moderator mode only.
Parameters:
sharedletMIME - The MIME type of the sharedlet to enable a capability for.
capability - The name of the capability to enable.
Throws:
PermissionDeniedException - The the capability manager is in the SLAVE_MODE or if the role the sharedlet is in can not see the moderatable element as defined by the role definition.

disableCapability

public void disableCapability(java.lang.String sharedletMIME,
                              java.lang.String capability)
                       throws PermissionDeniedException
Used to disable capability of a local user. This method is enabled in Host/ Moderator mode only.
Parameters:
sharedletMIME - The MIME type of the sharedlet to disable a capability for.
capability - The name of the capability to disable.
Throws:
PermissionDeniedException - The the capability manager is in the SLAVE_MODE or if the role the sharedlet is in can not see the moderatable element as defined by the role definition.