WebDAV - LibreOffice

Hi,

LibreOffice has support for the WebDAV protocol.
In webdav.applications, I added an entry:

{"vnd.libreoffice.command":{"name":"LibreOffice","protocols":{"writable":"vnd.libreoffice.command:ofe%7Cu%7C","read_only":"vnd.libreoffice.command:ofv%7Cu%7C"},"extensions":["odt","doc","docx","xls"]}}

Windows registry entry:

[HKEY_CLASSES_ROOT\vnd.libreoffice.command]
@="URL:vnd.libreoffice.command"
"URL Protocol"=""
"UseOriginalUrlEncoding"=dword:00000001

[HKEY_CLASSES_ROOT\vnd.libreoffice.command\DefaultIcon]
@="C:\\Program Files\\LibreOffice\\program\\soffice.bin,0"

[HKEY_CLASSES_ROOT\vnd.libreoffice.command\shell]

[HKEY_CLASSES_ROOT\vnd.libreoffice.command\shell\open]

[HKEY_CLASSES_ROOT\vnd.libreoffice.command\shell\open\command]
@="\"C:\\Program Files\\LibreOffice\\program\\swriter.exe\" \"%1\""

but LibreOffice does not open the remote file (only the splash screen is shown).

Regards
Marcin

I found reason.
WebDav module incorrectly generates a url in Location header

Is:
vnd.libreoffice.command:ofe%7Cu%7Chttp://localhost:8080/app/webdav/document/4403cc97-bce8-27c1-d3c5-49562d5639c7/test.odt

Should be:
vnd.libreoffice.command:ofe|u|http://localhost:8080/app/webdav/document/4403cc97-bce8-27c1-d3c5-49562d5639c7/test.odt

If I paste correct url in FireFox, LibreOffice opens the file, but can not save it.

Regards
Marcin

@marcin.zawadowicz,

There is a bit of information in this thread. We will have a closer look and let you know.

P.S. Maybe I missing something but you specify vnd.libreoffice.command:ofe%7Cu%7C with %7C and not with | - so you get exactly what you are supposed to get. Try to change it in the webdav.applications property. Btw, it might be the reason, so it doesn’t work with the ms-word prefix.

Regards,
Aleksey

Hi,

If I change %7C to | I get an exception:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.haulmont.cuba.core.global.RemoteException:
---
java.lang.IllegalArgumentException: Illegal character in opaque part at index 27: vnd.libreoffice.command:ofe|u|http://localhost:8080/app/webdav/document/4403cc97-bce8-27c1-d3c5-49562d5639c7/test.odt
---
java.net.URISyntaxException: Illegal character in opaque part at index 27: vnd.libreoffice.command:ofe|u|http://localhost:8080/app/webdav/document/4403cc97-bce8-27c1-d3c5-49562d5639c7/test.odt
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1013)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Oh, got it. Thanks for educating me :slight_smile:

Hi @marcin.zawadowicz,

I had a brief look, the exception originates in WebdavUriBuilder#buildURI, more precisely URI.create fails in:

    protected URI buildURI(WebdavDocumentVersion ver, String encodedFileName) {
        //noinspection StringBufferReplaceableByString
        return URI.create(new StringBuilder()
                .append(application.getProtocols().get(applicationProtocol))
                ...
                .toString()).normalize();
    }

It returns URI, which is, in the final stage, gets casted to a String in the WebdavUrlManagementServiceBean#retrieveDocumentUrlByLatestWebdavDocumentVersion and WebdavUrlManagementServiceBean#retrieveConcreteVersionUrlByWebdavDocumentVersion.

What I would propose, is to override both WebdavUriBuilder#buildURI - to return String, without creating URI, so we could use pipes in the webdav.applications property and try again. To override these methods and make the platform to use our new implementation have a look at this chapter in the documentation.

P.S. We will try it tomorrow anyway, so you can just wait for one-two days :).

Regards,
Aleksey

Hi @marcin.zawadowicz,

we have tried the fix which was proposed by @stukalov and after the fix, the documents were correctly opened in the LibreOffice.
But we still investigating the issue with saving documents in the LibreOffice. We’ll let you know when this issue resolved. Ticket in our ticket system is https://youtrack.haulmont.com/issue/WD-734.

All of these fixes will be included in the next WebDAV update.

Regards,
Evgeny

Hi @marcin.zawadowicz,

Looks like LibreOffice doing different requests for WebDAV server than Microsoft Office. Microsoft Office just sends PUT request when we are saving the file. LibreOffice, in this case, trying to do multiple PROPFIND and GET requests for file and for file catalog and after GET request on catalog LibreOffice fails with error unable to create document in catalog.
We are still investigating this issue and we will provide an update on next week.

Regards,
Evgeny

Thank you.

Regards
Marcin

Hi @marcin.zawadowicz,

Sorry for the delayed response. We have recently published WebDAV add-on version 2.3.2 where we have fixed issue when documents can not be opened in LibreOffice.
But we are still working on the issue with saving the document.

Regards,
Evgeny