Package org.exoplatform.onlyoffice.rest
Class EditorService
- java.lang.Object
-
- org.exoplatform.onlyoffice.rest.EditorService
-
- All Implemented Interfaces:
org.exoplatform.services.rest.resource.ResourceContainer
public class EditorService extends Object implements org.exoplatform.services.rest.resource.ResourceContainer
REST service implementing Onlyoffice config storage service.
Created by The eXo Platform SAS.- Version:
- $Id: EditorService.java 00000 Feb 12, 2016 pnedonosko $
- Author:
- Peter Nedonosko
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPI_VERSIONThe Constant API_VERSION.protected OnlyofficeEditorServiceeditorsThe editors.protected Map<UUID,Config>initiatedThe initiated.protected static org.exoplatform.services.log.LogLOGThe Constant LOG.
-
Constructor Summary
Constructors Constructor Description EditorService(OnlyofficeEditorService editors)REST cloudDrives usesOnlyofficeEditorServicefor actual job.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.ResponseconfigPost(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request, String workspace, String path)Create configuration for Onlyoffice JS.javax.ws.rs.core.Responsecontent(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request, String userId, String key)Document content download link.protected StringgetClientHost(javax.servlet.http.HttpServletRequest request)Gets the client host.protected StringgetClientIpAddr(javax.servlet.http.HttpServletRequest request)Gets the client ip addr.javax.ws.rs.core.ResponsegetVersions(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request, String workspace, String key, int itemParPage, int pageNum)Getting versions of the given documentprotected booleanisValidHost(String host)Checks if is valid host.javax.ws.rs.core.ResponselocalState(javax.ws.rs.core.UriInfo uriInfo, String userId, String key)Editing document state in local storage.protected booleannotEmpty(String str)Check string is not empty.javax.ws.rs.core.Responsestatus(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request, String userId, String key, String statusText)Config status posted from the Document Server.javax.ws.rs.core.ResponseversionGet(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request)Return Onlyoffice REST API version.javax.ws.rs.core.ResponseviewerConfig(javax.servlet.http.HttpServletRequest request, String workspace, String fileId)Viewer config.
-
-
-
Field Detail
-
API_VERSION
public static final String API_VERSION
The Constant API_VERSION.- See Also:
- Constant Field Values
-
LOG
protected static final org.exoplatform.services.log.Log LOG
The Constant LOG.
-
editors
protected final OnlyofficeEditorService editors
The editors.
-
-
Constructor Detail
-
EditorService
public EditorService(OnlyofficeEditorService editors)
REST cloudDrives usesOnlyofficeEditorServicefor actual job.- Parameters:
editors- the editors
-
-
Method Detail
-
status
public javax.ws.rs.core.Response status(@Context javax.ws.rs.core.UriInfo uriInfo, @Context javax.servlet.http.HttpServletRequest request, String userId, String key, String statusText)Config status posted from the Document Server.
WARNING! It is publicly accessible service but access from the Documents Server host can be restricted (by default).- Parameters:
uriInfo- - request inforequest- the requestuserId- the user idkey- - config key generated when requested editor configstatusText- the status text- Returns:
Response
-
content
public javax.ws.rs.core.Response content(@Context javax.ws.rs.core.UriInfo uriInfo, @Context javax.servlet.http.HttpServletRequest request, String userId, String key)Document content download link.
WARNING! It is publicly accessible service but access from the Documents Server host can be restricted (by default).- Parameters:
uriInfo- - request inforequest- the requestuserId- the user idkey- - file key generated by /config method- Returns:
Response
-
viewerConfig
public javax.ws.rs.core.Response viewerConfig(@Context javax.servlet.http.HttpServletRequest request, String workspace, String fileId)Viewer config.- Parameters:
request- the requestworkspace- the workspacefileId- the file id- Returns:
- the response
-
configPost
@RolesAllowed("users") public javax.ws.rs.core.Response configPost(@Context javax.ws.rs.core.UriInfo uriInfo, @Context javax.servlet.http.HttpServletRequest request, String workspace, String path)Create configuration for Onlyoffice JS.- Parameters:
uriInfo- - request with base URIrequest- the requestworkspace- the workspacepath- the path- Returns:
- response with
-
versionGet
public javax.ws.rs.core.Response versionGet(@Context javax.ws.rs.core.UriInfo uriInfo, @Context javax.servlet.http.HttpServletRequest request)Return Onlyoffice REST API version.- Parameters:
uriInfo- - request with base URIrequest- the request- Returns:
- response with
-
localState
@RolesAllowed("users") public javax.ws.rs.core.Response localState(@Context javax.ws.rs.core.UriInfo uriInfo, String userId, String key)Editing document state in local storage.- Parameters:
uriInfo- - request infouserId- the user idkey- - config key generated when requested editor config- Returns:
Response
-
getVersions
@RolesAllowed("users") public javax.ws.rs.core.Response getVersions(@Context javax.ws.rs.core.UriInfo uriInfo, @Context javax.servlet.http.HttpServletRequest request, String workspace, String key, int itemParPage, int pageNum)Getting versions of the given document- Parameters:
uriInfo- the request inforequest- the requestworkspace- the document workspacekey- the document keyitemParPage- the versions par pagepageNum- the page number to load- Returns:
Response
-
getClientIpAddr
protected String getClientIpAddr(javax.servlet.http.HttpServletRequest request)
Gets the client ip addr.- Parameters:
request- the request- Returns:
- the client ip addr
-
getClientHost
protected String getClientHost(javax.servlet.http.HttpServletRequest request)
Gets the client host.- Parameters:
request- the request- Returns:
- the client host
-
notEmpty
protected boolean notEmpty(String str)
Check string is not empty.- Parameters:
str- the str- Returns:
- true, if not empty, false otherwise
-
isValidHost
protected boolean isValidHost(String host)
Checks if is valid host. It's a trivial check fornull, non empty string and not "unknown" text.- Parameters:
host- the host name or IP address- Returns:
- true, if is valid host
-
-