Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.ws.rs.core.Response configPost​(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request, String workspace, String path)
      Create configuration for Onlyoffice JS.
      javax.ws.rs.core.Response content​(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request, String userId, String key)
      Document content download link.
      protected String getClientHost​(javax.servlet.http.HttpServletRequest request)
      Gets the client host.
      protected String getClientIpAddr​(javax.servlet.http.HttpServletRequest request)
      Gets the client ip addr.
      javax.ws.rs.core.Response getVersions​(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request, String workspace, String key, int itemParPage, int pageNum)
      Getting versions of the given document
      protected boolean isValidHost​(String host)
      Checks if is valid host.
      javax.ws.rs.core.Response localState​(javax.ws.rs.core.UriInfo uriInfo, String userId, String key)
      Editing document state in local storage.
      protected boolean notEmpty​(String str)
      Check string is not empty.
      javax.ws.rs.core.Response status​(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.Response versionGet​(javax.ws.rs.core.UriInfo uriInfo, javax.servlet.http.HttpServletRequest request)
      Return Onlyoffice REST API version.
      javax.ws.rs.core.Response viewerConfig​(javax.servlet.http.HttpServletRequest request, String workspace, String fileId)
      Viewer config.
    • Field Detail

      • LOG

        protected static final org.exoplatform.services.log.Log LOG
        The Constant LOG.
      • initiated

        protected final Map<UUID,​Config> initiated
        The initiated.
    • 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 info
        request - the request
        userId - the user id
        key - - config key generated when requested editor config
        statusText - 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 info
        request - the request
        userId - the user id
        key - - 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 request
        workspace - the workspace
        fileId - 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 URI
        request - the request
        workspace - the workspace
        path - 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 URI
        request - 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 info
        userId - the user id
        key - - 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 info
        request - the request
        workspace - the document workspace
        key - the document key
        itemParPage - the versions par page
        pageNum - 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 for null, non empty string and not "unknown" text.
        Parameters:
        host - the host name or IP address
        Returns:
        true, if is valid host