cancel
Showing results for 
Search instead for 
Did you mean: 

What is the correct way to get the Nuxeo server's URL in automation code?

Steven_Huwig1
Star Contributor
Star Contributor

Hello,

As part of some systems integration, I would like to generate an absolute URL for a given Nuxeo document. I have all of the pieces working except the base URL of the server.

I have the following code:

    DocumentLocation docLoc = new DocumentLocationImpl(newFile);
    DocumentView docView = new DocumentViewImpl(docLoc);
    DocumentViewCodecManager dvcMgr = Framework.getLocalService(
            DocumentViewCodecManager.class);
    String docURL = dvcMgr.getUrlFromDocumentView(
            "restdocid", docView, true, baseURL);

and it is giving me output like site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83 when I substitute in BaseURL.getBaseURL(). It seems to me that I just need the value of the configuration parameter nuxeo.url, but is BaseURL from web code the best place to look for that? I'm not actually doing any web or frontend here; I'm trying to generate a canonical URL for other systems to use, without forcing them to resolve server + path on their end.

To sum up, what's the best way to make getUrlFromDocumentView return an absolute URL like http://current-host.com/nuxeo/site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83, when running outside of web request code?

0 REPLIES 0