org.eclipse.emf.emfstore.internal.client.model.connectionmanager
Class ServerCall<U>

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.model.connectionmanager.ServerCall<U>
Type Parameters:
U - the return type of the wrapped action
All Implemented Interfaces:
APIDelegate<ESServerCall>
Direct Known Subclasses:
CommitController, ExportProjectHistoryController, ImportProjectHistoryController, RevertCommitController, ShareController, UpdateController

public abstract class ServerCall<U>
extends Object
implements APIDelegate<ESServerCall>

This class is intended to wrap all server calls. It may be used either by sub-classing or using anonymous classes.
The SessionManager ensures there's a valid session before executing the call.
For call of the ConnectionManager, always use getSessionId(), since it is injected by the SessionManager.
If initialized with an user session, it will be used for the server class when the SessionProvider isn't extended by the user to change this behavior.
Using serverInfo as an input will call the login dialog in the default implementation. Further, in the default implementation, when the ProjectSpace is set, it is checked whether it has an user session attached to it.

Author:
wesendon, emueller

Constructor Summary
ServerCall()
          Default constructor.
ServerCall(ProjectSpace localProject)
          Default constructor with project space.
ServerCall(ProjectSpace localProject, org.eclipse.core.runtime.IProgressMonitor monitor)
          Default constructor with project space and progress monitor.
ServerCall(ServerInfo server)
          Default constructor with serverinfo.
ServerCall(ServerInfo server, org.eclipse.core.runtime.IProgressMonitor monitor)
          Default constructor with server info and progress monitor.
ServerCall(Usersession usersession)
          Default constructor with user session.
ServerCall(Usersession usersession, org.eclipse.core.runtime.IProgressMonitor monitor)
          Default constructor with user session and progress monitor.
 
Method Summary
 ESServerCall createAPI()
          Creates the API interface for this class.
 U execute()
          Executes the server call.
 org.eclipse.core.runtime.IProgressMonitor getProgressMonitor()
          Returns the progress monitor instance that may be used during execution of this server call.
 ProjectSpaceBase getProjectSpace()
          Returns the project space that will be checked for a valid user session when executing this server call.
 ServerInfo getServer()
          Returns the server info that is used by this server call, if set.
 Usersession getUsersession()
          Returns the user session that is used by this server call.
 void run(SessionId sessionId)
          Runs this call with the given session ID.
 ServerCall<U> setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor monitor)
          Sets the progress monitor instance that may be used during execution of this server call.
 ServerCall<U> setServer(ServerInfo server)
          Sets the server info that is used by this server call.
 void setSessionId(SessionId sessionId)
          Sets the session ID to be used by this server call.
 ServerCall<U> setUsersession(Usersession usersession)
          Sets the user session to be used by this server call.
 ESServerCall toAPI()
          Returns the API interface of this class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerCall

public ServerCall()
Default constructor.


ServerCall

public ServerCall(Usersession usersession)
Default constructor with user session.

Parameters:
usersession - preselected user session

ServerCall

public ServerCall(ProjectSpace localProject)
Default constructor with project space.

Parameters:
localProject - relevant project space if existent

ServerCall

public ServerCall(ServerInfo server)
Default constructor with serverinfo.

Parameters:
server - a given server

ServerCall

public ServerCall(Usersession usersession,
                  org.eclipse.core.runtime.IProgressMonitor monitor)
Default constructor with user session and progress monitor.

Parameters:
usersession - preselected user session
monitor - monitor a progress monitor instance that is used during execution of the server call

ServerCall

public ServerCall(ProjectSpace localProject,
                  org.eclipse.core.runtime.IProgressMonitor monitor)
Default constructor with project space and progress monitor.

Parameters:
localProject - relevant project, if existent
monitor - monitor a progress monitor instance that is used during execution of the server call

ServerCall

public ServerCall(ServerInfo server,
                  org.eclipse.core.runtime.IProgressMonitor monitor)
Default constructor with server info and progress monitor.

Parameters:
server - a given server info
monitor - monitor a progress monitor instance that is used during execution of the server call
Method Detail

getServer

public ServerInfo getServer()
Returns the server info that is used by this server call, if set.

Returns:
the server info that is used by this server call, if set

setServer

public ServerCall<U> setServer(ServerInfo server)
Sets the server info that is used by this server call.

Parameters:
server - the server info that should be used by this server call
Returns:
the server call itself

setUsersession

public ServerCall<U> setUsersession(Usersession usersession)
Sets the user session to be used by this server call.

Parameters:
usersession - the user session to be used by the server call
Returns:
the server call itself

getUsersession

public Usersession getUsersession()
Returns the user session that is used by this server call.

Returns:
the user session in use

getProjectSpace

public ProjectSpaceBase getProjectSpace()
Returns the project space that will be checked for a valid user session when executing this server call.

Returns:
the project space that will be checked for a valid user session

setProgressMonitor

public ServerCall<U> setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor monitor)
Sets the progress monitor instance that may be used during execution of this server call.

Parameters:
monitor - a progress monitor instance that may used during execution of this server call
Returns:
the server call itself

getProgressMonitor

public org.eclipse.core.runtime.IProgressMonitor getProgressMonitor()
Returns the progress monitor instance that may be used during execution of this server call.

Returns:
the progress monitor instance that may be used during execution of this server call

setSessionId

public void setSessionId(SessionId sessionId)
Sets the session ID to be used by this server call.

Parameters:
sessionId - the session ID to be used for authentication against the server

run

public void run(SessionId sessionId)
         throws ESException
Runs this call with the given session ID.

Parameters:
sessionId - the session ID to be used for authentication against the server
Throws:
ESException - in case any exception occurs during execution of the call

execute

public U execute()
          throws ESException
Executes the server call.

Returns:
a return value of type U
Throws:
ESException - in case any exception occurs during execution of the call

toAPI

public ESServerCall toAPI()
Returns the API interface of this class.

Specified by:
toAPI in interface APIDelegate<ESServerCall>
Returns:
the API interface of this class
See Also:
APIDelegate.toAPI()

createAPI

public ESServerCall createAPI()
Creates the API interface for this class.

Specified by:
createAPI in interface APIDelegate<ESServerCall>
Returns:
the API interface of this class
See Also:
APIDelegate.createAPI()


Copyright © 2015. All Rights Reserved.