Package de.espirit.firstspirit.access
Interface Connection
- All Superinterfaces:
AutoCloseable
,Closeable
,ServicesBroker
Connection to a FirstSpirit server.
- Since:
- 2.3
-
Field Summary
Fields inherited from interface de.espirit.firstspirit.access.ServicesBroker
TYPE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
Connects the server.Creates a one-time FS SSO ticket for the user of this connection.createTicket
(boolean oneTimeTicket) Creates a FS SSO ticket for the user of this connection.void
Disconnects from the server and clears all services.@NotNull SpecialistsBroker
Returns broker without project binding.@NotNull ClassLoader
Returns a class loader which can load classes from the server and from module libraries.de.espirit.firstspirit.access.ExceptionHandler
Returns currentExceptionHandler
.getHost()
Get server hostint
getMode()
Get the connection mode, eitherConnectionManager.HTTP_MODE
orConnectionManager.SOCKET_MODE
.int
getPort()
Get server port@Nullable Project
getProjectById
(long id) Return a project with a specific id ornull
if no project exists with the given id or the project is not visible for the current user.@Nullable Project
getProjectByName
(String name) Return a project with a specific name ornull
if no project exists with the specified name.Project[]
Get all active projects allowed for the current user.
Checks if the current user is server admin and is allowed to edit a project using java client or webedit.
UseProjectStorage.getProjects(boolean)
to get projects unfiltered.Returns the remote connection specified by the givenRemoteProjectConfiguration
.Returns server properties.@NotNull Object
getService
(String serviceName) Returns a service instance for the given name.@Nullable String
Get servlet zone, used in HTTP mode only for constructing the connection URL.getUser()
Return the user of the current sessionboolean
Returnstrue
if this connection is connected and working.boolean
isRemote()
Indicates whether this connection is related to a remote project (based on aRemoteProjectConfiguration
) or not.void
removeTicket
(String ticket) Destroys the giventicket
; neccessary for long-life tickets created withcreateTicket(false)
!void
setExceptionHandler
(de.espirit.firstspirit.access.ExceptionHandler handler) Sets theExceptionHandler
for this connection.Methods inherited from interface de.espirit.firstspirit.access.ServicesBroker
getService
-
Method Details
-
connect
void connect() throws IOException, AuthenticationException, MaximumNumberOfSessionsExceededExceptionConnects the server.- Throws:
AuthenticationException
- if the authentication of the belonging user failedMaximumNumberOfSessionsExceededException
- if the maximum number of allowed sessions (license value) exceededIOException
- Since:
- 2.3
-
isConnected
boolean isConnected()Returnstrue
if this connection is connected and working. Returnsfalse
if the connection is not connected or is stalled and has IO problems.
Important: Connection problems, detected during this call, can cause adisconnect
.- Returns:
true
if this connection is connected and working.- Since:
- 2.3
-
disconnect
Disconnects from the server and clears all services. This method can be called even if the connection is already disconnected.- Throws:
IOException
- Since:
- 2.3
-
getHost
String getHost()Get server host- Returns:
- The hostname
- Since:
- 3.0.4
-
getPort
int getPort()Get server port- Returns:
- The portnumber
- Since:
- 3.0.4
-
getMode
int getMode()Get the connection mode, eitherConnectionManager.HTTP_MODE
orConnectionManager.SOCKET_MODE
.- Returns:
ConnectionManager.HTTP_MODE
orConnectionManager.SOCKET_MODE
- Since:
- 3.0.4
-
getServletZone
Get servlet zone, used in HTTP mode only for constructing the connection URL. URL schema: http://host:port/servletZone/do.ClientIOServlet- Returns:
- The servlet zone
- Since:
- 4.0.95
-
getBroker
Returns broker without project binding. Request thebroker agent
of given specialists broker toget hold of a broker with project relation
.- Since:
- 5.0.207
-
getProjects
Project[] getProjects()Get all active projects allowed for the current user.
Checks if the current user is server admin and is allowed to edit a project using java client or webedit.
UseProjectStorage.getProjects(boolean)
to get projects unfiltered.- Returns:
- the projects
- Since:
- 2.3
-
getProjectByName
Return a project with a specific name ornull
if no project exists with the specified name.- Parameters:
name
- name of the project- Returns:
- the project or
null
if no project exists with the specified name. - Since:
- 2.3.17
-
getProjectById
Return a project with a specific id ornull
if no project exists with the given id or the project is not visible for the current user.- Parameters:
id
- id of the project- Returns:
- the project or
null
if no project exists with the given id or the project is not visible for the current user. - Since:
- 4.0.17
-
getUser
Return the user of the current session- Returns:
- the user
- Throws:
InvalidSessionException
- Since:
- 2.3.23
-
getService
Returns a service instance for the given name.- Parameters:
serviceName
- The name of the service to look up.- Returns:
- A service instance.
- Throws:
ServiceNotFoundException
- If no appropriate service was found.- Since:
- 3.0.133
-
createTicket
String createTicket()Creates a one-time FS SSO ticket for the user of this connection. This kind of ticket can be used only once and will expire after a short amount of time. For long-life tickets usecreateTicket(false)
.- Returns:
- a one-time FS SSO ticket for the user of this connection.
- Since:
- 4.0.17
-
createTicket
Creates a FS SSO ticket for the user of this connection. One-time-tickets can be used only once and will expire after a short amount of time. Long-life-tickets are free of such restrictions but must beinvalidated
manually!- Parameters:
oneTimeTicket
-true
for one-time-tickets,false
for long-life-tickets.- Returns:
- a FS SSO ticket for the user of this connection.
- Since:
- 4.0.17
- See Also:
-
removeTicket
Destroys the giventicket
; neccessary for long-life tickets created withcreateTicket(false)
!- Parameters:
ticket
- Ticket to destroy.- Since:
- 4.0.17
- See Also:
-
getRemoteConnection
Connection getRemoteConnection(RemoteProjectConfiguration config) throws IOException, AuthenticationException, MaximumNumberOfSessionsExceededException Returns the remote connection specified by the givenRemoteProjectConfiguration
. If already existing the cached remote connection will be returned, otherwise a new connection will be established with the given remote config params.- Parameters:
config
- the remote configuration params to specifiy the connection- Returns:
- the remote connection specified by the given
RemoteProjectConfiguration
. - Throws:
IOException
AuthenticationException
MaximumNumberOfSessionsExceededException
- Since:
- 4.0.17
-
isRemote
boolean isRemote()Indicates whether this connection is related to a remote project (based on aRemoteProjectConfiguration
) or not.- Returns:
true
if this connection is a related to a remote project.- Since:
- 4.0.17
-
getExceptionHandler
de.espirit.firstspirit.access.ExceptionHandler getExceptionHandler()Returns currentExceptionHandler
.- Returns:
- current
ExceptionHandler
. - Since:
- 4.0.17
-
setExceptionHandler
void setExceptionHandler(de.espirit.firstspirit.access.ExceptionHandler handler) Sets theExceptionHandler
for this connection.- Parameters:
handler
- newExceptionHandler
.- Since:
- 4.0.17
-
getServerConfiguration
ServerConfiguration getServerConfiguration()Returns server properties.- Returns:
- server properties.
- Since:
- 4.0.17
-
getClassLoader
Returns a class loader which can load classes from the server and from module libraries.- Since:
- 4.0.52
-