Skip to content

Commit b44d5f6

Browse files
committed
DXA DXA 2.0 CTP 2 Release
2 parents 94237a7 + a810248 commit b44d5f6

131 files changed

Lines changed: 5744 additions & 3304 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ task help(type: MavenHelpTask)
3131

3232
task buildFramework(type: MavenBuildTask) {
3333
configurations = [
34-
//["dxa-bom"],
34+
["dxa-oss-parent"],
3535
["dxa-framework"],
3636
["> dxa-webapp > clean org.apache.maven.plugins:maven-archetype-plugin:2.4:create-from-project -Darchetype.properties=archetype.properties"]
3737
]

dxa-builder/build.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,33 @@ targetCompatibility = '1.8'
1010

1111
def isRelease = !version.endsWith("-SNAPSHOT") && project.hasProperty('release')
1212

13+
gradle.taskGraph.whenReady { taskGraph ->
14+
if (taskGraph.allTasks.any { it instanceof Sign }) {
15+
if (isRelease && !(project.hasProperty('signing.keyId') &&
16+
project.hasProperty('signing.secretKeyRingFile') &&
17+
project.hasProperty('signing.password'))) {
18+
def reader = System.in.newReader()
19+
println "\n\nWe have to sign some things in this build." +
20+
"\n\nPlease enter your signing details."
21+
22+
println "PGP Key Id: "
23+
def id = reader.readLine()
24+
25+
println "PGP Secret Key Ring File (absolute path): "
26+
def file = reader.readLine()
27+
28+
println "PGP Private Key Password: "
29+
def password = reader.readLine()
30+
31+
allprojects { ext."signing.keyId" = id }
32+
allprojects { ext."signing.secretKeyRingFile" = file }
33+
allprojects { ext."signing.password" = password }
34+
35+
reader.printf "\nThanks.\n\n"
36+
}
37+
}
38+
}
39+
1340
task wrapper(type: Wrapper) {
1441
gradleVersion = '2.9'
1542
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"

dxa-builder/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=2.0.0-SNAPSHOT
1+
version=2.0.0-CTP2

dxa-builder/src/main/groovy/com/sdl/dxa/builder/configuration/parameters/XmlProperty.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.sdl.dxa.builder.configuration.parameters
22

3+
import org.jdom2.Namespace
4+
35
class XmlProperty extends Property {
46

57
private Map<String, String> xmlAddNodesMap = [:]
68
private Map<String, String> xmlAddAttributesMap = [:]
79
private String[] xmlModifyArray = []
810

11+
Namespace namespace
912
boolean canBeEmpty
1013
Map<String, Tuple2<String, String>> addNodesMap = [:]
1114
Map<String, Tuple2<String, String>> addAttributesMap = [:]
@@ -26,6 +29,12 @@ class XmlProperty extends Property {
2629
this
2730
}
2831

32+
XmlProperty thatModifiesXml(Namespace namespace, String... xmlModifyNodes) {
33+
this.xmlModifyArray = xmlModifyNodes
34+
this.namespace = namespace
35+
this
36+
}
37+
2938
XmlProperty thatCanBeEmpty() {
3039
this.canBeEmpty = true
3140
this

dxa-builder/src/main/groovy/com/sdl/dxa/builder/configuration/writers/XmlWriter.groovy

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.sdl.dxa.builder.configuration.writers
33
import com.sdl.dxa.builder.configuration.parameters.XmlProperty
44
import org.jdom2.Document
55
import org.jdom2.Element
6+
import org.jdom2.filter.Filters
67
import org.jdom2.input.SAXBuilder
78
import org.jdom2.output.Format
89
import org.jdom2.output.XMLOutputter
@@ -53,15 +54,15 @@ class XmlWriter {
5354
this
5455
}
5556

56-
XmlWriter addAttributes(Map<String, Tuple2<String, String>> mapToAdd) {
57-
bulkEdit mapToAdd, { nodes, Tuple2<String, String> value ->
57+
XmlWriter addAttributes(Map<String, Tuple2<String, String>> mapToAdd, XmlProperty xmlProperty) {
58+
bulkEdit mapToAdd, xmlProperty, { nodes, Tuple2<String, String> value ->
5859
nodes*.setAttribute(value.first, value.second)
5960
}
6061
this
6162
}
6263

63-
XmlWriter addNodesAfter(Map<String, Tuple2<String, String>> mapToAdd) {
64-
bulkEdit mapToAdd, { nodes, Tuple2<String, String> value ->
64+
XmlWriter addNodesAfter(Map<String, Tuple2<String, String>> mapToAdd, XmlProperty xmlProperty) {
65+
bulkEdit mapToAdd, xmlProperty, { nodes, Tuple2<String, String> value ->
6566
def tagName = value.first
6667
def tagValue = value.second
6768

@@ -73,22 +74,41 @@ class XmlWriter {
7374
this
7475
}
7576

76-
XmlWriter modifyByXPath(Map<String, String> mapToModify) {
77-
bulkEdit mapToModify, { nodes, value ->
77+
XmlWriter modifyByXPath(Map<String, String> mapToModify, XmlProperty xmlProperty) {
78+
bulkEdit mapToModify, xmlProperty, { nodes, value ->
7879
nodes*.value = value
7980
}
8081
this
8182
}
8283

84+
85+
XmlWriter addAttributes(Map<String, Tuple2<String, String>> mapToAdd) {
86+
addAttributes mapToAdd, null
87+
}
88+
89+
XmlWriter addNodesAfter(Map<String, Tuple2<String, String>> mapToAdd) {
90+
addNodesAfter mapToAdd, null
91+
}
92+
93+
XmlWriter modifyByXPath(Map<String, String> mapToModify) {
94+
modifyByXPath mapToModify, null
95+
}
96+
8397
XmlWriter modify(XmlProperty xmlProperty) {
84-
addNodesAfter(xmlProperty.addNodesMap)
85-
addAttributes(xmlProperty.addAttributesMap)
86-
modifyByXPath(xmlProperty.modifyMap)
98+
addNodesAfter(xmlProperty.addNodesMap, xmlProperty)
99+
addAttributes(xmlProperty.addAttributesMap, xmlProperty)
100+
modifyByXPath(xmlProperty.modifyMap, xmlProperty)
87101
}
88102

89-
private bulkEdit(Map<String, ?> map, Closure callback) {
103+
private bulkEdit(Map<String, ?> map, XmlProperty xmlProperty, Closure callback) {
90104
map?.each {
91-
callback xPathFactory.compile(it.key).evaluate(document), it.value
105+
if (xmlProperty != null && xmlProperty.namespace != null) {
106+
return callback(xPathFactory.compile(it.key, Filters.fpassthrough(), null,
107+
xmlProperty.namespace).evaluate(document), it.value)
108+
} else {
109+
return callback(xPathFactory.compile(it.key).evaluate(document), it.value)
110+
}
111+
92112
}
93113
}
94114
}

dxa-framework/dxa-common-api/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.sdl.dxa</groupId>
88
<artifactId>dxa-framework</artifactId>
9-
<version>2.0.0-SNAPSHOT</version>
9+
<version>2.0.0-CTP2</version>
1010
</parent>
1111

1212
<artifactId>dxa-common-api</artifactId>
@@ -63,6 +63,16 @@
6363
<artifactId>guava</artifactId>
6464
</dependency>
6565

66+
<dependency>
67+
<groupId>javax.cache</groupId>
68+
<artifactId>cache-api</artifactId>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.ehcache</groupId>
72+
<artifactId>ehcache</artifactId>
73+
<scope>test</scope>
74+
</dependency>
75+
6676
<!-- Joda Time -->
6777
<dependency>
6878
<groupId>joda-time</groupId>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.sdl.dxa.caching;
2+
3+
import com.google.common.collect.Lists;
4+
import com.sdl.webapp.common.api.WebRequestContext;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.cache.interceptor.KeyGenerator;
7+
import org.springframework.cache.interceptor.SimpleKeyGenerator;
8+
import org.springframework.stereotype.Component;
9+
10+
import java.lang.reflect.Method;
11+
12+
@Component
13+
public class LocalizationAwareKeyGenerator implements KeyGenerator {
14+
15+
@SuppressWarnings("SpringAutowiredFieldsWarningInspection")
16+
@Autowired
17+
private WebRequestContext webRequestContext;
18+
19+
@Override
20+
public Object generate(Object target, Method method, Object... params) {
21+
return SimpleKeyGenerator.generateKey(Lists.asList(webRequestContext.getLocalization().getId(), params).toArray(new Object[params.length + 1]));
22+
}
23+
24+
public Object generate(Object... params) {
25+
return generate(null, null, params);
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.sdl.dxa.caching;
2+
3+
import com.sdl.webapp.common.api.model.ViewModel;
4+
5+
import java.lang.annotation.ElementType;
6+
import java.lang.annotation.Inherited;
7+
import java.lang.annotation.Retention;
8+
import java.lang.annotation.RetentionPolicy;
9+
import java.lang.annotation.Target;
10+
11+
/**
12+
* Annotates types that should never be cached to be used with subtypes of {@link ViewModel}.
13+
*/
14+
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
15+
@Retention(RetentionPolicy.RUNTIME)
16+
@Inherited
17+
public @interface NeverCached {
18+
19+
/**
20+
* Qualifier of the annotated model to be used as a one-to-one identifier of the type.
21+
*
22+
* @return alias aka qualifier of the annotated model
23+
*/
24+
String qualifier();
25+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.sdl.dxa.caching.wrapper;
2+
3+
import com.sdl.webapp.common.api.model.MvcData;
4+
import lombok.Value;
5+
6+
import javax.servlet.http.HttpServletRequest;
7+
8+
/**
9+
* Composite key (DTO) for output caching.
10+
*/
11+
@Value
12+
public class CompositeOutputCacheKey {
13+
14+
private String pageId;
15+
16+
private String name;
17+
18+
private String include;
19+
20+
private MvcData mvcData;
21+
22+
private HttpServletRequest request;
23+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.sdl.dxa.caching.wrapper;
2+
3+
import lombok.Builder;
4+
import lombok.Value;
5+
6+
/**
7+
* Entity that determines if this key should be cached.
8+
*/
9+
@Value
10+
@Builder
11+
public class ConditionalKey {
12+
13+
private Object key;
14+
15+
private boolean skipCaching;
16+
}

0 commit comments

Comments
 (0)