Class OnlyOfficeManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.workspaces.documents.onlyoffice.OnlyOfficeManager
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class OnlyOfficeManager extends AbstractLogEnabled implements Component, Serviceable
Main helper for OnlyOffice edition
-
-
Field Summary
Fields Modifier and Type Field Description protected CurrentUserProvider
_currentUserProvider
The current user providerprotected JSONUtils
_jsonUtils
The JSON utilsprotected OnlyOfficeKeyManager
_onlyOfficeKeyManager
The Only Office key managerprotected AmetysObjectResolver
_resolver
The Ametys object resolverprotected SourceResolver
_sourceResolver
The source resolverprotected AuthenticationTokenManager
_tokenManager
The token managerstatic String
ROLE
The Avalon rolestatic String
THUMBNAIL_FILE_PATH
The path for thumbnail filestatic String
WORKSPACE_PATH_CACHE
The path for workspace cache
-
Constructor Summary
Constructors Constructor Description OnlyOfficeManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_generatePNGFileInCache(String projectName, String uri, String fileId)
Generate a png file from the uriboolean
canBePreviewed(String resourceId)
Determines if the resource file can have a preview of thumbnail from only officevoid
deleteProjectThumbnailsInCache(String projectName)
Delete project thumbnails in cachevoid
deleteThumbnailInCache(String projectName, String resourceId)
Delete thumbnail in cacheboolean
generateThumbnailInCache(String projectName, String resourceId, UserIdentity user)
Generate thumbnail of the resource as pngString
generateToken(String fileId)
Generate a token for OnlyOffice useMap<String,Object>
getOnlyOfficeInfo(String resourceId)
Get the needed information for Only Office editionFile
getThumbnailFile(String projectName, String resourceId)
Get thumbnail fileboolean
isOnlyOfficeAvailable()
Determines if OnlyOffice edition is availablevoid
service(ServiceManager manager)
Map<String,Object>
signConfiguration(String toSign)
Sign a json configuration for OnlyOffice using a secret parametrized key-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
WORKSPACE_PATH_CACHE
public static final String WORKSPACE_PATH_CACHE
The path for workspace cache- See Also:
- Constant Field Values
-
THUMBNAIL_FILE_PATH
public static final String THUMBNAIL_FILE_PATH
The path for thumbnail file- See Also:
- Constant Field Values
-
_tokenManager
protected AuthenticationTokenManager _tokenManager
The token manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_onlyOfficeKeyManager
protected OnlyOfficeKeyManager _onlyOfficeKeyManager
The Only Office key manager
-
_jsonUtils
protected JSONUtils _jsonUtils
The JSON utils
-
_sourceResolver
protected SourceResolver _sourceResolver
The source resolver
-
-
Constructor Detail
-
OnlyOfficeManager
public OnlyOfficeManager()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
isOnlyOfficeAvailable
public boolean isOnlyOfficeAvailable()
Determines if OnlyOffice edition is available- Returns:
- true if OnlyOffice edition is available
-
getOnlyOfficeInfo
public Map<String,Object> getOnlyOfficeInfo(String resourceId)
Get the needed information for Only Office edition- Parameters:
resourceId
- the id of resource to edit- Returns:
- the only office informations
-
generateToken
public String generateToken(String fileId)
Generate a token for OnlyOffice use- Parameters:
fileId
- id of the resource that will be used by OnlyOffice- Returns:
- the token
-
signConfiguration
public Map<String,Object> signConfiguration(String toSign)
Sign a json configuration for OnlyOffice using a secret parametrized key- Parameters:
toSign
- The json to sign- Returns:
- The signed json
-
canBePreviewed
public boolean canBePreviewed(String resourceId)
Determines if the resource file can have a preview of thumbnail from only office- Parameters:
resourceId
- the resource id- Returns:
true
if resource file can have a preview of thumbnail from only office
-
generateThumbnailInCache
public boolean generateThumbnailInCache(String projectName, String resourceId, UserIdentity user)
Generate thumbnail of the resource as png- Parameters:
projectName
- the project nameresourceId
- the resource iduser
- the user generating the thumbnail- Returns:
true
is the thumbnail is generated
-
deleteThumbnailInCache
public void deleteThumbnailInCache(String projectName, String resourceId)
Delete thumbnail in cache- Parameters:
projectName
- the project nameresourceId
- the resourceId id
-
deleteProjectThumbnailsInCache
public void deleteProjectThumbnailsInCache(String projectName)
Delete project thumbnails in cache- Parameters:
projectName
- the project name
-
_generatePNGFileInCache
protected void _generatePNGFileInCache(String projectName, String uri, String fileId) throws IOException
Generate a png file from the uri- Parameters:
projectName
- the project nameuri
- the urifileId
- the id of the file- Throws:
IOException
- if an error occurred
-
getThumbnailFile
public File getThumbnailFile(String projectName, String resourceId)
Get thumbnail file- Parameters:
projectName
- the project nameresourceId
- the resource id- Returns:
- the thumbnail file. Can be
null
if doesn't exist.
-
-