5

Version of Tridion: SDL Tridion 2013 SP1
Content delivery platform: WAS8 on JDK7

For a custom MVC application I'm trying to determine the publication ID of my context publication from the URL of the request.

For example:
http://mydomain.com/somepath/index.jsp -> publication ID 11
http://mydomain.be/nl/somepath/index.jsp -> publication ID 12
http://mydomain.be/fr/somepath/index.jsp -> publication ID 13

The configuration file cd_dynamic_conf.xml stores this information exactly and apparently certain parts of SDL Tridion Content delivery use this configuration file to make this mapping (at least Experience Manager).

I've found the interface com.tridion.dynamiccontent.publication.MappingsResolver which appears to do exactly what I would want but the only documented implementing class is MappingsResolverImplwhich requires a com.tridion.configuration.Configuration object to be passed in it's constructor (which is not documented in the 2013 content delivery API docs).

Have I stumbled on something that is part of the public API by accident? Why is Configuration not documented in the public API? How do I get a Configuration object? Is there anyone who has ever attempted something similar and has sample code available? Am I even looking at the right part of the Content Delivery API for performing this task?

I know that frameworks ala DD4T use their own mapping configuration in web.config but I was thinking this is a fairly standard use case when combining SDL Tridion with an MVC front-end application so I assumed the API would have something to perform this task (without having to resort to custom-parsing the config files or worse; duplicating the configuration data).

2

I see two different cases here

Case I. Logic is executed in the page In this case, you can calculate that information during publishing time, when you publish the page you know the publication that the page belongs to. If the functionality you need to execute is coded within the page itself, you don't need to do any mapping as you calculate that during publishing.

Case II. Logic is executed before the page is reached If you need to determine the publication just based on the url (as for instance implementing certain functionality in a filter) you will require a mapping between publication ids and main path of urls, based the info you provided those would be "/" 11, "nl" 12, "fr" 13

As an option (maybe not the best) you could do that having the filter accessing a Dynamic Component Presentation that outputs the mapping between the publication ids. You can create the mapping between publication ids and paths "/" "/nl" "/fr" during publishing time for the DCP

|improve this answer|||||
  • My apologies if the question was unclear but what I am looking for is case II; the servlet handling the request in my MVC app needs to get the content of the page from the broker database; this is possible using the publication ID and the path from the URL but I need the mapping of the domain/root path to the publication ID (as stored in cd_dynamic_conf.xml); I know a custom solution is possible but that would lead to information duplication as this information is already available in cd_dynamix_conf.xml... – Bjørn van Dommelen Mar 11 '14 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.