OXY-URL: File URLs in Oxygen XML Web Author
Oxygen XML Web Author works with files such as DITA documents, images referenced from documents, and DITA maps used as a context for editing. Oxygen XML Web Author can be instructed to load or save a particular file using an OXY-URL that identifies that file.
- It must have a unique scheme according to the file storage system the file comes from.
- It should behave like an identifier for the file that it references.
- It is usually different from other URLs identifying the file, such as one that would
open it in a CMS web interface (herein called CMS-URL) or the one that is
used to access the raw content of the file (herein called
RAW-URL).
Example: OXY-URL for a File in Oxygen's User Manual
Suppose that the OXY-URL for the DITA/topics/intro.dita topic from the Oxygen User Manual (hosted on GitHub) is the following:gitgh://https%3A%2F%2Fgithub.com%2Foxygenxml%2Fug/master/DITA/topics/introduction.dita
Notice that:- The URL scheme is gitgh.
- It uniquely identifies the file DITA/topics/introduction.dita
on branch
masterin the repositoryoxygenxml/ugon GitHub. - It is different from the URL used to access the file in the GitHub web interface
(CMS-URL)
https://github.com/oxygenxml/ug/blob/master/DITA/topics/introduction.ditaand from the URL used to access the file's raw content (RAW-URL)https://raw.githubusercontent.com/oxygenxml/ug/master/DITA/topics/introduction.dita.
Unique URL Scheme
- GitHub
- The URLs have the following
format:
gitgh://REPOSITORY_URI/BRANCH/PATH_TO_FILE
- GitLab
- The URLs have the following
format:
gitgl://REPOSITORY_URI/BRANCH/PATH_TO_FILE
- GitLab On-Premise
- The URLs have the following
format:
gitgle://REPOSITORY_URI/BRANCH/PATH_TO_FILE
- Bitbucket
- The URLs have the following
format:
gitbb://REPOSITORY_URI/BRANCH/PATH_TO_FILE
- Git
- The URLs have the following
format:
git://REPOSITORY_URI/BRANCH/PATH_TO_FILE
- WebDAV
- The URLs have the following
format:
webdav-https://dav.box.com/dav/path/to/file.dita
where the WebDAV URL of the file is:
https://dav.box.com/dav/path/to/file.dita. - SharePoint
- The URL of the file is the SharePoint file URL, prefixed with
spo-, as in the following example:spo-https://mycompany.sharepoint.com/myfolder/Shared%20Documents/myfile.dita
- REST
- The URLs have the following
format:
rest://<server-id>/path/to/file.dita
The format can be further specified by the implementer of the REST API.
Opening and Saving Files
For Oxygen XML Web Author to be able to open and save files identified by an OXY-URL, you need to provide a ro.sync.ecss.extensions.api.webapp.plugin.URLStreamHandlerWithContext class and associate it with the scheme of your OXY-URL.
User Authentication
- If the user is not authenticated to the CMS or if the credentials are rejected by the
CMS, you should throw a
ro.sync.ecss.extensions.api.webapp.plugin.UserActionRequiredExceptionexception. This exception is automatically relayed to the client-side as async.api.WebappMessageJavaScript object. - On the client side, follow these steps:
- Use the
sync.api.Editor.EventTypes.CUSTOM_MESSAGE_RECEIVEDevent to intercept the messages sent from the server-side. - Display a dialog box to collect the user credentials.
- Send the new credentials to a ro.sync.ecss.extensions.api.webapp.plugin.WebappServletPluginExtension
that you registered. This servlet will make the credentials available to the
ro.sync.ecss.extensions.api.webapp.plugin.URLStreamHandlerWithContextinstance presented above. - Retry the operation that triggered the authentication procedure.
- Use the
Resolving References to Other Files
The XML content edited in Oxygen XML Web Author may contain references to other files. To access a referenced file, Oxygen XML Web Author needs to compute its OXY-URL based on the OXY-URL of the edited file and the value of the reference to it.
<img src="../image/iris.jpg" />is
../image/iris.jpg
Relative References
Oxygen XML Web Author tries to resolve relative references against the OXY-URL of the currently open file. Also, when inserting references to other files (for example, images), Oxygen XML Web Author tries to insert relative URLs.
Absolute References (Usually CMS-URL)
For example, suppose an image is referenced in a DITA topic and the OXY-URL of the topic (from a GitHub repository) is:
gitgh://ff33bba498@https%3A%2F%2Fgithub.com%2Foxygenxml%2Fug/master/DITA/topics/intro.dita
and the CMS-URL of the referenced image is:
https://github.com/oxygenxml/ug/blob/master/DITA/img/login.png
then the resolved OXY-URL of the image should be:
gitgh://ff33bba498@https%3A%2F%2Fgithub.com%2Foxygenxml%2Fug/master/DITA/img/login.png
WebDAV Example
URIResolver
rewrites references to HTTP URLs to use WebDAV and inherit the
credentials:URIResolver uriResolver = new URIResolver() {
@Override
public Source resolve(String href, String base) throws TransformerException {
if (base != null && base.indexOf("webdav-") == 0) {
if (href.indexOf("http://") == 0 || href.indexOf("https://") == 0) {
try {
URL hrefUrl = new URL(href);
URL baseUrl = new URL(base);
final URL hrefWithUserInfo =
URLUtil.attachUserInfo(hrefUrl, baseUrl.getUserInfo(), null);
return new Source() {
@Override
public void setSystemId(String systemId) {
}
@Override
public String getSystemId() {
return "webdav-" + hrefWithUserInfo.toExternalForm();
}
};
} catch (MalformedURLException e) {
}
}
}
return null;
}
};public class SampleWorkspaceAccess implements WorkspaceAccessPluginExtension {
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.getXMLUtilAccess().addPriorityURIResolver(uriResolver);
}
public boolean applicationClosing() {
return true;
}
}To make Oxygen XML Web Author insert an absolute CMS-URL in content, you should also provide a RelativeReferencesResolver to be used in the Java server-side code and a ReferencesResolver to be used by the JavaScript client-side code.