-1

I'm wondering how could I get the host and port of the server where Share is running in, within a JS webscript. I have been searching both in Google and forums but I didn't find anything useful. I was also searching in the Share's source code with the same result. Is possible to do it?

I've also been thinking about an alternative solution consisting in defining dynamically host an port in the component's config file, but I don't know whether it is possible or not.

Did anybody do it before?

Thanks.

  • 1
    Did you have a look at the question [How to retrieve the hostname from an Alfresco Share webscript](http://stackoverflow.com/questions/13491604/how-to-retrieve-the-hostname-from-an-alfresco-share-webscript) - I think that might be what you're after, and if so the answer from that should solve your problem! – Gagravarr Dec 06 '12 at 08:55
  • Thanks Gagravarr, I have been having a look and seems helpful, but I'd prefer Share's built in mechanism, whether it exists of course :) The thing is, does what I'm looking for exist? If doesn't, I will go for you approach. – Alejandro García Seco Dec 06 '12 at 09:48

1 Answers1

3

You can check this reply How to retrieve the hostname from an Alfresco Share webscript

On the repository side, the URLs for Alfresco and Share are known. You can get all the individual parts from SysAdminParams and you can use UrlUtils to have the different parts joined together for you to give a full URL.

As far as I can tell though, these details are only ever held on the Alfresco Repository tier, and are never passed over to Share. All the absolute URLs in Share seem to be generated in the Repo and sent over

One option then is for you to change your webscript to be a repo webscript rather than a share one. That'll give you access to the appropriate beans. Share will proxy Repo webscripts for you, so you can still access it directly in Share as the logged in user. You'll want a URL a bit like /share/proxy/alfresco/my/web/script to access them.

Otherwise, create a new repo webscript that exposes the useful bits of the SysAdminParams and Share URLs, and have your share webscript fetch it (likely with caching). There are lots of examples of that too to work with.

Community
  • 1
  • 1
plus-
  • 45,453
  • 15
  • 60
  • 73