Class DefaultWopiFileEditionManager
- java.lang.Object
-
- org.silverpeas.core.wopi.DefaultWopiFileEditionManager
-
- All Implemented Interfaces:
Initialization
,WopiFileEditionManager
@Service public class DefaultWopiFileEditionManager extends Object implements WopiFileEditionManager, Initialization
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultWopiFileEditionManager.WopiCacheCleanerJob
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultWopiFileEditionManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enable(boolean enable)
Enables the services.List<WopiFile>
getEditedFilesBy(WopiUser user)
Gets the list of file edited by the given user.<R> R
getEditionContextFrom(String fileId, String accessToken, BiFunction<Optional<WopiUser>,Optional<WopiFile>,R> contextInitializer)
Gets the edition context from a WOPI file identifier and an access token.List<WopiUser>
getEditorsOfFile(WopiFile file)
Gets the list of users which are editor of the given file.void
init()
Initializes some resources required by the services or performs some initialization processes at Silverpeas startup.boolean
isEnabled()
Indicates if the WOPI edition is enabled.boolean
isHandled(WopiFile file)
Indicates if givenWopiFile
is handled by WOPI client.List<WopiFile>
listCurrentFiles()
Gets the list of WOPI files from the context.List<WopiUser>
listCurrentUsers()
Gets the list of WOPI users from the context.void
notifyEditionWith(WopiFile file, Set<String> userIds)
Notifies the manager of the number of users which are editing the given file at an instant.Optional<WopiEdition>
prepareEditionWith(SilverpeasUserSession spUserSession, WopiFile anyFile)
Prepares a WOPI edition from given data.void
revokeFile(WopiFile file)
Revokes from the WOPI edition context the given WOPI file.void
revokeUser(WopiUser user)
Revokes from the WOPI edition context the given WOPI user.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.initialization.Initialization
getPriority, release
-
-
-
-
Method Detail
-
init
public void init() throws Exception
Description copied from interface:Initialization
Initializes some resources required by the services or performs some initialization processes at Silverpeas startup.- Specified by:
init
in interfaceInitialization
- Throws:
Exception
- if an error occurs during the initialization process. In this case the Silverpeas startup fails.
-
notifyEditionWith
public void notifyEditionWith(WopiFile file, Set<String> userIds)
Description copied from interface:WopiFileEditionManager
Notifies the manager of the number of users which are editing the given file at an instant.- Specified by:
notifyEditionWith
in interfaceWopiFileEditionManager
- Parameters:
file
- aWopiFile
a file.userIds
- set of wopi user identifiers.
-
getEditedFilesBy
public List<WopiFile> getEditedFilesBy(WopiUser user)
Description copied from interface:WopiFileEditionManager
Gets the list of file edited by the given user.- Specified by:
getEditedFilesBy
in interfaceWopiFileEditionManager
- Parameters:
user
- aWopiUser
instance.- Returns:
- a list of
WopiFile
.
-
getEditorsOfFile
public List<WopiUser> getEditorsOfFile(WopiFile file)
Description copied from interface:WopiFileEditionManager
Gets the list of users which are editor of the given file.- Specified by:
getEditorsOfFile
in interfaceWopiFileEditionManager
- Parameters:
file
- aWopiFile
instance.- Returns:
- a list of
WopiUser
.
-
enable
public void enable(boolean enable)
Description copied from interface:WopiFileEditionManager
Enables the services.This usable only in the case of WOPI is enable by setting property file.
When enabled by setting file, it is possible the enable/disable the services in order to get as fast as possible control on WOPI exchanges.- Specified by:
enable
in interfaceWopiFileEditionManager
- Parameters:
enable
- true to enable, false to disable.
-
isEnabled
public boolean isEnabled()
Description copied from interface:WopiFileEditionManager
Indicates if the WOPI edition is enabled.- Specified by:
isEnabled
in interfaceWopiFileEditionManager
- Returns:
- true if enabled, false otherwise.
-
isHandled
public boolean isHandled(WopiFile file)
Description copied from interface:WopiFileEditionManager
Indicates if givenWopiFile
is handled by WOPI client.- Specified by:
isHandled
in interfaceWopiFileEditionManager
- Parameters:
file
- the wopi file to check.- Returns:
- true if handled, false otherwise.
-
prepareEditionWith
public Optional<WopiEdition> prepareEditionWith(SilverpeasUserSession spUserSession, WopiFile anyFile)
Description copied from interface:WopiFileEditionManager
Prepares a WOPI edition from given data.If WOPI is enabled and if the file is handled by the WOPI client, a
WopiEdition
instance is returned. It contains the necessary data to initialize an edition from the WEB services.- Specified by:
prepareEditionWith
in interfaceWopiFileEditionManager
- Parameters:
spUserSession
- the silverpeas session from which the edition is needed.anyFile
- a Silverpeas's WOPI file.- Returns:
- an optional
WopiEdition
instance.
-
getEditionContextFrom
public <R> R getEditionContextFrom(String fileId, String accessToken, BiFunction<Optional<WopiUser>,Optional<WopiFile>,R> contextInitializer)
Description copied from interface:WopiFileEditionManager
Gets the edition context from a WOPI file identifier and an access token.If no file exists into context against the given file identifier, then the given optional WOPI file to context initializer is empty.
If no user exists into context against the given access token, then the given optional WOPI user to context initializer is empty.
- Specified by:
getEditionContextFrom
in interfaceWopiFileEditionManager
- Type Parameters:
R
- the type of the context.- Parameters:
fileId
- a file identifier as string.accessToken
- an access token as string.contextInitializer
- the context initializer.- Returns:
- an initialized context.
-
revokeUser
public void revokeUser(WopiUser user)
Description copied from interface:WopiFileEditionManager
Revokes from the WOPI edition context the given WOPI user.The revocation is done from instance data and not directly from the instance reference.
- Specified by:
revokeUser
in interfaceWopiFileEditionManager
- Parameters:
user
- aWopiUser
instance.
-
revokeFile
public void revokeFile(WopiFile file)
Description copied from interface:WopiFileEditionManager
Revokes from the WOPI edition context the given WOPI file.The revocation is done from instance data and not directly from the instance reference.
- Specified by:
revokeFile
in interfaceWopiFileEditionManager
- Parameters:
file
- aWopiFile
instance.
-
listCurrentUsers
public List<WopiUser> listCurrentUsers()
Description copied from interface:WopiFileEditionManager
Gets the list of WOPI users from the context.- Specified by:
listCurrentUsers
in interfaceWopiFileEditionManager
- Returns:
- a list of
WopiUser
instances.
-
listCurrentFiles
public List<WopiFile> listCurrentFiles()
Description copied from interface:WopiFileEditionManager
Gets the list of WOPI files from the context.- Specified by:
listCurrentFiles
in interfaceWopiFileEditionManager
- Returns:
- a list of
WopiFile
instances.
-
-