spring-content icon indicating copy to clipboard operation
spring-content copied to clipboard

Support for LibreOffice Online

Open lmtoo opened this issue 4 years ago • 11 comments

Hi, @paulcwarren , I found LibreOffice Online support office web preview and edit, but this required wopi or webdav protocol, there is also a docker image docker pull collabora/code:latest which can quickly startup with Nextcloud , is spring-content can support this with new wopi or webdav module?

There is WOPI REST API Reference

lmtoo avatar Oct 16 '20 05:10 lmtoo

Hi @lmtoo, this is cool. I have created several webdav implementations over the years so this one is more familiar to me but might be quite involved.

But WOPI might be more focussed API and therefore easier to implement. I wonder if we could get away with implementing just GetFile, PutFile and DeleteFile?

Either way though this may look a lot like the CMIS support whereby the developer would decorate his entity model/repository/stores with @Webdav or @Wopi annotations that would drive the integration.

paulcwarren avatar Oct 20 '20 05:10 paulcwarren

Looking at this C# example it doesnt look too hard at all to implement actually so this might be completely dooable - at least for a very simple GetFile, PutFile and we can iterate on it from there.

paulcwarren avatar Oct 20 '20 05:10 paulcwarren

Hi, @paulcwarren , I found a document about to intergration, but I have a little confusing about it , How web app to intergration libreOffice online

lmtoo avatar Jan 14 '21 06:01 lmtoo

I'm also having trouble parsing all of this too. The documentation is definitely not great. I was looking at NextCloud and Collabora Code.

What i have worked out so far...

I think NextCloud would be like our web apps. It has an iframe in it that hosts a document editor. I think Collabora is a distribution/variant of LibreOffice. It is the document editor and a WOPI client. Spring Content would be a WOPI host (server).

I think the way it works is that the webapp calls a "discovery" endpoint (unclear to me what serves this endpoint) that returns an XML document that tells the webapp about the WOPI host and the URLs for each type of document and each type of operation. This allows the webapp to invoke an editing session on a document.

paulcwarren avatar Jan 19 '21 07:01 paulcwarren

I've had some success today. Here is what I did.

  1. I created a sample Spring Boot webapp and added a host html page based on this example.

form action: http://localhost:9980/loleaflet/eec532f/loleaflet.html?WOPISrc=http%3A%2F%2F192.168.0.242%3A8080%2Fwopi%2Ffiles%2Fabcdef0123456789 access_token=12345 access_token_ttl=31536000

  1. I also added a couple of WOPI endpoints:
    @RestController
    public static class WopiController {

        @RequestMapping(method=RequestMethod.GET, value="/wopi/files/{fileId}", produces="application/json")
        public String wopiFile() {
            return
                    "{" +
                    "\"BaseFileName\":\"helloworld.txt\"," +
                    "\"OwnerId\":\"me\"," +
                    "\"Size\":\"12\"," +
                    "\"UserId\":\"me\"" +
                    "}";

        }


        @RequestMapping(method=RequestMethod.GET, value="/wopi/files/{fileId}/contents")
        public String wopiFileContent() {
            return "Hello World!";
        }
    }
  1. I started this server on port 8080. I made sure I knew the IP address of my machine. 192.168.0.242 in my case.
  2. I ran the collabora code docker container as follows:

docker run -t -d -p 9980:9980 -e "domain=192\\.168\\.0\\.242:8080" -e "username=admin" -e "password=secret" --restart always -e "extra_params=--o:ssl.enable=false" --cap-add MKNOD collabora/code

  1. I requested http://localhost:9980/index.html in my browser. I can see it hit my wopi endpoints and serves the content.
  2. I can see libre office attempts to start-up but seems to get stuck: Screen Shot 2021-01-19 at 11 15 47 PM )
  3. If I inspect the collabora code logs (docker logs -f <container-id>) I see a suspicious error:
kit-00041-00034 2021-01-20 07:15:23.061148 [ kitbroker_002 ] ERR  Failed to get LoKitDocument instance for [file:///tmp/user/docs/XR3dpjeX975SKzQE/helloworld.txt].| kit/ChildSession.cpp:634

So, maybe almost there? Anyway, some progress in understanding how this all works.

HTH

paulcwarren avatar Jan 20 '21 07:01 paulcwarren

Made some more progress.

I think I have a good idea how to implement this now.

paulcwarren avatar Jan 21 '21 06:01 paulcwarren

Great, I have tried this out , thanks so much

lmtoo avatar Jan 21 '21 15:01 lmtoo

So, I have a pretty good idea how to build this now.

I think it will look like the CMIS module. From a Developer perspective you'll be able to decorate your entity classes with an @WopiDoc annotation and SC will provide the WOPI endpoints that will expose those documents.

Thinking we'll implement files only at this point.

paulcwarren avatar Jan 21 '21 17:01 paulcwarren

Any Plans to implement this in near future ?

anuragpathak21 avatar Feb 24 '21 09:02 anuragpathak21

We can certainly consider adding some level of experimental support for this in the near term @anuragpathak21. I only figured out individual file access. Would that be sufficient for you?

paulcwarren avatar Feb 25 '21 06:02 paulcwarren

We can certainly consider adding some level of experimental support for this in the near term @anuragpathak21. I only figured out individual file access. Would that be sufficient for you?

Individual file will work

anuragpathak21 avatar Feb 25 '21 07:02 anuragpathak21