handlerMethods =
this.requestMappingHandlerMapping.getHandlerMethods();
diff --git a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ControllerUtils.java b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ControllerUtils.java
index f364b51fa..5ca6ce021 100644
--- a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ControllerUtils.java
+++ b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ControllerUtils.java
@@ -13,6 +13,10 @@ public final class ControllerUtils {
public static final String INCLUDE_PATH_PREFIX = "/system/mvc/";
+ public static final String FRAMEWORK_CONTROLLER_MAPPING = "Framework";
+
+ public static final String INCLUDE_MAPPING = INCLUDE_PATH_PREFIX + FRAMEWORK_CONTROLLER_MAPPING;
+
public static final String SECTION_ERROR_VIEW = "Shared/Error/SectionError";
@Deprecated
diff --git a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/EntityController.java b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/EntityController.java
index fc6554da0..7477e5b32 100644
--- a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/EntityController.java
+++ b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/EntityController.java
@@ -5,7 +5,6 @@
import com.sdl.webapp.common.api.model.MvcData;
import com.sdl.webapp.common.api.model.ViewModel;
import com.sdl.webapp.common.api.model.entity.RedirectEntity;
-import com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
@@ -14,21 +13,20 @@
import javax.servlet.http.HttpServletRequest;
-import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CoreAreaConstants.CORE_AREA_NAME;
-import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CoreAreaConstants.ENTITY_CONTROLLER_NAME;
-import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_PATH_PREFIX;
+import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_MAPPING;
import static com.sdl.webapp.common.controller.RequestAttributeNames.ENTITY_MODEL;
/**
- * Entity controller for the Core area that handles include requests to /system/mvc/Core/Entity/Entity/{entityId}
.
+ * Entity controller for the Core area that handles include requests to /system/mvc/Framework/Entity/Entity/{entityId}
.
+ *
+ * @see ControllerUtils
*/
@Controller
-@RequestMapping(INCLUDE_PATH_PREFIX + CORE_AREA_NAME + '/' + ENTITY_CONTROLLER_NAME)
+@RequestMapping(INCLUDE_MAPPING + "/Entity")
public class EntityController extends BaseController {
private static final Logger LOG = LoggerFactory.getLogger(EntityController.class);
-
/**
* Handles a request for an entity.
*
@@ -38,7 +36,7 @@ public class EntityController extends BaseController {
* @throws ContentProviderException If an error occurs so that the entity cannot not be retrieved.
* @throws java.lang.Exception if any.
*/
- @RequestMapping(value = DefaultsMvcData.CoreAreaConstants.ENTITY_ACTION_NAME + "/{entityId}")
+ @RequestMapping(value = "Entity" + "/{entityId}")
public String handleGetEntity(HttpServletRequest request,
@PathVariable String entityId)
throws Exception {
diff --git a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ListController.java b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ListController.java
index f995df622..c74ad4b2a 100644
--- a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ListController.java
+++ b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/ListController.java
@@ -17,18 +17,17 @@
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
-import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CoreAreaConstants.CORE_AREA_NAME;
-import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CoreAreaConstants.LIST_ACTION_NAME;
-import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CoreAreaConstants.LIST_CONTROLLER_NAME;
-import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_PATH_PREFIX;
+import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_MAPPING;
import static org.springframework.util.CollectionUtils.isEmpty;
/**
- * List controller for the Core area that handles include requests to /system/mvc/Core/List/{regionName}/{entityId}
.
+ * List controller for the Core area that handles include requests to /system/mvc/Framework/List/{regionName}/{entityId}
.
+ *
+ * @see ControllerUtils
*/
@Slf4j
@Controller
-@RequestMapping(INCLUDE_PATH_PREFIX + CORE_AREA_NAME + '/' + LIST_CONTROLLER_NAME)
+@RequestMapping(INCLUDE_MAPPING + "/List")
public class ListController extends EntityController {
private final WebRequestContext webRequestContext;
@@ -54,7 +53,7 @@ private static int getOrDefault(HttpServletRequest request, String parameterName
* @return the name of the entity view that should be rendered for this request.
* @throws java.lang.Exception exception in case view is not resolved for any reason
*/
- @RequestMapping(value = LIST_ACTION_NAME + "/{entityId}")
+ @RequestMapping(value = "List" + "/{entityId}")
public String handleGetList(HttpServletRequest request, @PathVariable String entityId) throws Exception {
log.trace("handleGetList: entityId={}", entityId);
// The List action is effectively just an alias for the general Entity action (we keep it for backward compatibility).
diff --git a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/NavigationController.java b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/NavigationController.java
index 38e5c0858..69a14f874 100644
--- a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/NavigationController.java
+++ b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/NavigationController.java
@@ -8,7 +8,6 @@
import com.sdl.webapp.common.api.model.entity.NavigationLinks;
import com.sdl.webapp.common.api.model.entity.SitemapItem;
import com.sdl.webapp.common.api.model.entity.TaxonomyNode;
-import com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData;
import com.sdl.webapp.common.api.navigation.NavigationProvider;
import com.sdl.webapp.common.api.navigation.NavigationProviderException;
import org.jetbrains.annotations.NotNull;
@@ -25,19 +24,21 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_PATH_PREFIX;
+import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_MAPPING;
import static com.sdl.webapp.common.controller.RequestAttributeNames.ENTITY_MODEL;
/**
* Navigation controller for the Core area.
*
- * This handles include requests to /system/mvc/Core/Navigation/Navigation/{regionName}/{entityId}
- * and /system/mvc/Core/Navigation/SiteMap/{regionName}/{entityId}
+ * This handles include requests to /system/mvc/Framework/Navigation/Navigation/{regionName}/{entityId}
+ * and /system/mvc/Framework/Navigation/SiteMap/{regionName}/{entityId}
*
+ *
+ * @see ControllerUtils
*/
@Controller
-@RequestMapping(INCLUDE_PATH_PREFIX + DefaultsMvcData.CoreAreaConstants.CORE_AREA_NAME + '/' + DefaultsMvcData.CoreAreaConstants.NAVIGATION_CONTROLLER_NAME)
+@RequestMapping(INCLUDE_MAPPING + "/Navigation")
public class NavigationController extends BaseController {
private static final Logger LOG = LoggerFactory.getLogger(NavigationController.class);
@@ -117,7 +118,7 @@ private static void moveHomeItemToTopLevelIfNeeded(@NotNull SitemapItem navigati
* @throws NavigationProviderException If an error occurs so that the navigation data cannot be retrieved.
* @throws java.lang.Exception if any.
*/
- @RequestMapping(value = DefaultsMvcData.CoreAreaConstants.NAVIGATION_ACTION_NAME + "/{entityId}")
+ @RequestMapping(value = "Navigation/{entityId}")
public String handleGetNavigation(HttpServletRequest request,
@PathVariable String entityId, @RequestParam String navType)
throws Exception {
@@ -172,7 +173,7 @@ public String handleGetNavigation(HttpServletRequest request,
* @return The name of the entity view that should be rendered for this request.
* @throws NavigationProviderException If an error occurs so that the navigation data cannot be retrieved.
*/
- @RequestMapping(value = DefaultsMvcData.CoreAreaConstants.SITEMAP_ACTION_NAME + "/{entityId}")
+ @RequestMapping(value = "SiteMap/{entityId}")
public String handleGetSiteMap(HttpServletRequest request,
@PathVariable String entityId) throws NavigationProviderException {
LOG.trace("handleGetSiteMap: entityId={}", entityId);
diff --git a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/RegionController.java b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/RegionController.java
index 0aa0215b2..7291f48fe 100644
--- a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/RegionController.java
+++ b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/controller/RegionController.java
@@ -3,7 +3,6 @@
import com.sdl.webapp.common.api.model.MvcData;
import com.sdl.webapp.common.api.model.RegionModel;
import com.sdl.webapp.common.api.model.ViewModel;
-import com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
@@ -12,18 +11,21 @@
import javax.servlet.http.HttpServletRequest;
-import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_PATH_PREFIX;
+import static com.sdl.webapp.common.controller.ControllerUtils.INCLUDE_MAPPING;
import static com.sdl.webapp.common.controller.RequestAttributeNames.REGION_MODEL;
/**
* Region controller for the Core area.
*
- * This handles include requests to /system/mvc/Core/Region/{regionName}
+ * This handles include requests to /system/mvc/Framework/Region/{regionName}
*
+ *
+ * @see ControllerUtils
*/
@Controller
-@RequestMapping(INCLUDE_PATH_PREFIX + DefaultsMvcData.CoreAreaConstants.CORE_AREA_NAME + '/' + DefaultsMvcData.CoreAreaConstants.REGION_CONTROLLER_NAME)
+@RequestMapping(INCLUDE_MAPPING + "/Region")
public class RegionController extends BaseController {
+
private static final Logger LOG = LoggerFactory.getLogger(RegionController.class);
/**
@@ -34,7 +36,7 @@ public class RegionController extends BaseController {
* @return The name of the region view that should be rendered for this request.
* @throws java.lang.Exception exception
*/
- @RequestMapping(value = DefaultsMvcData.CoreAreaConstants.REGION_ACTION_NAME + "/{regionName}")
+ @RequestMapping(value = "Region" + "/{regionName}")
public String handleGetRegion(HttpServletRequest request, @PathVariable String regionName) throws Exception {
LOG.trace("handleGetRegion: regionName={}", regionName);
diff --git a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/util/InitializationUtils.java b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/util/InitializationUtils.java
index 1e59c9781..b7e35d9d0 100644
--- a/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/util/InitializationUtils.java
+++ b/dxa-framework/dxa-common-api/src/main/java/com/sdl/webapp/common/util/InitializationUtils.java
@@ -5,6 +5,7 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.input.BOMInputStream;
+import org.jetbrains.annotations.Nullable;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@@ -26,6 +27,8 @@
import java.util.List;
import java.util.Properties;
+import static org.apache.commons.lang3.StringUtils.defaultString;
+
@Slf4j
public final class InitializationUtils {
@@ -314,4 +317,19 @@ public static void registerListener(@NonNull ServletContext servletContext, @Non
servletContext.addListener(listener);
log.info(REGISTERED_LOG_MESSAGE, listener.getClass().getName());
}
+
+ /**
+ * Returns the value from configuration by {@code key} specified or {@code defaultValue} if there is no property with such key.
+ * Empty values from configuration are treated as values meaning this method doesn't check if the value is blank.
+ *
+ * @param key key to look up
+ * @param defaultValue default value if configuration property doesn't exist
+ * @return value for key, or defaultValue
+ * @since 1.7
+ */
+ @Nullable
+ public static String getConfiguration(String key, String defaultValue) {
+ return defaultString(loadDxaProperties().getProperty(key), defaultValue);
+ }
+
}
diff --git a/dxa-framework/dxa-common-api/src/main/resources/dxa.defaults.properties b/dxa-framework/dxa-common-api/src/main/resources/dxa.defaults.properties
index da7ed50f2..b1a59c640 100644
--- a/dxa-framework/dxa-common-api/src/main/resources/dxa.defaults.properties
+++ b/dxa-framework/dxa-common-api/src/main/resources/dxa.defaults.properties
@@ -8,6 +8,12 @@ dxa.web.views.prefix=/WEB-INF/Views/
dxa.web.views.suffix=.jsp
dxa.web.default.init=true
+dxa.web.default.area.name=Core
+dxa.web.default.region.name=Main
+dxa.web.default.controller.name=Entity
+dxa.web.default.controller.area.name=Framework
+dxa.web.default.action.name=Entity
+
dxa.json.xpm.aware=true
#DXA Tridion 2013 Provider
diff --git a/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/mvcdata/DefaultsMvcDataTest.java b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/mvcdata/DefaultsMvcDataTest.java
new file mode 100644
index 000000000..b39a8efbe
--- /dev/null
+++ b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/mvcdata/DefaultsMvcDataTest.java
@@ -0,0 +1,32 @@
+package com.sdl.webapp.common.api.model.mvcdata;
+
+import org.junit.Test;
+
+import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CORE_ENTITY;
+import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CORE_PAGE;
+import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.CORE_REGION;
+import static org.junit.Assert.assertEquals;
+
+public class DefaultsMvcDataTest {
+
+ @Test
+ public void shouldReturnDefaultsFromConfiguration() {
+ assertEquals("AreaName", DefaultsMvcData.getDefaultAreaName());
+ assertEquals("RegionName", DefaultsMvcData.getDefaultRegionName());
+ assertEquals("ControllerName", DefaultsMvcData.getDefaultControllerName());
+ assertEquals("ControllerAreaName", DefaultsMvcData.getDefaultControllerAreaName());
+ assertEquals("ActionName", DefaultsMvcData.getDefaultActionName());
+ }
+
+ @Test
+ public void shouldSetDefaultForCoreEnums() {
+ assertEquals("AreaName", CORE_ENTITY.getAreaName());
+ assertEquals("Framework", CORE_ENTITY.getControllerAreaName());
+
+ assertEquals("AreaName", CORE_PAGE.getAreaName());
+ assertEquals("Framework", CORE_PAGE.getControllerAreaName());
+
+ assertEquals("AreaName", CORE_REGION.getAreaName());
+ assertEquals("Framework", CORE_REGION.getControllerAreaName());
+ }
+}
\ No newline at end of file
diff --git a/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/mvcdata/MvcDataCreatorTest.java b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/mvcdata/MvcDataCreatorTest.java
index 6a470088d..fe3734e31 100644
--- a/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/mvcdata/MvcDataCreatorTest.java
+++ b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/mvcdata/MvcDataCreatorTest.java
@@ -22,7 +22,7 @@ private static void assertPartsAreSet(Parts parts, MvcData mvcData) {
public void shouldShouldCorrectlyParseDifferentTypeOfInitNames() {
//given
String fullName = "Core:Entity:YouTubeVideo";
- String areaViewName = "Core:YouTubeVideo";
+ String areaViewName = "Hello:YouTubeVideo";
String viewName = "YouTubeVideo";
//when
@@ -40,16 +40,25 @@ public void shouldShouldCorrectlyParseDifferentTypeOfInitNames() {
.create();
//then
- Parts parts = new Parts()
- .controllerAreaName("Core")
+
+ assertPartsAreSet(new Parts()
+ .controllerAreaName("Framework")
.controllerName("Entity")
.areaName("Core")
.actionName("Entity")
- .viewName(viewName);
-
- assertPartsAreSet(parts, mvcDataFull);
- assertPartsAreSet(parts, mvcDataHalf);
- assertPartsAreSet(parts, mvcDataShort);
+ .viewName(viewName), mvcDataFull);
+ assertPartsAreSet(new Parts()
+ .controllerAreaName("Framework")
+ .controllerName("Entity")
+ .areaName("Hello")
+ .actionName("Entity")
+ .viewName(viewName), mvcDataHalf);
+ assertPartsAreSet(new Parts()
+ .controllerAreaName("Framework")
+ .controllerName("Entity")
+ .areaName("AreaName")
+ .actionName("Entity")
+ .viewName(viewName), mvcDataShort);
//when
mvcDataFull = creator(mvcDataFull).defaults(DefaultsMvcData.CORE_ENTITY).create();
@@ -57,15 +66,24 @@ public void shouldShouldCorrectlyParseDifferentTypeOfInitNames() {
mvcDataShort = creator(mvcDataShort).defaults(DefaultsMvcData.CORE_ENTITY).create();
//then
- Parts fullParts = new Parts()
- .controllerAreaName("Core")
+ assertPartsAreSet(new Parts()
+ .controllerAreaName("Framework")
.controllerName("Entity")
.actionName("Entity")
.areaName("Core")
- .viewName(viewName);
- assertPartsAreSet(fullParts, mvcDataFull);
- assertPartsAreSet(fullParts, mvcDataHalf);
- assertPartsAreSet(fullParts, mvcDataShort);
+ .viewName(viewName), mvcDataFull);
+ assertPartsAreSet(new Parts()
+ .controllerAreaName("Framework")
+ .controllerName("Entity")
+ .actionName("Entity")
+ .areaName("Hello")
+ .viewName(viewName), mvcDataHalf);
+ assertPartsAreSet(new Parts()
+ .controllerAreaName("Framework")
+ .controllerName("Entity")
+ .actionName("Entity")
+ .areaName("AreaName")
+ .viewName(viewName), mvcDataShort);
}
@Test(expected = IllegalArgumentException.class)
@@ -126,10 +144,10 @@ public void shouldSetDefaultsValuesForEntity() {
//then
assertPartsAreSet(new Parts()
- .controllerAreaName("Core")
+ .controllerAreaName("Framework")
.controllerName("Entity")
.actionName("Entity")
- .areaName("Core")
+ .areaName("AreaName")
.viewName(viewName), mvcData);
}
diff --git a/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/page/AbstractPageModelImplTest.java b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/page/AbstractPageModelImplTest.java
index 7ce16f775..370b328b3 100644
--- a/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/page/AbstractPageModelImplTest.java
+++ b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/api/model/page/AbstractPageModelImplTest.java
@@ -212,4 +212,17 @@ public void shouldCollectFeedItems() throws DxaException {
//then
assertThat(feedItems, IsIterableContainingInOrder.contains(feedItem, feedItem2));
}
+
+ @Test
+ public void shouldRemoveTcmPartFromPageId() {
+ //given
+ DefaultPageModel pageModel = new DefaultPageModel();
+ pageModel.setId("tcm:1-2-3");
+
+ //when
+ String pureId = pageModel.getIdWithoutTcm();
+
+ //then
+ assertEquals("2", pureId);
+ }
}
\ No newline at end of file
diff --git a/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/util/InitializationUtilsTest.java b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/util/InitializationUtilsTest.java
index 10839ad7b..e922851a4 100644
--- a/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/util/InitializationUtilsTest.java
+++ b/dxa-framework/dxa-common-api/src/test/java/com/sdl/webapp/common/util/InitializationUtilsTest.java
@@ -377,4 +377,12 @@ public void shouldUserClassNameForFilterRegistration() {
}
+ @Test
+ public void shouldGetConfigurationByKey() {
+ //when
+ assertEquals("cid", InitializationUtils.getConfiguration("dxa.modules.cid", null));
+ assertNull(InitializationUtils.getConfiguration("not.existing.key", null));
+ assertEquals("hello", InitializationUtils.getConfiguration("not.existing.key", "hello"));
+ }
+
}
\ No newline at end of file
diff --git a/dxa-framework/dxa-common-api/src/test/resources/dxa.defaults.properties b/dxa-framework/dxa-common-api/src/test/resources/dxa.defaults.properties
index 069a26ab8..3c02b254d 100644
--- a/dxa-framework/dxa-common-api/src/test/resources/dxa.defaults.properties
+++ b/dxa-framework/dxa-common-api/src/test/resources/dxa.defaults.properties
@@ -6,4 +6,9 @@ dxa.web.views.folder=/META-INF/resources/
dxa.web.views.override.folder=Override
dxa.web.views.prefix=/WEB-INF/Views/
dxa.web.views.suffix=.jsp
-spring.profiles.include=profile-default
\ No newline at end of file
+spring.profiles.include=profile-default
+dxa.web.default.area.name=AreaName
+dxa.web.default.region.name=RegionName
+dxa.web.default.controller.name=ControllerName
+dxa.web.default.controller.area.name=ControllerAreaName
+dxa.web.default.action.name=ActionName
\ No newline at end of file
diff --git a/dxa-framework/dxa-common-impl/pom.xml b/dxa-framework/dxa-common-impl/pom.xml
index cf58c8496..691a558fc 100644
--- a/dxa-framework/dxa-common-impl/pom.xml
+++ b/dxa-framework/dxa-common-impl/pom.xml
@@ -7,7 +7,7 @@
dxa-framework
com.sdl.dxa
- 1.7.0-SNAPSHOT
+ 1.7.0
dxa-common-impl
diff --git a/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/model/ViewModelRegistryImpl.java b/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/model/ViewModelRegistryImpl.java
index e15adf0bb..2404dcc9f 100644
--- a/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/model/ViewModelRegistryImpl.java
+++ b/dxa-framework/dxa-common-impl/src/main/java/com/sdl/webapp/common/impl/model/ViewModelRegistryImpl.java
@@ -21,10 +21,9 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import static com.sdl.webapp.common.api.model.mvcdata.DefaultsMvcData.getDefaultAreaName;
+
@Component
-/**
- * ViewModelRegistryImpl class.
- */
public class ViewModelRegistryImpl implements ViewModelRegistry {
private static final Logger LOG = LoggerFactory.getLogger(ViewModelRegistryImpl.class);
@@ -40,60 +39,34 @@ public class ViewModelRegistryImpl implements ViewModelRegistry {
* {@inheritDoc}
*/
@Override
- public void registerViewModel(MvcData viewData, Class extends ViewModel> entityClass) {
- try {
- if (lock.tryLock(10, TimeUnit.SECONDS)) {
- if (viewData != null) {
- if (viewEntityClassMap.containsKey(viewData)) {
- LOG.warn("View {} registered multiple times.", viewData);
- return;
- }
- viewEntityClassMap.put(viewData, entityClass);
- }
- semanticMappingRegistry.registerEntity((Class extends EntityModel>) entityClass);
- }
- } catch (InterruptedException e) {
- LOG.warn(e.getMessage(), e);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Class extends ViewModel> getViewModelType(final MvcData viewData) {
+ public Class extends ViewModel> getViewEntityClass(final String viewName) throws DxaException {
+ final String areaName;
+ final String scopedViewName;
+ if (!viewName.contains(":")) { // default module
+ areaName = getDefaultAreaName();
+ scopedViewName = viewName;
+ } else {
+ String[] parts = viewName.split(":");
+ areaName = parts[0];
+ scopedViewName = parts[1];
+ }
Predicate>> keyNamePredicate =
new Predicate>>() {
@Override
public boolean apply(Map.Entry> input) {
- MvcData thisKey = input.getKey();
- return thisKey.getViewName().equals(viewData.getViewName()) &&
- thisKey.getControllerName().equals(viewData.getControllerName()) &&
- thisKey.getAreaName().equals(viewData.getAreaName());
- }
- };
- Predicate>> keyNamePredicateNoArea =
- new Predicate>>() {
- @Override
- public boolean apply(Map.Entry> input) {
- MvcData thisKey = input.getKey();
- return thisKey.getViewName().equals(viewData.getViewName()) &&
- (thisKey.getControllerName().equals(viewData.getControllerName()) || viewData.getControllerName() == null);
+ return input.getKey().getAreaName().equals(areaName) && input.getKey().getViewName().equals(scopedViewName);
}
};
+
+
Map> possibleValues = Maps.filterEntries(viewEntityClassMap, keyNamePredicate);
if (possibleValues.isEmpty()) {
- //first let's see if there is another relevant view
- possibleValues = Maps.filterEntries(viewEntityClassMap, keyNamePredicateNoArea);
- }
- if (possibleValues.isEmpty()) {
- return null;
+ throw new DxaException(String.format("Could not find a view model for the view name %s", viewName));
} else {
return possibleValues.entrySet().iterator().next().getValue();
}
+
}
/** {@inheritDoc} */
@@ -126,35 +99,63 @@ public Class extends ViewModel> getMappedModelTypes(String semanticTypeName) {
return getViewModelType(mvcData);
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
- public Class extends ViewModel> getViewEntityClass(final String viewName) throws DxaException {
+ public Class extends ViewModel> getViewModelType(final MvcData viewData) {
- final String areaName;
- final String scopedViewName;
- if (!viewName.contains(":")) { // Core module
- areaName = "Core";
- scopedViewName = viewName;
- } else {
- String[] parts = viewName.split(":");
- areaName = parts[0];
- scopedViewName = parts[1];
- }
Predicate>> keyNamePredicate =
new Predicate>>() {
@Override
public boolean apply(Map.Entry> input) {
- return input.getKey().getAreaName().equals(areaName) && input.getKey().getViewName().equals(scopedViewName);
+ MvcData thisKey = input.getKey();
+ return thisKey.getViewName().equals(viewData.getViewName()) &&
+ thisKey.getControllerName().equals(viewData.getControllerName()) &&
+ thisKey.getAreaName().equals(viewData.getAreaName());
+ }
+ };
+ Predicate>> keyNamePredicateNoArea =
+ new Predicate>>() {
+ @Override
+ public boolean apply(Map.Entry> input) {
+ MvcData thisKey = input.getKey();
+ return thisKey.getViewName().equals(viewData.getViewName()) &&
+ (thisKey.getControllerName().equals(viewData.getControllerName()) || viewData.getControllerName() == null);
}
};
-
-
Map> possibleValues = Maps.filterEntries(viewEntityClassMap, keyNamePredicate);
if (possibleValues.isEmpty()) {
- throw new DxaException(String.format("Could not find a view model for the view name %s", viewName));
+ //first let's see if there is another relevant view
+ possibleValues = Maps.filterEntries(viewEntityClassMap, keyNamePredicateNoArea);
+ }
+ if (possibleValues.isEmpty()) {
+ return null;
} else {
return possibleValues.entrySet().iterator().next().getValue();
}
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void registerViewModel(MvcData viewData, Class extends ViewModel> entityClass) {
+ try {
+ if (lock.tryLock(10, TimeUnit.SECONDS)) {
+ if (viewData != null) {
+ if (viewEntityClassMap.containsKey(viewData)) {
+ LOG.warn("View {} registered multiple times.", viewData);
+ return;
+ }
+ viewEntityClassMap.put(viewData, entityClass);
+ }
+ semanticMappingRegistry.registerEntity((Class extends EntityModel>) entityClass);
+ }
+ } catch (InterruptedException e) {
+ LOG.warn(e.getMessage(), e);
+ } finally {
+ lock.unlock();
+ }
}
}
diff --git a/dxa-framework/dxa-common-impl/src/test/java/com/sdl/webapp/common/impl/model/ViewModelRegistryImplTest.java b/dxa-framework/dxa-common-impl/src/test/java/com/sdl/webapp/common/impl/model/ViewModelRegistryImplTest.java
new file mode 100644
index 000000000..a671cb9a0
--- /dev/null
+++ b/dxa-framework/dxa-common-impl/src/test/java/com/sdl/webapp/common/impl/model/ViewModelRegistryImplTest.java
@@ -0,0 +1,139 @@
+package com.sdl.webapp.common.impl.model;
+
+import com.google.common.collect.Sets;
+import com.sdl.webapp.common.api.mapping.semantic.SemanticMappingRegistry;
+import com.sdl.webapp.common.api.model.ViewModel;
+import com.sdl.webapp.common.api.model.ViewModelRegistry;
+import com.sdl.webapp.common.api.model.entity.AbstractEntityModel;
+import com.sdl.webapp.common.api.model.mvcdata.MvcDataCreator;
+import com.sdl.webapp.common.exceptions.DxaException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.doReturn;
+import static org.springframework.test.util.ReflectionTestUtils.getField;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ViewModelRegistryImplTest {
+
+ @Mock
+ private SemanticMappingRegistry semanticMappingRegistry;
+
+ @InjectMocks
+ private ViewModelRegistry registry = new ViewModelRegistryImpl();
+
+ @Before
+ public void init() {
+ registry.registerViewModel(MvcDataCreator.creator()
+ .fromQualifiedName("Core:Entity:TestEntity")
+ .create(), TestEntity.class);
+
+ registry.registerViewModel(MvcDataCreator.creator()
+ .fromQualifiedName("Test:Entity:TestEntity2")
+ .create(), TestEntity2.class);
+
+ doReturn(TestEntity.class).when(semanticMappingRegistry).getEntityClassByFullyQualifiedName("registered");
+ }
+
+ @Test
+ public void shouldResolveEntityClass_ToDefaultModule() throws DxaException {
+ //when
+ Class extends ViewModel> entityClass = registry.getViewEntityClass("TestEntity");
+
+ //then
+ assertEquals(TestEntity.class, entityClass);
+ }
+
+ @Test
+ public void shouldResolveEntityClass_ToExplicitAreaName() throws DxaException {
+ //when
+ Class extends ViewModel> entityClass = registry.getViewEntityClass("Test:TestEntity2");
+
+ //then
+ assertEquals(TestEntity2.class, entityClass);
+ }
+
+ @Test
+ public void shouldRegisterFirstView_WhenMappingIsMultiple() {
+ //given
+ int initial = ((Map) getField(registry, "viewEntityClassMap")).size();
+
+ //when
+ registry.registerViewModel(MvcDataCreator.creator()
+ .fromQualifiedName("Core:Entity:TestEntity")
+ .create(), TestEntity3.class);
+
+ //then
+ assertEquals(((Map) getField(registry, "viewEntityClassMap")).size(), initial);
+ }
+
+ @Test(expected = DxaException.class)
+ public void shouldThrowException_WhenClassNotFound() throws DxaException {
+ //when
+ registry.getViewEntityClass("Area:View");
+ }
+
+ @Test
+ public void shouldReturnViewModel_WhenRegistered() {
+ //when
+ Class extends ViewModel> registered = registry.getMappedModelTypes("registered");
+
+ //then
+ assertEquals(TestEntity.class, registered);
+ }
+
+ @Test
+ public void shouldViewModel_WhenRegistered_WithSet() {
+ //when
+ Class extends ViewModel> registered = registry.getMappedModelTypes(Sets.newHashSet("not-registered", "registered"));
+
+ //then
+ assertEquals(TestEntity.class, registered);
+ }
+
+ @Test
+ public void shouldReturnNull_IfNothingIfSemanticRegistryFound() {
+ Class extends ViewModel> registered = registry.getMappedModelTypes(Sets.newHashSet("not-registered", "not-registered-2"));
+
+ //then
+ assertNull(registered);
+ }
+
+ @Test
+ public void shouldResolveFromViewRegistry_IfSemanticRegistryFailed() {
+ //when
+ Class extends ViewModel> entityClass = registry.getMappedModelTypes("Test:Entity:TestEntity2");
+
+ //then
+ assertEquals(TestEntity2.class, entityClass);
+ }
+
+ @Test
+ public void shouldResolveFromViewRegistry_IfSemanticRegistryFailed_WithNoArea() {
+ //when
+ Class extends ViewModel> entityClass = registry.getMappedModelTypes("TestEntity2");
+
+ //then
+ assertEquals(TestEntity2.class, entityClass);
+ }
+
+ private class TestEntity extends AbstractEntityModel {
+
+ }
+
+ private class TestEntity2 extends AbstractEntityModel {
+
+ }
+
+ private class TestEntity3 extends AbstractEntityModel {
+
+ }
+}
\ 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 a4b6b5bbf..d435ff051 100644
--- a/dxa-framework/dxa-tridion-provider/pom.xml
+++ b/dxa-framework/dxa-tridion-provider/pom.xml
@@ -6,7 +6,7 @@
dxa-framework
com.sdl.dxa
- 1.7.0-SNAPSHOT
+ 1.7.0
dxa-tridion-provider
diff --git a/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/EntityBuilderImpl.java b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/EntityBuilderImpl.java
index 62fc6549b..6efc669c9 100644
--- a/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/EntityBuilderImpl.java
+++ b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/EntityBuilderImpl.java
@@ -7,13 +7,11 @@
import com.sdl.webapp.common.api.mapping.semantic.SemanticMappingRegistry;
import com.sdl.webapp.common.api.mapping.semantic.config.SemanticSchema;
import com.sdl.webapp.common.api.model.EntityModel;
-import com.sdl.webapp.common.api.model.MvcData;
import com.sdl.webapp.common.api.model.ViewModelRegistry;
import com.sdl.webapp.common.api.model.entity.AbstractEntityModel;
import com.sdl.webapp.common.api.model.entity.EclItem;
import com.sdl.webapp.common.api.model.entity.ExceptionEntity;
import com.sdl.webapp.common.api.model.entity.MediaItem;
-import com.sdl.webapp.common.api.model.mvcdata.MvcDataImpl;
import com.sdl.webapp.common.controller.exception.NotFoundException;
import com.sdl.webapp.common.exceptions.DxaException;
import com.sdl.webapp.tridion.SemanticFieldDataProviderImpl;
@@ -37,20 +35,13 @@
import java.util.Map;
import java.util.Objects;
+import static com.sdl.webapp.util.dd4t.MvcDataHelper.createMvcData;
import static org.apache.commons.lang3.StringUtils.isEmpty;
@Slf4j
@Service
public final class EntityBuilderImpl implements EntityBuilder {
- private static final String DEFAULT_AREA_NAME = "Core";
-
- private static final String DEFAULT_CONTROLLER_NAME = "Entity";
-
- private static final String DEFAULT_ACTION_NAME = "Entity";
-
- private static final String DEFAULT_REGION_NAME = "Main";
-
@Autowired
private ViewModelRegistry viewModelRegistry;
@@ -139,101 +130,6 @@ private static Map createXpmMetadata(EntityModel entity, Compone
return xpmMetaData;
}
- private static String[] getControllerNameParts(Map templateMeta) {
- String fullName = FieldUtils.getStringValue(templateMeta, "controller");
- if (isEmpty(fullName)) {
- fullName = DEFAULT_CONTROLLER_NAME;
- }
- return splitName(fullName);
- }
-
- private static String getActionName(Map templateMeta) {
- String actionName = FieldUtils.getStringValue(templateMeta, "action");
- if (isEmpty(actionName)) {
- actionName = DEFAULT_ACTION_NAME;
- }
- return actionName;
- }
-
- private static String[] getViewNameParts(ComponentTemplate componentTemplate) {
- String fullName = FieldUtils.getStringValue(componentTemplate.getMetadata(), "view");
- if (isEmpty(fullName)) {
- fullName = componentTemplate.getTitle().replaceAll("\\[.*\\]|\\s", "");
- }
- return splitName(fullName);
- }
-
- private static String[] getRegionNameParts(Map templateMeta) {
- String fullName = FieldUtils.getStringValue(templateMeta, "regionView");
- if (isEmpty(fullName)) {
- fullName = DEFAULT_REGION_NAME;
- }
- return splitName(fullName);
- }
-
- private static String[] splitName(String name) {
- final String[] parts = name.split(":");
- return parts.length > 1 ? parts : new String[]{DEFAULT_AREA_NAME, name};
- }
-
- private static Map getMvcMetadata(ComponentTemplate componentTemplate) {
-
- // TODO: Move this code into a generic MvcDataHelper class
-
- Map metadata = new HashMap<>();
- Map metadataFields = componentTemplate.getMetadata();
-
- for (Map.Entry entry : metadataFields.entrySet()) {
- String fieldName = entry.getKey();
- if ("view".equals(fieldName) || "regionView".equals(fieldName) || "controller".equals(fieldName) ||
- "action".equals(fieldName) || "routeValues".equals(fieldName)) {
- continue;
- }
- Field field = entry.getValue();
- if (!field.getValues().isEmpty()) {
- metadata.put(fieldName, field.getValues().get(0).toString()); // Assume single-value text fields for template metadata
- }
- }
- return metadata;
- }
-
- private static MvcData createMvcData(ComponentPresentation componentPresentation) {
- final ComponentTemplate componentTemplate = componentPresentation.getComponentTemplate();
- final Map templateMeta = componentTemplate.getMetadata();
-
- final String[] controllerNameParts = getControllerNameParts(templateMeta);
- final String[] viewNameParts = getViewNameParts(componentTemplate);
- final String[] regionNameParts = getRegionNameParts(templateMeta);
-
- final String actionName = getActionName(templateMeta);
-
- final Map mvcMetadata = EntityBuilderImpl.getMvcMetadata(componentPresentation.getComponentTemplate());
-
- final Map routeValues = new HashMap<>();
-
- String routeValuesStrings = FieldUtils.getStringValue(templateMeta, "routeValues");
- if (routeValuesStrings != null) {
- for (String value : routeValuesStrings.split(",")) {
- final String[] parts = value.split(":");
- if (parts.length > 1 && !routeValues.containsKey(parts[0])) {
- routeValues.put(parts[0], parts[1]);
- }
- }
- }
-
- return MvcDataImpl.newBuilder()
- .controllerAreaName(controllerNameParts[0])
- .controllerName(controllerNameParts[1])
- .areaName(viewNameParts[0])
- .viewName(viewNameParts[1])
- .regionAreaName(regionNameParts[0])
- .regionName(regionNameParts[1])
- .actionName(actionName)
- .metadata(mvcMetadata)
- .routeValues(routeValues)
- .build();
- }
-
/**
* {@inheritDoc}
*/
diff --git a/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/PageBuilderImpl.java b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/PageBuilderImpl.java
index 0d7270f65..7082addb7 100644
--- a/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/PageBuilderImpl.java
+++ b/dxa-framework/dxa-tridion-provider/src/main/java/com/sdl/webapp/tridion/mapping/PageBuilderImpl.java
@@ -24,17 +24,16 @@
import com.sdl.webapp.common.api.model.region.RegionModelImpl;
import com.sdl.webapp.common.api.model.region.RegionModelSetImpl;
import com.sdl.webapp.common.exceptions.DxaException;
-import com.sdl.webapp.common.util.TcmUtils;
import com.sdl.webapp.tridion.SemanticFieldDataProviderImpl;
import com.sdl.webapp.tridion.fields.FieldConverterRegistry;
import com.sdl.webapp.tridion.fields.converters.FieldConverter;
import com.sdl.webapp.tridion.fields.exceptions.FieldConverterException;
import com.sdl.webapp.tridion.fields.exceptions.UnsupportedFieldTypeException;
import com.sdl.webapp.util.dd4t.FieldUtils;
+import com.sdl.webapp.util.dd4t.MvcDataHelper;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;
import org.dd4t.contentmodel.ComponentPresentation;
-import org.dd4t.contentmodel.ComponentTemplate;
import org.dd4t.contentmodel.Field;
import org.dd4t.contentmodel.FieldSet;
import org.dd4t.contentmodel.FieldType;
@@ -52,15 +51,15 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import static com.google.common.base.Strings.isNullOrEmpty;
+import static com.sdl.webapp.util.dd4t.MvcDataHelper.createPageMvcData;
+import static com.sdl.webapp.util.dd4t.MvcDataHelper.createRegionMvcData;
+import static com.sdl.webapp.util.dd4t.MvcDataHelper.getRegionName;
@Component
public final class PageBuilderImpl implements PageBuilder {
@@ -79,20 +78,6 @@ public final class PageBuilderImpl implements PageBuilder {
private static final String COMPONENT_PAGE_TITLE_FIELD_NAME = "headline";
- private static final String DEFAULT_AREA_NAME = "Core";
-
- private static final String PAGE_CONTROLLER_NAME = "Page";
-
- private static final String PAGE_ACTION_NAME = "Page";
-
- private static final String REGION_CONTROLLER_NAME = "Region";
-
- private static final String REGION_ACTION_NAME = "Region";
-
- private static final String DEFAULT_REGION_NAME = "Main";
-
- private static final Pattern REGION_VIEW_NAME_PATTERN = Pattern.compile(".*\\[(.*)\\]");
-
@Autowired
private ModelBuilderPipeline modelBuilderPipeline;
@@ -173,22 +158,6 @@ private static String extract(Map metaMap, String key) {
return metaMap.get(key).getValues().get(0).toString();
}
- private static String getRegionName(ComponentPresentation cp) {
- final Map templateMeta = cp.getComponentTemplate().getMetadata();
- if (templateMeta != null) {
- String regionName = FieldUtils.getStringValue(templateMeta, "regionName");
- if (isNullOrEmpty(regionName)) {
- //fallback if region name field is empty, use regionView name
- regionName = FieldUtils.getStringValue(templateMeta, "regionView");
- if (isNullOrEmpty(regionName)) {
- regionName = DEFAULT_REGION_NAME;
- }
- }
- return regionName;
- }
-
- return null;
- }
private static Map createXpmMetaData(org.dd4t.contentmodel.Page page, Localization localization) {
final PageTemplate pageTemplate = page.getPageTemplate();
@@ -205,28 +174,6 @@ private static Map createXpmMetaData(org.dd4t.contentmodel.Page
return xpmMetaDataBuilder.build();
}
- private static String[] getPageViewNameParts(PageTemplate pageTemplate) {
- String fullName = FieldUtils.getStringValue(pageTemplate.getMetadata(), "view");
- if (isNullOrEmpty(fullName)) {
- fullName = pageTemplate.getTitle().replaceAll(" ", "");
- }
- return splitName(fullName);
- }
-
- private static String[] getRegionViewNameParts(ComponentTemplate componentTemplate) {
- String fullName = FieldUtils.getStringValue(componentTemplate.getMetadata(), "regionView");
- if (isNullOrEmpty(fullName)) {
- final Matcher matcher = REGION_VIEW_NAME_PATTERN.matcher(componentTemplate.getTitle());
- fullName = matcher.matches() ? matcher.group(1) : DEFAULT_REGION_NAME;
- }
- return splitName(fullName);
- }
-
- private static String[] splitName(String name) {
- final String[] parts = name.split(":");
- return parts.length > 1 ? parts : new String[]{DEFAULT_AREA_NAME, name};
- }
-
/**
* {@inheritDoc}
*/
@@ -326,10 +273,11 @@ private PageModel createPageModel(org.dd4t.contentmodel.Page genericPage, Locali
final Class extends ViewModel> entityClass = viewModelRegistry.getMappedModelTypes(semanticSchema.getFullyQualifiedNames());
pageModel = (PageModel) createViewModel(entityClass, semanticSchema, genericPage);
} else {
- throw new DxaException(String.format("Cannot instantiate new page of template %s", genericPage.getPageTemplate().getTitle()));
+ throw new DxaException(String.format("Cannot instantiate new page of template '%s' with Mvc data = %s",
+ genericPage.getPageTemplate().getTitle(), pageMvcData.toString()));
}
- pageModel.setId(String.valueOf(TcmUtils.getItemId(genericPage.getId())));
+ pageModel.setId(genericPage.getId());
// It's confusing, but what DD4T calls the "title" is what is called the "name" in the view model
pageModel.setName(genericPage.getTitle());
@@ -536,66 +484,6 @@ private Map processMetadataField(final Field field) {
return result;
}
- private MvcData createPageMvcData(PageTemplate pageTemplate) {
- final String[] viewNameParts = getPageViewNameParts(pageTemplate);
- return MvcDataCreator.creator()
- .defaults(DefaultsMvcData.CORE_PAGE)
- .builder()
- .areaName(viewNameParts[0])
- .viewName(viewNameParts[1])
- .metadata(getMvcMetadata(pageTemplate))
- .build();
- }
-
- private MvcData createRegionMvcData(ComponentTemplate componentTemplate) {
- final String[] viewNameParts = getRegionViewNameParts(componentTemplate);
- return MvcDataCreator.creator()
- .defaults(DefaultsMvcData.CORE_REGION)
- .builder()
- .areaName(viewNameParts[0])
- .viewName(viewNameParts[1])
- .build();
- }
-
- private Map getMvcMetadata(PageTemplate pageTemplate) {
-
- Map metadata = new HashMap<>();
- Map metadataFields = pageTemplate.getMetadata();
- for (Map.Entry entry : metadataFields.entrySet()) {
-
- String fieldName = entry.getKey();
- if (fieldName.equals("view") ||
- fieldName.equals("includes")) {
- continue;
- }
- Field field = entry.getValue();
- if (field.getFieldType() == FieldType.EMBEDDED) {
- // Output embedded field as List