Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.project.internal.SarosSession Class Reference
Inheritance diagram for de.fu_berlin.inf.dpp.project.internal.SarosSession:
de.fu_berlin.inf.dpp.session.ISarosSession

List of all members.

Public Member Functions

 SarosSession (final String id, String nickname, int colorID, ISarosContext sarosContext)
 SarosSession (final String id, JID hostJID, String clientNickname, String hostNickname, int clientColorID, int hostColorID, ISarosContext sarosContext)
void addSharedResources (IProject project, String projectID, List< IResource > dependentResources)
List< UsergetUsers ()
List< UsergetRemoteUsersWithReadOnlyAccess ()
List< UsergetUsersWithReadOnlyAccess ()
List< UsergetUsersWithWriteAccess ()
List< UsergetRemoteUsersWithWriteAccess ()
List< UsergetRemoteUsers ()
boolean userHasProject (User user, IProject project)
void initiatePermissionChange (final User user, final Permission newPermission) throws CancellationException, InterruptedException
void setPermission (final User user, final Permission permission)
String getID ()
User getHost ()
boolean isHost ()
boolean hasWriteAccess ()
boolean hasExclusiveWriteAccess ()
void addUser (final User user)
void userStartedQueuing (final User user)
void userFinishedProjectNegotiation (final User user)
void removeUser (final User user)
void kickUser (final User user)
void addListener (ISharedProjectListener listener)
void removeListener (ISharedProjectListener listener)
Set< IProjectgetProjects ()
void start ()
void stop ()
User getUser (JID jid)
JID getResourceQualifiedJID (JID jid)
User getLocalUser ()
ConcurrentDocumentClient getConcurrentDocumentClient ()
ConcurrentDocumentServer getConcurrentDocumentServer ()
void exec (List< IActivity > activities)
void addActivityProducer (IActivityProducer producer)
void removeActivityProducer (IActivityProducer producer)
void addActivityConsumer (IActivityConsumer consumer)
void removeActivityConsumer (IActivityConsumer consumer)
boolean isShared (IResource resource)
List< IResourcegetSharedResources ()
boolean useVersionControl ()
String getProjectID (IProject project)
IProject getProject (String projectID)
Map< IProject, List< IResource > > getProjectResourcesMapping ()
List< IResourcegetSharedResources (IProject project)
boolean isCompletelyShared (IProject project)
void addProjectMapping (String projectID, IProject project)
void removeProjectMapping (String projectID, IProject project)
Object getComponent (Object key)
StopManager getStopManager ()
void changeColor (int colorID)
Set< Integer > getUnavailableColors ()
void enableQueuing (IProject project)
void disableQueuing ()

Package Functions

boolean hasActivityProducers ()
boolean hasActivityConsumers ()

Detailed Description

TODO Review if SarosSession, ConcurrentDocumentManager, ActivitySequencer all honor start() and stop() semantics.


Constructor & Destructor Documentation

de.fu_berlin.inf.dpp.project.internal.SarosSession.SarosSession ( final String  id,
String  nickname,
int  colorID,
ISarosContext  sarosContext 
)

Constructor for host.

de.fu_berlin.inf.dpp.project.internal.SarosSession.SarosSession ( final String  id,
JID  hostJID,
String  clientNickname,
String  hostNickname,
int  clientColorID,
int  hostColorID,
ISarosContext  sarosContext 
)

Constructor for client.


Member Function Documentation

void de.fu_berlin.inf.dpp.project.internal.SarosSession.addActivityConsumer ( IActivityConsumer  consumer)

Adds an IActivityConsumer so it will be called when an activity is to be executed locally.

Parameters:
consumerThe exec() method of this consumer will be called. "Consume" is not meant in a destructive way: all consumers will be called for every activity.
See also:
removeActivityConsumer(IActivityConsumer)

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.addActivityProducer ( IActivityProducer  producer)

Adds an IActivityProducer so the production of its activities will be noticed.

Parameters:
producerThe session will register an IActivityListener on this producer. It is expected that the producer will inform that listener about new activities via created().
See also:
removeActivityProducer(IActivityProducer)

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.addListener ( ISharedProjectListener  listener)

Adds the given shared project listener. This call is ignored if the listener is already a listener of this session.

Parameters:
listenerThe listener that is to be added.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.addProjectMapping ( String  projectID,
IProject  project 
)

Stores a bidirectional mapping between project and projectID.

This information is necessary for receiving (unserializing) resource-related activities.

Parameters:
projectIDSession-wide ID of the project
projectthe local representation of the project
See also:
removeProjectMapping(String, IProject)

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.addSharedResources ( IProject  project,
String  projectID,
List< IResource dependentResources 
)

Adds the specified project and/or resources to this session.

Parameters:
projectThe project to share.
projectIDThe global project ID.
dependentResourcesThe project dependent resources.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.addUser ( final User  user)
void de.fu_berlin.inf.dpp.project.internal.SarosSession.changeColor ( int  colorID)

Changes the color for the current session. The color change is performed on the session host and may therefore result in a different color id.

Parameters:
colorIDthe new color id that should be used during the session

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.disableQueuing ( )

FOR INTERNAL USE ONLY !

Disables queuing for all shared projects and flushes all queued activities.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.enableQueuing ( IProject  project)

FOR INTERNAL USE ONLY !

Starts queuing of incoming IResourceActivity project-related activities}, since they cannot be applied before their corresponding project is received and extracted.

That queuing relies on an existing project-to-projectID mapping (see addProjectMapping(String, IProject, JID)), otherwise incoming activities cannot be queued and will be lost.

Parameters:
projectthe project for which project-related activities should be queued
See also:
disableQueuing()

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.exec ( List< IActivity activities)

7, Activity sending, Incoming activities:

The ActivitySequencer will call this function for activities received over the Network Layer.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

Object de.fu_berlin.inf.dpp.project.internal.SarosSession.getComponent ( Object  key)

Returns the session runtime component with the given key.

Parameters:
keythe key of the component
Returns:
the runtime component or null if the component is either not available or does not exists
Deprecated:
This method should be used with great care. It is up to to the caller to ensure that the returned reference can be garbage collected when the session has stopped

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

ConcurrentDocumentClient de.fu_berlin.inf.dpp.project.internal.SarosSession.getConcurrentDocumentClient ( )

the concurrent document manager is responsible for all jupiter controlled documents

Returns:
the concurrent document manager

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

ConcurrentDocumentServer de.fu_berlin.inf.dpp.project.internal.SarosSession.getConcurrentDocumentServer ( )

the concurrent document manager is responsible for all jupiter controlled documents

Returns:
the concurrent document manager

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

User de.fu_berlin.inf.dpp.project.internal.SarosSession.getHost ( )

Returns the host of this session.

This method will always return the same value for this session

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

String de.fu_berlin.inf.dpp.project.internal.SarosSession.getID ( )

Returns the id of the current session.

Returns:
the id of the current session

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

User de.fu_berlin.inf.dpp.project.internal.SarosSession.getLocalUser ( )

Returns the local user of this session.

This method will always return the same value for this session

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

IProject de.fu_berlin.inf.dpp.project.internal.SarosSession.getProject ( String  projectID)

Returns the project with the given ID.

Returns:
the project with the given ID or null if no project with this ID is shared

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

String de.fu_berlin.inf.dpp.project.internal.SarosSession.getProjectID ( IProject  project)

Returns the global ID of the project.

Returns:
the global ID of the project or null if this project is not shared

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

Map<IProject, List<IResource> > de.fu_berlin.inf.dpp.project.internal.SarosSession.getProjectResourcesMapping ( )

Returns a map with the mapping of shared resources to their project.

Returns:
project-->resource mapping

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

Set<IProject> de.fu_berlin.inf.dpp.project.internal.SarosSession.getProjects ( )
Returns:
the shared projects associated with this session, never null but may be empty

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<User> de.fu_berlin.inf.dpp.project.internal.SarosSession.getRemoteUsers ( )
Returns:
a list of all remote users of this session

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<User> de.fu_berlin.inf.dpp.project.internal.SarosSession.getRemoteUsersWithReadOnlyAccess ( )

Returns all users in this project which are both remotely and have Permission#READONLY_ACCESS right now.

This is a snapshot copy. This list does not change if users' Permission change.

There is no guarantee that the users in this list will be part of the project after you exit the SWT thread context.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<User> de.fu_berlin.inf.dpp.project.internal.SarosSession.getRemoteUsersWithWriteAccess ( )
JID de.fu_berlin.inf.dpp.project.internal.SarosSession.getResourceQualifiedJID ( JID  jid)

Given a JID (resource qualified or not), will return the resource qualified JID associated with this user or null if no user for the given JID exists in the session.

 E.g:
 
 JID rqJID = session.getResourceQualifiedJID(new JID("alice@foo.com");
 System.out.println(rqJID);
 
 

Will print out something like alice@foo.com/Saros*****

Parameters:
jidthe JID to retrieve the resource qualified JID for
Returns:
the resource qualified JID or null if no user is found with this JID
Deprecated:
Do not use this method in new code, ensure you can obtain a resource qualified JID and use getUser(JID) instead.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<IResource> de.fu_berlin.inf.dpp.project.internal.SarosSession.getSharedResources ( )

Returns all shared resources in this session.

Returns:
a list of all shared resources (excluding projects) from this session.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<IResource> de.fu_berlin.inf.dpp.project.internal.SarosSession.getSharedResources ( IProject  project)

Returns the shared resources of the project in this session.

Parameters:
project
Returns:
the shared resources or null if this project is not or fully shared.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

StopManager de.fu_berlin.inf.dpp.project.internal.SarosSession.getStopManager ( )

Return the stop manager of this session.

Returns:

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

Set<Integer> de.fu_berlin.inf.dpp.project.internal.SarosSession.getUnavailableColors ( )

Returns a snapshot of the currently unavailable (in use) color ids.

Returns:

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

User de.fu_berlin.inf.dpp.project.internal.SarosSession.getUser ( JID  jid)

Given a resource qualified JID, this method will return the user which has the identical ID including resource.

Use getResourceQualifiedJID(JID) in the case if you do not know the RQ-JID.

Returns:
the user with the given fully qualified JID or null if not user with such a JID exists in the session

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<User> de.fu_berlin.inf.dpp.project.internal.SarosSession.getUsers ( )
Returns:
a list of all users of this session

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<User> de.fu_berlin.inf.dpp.project.internal.SarosSession.getUsersWithReadOnlyAccess ( )

Returns a list of all users in this session have Permission#READONLY_ACCESS right now.

This is a snapshot copy. This list does not change if users' Permission change.

There is no guarantee that the users in this list will be part of the project after you exit the SWT thread context.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

List<User> de.fu_berlin.inf.dpp.project.internal.SarosSession.getUsersWithWriteAccess ( )

Returns a list of all users in this session which have Permission#WRITE_ACCESS right now.

This is a snapshot copy. This list does not change if users' Permission change.

There is no guarantee that the users in this list will be part of the project after you exit the SWT thread context.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.hasActivityConsumers ( ) [package]

This method is only meant to be used by unit tests to verify the cleanup of activity producers and consumers.

Returns:
the size of the internal activity consumer collection
boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.hasActivityProducers ( ) [package]

This method is only meant to be used by unit tests to verify the cleanup of activity producers and consumers.

Returns:
the size of the internal activity producer collection
boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.hasExclusiveWriteAccess ( )
Returns:
true, if there is exactly one user with Permission#WRITE_ACCESS, false otherwise.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.hasWriteAccess ( )
Returns:
true if the local user has write access, false otherwise

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.initiatePermissionChange ( final User  user,
final Permission  newPermission 
) throws CancellationException, InterruptedException
boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.isCompletelyShared ( IProject  project)

Checks if selected project is a complete shared one or partial shared.

Parameters:
project
Returns:
true if complete, false if partial

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.isHost ( )
Returns:
true if the local user is the host of this session, false otherwise.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.isShared ( IResource  resource)
Returns:
true if the given resource is currently shared in this session, false otherwise

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.kickUser ( final User  user)
void de.fu_berlin.inf.dpp.project.internal.SarosSession.removeActivityConsumer ( IActivityConsumer  consumer)

Removes an IActivityConsumer from the session

Parameters:
consumerThis consumer will no longer be called when an activity is to be executed locally.
See also:
addActivityConsumer(IActivityConsumer)

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.removeActivityProducer ( IActivityProducer  producer)

Removes an IActivityProducer from the session.

Parameters:
producerThe session will unregister its IActivityListener from this producer and it is expected that the producer no longer calls created().
See also:
addActivityProducer(IActivityProducer)

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.removeListener ( ISharedProjectListener  listener)

Removes the given shared project listener. This call is ignored if the listener does not belong to the current listeners of this session.

Parameters:
listenerthe listener that is to be removed.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.removeProjectMapping ( String  projectID,
IProject  project 
)

Removes the bidirectional mapping project and projectId that was created by addProjectMapping() .

TODO Why is the project parameter needed here? This forces callers to store the mapping themselves (or retrieve it just before calling this method).

Parameters:
projectIDSession-wide ID of the project
projectthe local representation of the project

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.removeUser ( final User  user)
void de.fu_berlin.inf.dpp.project.internal.SarosSession.setPermission ( final User  user,
final Permission  permission 
)
void de.fu_berlin.inf.dpp.project.internal.SarosSession.start ( )

FOR INTERNAL USE ONLY !

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.stop ( )

Stops this session and performing cleanup as necessary. All remote users will also be notified about the local session stop.

Exceptions:
IllegalStateExceptionif the session is already stopped or was not started at all
void de.fu_berlin.inf.dpp.project.internal.SarosSession.userFinishedProjectNegotiation ( final User  user)

Informs all participants and listeners that a user now has finished the Project Negotiation.

Parameters:
user

This informs all participants, that a user is now able to process IResourceActivities. After receiving this message the participants will send their awareness information.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.userHasProject ( User  user,
IProject  project 
)

Checks if the user is ready to process IResourceActivitys for a given project

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

void de.fu_berlin.inf.dpp.project.internal.SarosSession.userStartedQueuing ( final User  user)

Informs all listeners that a user now has Projects and can process IResourceActivitys.

This method may only called by the host.

Parameters:
user

Updates the projects for the given user, so that host knows that he can now send ever Activity

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

boolean de.fu_berlin.inf.dpp.project.internal.SarosSession.useVersionControl ( )

Returns true if VCS support is enabled for this session.

This setting can be changed in the Preferences. VCS support can be disabled during a running session, but enabling VCS support doesn't have any effect.

Returns:
true if this session uses Version Control, otherwise false.

Implements de.fu_berlin.inf.dpp.session.ISarosSession.

 All Classes Namespaces Files Functions Variables Enumerations