diff --git a/README.md b/README.md index 6a7fec7b9..41e1af72e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ If you encounter any issues with the Digital Experience Accelerator, please reac Documentation ------------- -Documentation can be found online in the SDL documentation portal: http://docs.sdl.com/sdldxa +Documentation can be found online in the SDL documentation portal: http://docs.sdl.com/sdldxa2-ctp Repositories diff --git a/build.gradle b/build.gradle index 1d67a77d9..8628b9122 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ task help(type: MavenHelpTask) task buildFramework(type: MavenBuildTask) { configurations = [ - ["dxa-bom"], + //["dxa-bom"], ["dxa-framework"], ["> dxa-webapp > clean org.apache.maven.plugins:maven-archetype-plugin:2.4:create-from-project -Darchetype.properties=archetype.properties"] ] diff --git a/dxa-bom/pom.xml b/dxa-bom/pom.xml index e42035f42..93a4432fb 100644 --- a/dxa-bom/pom.xml +++ b/dxa-bom/pom.xml @@ -186,13 +186,31 @@ com.sdl.dxa.modules dxa-module-context-expressions ${dxa-module-context-expressions} - compile + + + com.sdl.dxa.modules + dxa-module-context-expressions-abstract + ${dxa-module-context-expressions} + + + com.sdl.dxa.modules + dxa-module-context-expressions-legacy + ${dxa-module-context-expressions} com.sdl.dxa.modules dxa-module-smarttarget ${dxa-module-smarttarget.version} - runtime + + + com.sdl.dxa.modules + dxa-module-smarttarget-abstract + ${dxa-module-smarttarget.version} + + + com.sdl.dxa.modules + dxa-module-smarttarget-legacy + ${dxa-module-smarttarget.version} com.sdl.dxa.modules diff --git a/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/taglib/xpm/XpmButtonTag.java b/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/taglib/xpm/XpmButtonTag.java index b924c49c0..8531f1de9 100644 --- a/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/taglib/xpm/XpmButtonTag.java +++ b/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/taglib/xpm/XpmButtonTag.java @@ -45,8 +45,12 @@ protected HtmlNode generateXpmMarkup() { .build(); } else { String title = "Edit " + this.region.getXpmMetadata().get(INCLUDED_FROM_PAGE_TITLE_XPM_METADATA_KEY); - String editUrl = ApplicationContextHolder.getContext().getBean(WebRequestContext.class).getLocalization().localizePath( - this.region.getXpmMetadata().get(INCLUDED_FROM_PAGE_FILE_NAME_XPM_METADATA_KEY).toString()); + String urlOfInclude = this.region.getXpmMetadata().get(INCLUDED_FROM_PAGE_FILE_NAME_XPM_METADATA_KEY).toString(); + if (!urlOfInclude.matches("/?system/include.*")) { + urlOfInclude = String.format("system/include/%s", urlOfInclude.startsWith("/") ? urlOfInclude.substring(1) : urlOfInclude); + } + String editUrl = ApplicationContextHolder.getContext().getBean(WebRequestContext.class) + .getLocalization().localizePath(urlOfInclude); return HtmlBuilders.div() .withClass("xpm-button" + (cssClass == null ? "" : " " + cssClass)) .withNode(HtmlBuilders.a(editUrl) diff --git a/dxa-framework/dxa-common/src/main/java/com/sdl/dxa/common/dto/PageRequestDto.java b/dxa-framework/dxa-common/src/main/java/com/sdl/dxa/common/dto/PageRequestDto.java index 30b3ba91a..17c44c373 100644 --- a/dxa-framework/dxa-common/src/main/java/com/sdl/dxa/common/dto/PageRequestDto.java +++ b/dxa-framework/dxa-common/src/main/java/com/sdl/dxa/common/dto/PageRequestDto.java @@ -2,6 +2,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Value; import org.springframework.util.Assert; @@ -10,6 +11,7 @@ */ @Builder @Value +@EqualsAndHashCode(exclude = "depthCounter") public class PageRequestDto { private int publicationId; diff --git a/dxa-framework/dxa-common/src/test/java/com/sdl/dxa/common/dto/PageRequestDtoTest.java b/dxa-framework/dxa-common/src/test/java/com/sdl/dxa/common/dto/PageRequestDtoTest.java new file mode 100644 index 000000000..5b3df6485 --- /dev/null +++ b/dxa-framework/dxa-common/src/test/java/com/sdl/dxa/common/dto/PageRequestDtoTest.java @@ -0,0 +1,27 @@ +package com.sdl.dxa.common.dto; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class PageRequestDtoTest { + + @Test + public void shouldIgnoreDepthCounter_InEqualsAndHashCodeCheck() { + //given + PageRequestDto dto1 = PageRequestDto.builder() + .includePages(PageRequestDto.PageInclusion.INCLUDE) + .path("/").build(); + + PageRequestDto dto2 = PageRequestDto.builder() + .includePages(PageRequestDto.PageInclusion.INCLUDE) + .path("/").build(); + + //when + dto2.depthIncreaseAndCheckIfSafe(); + + //then + assertEquals(dto2, dto1); + assertEquals(dto2.hashCode(), dto1.hashCode()); + } +} \ No newline at end of file diff --git a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/BrokerComponentPresentationProvider.java b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/BrokerComponentPresentationProvider.java index f5e35f9a7..06696be72 100644 --- a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/BrokerComponentPresentationProvider.java +++ b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/BrokerComponentPresentationProvider.java @@ -57,6 +57,7 @@ protected ComponentPresentation getDynamicComponentPresentationInternal(int comp return getComponentPresentation(result.getContent()); } + /** * {@inheritDoc} */ @@ -75,7 +76,9 @@ public ComponentPresentation getDynamicComponentPresentation(int componentId, in return getDynamicComponentPresentationInternal(componentId, templateId, publicationId); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public List getDynamicComponentPresentations(final String[] itemUris, final int templateId, final int publicationId) throws ItemNotFoundException, SerializationException { diff --git a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/SpringContextConfiguration.java b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/SpringContextConfiguration.java index cb79381a4..4eca1907a 100644 --- a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/SpringContextConfiguration.java +++ b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/SpringContextConfiguration.java @@ -1,13 +1,5 @@ package com.sdl.webapp.tridion; -import com.sdl.web.api.content.BinaryContentRetriever; -import com.sdl.web.api.dynamic.BinaryContentRetrieverImpl; -import com.sdl.web.api.dynamic.DynamicMappingsRetriever; -import com.sdl.web.api.dynamic.DynamicMappingsRetrieverImpl; -import com.sdl.web.api.dynamic.DynamicMetaRetriever; -import com.sdl.web.api.dynamic.DynamicMetaRetrieverImpl; -import com.sdl.web.api.taxonomies.TaxonomyRelationManager; -import com.tridion.taxonomies.TaxonomyFactory; import org.dd4t.contentmodel.impl.BaseField; import org.dd4t.contentmodel.impl.ComponentImpl; import org.dd4t.core.factories.ComponentPresentationFactory; @@ -37,16 +29,6 @@ @ComponentScan("com.sdl.webapp.tridion") public class SpringContextConfiguration { - @Bean - public TaxonomyFactory webTaxonomyFactory() { - return new TaxonomyFactory(); - } - - @Bean - public TaxonomyRelationManager taxonomyRelationManager() { - return new TaxonomyRelationManager(); - } - @Bean public BrokerLinkProvider linkProvider() { BrokerLinkProvider linkProvider = new BrokerLinkProvider(); @@ -82,21 +64,6 @@ public ComponentPresentationProvider componentPresentationProvider() { return componentPresentationProvider; } - @Bean - public DynamicMetaRetriever dynamicMetaRetriever() { - return new DynamicMetaRetrieverImpl(); - } - - @Bean - public BinaryContentRetriever binaryContentRetriever() { - return new BinaryContentRetrieverImpl(); - } - - @Bean - public DynamicMappingsRetriever dynamicMappingsRetriever() { - return new DynamicMappingsRetrieverImpl(); - } - @Bean public PayloadCacheProvider cacheProvider() { EHCacheProvider cacheProvider = new EHCacheProvider(); @@ -178,6 +145,7 @@ public DataBindFactory databindFactory() { @Configuration @Profile("dxa.no-cache") public static class NoCacheConfiguration { + @Bean public PayloadCacheProvider cacheProvider() { return new NoCacheProvider(); diff --git a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/fields/converters/ComponentLinkFieldConverter.java b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/fields/converters/ComponentLinkFieldConverter.java index 7df18924f..17c4822ba 100644 --- a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/fields/converters/ComponentLinkFieldConverter.java +++ b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/fields/converters/ComponentLinkFieldConverter.java @@ -5,8 +5,10 @@ import com.sdl.webapp.common.api.content.LinkResolver; import com.sdl.webapp.common.api.localization.Localization; import com.sdl.webapp.common.api.mapping.semantic.SemanticMappingException; +import com.sdl.webapp.common.api.model.EntityModel; import com.sdl.webapp.common.api.model.entity.AbstractEntityModel; import com.sdl.webapp.common.api.model.entity.Link; +import com.sdl.webapp.common.util.TcmUtils; import com.sdl.webapp.tridion.fields.exceptions.FieldConverterException; import com.sdl.webapp.tridion.fields.exceptions.UnsupportedTargetTypeException; import com.sdl.webapp.tridion.mapping.ModelBuilderPipeline; @@ -26,6 +28,7 @@ public class ComponentLinkFieldConverter extends AbstractFieldConverter { private static final FieldType[] SUPPORTED_FIELD_TYPES = {FieldType.COMPONENTLINK}; private final LinkResolver linkResolver; + private final WebRequestContext webRequestContext; @Autowired @@ -69,10 +72,11 @@ public Object createPageLink(org.dd4t.contentmodel.Page page, Class targetCla String pageId = page.getId(); final String url = linkResolver.resolveLink(pageId, null); - if (targetClass.isAssignableFrom(String.class)) { + if (targetClass == String.class) { return url; - } else if (targetClass.isAssignableFrom(Link.class)) { + } else if (Link.class.isAssignableFrom(targetClass)) { final Link link = new Link(); + link.setId(String.valueOf(TcmUtils.getItemId(pageId))); link.setUrl(url); return link; } else { @@ -85,18 +89,20 @@ public Object createComponentLink(org.dd4t.contentmodel.Component component, Cla String componentId = component.getId(); final String url = linkResolver.resolveLink(componentId, null); - if (targetClass.isAssignableFrom(String.class)) { + if (String.class == targetClass) { return url; - } else if (targetClass.isAssignableFrom(Link.class)) { + } else if (Link.class.isAssignableFrom(targetClass)) { final Link link = new Link(); + link.setId(String.valueOf(TcmUtils.getItemId(componentId))); link.setUrl(url); return link; - } else if (AbstractEntityModel.class.isAssignableFrom(targetClass)) { + } else if (EntityModel.class.isAssignableFrom(targetClass)) { //what we want should be assignable from what we want to have Localization localization = this.webRequestContext.getLocalization(); try { Object retval = builder.createEntityModel(component, localization); - if (targetClass.isAssignableFrom(retval.getClass())) { + // what we got should be assignable from what we expected + if (retval != null && targetClass.isAssignableFrom(retval.getClass())) { return retval; } else { return null; diff --git a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultContentProvider.java b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultContentProvider.java index 01bb012db..724dc2d5f 100644 --- a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultContentProvider.java +++ b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultContentProvider.java @@ -13,6 +13,7 @@ import com.sdl.webapp.common.exceptions.DxaItemNotFoundException; import com.sdl.webapp.common.util.LocalizationUtils; import com.sdl.webapp.common.util.TcmUtils; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.dd4t.contentmodel.Component; import org.dd4t.contentmodel.ComponentPresentation; @@ -37,7 +38,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.util.UriUtils; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -82,8 +85,9 @@ public DefaultContentProvider(WebRequestContext webRequestContext, } @Override + @SneakyThrows(UnsupportedEncodingException.class) protected PageModel _loadPage(String _path, Localization localization) throws ContentProviderException { - return LocalizationUtils.findPageByPath(_path, localization, (path, publicationId) -> { + return LocalizationUtils.findPageByPath(UriUtils.encodePath(_path, "UTF-8"), localization, (path, publicationId) -> { final org.dd4t.contentmodel.Page genericPage; try { synchronized (LOCK) { diff --git a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultRichTextProcessor.java b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultRichTextProcessor.java index 598233dc3..3a75c128a 100644 --- a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultRichTextProcessor.java +++ b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/mapping/DefaultRichTextProcessor.java @@ -54,15 +54,13 @@ import static org.apache.commons.lang3.StringUtils.isEmpty; @Component -/** - *

DefaultRichTextProcessor class.

- */ public class DefaultRichTextProcessor implements RichTextProcessor { /** * Constant EMBEDDED_ENTITY="EmbeddedEntity" */ public static final String EMBEDDED_ENTITY = "EmbeddedEntity"; + private static final Logger LOG = LoggerFactory.getLogger(DefaultRichTextProcessor.class); @Autowired diff --git a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/navigation/StaticNavigationProvider.java b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/navigation/StaticNavigationProvider.java index 4b584b506..cec8cc3e3 100644 --- a/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/navigation/StaticNavigationProvider.java +++ b/dxa-framework/dxa-dd4t-provider/src/main/java/com/sdl/webapp/tridion/navigation/StaticNavigationProvider.java @@ -10,7 +10,6 @@ import org.dd4t.core.exceptions.ItemNotFoundException; import org.dd4t.core.factories.PageFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import java.io.ByteArrayInputStream; @@ -19,7 +18,6 @@ @Service @Slf4j -@Profile("!r2.provider") public class StaticNavigationProvider extends AbstractStaticNavigationProvider { private static final Object $LOCK = new Object(); diff --git a/dxa-framework/dxa-r2-provider/pom.xml b/dxa-framework/dxa-r2-provider/pom.xml index 8ffb8f72a..40e0bbda9 100644 --- a/dxa-framework/dxa-r2-provider/pom.xml +++ b/dxa-framework/dxa-r2-provider/pom.xml @@ -64,11 +64,6 @@ pom
- - xalan - xalan - - com.fasterxml.jackson.core jackson-annotations diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/R2.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/R2.java deleted file mode 100644 index f7f2c22f2..000000000 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/R2.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.sdl.dxa; - -import com.sdl.webapp.tridion.navigation.DynamicNavigationProvider; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marker annotation/shortcut for R2 pipeline profile. This annotation should be put on {@link Component}s and subclasses - * to conditionally enable them in case of presence of {@code r2.provider} Spring profile. - *

Pay attention that this also makes a bean {@code @Primary}. This means that in case you have 2+ - * beans of the same time, this potentially won't work, solution is simple (without double use of {@code @Primary}):

- *

- * interface Interface {}
- *
- * interface MoreConcreteInterface extends Interface {}
- *
- * @Profile("!special")
- * @Service
- * class Bean1_NotSpecial implements MoreConcreteInterface { }
- *
- * @Profile("special")
- * @Service
- * class Bean2_Special implements MoreConcreteInterface { }
- *
- * @Primary
- * @Profile("special")
- * @Service
- * class Bean3_Special implements interface Interface {
- *      @Autowired MoreConcreteInterface dependency;
- * }
- * 
- * - * @see Primary - * @see Profile - * @see DynamicNavigationProvider - * @see com.sdl.dxa.tridion.navigation.StaticNavigationProvider - * @see com.sdl.webapp.tridion.navigation.AbstractStaticNavigationProvider - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) -@Profile("r2.provider") -@Primary -public @interface R2 { - -} diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/R2SpringConfiguration.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/R2SpringConfiguration.java index e610f3f07..9a5b0ad64 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/R2SpringConfiguration.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/R2SpringConfiguration.java @@ -1,7 +1,6 @@ package com.sdl.dxa.tridion; import com.fasterxml.jackson.databind.ObjectMapper; -import com.sdl.dxa.R2; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -11,21 +10,26 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.client.RestTemplate; -@R2 +import java.util.stream.Collectors; + @Slf4j @Configuration @EnableCaching public class R2SpringConfiguration { - @Autowired @Qualifier("dxaR2ObjectMapper") private ObjectMapper objectMapper; - + @Bean public RestTemplate modelServiceRestTemplate() { RestTemplate restTemplate = new RestTemplate(); - restTemplate.getMessageConverters().add(0, dxaR2MappingJackson2HttpMessageConverter()); + // replace the default JSON message converter with R2 on the right place in collection + restTemplate.setMessageConverters( + restTemplate.getMessageConverters().stream() + .map(converter -> converter instanceof MappingJackson2HttpMessageConverter ? + dxaR2MappingJackson2HttpMessageConverter() : converter) + .collect(Collectors.toList())); return restTemplate; } diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ContentModelDataConverter.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ContentModelDataConverter.java index bc031831b..dc1b71bac 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ContentModelDataConverter.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ContentModelDataConverter.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.ContentModelData; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; import com.sdl.dxa.tridion.mapping.impl.DefaultSemanticFieldDataProvider; @@ -17,7 +16,6 @@ import java.util.Collections; import java.util.List; -@R2 @Component @Slf4j public class ContentModelDataConverter implements SourceConverter { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/EntityModelDataConverter.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/EntityModelDataConverter.java index 0f2ce1e8d..cbee7fd6a 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/EntityModelDataConverter.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/EntityModelDataConverter.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.EntityModelData; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; import com.sdl.dxa.tridion.mapping.impl.DefaultSemanticFieldDataProvider; @@ -15,7 +14,6 @@ import java.util.Collections; import java.util.List; -@R2 @Component @Slf4j public class EntityModelDataConverter implements SourceConverter { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/KeywordModelDataConverter.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/KeywordModelDataConverter.java index 12307f907..95ce29b0b 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/KeywordModelDataConverter.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/KeywordModelDataConverter.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.KeywordModelData; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; import com.sdl.dxa.tridion.mapping.converter.source.keyword.Converter; @@ -13,7 +12,6 @@ import java.util.Collections; import java.util.List; -@R2 @Component public class KeywordModelDataConverter implements SourceConverter { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ListWrapperConverter.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ListWrapperConverter.java index 139d242da..3ad45347d 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ListWrapperConverter.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/ListWrapperConverter.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.util.ListWrapper; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; import com.sdl.dxa.tridion.mapping.impl.DefaultSemanticFieldDataProvider; @@ -17,7 +16,6 @@ import java.util.HashSet; import java.util.List; -@R2 @Component public class ListWrapperConverter implements SourceConverter { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/NumberConverter.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/NumberConverter.java index 90855b6d5..f2b173587 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/NumberConverter.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/NumberConverter.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; import com.sdl.dxa.tridion.mapping.impl.DefaultSemanticFieldDataProvider; import com.sdl.webapp.common.api.mapping.semantic.config.SemanticField; @@ -13,7 +12,6 @@ @Slf4j @Component -@R2 public class NumberConverter implements SourceConverter { @Override diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/RichTextDataConverter.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/RichTextDataConverter.java index 9b23426dc..393b6ecdb 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/RichTextDataConverter.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/RichTextDataConverter.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.EntityModelData; import com.sdl.dxa.api.datamodel.model.RichTextData; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; @@ -21,7 +20,6 @@ @Slf4j @Component -@R2 public class RichTextDataConverter implements SourceConverter { @Override diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/SourceConverterFactory.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/SourceConverterFactory.java index 17627e957..018c437e1 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/SourceConverterFactory.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/SourceConverterFactory.java @@ -1,14 +1,16 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.EntityModelData; import com.sdl.dxa.api.datamodel.model.PageModelData; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; import com.sdl.dxa.tridion.mapping.impl.DefaultSemanticFieldDataProvider; +import com.sdl.webapp.common.api.WebRequestContext; +import com.sdl.webapp.common.api.content.LinkResolver; import com.sdl.webapp.common.api.mapping.semantic.config.SemanticField; import com.sdl.webapp.common.api.model.EntityModel; import com.sdl.webapp.common.api.model.entity.Link; import com.sdl.webapp.common.exceptions.DxaException; +import com.sdl.webapp.common.util.TcmUtils; import com.sdl.webapp.tridion.fields.exceptions.FieldConverterException; import com.sdl.webapp.tridion.fields.exceptions.UnsupportedTargetTypeException; import lombok.extern.slf4j.Slf4j; @@ -22,11 +24,16 @@ import java.util.Map; import java.util.Set; -@R2 @Service @Slf4j public class SourceConverterFactory { + @Autowired + private WebRequestContext webRequestContext; + + @Autowired + private LinkResolver linkResolver; + private Map, SourceConverter> converters = new HashMap<>(); @Autowired @@ -78,7 +85,8 @@ private static TypeInformation getTypeInformation(TypeDescriptor targetType) { public Object selfLink(Object toLink, TypeDescriptor targetType, ModelBuilderPipeline pipeline) throws DxaException { Class objectType = getClassForSelfLinking(toLink, targetType); - String url = toLink instanceof EntityModelData ? ((EntityModelData) toLink).getLinkUrl() : ((PageModelData) toLink).getUrlPath(); + String itemId = toLink instanceof EntityModelData ? ((EntityModelData) toLink).getId() : ((PageModelData) toLink).getId(); + String url = resolveLink(itemId, webRequestContext, linkResolver); if (objectType == String.class) { return url; } else if (Link.class.isAssignableFrom(objectType)) { @@ -112,4 +120,10 @@ private Class getClassForSelfLinking(Object toLink, TypeDescriptor targetType return objectType; } + + private static String resolveLink(String itemId, WebRequestContext webRequestContext, LinkResolver linkResolver) { + String publicationId = webRequestContext.getLocalization().getId(); + String url = TcmUtils.isTcmUri(itemId) ? itemId : TcmUtils.buildTcmUri(publicationId, itemId); + return linkResolver.resolveLink(url, publicationId); + } } diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/StringConverter.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/StringConverter.java index c2cee4dea..c5f2d2c33 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/StringConverter.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/converter/StringConverter.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.converter; -import com.sdl.dxa.R2; import com.sdl.dxa.tridion.mapping.ModelBuilderPipeline; import com.sdl.dxa.tridion.mapping.impl.DefaultSemanticFieldDataProvider; import com.sdl.webapp.common.api.mapping.semantic.config.SemanticField; @@ -18,7 +17,6 @@ import java.util.Date; import java.util.List; -@R2 @Component @Slf4j public class StringConverter implements SourceConverter { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultContentProvider.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultContentProvider.java index 1bb4d5572..43ac9faae 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultContentProvider.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultContentProvider.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.impl; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.ContentModelData; import com.sdl.dxa.api.datamodel.model.EntityModelData; import com.sdl.dxa.api.datamodel.model.PageModelData; @@ -30,7 +29,6 @@ import static com.sdl.dxa.common.dto.PageRequestDto.PageInclusion.INCLUDE; -@R2 @Service("r2ContentProvider") @Slf4j public class DefaultContentProvider extends AbstractDefaultContentProvider { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultModelBuilder.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultModelBuilder.java index 8d61a277f..36b34fb7f 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultModelBuilder.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/DefaultModelBuilder.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.impl; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.BinaryContentData; import com.sdl.dxa.api.datamodel.model.EntityModelData; import com.sdl.dxa.api.datamodel.model.ExternalContentData; @@ -52,7 +51,6 @@ */ @Slf4j @Service -@R2 public class DefaultModelBuilder implements EntityModelBuilder, PageModelBuilder { @Autowired diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/ModelBuilderPipelineImpl.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/ModelBuilderPipelineImpl.java index c51dfad25..fa22c4a90 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/ModelBuilderPipelineImpl.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/mapping/impl/ModelBuilderPipelineImpl.java @@ -1,6 +1,5 @@ package com.sdl.dxa.tridion.mapping.impl; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.EntityModelData; import com.sdl.dxa.api.datamodel.model.PageModelData; import com.sdl.dxa.tridion.mapping.EntityModelBuilder; @@ -29,7 +28,6 @@ * @see PageModelBuilder */ @Service("r2modelBuilder") -@R2 @Slf4j public class ModelBuilderPipelineImpl implements ModelBuilderPipeline { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/navigation/StaticNavigationProvider.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/navigation/StaticNavigationProvider.java index f002c554d..bed127da0 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/navigation/StaticNavigationProvider.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/navigation/StaticNavigationProvider.java @@ -8,14 +8,12 @@ import com.sdl.webapp.common.api.localization.Localization; import com.sdl.webapp.tridion.navigation.AbstractStaticNavigationProvider; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.StandardCharsets; -@Profile("r2.provider") @Service("r2StaticNavigationProvider") public class StaticNavigationProvider extends AbstractStaticNavigationProvider { diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/rest/DefaultModelService.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/rest/DefaultModelService.java index 6216b7c9b..4f4c7f5ee 100644 --- a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/rest/DefaultModelService.java +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/rest/DefaultModelService.java @@ -1,115 +1,72 @@ package com.sdl.dxa.tridion.rest; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.sdl.dxa.R2; import com.sdl.dxa.api.datamodel.model.EntityModelData; import com.sdl.dxa.api.datamodel.model.PageModelData; import com.sdl.dxa.common.dto.EntityRequestDto; import com.sdl.dxa.common.dto.PageRequestDto; -import com.sdl.web.client.configuration.XMLConfigurationHolder; -import com.sdl.web.client.configuration.XMLConfigurationReaderImpl; -import com.sdl.web.client.configuration.api.ConfigurationException; -import com.sdl.web.client.impl.DefaultDiscoveryClient; -import com.sdl.web.discovery.datalayer.model.ContentServiceCapability; -import com.sdl.web.discovery.datalayer.model.KeyValuePair; import com.sdl.webapp.common.api.WebRequestContext; import com.sdl.webapp.common.api.content.ContentProviderException; import com.sdl.webapp.common.api.content.PageNotFoundException; import com.sdl.webapp.common.api.localization.Localization; import com.sdl.webapp.common.exceptions.DxaItemNotFoundException; +import com.tridion.ambientdata.AmbientDataContext; +import com.tridion.ambientdata.claimstore.ClaimStore; +import com.tridion.ambientdata.web.WebClaims; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.Cacheable; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import org.springframework.util.StreamUtils; import org.springframework.web.client.HttpStatusCodeException; -import org.springframework.web.client.ResponseExtractor; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; -import javax.annotation.PostConstruct; +import java.net.URI; import java.util.Arrays; -import java.util.Objects; -import java.util.Properties; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; -import static java.nio.charset.Charset.defaultCharset; - -@R2 @Slf4j @Service public class DefaultModelService implements ModelService { - private final RestTemplate restTemplate; - - private final ObjectMapper objectMapper; - - @Value("${cil.cd.client.conf}") - private String configurationFileName; - - @Value("${dxa.model.service.key}") - private String modelServiceKey; + private static final String X_PREVIEW_SESSION_TOKEN = "x-preview-session-token"; - @Value("${dxa.model.service.url:#{null}}") - private String modelServiceUrl; + private static final String PREVIEW_SESSION_TOKEN = "preview-session-token"; - @Value("${dxa.model.service.url.page.model}") - private String pageModelUrl; + private final RestTemplate restTemplate; - @Value("${dxa.model.service.url.entity.model}") - private String entityModelUrl; + private final ModelServiceConfiguration configuration; @SuppressWarnings("SpringAutowiredFieldsWarningInspection") @Autowired private WebRequestContext webRequestContext; @Autowired - public DefaultModelService(RestTemplate restTemplate, @Qualifier("dxaR2ObjectMapper") ObjectMapper objectMapper) { + public DefaultModelService(RestTemplate restTemplate, + ModelServiceConfiguration configuration) { this.restTemplate = restTemplate; - this.objectMapper = objectMapper; - } - - @PostConstruct - public void initService() throws ConfigurationException { - if (modelServiceUrl != null) { - log.debug("Using model service URL from properties, don't ask Discovery, {}", modelServiceUrl); - } else { - XMLConfigurationHolder configuration = (new XMLConfigurationReaderImpl()).readConfiguration(configurationFileName); - String serviceUri = configuration.getConfiguration("/DiscoveryService").getValue("ServiceUri"); - - Properties properties = new Properties(); - properties.put("ServiceUri", serviceUri); - - modelServiceUrl = new DefaultDiscoveryClient(properties).getCapability(ContentServiceCapability.class) - .orElseThrow(() -> new ConfigurationException("ContentServiceCapability is not available on Discovery " + serviceUri)) - .getExtensionProperties().stream() - .filter(keyValuePair -> Objects.equals(keyValuePair.getKey(), modelServiceKey)) - .map(KeyValuePair::getValue) - .findFirst() - .orElseThrow(() -> new ConfigurationException("DXA Model Service URL is not available on Discovery")); - - log.debug("Using model service from Discovery, {}", modelServiceUrl); - } - - this.pageModelUrl = modelServiceUrl + pageModelUrl; - this.entityModelUrl = modelServiceUrl + entityModelUrl; + this.configuration = configuration; } @NotNull @Override - @Cacheable(value = "default") +// @Cacheable(value = "default") public PageModelData loadPageModel(PageRequestDto pageRequest) throws ContentProviderException { - return _loadPage(pageModelUrl, _defaultExtractor(PageModelData.class), pageRequest); + return _loadPage(configuration.getPageModelUrl(), PageModelData.class, pageRequest); } - private T _loadPage(String serviceUrl, ResponseExtractor extractor, PageRequestDto pageRequest) throws ContentProviderException { + private T _loadPage(String serviceUrl, Class type, PageRequestDto pageRequest) throws ContentProviderException { Localization localization = webRequestContext.getLocalization(); try { - T page = _processRequest(serviceUrl, extractor, + T page = _processRequest(serviceUrl, type, pageRequest.getUriType(), pageRequest.getPublicationId() != 0 ? pageRequest.getPublicationId() : localization.getId(), pageRequest.getPath(), @@ -121,13 +78,25 @@ private T _loadPage(String serviceUrl, ResponseExtractor extractor, PageR } } - private ResponseExtractor _defaultExtractor(Class type) { - return response -> objectMapper.readValue(response.getBody(), type); - } - - private T _processRequest(String serviceUrl, ResponseExtractor extractor, Object... params) throws ContentProviderException { + private T _processRequest(String serviceUrl, Class type, Object... params) throws ContentProviderException { try { - return restTemplate.execute(serviceUrl, HttpMethod.GET, null, extractor, params); + HttpHeaders headers = new HttpHeaders(); + + //noinspection unchecked + String previewToken = _getClaimValue(WebClaims.REQUEST_HEADERS, X_PREVIEW_SESSION_TOKEN, + claim -> Optional.of(((List) claim).get(0))) + .orElseGet(() -> _getClaimValue(WebClaims.REQUEST_COOKIES, PREVIEW_SESSION_TOKEN, + claim -> Optional.of(claim.toString())) + .orElse(null)); + + if (previewToken != null) { + // commented because of bug in CIS https://jira.sdl.com/browse/CRQ-3935 + // headers.add(X_PREVIEW_SESSION_TOKEN, previewToken); + headers.add(HttpHeaders.COOKIE, String.format("%s=%s", PREVIEW_SESSION_TOKEN, previewToken)); + } + + ResponseEntity response = restTemplate.exchange(serviceUrl, HttpMethod.GET, new HttpEntity<>(headers), type, params); + return response.getBody(); } catch (HttpStatusCodeException e) { HttpStatus statusCode = e.getStatusCode(); log.info("Got response with a status code {}", statusCode); @@ -138,12 +107,24 @@ private T _processRequest(String serviceUrl, ResponseExtractor extractor, } } + @NotNull + private Optional _getClaimValue(URI uri, String key, Function> deriveValue) { + ClaimStore claimStore = AmbientDataContext.getCurrentClaimStore(); + if (claimStore != null) { + Map claims = claimStore.get(uri, Map.class); + if (claims != null && claims.containsKey(key)) { + return deriveValue.apply(claims.get(key)); + } + } + return Optional.empty(); + } + @NotNull @Override - @Cacheable(value = "default") +// @Cacheable(value = "default") public String loadPageContent(PageRequestDto pageRequest) throws ContentProviderException { - String serviceUrl = UriComponentsBuilder.fromUriString(pageModelUrl).queryParam("raw").build().toUriString(); - return _loadPage(serviceUrl, response -> StreamUtils.copyToString(response.getBody(), defaultCharset()), pageRequest); + String serviceUrl = UriComponentsBuilder.fromUriString(configuration.getPageModelUrl()).queryParam("raw").build().toUriString(); + return _loadPage(serviceUrl, String.class, pageRequest); } @NotNull @@ -155,11 +136,11 @@ public EntityModelData loadEntity(@NotNull String entityId) throws ContentProvid @NotNull @Override - @Cacheable(value = "default") +// @Cacheable(value = "default") public EntityModelData loadEntity(EntityRequestDto entityRequest) throws ContentProviderException { Localization localization = webRequestContext.getLocalization(); - EntityModelData modelData = _processRequest(entityModelUrl, _defaultExtractor(EntityModelData.class), + EntityModelData modelData = _processRequest(configuration.getEntityModelUrl(), EntityModelData.class, entityRequest.getUriType(), entityRequest.getPublicationId() != 0 ? entityRequest.getPublicationId() : localization.getId(), entityRequest.getComponentId(), diff --git a/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/rest/ModelServiceConfiguration.java b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/rest/ModelServiceConfiguration.java new file mode 100644 index 000000000..7ce7cbc35 --- /dev/null +++ b/dxa-framework/dxa-r2-provider/src/main/java/com/sdl/dxa/tridion/rest/ModelServiceConfiguration.java @@ -0,0 +1,70 @@ +package com.sdl.dxa.tridion.rest; + +import com.sdl.web.client.configuration.api.ConfigurationException; +import com.sdl.web.content.client.configuration.impl.BaseClientConfigurationLoader; +import com.sdl.web.discovery.datalayer.model.ContentServiceCapability; +import com.sdl.web.discovery.datalayer.model.KeyValuePair; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; + +import java.util.Objects; +import java.util.Optional; + +@Component +@Slf4j +@Getter +public class ModelServiceConfiguration { + + @Getter(AccessLevel.PRIVATE) + private String serviceUrl; + + private String pageModelUrl; + + private String entityModelUrl; + + public ModelServiceConfiguration(@Value("${dxa.model.service.key:#{null}}") String modelServiceKey, + @Value("${dxa.model.service.url:#{null}}") String modelServiceUrl, + @Value("${dxa.model.service.url.page.model}") String pageModelUrl, + @Value("${dxa.model.service.url.entity.model}") String entityModelUrl) + throws ConfigurationException { + if (modelServiceUrl != null) { + log.debug("Using Model Service Url {} from properties", modelServiceUrl); + this.serviceUrl = modelServiceUrl; + } else { + Assert.notNull(modelServiceKey, "At least one of two properties required: dxa.model.service.key, dxa.model.service.url"); + this.serviceUrl = new ModelServiceConfigurationLoader(modelServiceKey).getServiceUrl(); + log.debug("Using Model Service Url {} from Discovery Service", this.serviceUrl); + } + + this.pageModelUrl = this.serviceUrl + pageModelUrl; + this.entityModelUrl = this.serviceUrl + entityModelUrl; + } + + private static class ModelServiceConfigurationLoader extends BaseClientConfigurationLoader { + + private String serviceUrl; + + ModelServiceConfigurationLoader(String modelServiceKey) throws ConfigurationException { + super(); + + Optional capability = getCapabilityFromDiscoveryService(ContentServiceCapability.class); + if (capability.isPresent()) { + this.serviceUrl = capability.get().getExtensionProperties().stream() + .filter(keyValuePair -> Objects.equals(keyValuePair.getKey(), modelServiceKey)) + .map(KeyValuePair::getValue) + .findFirst() + .orElseThrow(() -> new ConfigurationException("DXA Model Service URL is not available on Discovery")); + } else + throw new ConfigurationException("ContentServiceCapability is not available, cannot get Model Service url"); + } + + @Override + protected String getServiceUrl() { + return this.serviceUrl; + } + } +} diff --git a/dxa-framework/dxa-r2-provider/src/main/resources/dxa.modules.r2.properties b/dxa-framework/dxa-r2-provider/src/main/resources/dxa.modules.r2.properties index ef7ffb455..8f6e24ef4 100644 --- a/dxa-framework/dxa-r2-provider/src/main/resources/dxa.modules.r2.properties +++ b/dxa-framework/dxa-r2-provider/src/main/resources/dxa.modules.r2.properties @@ -1,4 +1,3 @@ -cil.cd.client.conf=cd_client_conf.xml dxa.model.service.key=dxa-model-service dxa.model.service.url.entity.model=/EntityModel/{uriType}/{localizationId}/{componentId}-{templateId} dxa.model.service.url.page.model=/PageModel/{uriType}/{localizationId}/{pageUrl}?includes={pageInclusion} \ No newline at end of file diff --git a/dxa-framework/dxa-tridion-provider/pom.xml b/dxa-framework/dxa-tridion-provider/pom.xml index 19c03c5fc..5c1442a17 100644 --- a/dxa-framework/dxa-tridion-provider/pom.xml +++ b/dxa-framework/dxa-tridion-provider/pom.xml @@ -68,6 +68,11 @@ commons-lang3
+ + xalan + xalan + + org.jsoup jsoup diff --git a/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/config/TridionSpringConfiguration.java b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/config/TridionSpringConfiguration.java new file mode 100644 index 000000000..ea2da745b --- /dev/null +++ b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/config/TridionSpringConfiguration.java @@ -0,0 +1,42 @@ +package com.sdl.webapp.config; + +import com.sdl.web.api.content.BinaryContentRetriever; +import com.sdl.web.api.dynamic.BinaryContentRetrieverImpl; +import com.sdl.web.api.dynamic.DynamicMappingsRetriever; +import com.sdl.web.api.dynamic.DynamicMappingsRetrieverImpl; +import com.sdl.web.api.taxonomies.TaxonomyRelationManager; +import com.tridion.dynamiccontent.DynamicMetaRetriever; +import com.tridion.taxonomies.TaxonomyFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@ComponentScan({"com.sdl.webapp.tridion", "com.sdl.dxa.tridion"}) +@Configuration +public class TridionSpringConfiguration { + + @Bean + public DynamicMetaRetriever dynamicMetaRetriever() { + return new DynamicMetaRetriever(); + } + + @Bean + public BinaryContentRetriever binaryContentRetriever() { + return new BinaryContentRetrieverImpl(); + } + + @Bean + public DynamicMappingsRetriever dynamicMappingsRetriever() { + return new DynamicMappingsRetrieverImpl(); + } + + @Bean + public TaxonomyFactory webTaxonomyFactory() { + return new TaxonomyFactory(); + } + + @Bean + public TaxonomyRelationManager taxonomyRelationManager() { + return new TaxonomyRelationManager(); + } +} diff --git a/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/AbstractDefaultContentProvider.java b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/AbstractDefaultContentProvider.java index 4b07f0d67..f0df635ad 100644 --- a/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/AbstractDefaultContentProvider.java +++ b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/AbstractDefaultContentProvider.java @@ -101,9 +101,8 @@ public AbstractDefaultContentProvider(WebRequestContext webRequestContext, } @Override - @SneakyThrows(UnsupportedEncodingException.class) public PageModel getPageModel(String path, Localization localization) throws ContentProviderException { - return _loadPage(UriUtils.encodePath(path, "UTF-8"), localization); + return _loadPage(path, localization); } protected abstract PageModel _loadPage(String path, Localization localization) throws ContentProviderException; diff --git a/dxa-webapp/pom.xml b/dxa-webapp/pom.xml index 61a0af55c..3218d16f5 100644 --- a/dxa-webapp/pom.xml +++ b/dxa-webapp/pom.xml @@ -121,65 +121,117 @@ - context-expressions-module + googleanalytics-module - dxa-module-context-expressions com.sdl.dxa.modules + dxa-module-googleanalytics - googleanalytics-module + mediamanager-module com.sdl.dxa.modules - dxa-module-googleanalytics + dxa-module-mediamanager - mediamanager-module + 51degrees-module com.sdl.dxa.modules - dxa-module-mediamanager + dxa-module-51degrees - smarttarget-module + audience-manager-module com.sdl.dxa.modules - dxa-module-smarttarget + dxa-module-audience-manager - 51degrees-module + test-module com.sdl.dxa.modules - dxa-module-51degrees + dxa-module-test + - audience-manager-module + context-expressions-module com.sdl.dxa.modules - dxa-module-audience-manager + dxa-module-context-expressions - test-module + context-expressions-legacy-module com.sdl.dxa.modules - dxa-module-test + dxa-module-context-expressions-legacy + + + + + + smarttarget-module + + + com.sdl.dxa.modules + dxa-module-smarttarget + + + + + smarttarget-legacy-module + + + com.sdl.dxa.modules + dxa-module-smarttarget-legacy + + + + + + + internal-legacy + + + legacy + + + + + com.sdl.dxa + dxa-dd4t-provider + + + + + + + internal-r2 + + + !legacy + + + + + com.sdl.dxa + dxa-r2-provider @@ -209,16 +261,6 @@ dxa-common-impl - - com.sdl.dxa - dxa-r2-provider - - - - com.sdl.dxa - dxa-dd4t-provider - - org.springframework spring-beans