How can I configure a shorter URL than nxpath/default/default-domain for everything?

Hi there, the URLs of documents in Nuxeo tend to get rather long. https://mydomain.hoster.com/nuxeo/nxpath/default/default-domain/workspaces/project1/folder/document/@view_documents That is 115 characters, although there are no lengthy names and only one folder in the hierarchy. A large part of that is the default “middle” part starting from nxpath until default-domain (29 characters), that I cannot influence (to the best of my knowledge). I can rename a domain, but the path remains the same (which makes sense in many cases). Is there a way to change this part? If every part is necessary, I could still use only 1 character so that each URL would be shortened by 24 characters. That avoids problems with large URLs when using a lot of subfolders (which some users do). Thanks in advance for your help Regards René

0 votes

1 answers

1184 views

ANSWER

Hey Rene,

I believe what you're looking for can be found in the org.nuxeo.ecm.platform.url package. Found here: https://github.com/nuxeo/nuxeo/tree/434093e97825bf7e02578efd428e71f588704f20/nuxeo-services/nuxeo-platform-url-api/src/main/java/org/nuxeo/ecm/platform/url.

Although, Florent will likely be able to answer this question.

You may try to alter the EJBs, but maybe this is too deep. Likely, to get messy. I take it that it all starts at the 'nxpath' mapped servlet, so that may also be a good place to start.

I believe this is mapped in the deployment-fragment.xml on your tomcat server.

Hope this helps,

Yousuf

08/10/2016



Hi,

You could setup the “id” URL pattern, which is shorter, as the default one instead of the one relying on the document path.

Here is a sample runtime contribution (not tested) to achieve that:

  <require>org.nuxeo.ecm.platform.ui.web.rest.URLService.contrib</require>
  <extension point="urlpatterns" target="org.nuxeo.ecm.platform.ui.web.rest.URLService">
    <urlPattern enabled="true" name="id">
      <defaultURLPolicy>true</defaultURLPolicy>
      <needBaseURL>true</needBaseURL>
      <needRedirectFilter>true</needRedirectFilter>
      <needFilterPreprocessing>true</needFilterPreprocessing>
      <codecName>docid</codecName>
      <actionBinding>#{restHelper.initContextFromRestRequest}</actionBinding>
      <documentViewBinding>#{restHelper.documentView}</documentViewBinding>
      <newDocumentViewBinding>
        #{restHelper.newDocumentView}
      </newDocumentViewBinding>
      <bindings>
        <binding callGetter="false" name="tabId">
          #{webActions.currentTabId}
        </binding>
        <binding callGetter="false" name="subTabId">
          #{webActions.currentSubTabId}
        </binding>
        <binding name="tabIds">#{webActions.currentTabIds}</binding>
        <binding callGetter="false" name="language">
          #{restHelper.localeString}
        </binding>
      </bindings>
    </urlPattern>

    <urlPattern name="default" enabled="true">
      <defaultURLPolicy>false</defaultURLPolicy>
      <needBaseURL>true</needBaseURL>
      <needRedirectFilter>true</needRedirectFilter>
      <needFilterPreprocessing>true</needFilterPreprocessing>
      <codecName>docpath</codecName>
      <actionBinding>#{restHelper.initContextFromRestRequest}</actionBinding>
      <documentViewBinding>#{restHelper.documentView}</documentViewBinding>
      <newDocumentViewBinding>
        #{restHelper.newDocumentView}
      </newDocumentViewBinding>
      <bindings>
        <binding name="tabId" callGetter="false">
          #{webActions.currentTabId}
        </binding>
        <binding name="subTabId" callGetter="false">
          #{webActions.currentSubTabId}
        </binding>
        <binding name="tabIds">#{webActions.currentTabIds}</binding>
        <binding name="language" callGetter="false">
          #{restHelper.localeString}
        </binding>
        <binding name="mainTabId" callGetter="false">
          #{webActions.currentTabIds}
        </binding>
      </bindings>
    </urlPattern>

  </extension>

Note the change of values for the “defaultURLPolicy” property compared to the default configuration at http://explorer.nuxeo.com/nuxeo/site/distribution/cap-8.3/viewComponent/org.nuxeo.ecm.platform.ui.web.rest.URLService.contrib

You can also define your own URL policy, check the documentations at https://doc.nuxeo.com/x/EIzZ and https://doc.nuxeo.com/x/hwFu

1 votes