All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sdl.webapp.tridion.TridionLocalizationResolver Maven / Gradle / Ivy

There is a newer version: 2.3.2
Show newest version
package com.sdl.webapp.tridion;

import com.sdl.web.api.dynamic.DynamicMappingsRetriever;
import com.sdl.web.api.dynamic.mapping.PublicationMapping;
import com.tridion.configuration.ConfigurationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TridionLocalizationResolver extends AbstractTridionLocalizationResolver {
    @Autowired
    private DynamicMappingsRetriever dynamicMappingsRetriever;

    /**
     * {@inheritDoc}
     */
    @Override
    protected PublicationMappingData getPublicationMappingData(String url) throws PublicationMappingNotFoundException {
        try {
            PublicationMapping publicationMapping = dynamicMappingsRetriever.getPublicationMapping(url);

            if (publicationMapping == null) {
                throw new PublicationMappingNotFoundException("Publication mapping not found. " +
                        "Check if your cd_dynamic_conf.xml configuration file contains a publication mapping " +
                        "that matches this URL: " + url);
            }

            return new PublicationMappingData(
                    String.valueOf(publicationMapping.getPublicationId()),
                    getPublicationMappingPath(publicationMapping.getPath()));
        } catch (ConfigurationException e) {
            return null;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy