Skip to content

Commit

Permalink
DXA 2.0 Sprint 5
Browse files Browse the repository at this point in the history
  • Loading branch information
rpannekoek committed Mar 21, 2017
2 parents 8eb68ea + 63d264e commit cb9bfe2
Show file tree
Hide file tree
Showing 103 changed files with 2,148 additions and 1,252 deletions.
12 changes: 11 additions & 1 deletion dxa-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<mockito-version>1.10.19</mockito-version>

<!-- Spring -->
<spring.version>4.3.5.RELEASE</spring.version>
<spring.version>4.3.7.RELEASE</spring.version>
<spring-security.version>4.1.4.RELEASE</spring-security.version>

<jsoup.version>1.7.3</jsoup.version>
Expand All @@ -115,11 +115,21 @@
<artifactId>dxa-data-model</artifactId>
<version>${dxa.version}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common</artifactId>
<version>${dxa.version}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common-api</artifactId>
<version>${dxa.version}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-compatible</artifactId>
<version>${dxa.version}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common-impl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ class Property {
split.each {
String[] ab = it.split('->')
ab[0].split(',').each {
valueMapping.put it.trim(), ab[1].trim()
def key = it.trim()
def value = key == '$self$' ? key : ab[1].trim()
if (value == '$null$') {
value = null
} // mapping to null value
valueMapping.put key, value
}
}
this
Expand Down Expand Up @@ -44,6 +49,18 @@ class Property {
//endregion

String deriveValue(String value) {
this.valueMapping ? this.valueMapping.get(value) : value
if (value == null) {
return null
}
if (this.valueMapping) {
if (this.valueMapping.containsKey(value)) {
return this.valueMapping.get(value)
} else if (this.valueMapping.containsKey('$self$')) {
return value
}
throw new IllegalArgumentException("Cannot map $value for property $name")
} else {
return value
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ class Validator {
|| url?.matches(/^((https?|ftp):\/\/)?localhost(:\d+)?(\/[^\s]*)?$/))
})
}

static Validator emptyValue() {
new Validator(description: 'Should be empty value or null', validate: { String it ->
it == null || it.isEmpty()
})
}
//endregion

private static String removePath(String ipOrDomain) {
Expand Down
5 changes: 5 additions & 0 deletions dxa-framework/dxa-common-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<description>DXA Common API project containing framework interfaces and API</description>

<dependencies>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.sdl.webapp.common.api.model.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.sdl.dxa.common.util.PathUtils;
import com.sdl.webapp.common.api.localization.Localization;
import com.sdl.webapp.common.api.mapping.semantic.annotations.SemanticEntity;
import com.sdl.webapp.common.api.mapping.semantic.annotations.SemanticProperties;
import com.sdl.webapp.common.api.mapping.semantic.annotations.SemanticProperty;
import com.sdl.webapp.common.util.LocalizationUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

Expand Down Expand Up @@ -41,7 +41,7 @@ public class Link extends AbstractEntityModel {
* @return whether this request path is in context of this link
*/
public boolean isCurrentContext(String requestPath, Localization localization) {
return LocalizationUtils.isActiveContextPath(requestPath, localization, getUrl());
return PathUtils.isActiveContextPath(requestPath, localization.getPath(), getUrl());
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.sdl.webapp.common.api.model.mvcdata;

import com.sdl.dxa.api.datamodel.model.MvcModelData;
import com.sdl.dxa.common.util.MvcUtils;
import com.sdl.webapp.common.api.model.MvcData;
import com.sdl.webapp.common.util.StringUtils;

import java.util.Map;

Expand Down Expand Up @@ -74,30 +75,12 @@ public MvcData create() {
* @return new instance of creator
*/
public MvcDataCreator fromQualifiedName(String qualifiedViewName) {
String[] parts = qualifiedViewName == null || qualifiedViewName.isEmpty() ? null :
StringUtils.dashify(qualifiedViewName).split(":");

if (parts == null || parts.length < 1 || parts.length > 3) {
throw new IllegalArgumentException(
String.format("Invalid format for Qualified View Name: '%s'. " +
"Format must be 'ViewName' or 'AreaName:ViewName' " +
"or 'AreaName:ControllerName:ViewName.'", qualifiedViewName));
}
MvcModelData mvcModelData = MvcUtils.parseMvcQualifiedViewName(qualifiedViewName);

MvcDataImpl.MvcDataImplBuilder builder = MvcDataImpl.newBuilder();

if (parts.length == 1) {
builder.viewName(parts[0]);

} else if (parts.length == 2) {
builder.areaName(parts[0])
.viewName(parts[1]);

} else if (parts.length == 3) {
builder.areaName(parts[0])
.controllerName(parts[1])
.viewName(parts[2]);
}
builder.viewName(mvcModelData.getViewName());
builder.areaName(mvcModelData.getAreaName());
builder.controllerName(mvcModelData.getControllerName());

this.mvcData = builder.build();
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.sdl.webapp.common.api.xpm.XpmRegionConfig;
import com.sdl.webapp.common.exceptions.DxaException;
import com.sdl.webapp.common.util.ApplicationContextHolder;
import com.sdl.webapp.common.util.XpmUtils;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -38,22 +39,25 @@
public class RegionModelImpl extends AbstractViewModel implements RegionModel {

/**
* The XPM metadata key used for the ID of the (Include) Page from which the Region originates.
* Avoid using this in implementation code because it may change in a future release.
* @see XpmUtils.RegionXpmBuilder#INCLUDED_FROM_PAGE_ID_XPM_METADATA_KEY
* @deprecated since 2.0, use {@link XpmUtils.RegionXpmBuilder#INCLUDED_FROM_PAGE_ID_XPM_METADATA_KEY}
*/
public static final String INCLUDED_FROM_PAGE_ID_XPM_METADATA_KEY = "IncludedFromPageID";
@Deprecated
public static final String INCLUDED_FROM_PAGE_ID_XPM_METADATA_KEY = XpmUtils.RegionXpmBuilder.INCLUDED_FROM_PAGE_ID_XPM_METADATA_KEY;

/**
* The XPM metadata key used for the title of the (Include) Page from which the Region originates.
* Avoid using this in implementation code because it may change in a future release.
* @see XpmUtils.RegionXpmBuilder#INCLUDED_FROM_PAGE_TITLE_XPM_METADATA_KEY
* @deprecated since 2.0, use {@link XpmUtils.RegionXpmBuilder#INCLUDED_FROM_PAGE_TITLE_XPM_METADATA_KEY}
*/
public static final String INCLUDED_FROM_PAGE_TITLE_XPM_METADATA_KEY = "IncludedFromPageTitle";
@Deprecated
public static final String INCLUDED_FROM_PAGE_TITLE_XPM_METADATA_KEY = XpmUtils.RegionXpmBuilder.INCLUDED_FROM_PAGE_TITLE_XPM_METADATA_KEY;

/**
* The XPM metadata key used for the file name of the (Include) Page from which the Region originates.
* Avoid using this in implementation code because it may change in a future release.
* @see XpmUtils.RegionXpmBuilder#INCLUDED_FROM_PAGE_FILE_NAME_XPM_METADATA_KEY
* @deprecated since 2.0, use {@link XpmUtils.RegionXpmBuilder#INCLUDED_FROM_PAGE_FILE_NAME_XPM_METADATA_KEY}
*/
public static final String INCLUDED_FROM_PAGE_FILE_NAME_XPM_METADATA_KEY = "IncludedFromPageFileName";
@Deprecated
public static final String INCLUDED_FROM_PAGE_FILE_NAME_XPM_METADATA_KEY = XpmUtils.RegionXpmBuilder.INCLUDED_FROM_PAGE_FILE_NAME_XPM_METADATA_KEY;

private static final String XPM_REGION_MARKUP = "<!-- Start Region: {title: \"%s\", allowedComponentTypes: [%s], minOccurs: %s} -->";

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public static boolean parentFolderExists(@NotNull File file, boolean createIfNot
return parentFile != null && (parentFile.exists() || createIfNot && parentFile.mkdirs());
}

/**
* @deprecated since 2.0, use {@link com.sdl.dxa.common.util.PathUtils#hasExtension(String)} instead
*/
@Deprecated
public static boolean hasExtension(@NotNull String path) {
return path.lastIndexOf('.') > path.lastIndexOf('/');
}
Expand Down
Loading

0 comments on commit cb9bfe2

Please sign in to comment.