<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic What is the correct way to get the Nuxeo server&amp;apos;s URL in automation code? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/what-is-the-correct-way-to-get-the-nuxeo-server-apos-s-url-in/m-p/324430#M11431</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;As part of some systems integration, I would like to generate an &lt;EM&gt;absolute&lt;/EM&gt; URL for a given Nuxeo document. I have all of the pieces working except the base URL of the server.&lt;/P&gt;
&lt;P&gt;I have the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    DocumentLocation docLoc = new DocumentLocationImpl(newFile);
    DocumentView docView = new DocumentViewImpl(docLoc);
    DocumentViewCodecManager dvcMgr = Framework.getLocalService(
            DocumentViewCodecManager.class);
    String docURL = dvcMgr.getUrlFromDocumentView(
            "restdocid", docView, true, baseURL);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it is giving me output like &lt;CODE&gt;site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83&lt;/CODE&gt; when I substitute in &lt;CODE&gt;BaseURL.getBaseURL()&lt;/CODE&gt;. It seems to me that I just need the value of the configuration parameter &lt;CODE&gt;nuxeo.url&lt;/CODE&gt;, but is &lt;CODE&gt;BaseURL&lt;/CODE&gt; 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.&lt;/P&gt;
&lt;P&gt;To sum up, what's the best way to make &lt;CODE&gt;getUrlFromDocumentView&lt;/CODE&gt; return an absolute URL like &lt;CODE&gt;&lt;A href="http://current-host.com/nuxeo/site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83" target="test_blank"&gt;http://current-host.com/nuxeo/site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83&lt;/A&gt;&lt;/CODE&gt;, when running outside of web request code?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2015 18:20:18 GMT</pubDate>
    <dc:creator>Steven_Huwig1</dc:creator>
    <dc:date>2015-04-07T18:20:18Z</dc:date>
    <item>
      <title>What is the correct way to get the Nuxeo server&amp;apos;s URL in automation code?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/what-is-the-correct-way-to-get-the-nuxeo-server-apos-s-url-in/m-p/324430#M11431</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;As part of some systems integration, I would like to generate an &lt;EM&gt;absolute&lt;/EM&gt; URL for a given Nuxeo document. I have all of the pieces working except the base URL of the server.&lt;/P&gt;
&lt;P&gt;I have the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    DocumentLocation docLoc = new DocumentLocationImpl(newFile);
    DocumentView docView = new DocumentViewImpl(docLoc);
    DocumentViewCodecManager dvcMgr = Framework.getLocalService(
            DocumentViewCodecManager.class);
    String docURL = dvcMgr.getUrlFromDocumentView(
            "restdocid", docView, true, baseURL);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it is giving me output like &lt;CODE&gt;site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83&lt;/CODE&gt; when I substitute in &lt;CODE&gt;BaseURL.getBaseURL()&lt;/CODE&gt;. It seems to me that I just need the value of the configuration parameter &lt;CODE&gt;nuxeo.url&lt;/CODE&gt;, but is &lt;CODE&gt;BaseURL&lt;/CODE&gt; 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.&lt;/P&gt;
&lt;P&gt;To sum up, what's the best way to make &lt;CODE&gt;getUrlFromDocumentView&lt;/CODE&gt; return an absolute URL like &lt;CODE&gt;&lt;A href="http://current-host.com/nuxeo/site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83" target="test_blank"&gt;http://current-host.com/nuxeo/site/api/v1/id/5323d71a-9229-493e-b9c8-f556c6fdaf83&lt;/A&gt;&lt;/CODE&gt;, when running outside of web request code?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2015 18:20:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/what-is-the-correct-way-to-get-the-nuxeo-server-apos-s-url-in/m-p/324430#M11431</guid>
      <dc:creator>Steven_Huwig1</dc:creator>
      <dc:date>2015-04-07T18:20:18Z</dc:date>
    </item>
  </channel>
</rss>

