Page 1 of 1

Opening files through a protocol

Posted: Thu Dec 14, 2017 12:11 pm
by ankitr
Hi,

Is there a way to trigger loading a file in oXygen Author from a webpage? Basically, what we are trying to achieve is to have a normal HTML link to a DITA file rendered on a webpage. When the user clicks the link, the file opens in oXygen Author over HTTP. It could be a protocol that oxygen can handle like: oxygen://host:port/path/to/file.dita

Regards,
Ankit

Re: Opening files through a protocol

Posted: Thu Dec 14, 2017 12:59 pm
by adrian
Hello,

In short, not in a simple way. The main issue is the browser/OS configuration and lastly Oxygen.

From a web browser there are a number of complications:
1. Either the web browser needs to know what application should be used with that custom protocol, or the browser should pass the URI it to the operating system which has to have that custom protocol associated with the application.
Please see this discussion thread:
Open WebDAV Documents via link in browser
This discusses the use of a "webdav" protocol, which gets rewritten as "http" and gets passed to Oxygen via a script (associated to handle the webdav protocol).

2. You need to configure this on each system (client/web browser).

3. You need to pass to Oxygen a URI that it can handle, either something that Oxygen supports out-of-the-box (like http, https), or a custom protocol for which you have implemented an Oxygen custom protocol plugin.


As a side note. If you use a "http" URL (or another protocol known by the web browser), the browser will first download the file and, if configured appropriately, it will propose to start the application (Oxygen) associated with .dita files. However in this case the application (Oxygen) is working on a local copy (download) of the file, not the source indicated by the original URL.

Regards,
Adrian

Re: Opening files through a protocol

Posted: Fri Dec 15, 2017 7:42 am
by ankitr
Thanks for your reply Adrian.
For now, it seems that the best experience is possible through the custom protocol plugin route. Though it does require configuration on the client OS to assign a protocol to Oxygen. Is there a way to automate this on plugin installation?

Regards,
Ankit

Re: Opening files through a protocol

Posted: Fri Dec 15, 2017 4:03 pm
by Radu
Hi Ankit,

This is not something controlled from the Oxygen side. An Oxygen Java-implemented plugin could probably run an external process which would use some native Windows API to create the association but I'm not sure how this could be done.
Or maybe you could create an installation kit for the Oxygen plugin using some installer like "Advanced Installer" which would create the association in the operating system, then it would ask the end user where Oxygen is installed so that it could copy the plugin in the Oxygen "plugins" folder.

Regards,
Radu

Re: Opening files through a protocol

Posted: Mon Dec 18, 2017 5:15 pm
by ankitr
Thanks for the suggestions Radu. We will evaluate what works best and implement an appropriate solution.

Re: Opening files through a protocol

Posted: Fri Jan 05, 2018 2:55 pm
by ankitr
Hi,

Is there a way to get the path of the oxygen executable file (e.g. oxygenAuthor19.1.exe) from a plugin?
I believe this executable is a shell application to launch the actual oxygen jar file. I need this information to be put in Windows Registry to create a custom protocol handler.

Thanks,
Ankit

Re: Opening files through a protocol

Posted: Fri Jan 05, 2018 5:01 pm
by Radu
Hi Ankit,
Is there a way to get the path of the oxygen executable file (e.g. oxygenAuthor19.1.exe) from a plugin?
What kind of plugin? An Oxygen plugin or a web browser plugin?
Do you want to add the information in the "Windows Registry" manually or by calling some Windows API?
I'm sorry but I do not understand the big picture. Maybe you could give me more details about this.

Regards,
Radu

Re: Opening files through a protocol

Posted: Mon Jan 08, 2018 8:59 am
by ankitr
Hi Radu,

Apologies for the lack of detail in that post.

This is an Oxygen plugin. I have added a button in the Options page for the plugin (Options > Preferences > Plugins). Pressing this button creates a temporary ".reg" file which contains URL protocol registration instructions. I then trigger open this ".reg" file which causes Windows to open the default application for Registry files, which is Registry Editor (regedit). The registry editor adds the information available in the ".reg" file to the registry and this completes the custom URL registration process.

Now, the ".reg" file needs to contain the correct path to the OxygenAuthor.exe for Windows to open Oxygen Author each time a link with my custom protocol is clicked. Thus the need to obtain the path of the Oxygenauthor.exe file.

Regards,
Ankit

Re: Opening files through a protocol

Posted: Mon Jan 08, 2018 9:32 am
by Radu
Hi Ankit,

Thanks for the details.
The Oxygen installation folder can be found out like this:

Code: Select all

    String homeURL = System.getProperty("com.oxygenxml.editor.home.url");
File oxygenInstallationFolder = new File(new URI(homeURL));
We do not have API to obtain the name of the executable file which was used to start Oxygen. It is located in the installation folder and it's name is something like this oxygen19.1.exe (for Oxygen XML Editor) or oxygenAuthor19.1.exe (for Oxygen XML Author).
So in your Java code you can list the files in the oxygenInstallationFolder and search for the executable file.

Regards,
Radu

Re: Opening files through a protocol

Posted: Mon Jan 08, 2018 8:45 pm
by ankitr
Hi Radu,

Thanks for the sample code.
I have configured my plugin to look for a file in the oxygen home directory which starts with "oxygen" and ends with ".exe".

Regards,
Ankit