Skip to content

Commit

Permalink
2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rpannekoek committed Feb 13, 2018
2 parents 1610c7b + 0328e33 commit d7f3004
Show file tree
Hide file tree
Showing 309 changed files with 921 additions and 29,642 deletions.
54 changes: 29 additions & 25 deletions README.md
Expand Up @@ -4,19 +4,19 @@ SDL Digital Experience Accelerator Java Spring MVC web application

About
-----
The SDL Digital Experience Accelerator (DXA) is a reference implementation of SDL Web 8 and SDL Tridion 2013 SP1(*) intended to help you create, design and publish an SDL Web/Tridion-based website quickly.
The SDL Digital Experience Accelerator (DXA) is a reference implementation of SDL Web (version 8, 8.5, or Cloud) that we provide to help you more quickly create, design, and publish a website based on SDL Web.

It is available for .NET and Java Web Applications and has a modular architecture consisting of a Framework and example web application providing core functionality and separate Modules for additional, optional functionality.
DXA is available for both .NET and Java web applications. Its modular architecture consists of a framework and example web application, which includes all core SDL Web functionality as well as separate Modules for additional, optional functionality.

This repository contains the source code of the DXA Framework, example web application and Maven archetype for Java.
The full DXA distribution (including CM-side items and installation support) is downloadable from the [SDL Appstore site](https://appstore.sdl.com/web-content-management/app/sdl-digital-experience-accelerator-java/737/) (latest version)
or the [Releases in GitHub](https://github.com/sdl/dxa-web-application-java/releases) (all versions)
This repository contains the source code of the DXA Framework, an example Java web application, and a Maven archetype for Java.

The full DXA distribution (including Content Manager-side items and installation support) is downloadable from the [SDL Appstore site](https://appstore.sdl.com/web-content-management/app/sdl-digital-experience-accelerator-java/737/) (latest version)
or the [Releases in GitHub](https://github.com/sdl/dxa-web-application-java/releases) (all versions)
Furthermore, the compiled DXA artifacts are available on [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cdxa).
To facilitate upgrades, it is highly recommended to use official, compiled DXA artifacts from Maven Central instead of a custom build.
If you really have to modify the DXA Framework, we kindly request you to submit your changes as a Contribution; see below.

(*) SDL Tridion 2013 SP1 is only supported up to DXA version 1.6.
To facilitate upgrades, we strongly recommend that you use official, compiled DXA artifacts from Maven Central instead of a custom build.
If you really must modify the DXA framework, we kindly request you to submit your changes as a Contribution (see the Branches and Contributions section below).


Support
---------------
Expand All @@ -25,12 +25,12 @@ If you encounter any issues with the Digital Experience Accelerator, please reac

- Report issues directly in [this repository](https://github.com/sdl/dxa-web-application-java/issues)
- Ask questions 24/7 on the SDL Web Community at https://tridion.stackexchange.com
- Contact Technical Support through the Customer Support Web Portal at https://www.sdl.com/support
- Contact Technical Support through the SDL Support web portal at https://www.sdl.com/support


Documentation
-------------
Documentation can be found online in the SDL documentation portal: http://docs.sdl.com/sdldxa2-ctp
Documentation can be found online in the SDL documentation portal: http://docs.sdl.com/sdldxa20


Repositories
Expand All @@ -41,51 +41,55 @@ The following repositories with source code are available:
- https://github.com/sdl/dxa-html-design - Whitelabel HTML Design
- https://github.com/sdl/dxa-model-service - Model Service (Java)
- https://github.com/sdl/dxa-modules - Modules (.NET and Java)
- https://github.com/sdl/dxa-web-application-dotnet - ASP.NET MVC web application (incl. framework)
- https://github.com/sdl/dxa-web-application-java - Java Spring MVC web application (incl. framework)
- https://github.com/sdl/dxa-web-application-dotnet - ASP.NET MVC web application (including framework)
- https://github.com/sdl/dxa-web-application-java - Java Spring MVC web application (including framework)


Branches and Contributions
--------------------------
We are using the following branching strategy:

- `master` - Represents the latest stable version. This may be a pre-release version (tagged as `DXA x.y Sprint z`). Updated each development Sprint (approx. bi-weekly).
- `master` - Represents the latest stable version. This may be a pre-release version (tagged as `DXA x.y Sprint z`). Updated each development Sprint (approximately bi-weekly).
- `develop` - Represents the latest development version. Updated very frequently (typically nightly).
- `release/x.y` - Represents the x.y Release. If hotfixes are applicable, they will be applied to the appropriate release branch, so that the release branch actually represent the initial release plus hotfixes.
- `release/x.y` - Represents the x.y Release. If hotfixes are applicable, they will be applied to the appropriate release branch so that the branch actually represents the initial release plus hotfixes.

All releases (including pre-releases and hotfix releases) are tagged.

Note that development sources (on `develop` branch) have dependencies on SNAPSHOT versions of the DXA artifacts, which are available here: https://oss.sonatype.org/content/repositories/snapshots/com/sdl/dxa/

If you wish to submit a Pull Request, it should normally be submitted on the `develop` branch, so it can be incorporated in the upcoming release.
If you wish to submit a Pull Request, it should normally be submitted on the `develop` branch so that it can be incorporated in the upcoming release.

Fixes for really severe/urgent issues (which qualify as hotfixes) should be submitted as Pull Request on the appropriate release branch.
Fixes for severe/urgent issues (that qualify as hotfixes) should be submitted as Pull Requests on the appropriate release branch.

Please always submit an Issue for the problem and indicate whether you think it qualifies as a hotfix; Pull Requests on release branches will only be accepted after agreement on the severity of the issue.
Always submit an Issue for the problem, and indicate whether you think it qualifies as a hotfix. Pull Requests on release branches will only be accepted after agreement on the severity of the issue.
Furthermore, Pull Requests on release branches are expected to be extensively tested by the submitter.

Of course, it's also possible (and appreciated) to report an Issue without associated Pull Requests.
Of course, it is also possible (and appreciated) to report an issue without associated Pull Requests.


DXA Builder
-----------
Current DXA Builder is available in Maven Central, latest DXA Builder is also available as a public snapshot.
The current DXA Builder is available in Maven Central, and the latest DXA Builder is also available as a public snapshot.

If you have not configured a snapshot repository and don't want to, you may need to install the DXA Builder locally in order to run the SNAPSHOT.

To install it, run the wrapper script of the `dxa-builder` project: `gradlew(.bat) publishLocal`
On Windows, you can also just run `get-started.cmd` script at first run.

You may need DXA Builder to be installed locally to run the SNAPSHOT build if you haven't configured snapshot repository and you don't want to.
To install it run the wrapper script of `dxa-builder` project: `gradlew(.bat) publishLocal`
On Windows you can also just run `get-started.cmd` script at first run.

DD4T support
---
DD4T 2.1 for Java is incorporated into DXA codebase in `dxa-compatible` artifact. You don't need separate dependencies on DD4T if you're migrating to DXA from DD4T.
DD4T 2.1 for Java is incorporated into the DXA codebase in the `dxa-compatible` artifact. As a result, when migrating from DD4T to DXA, you do not need separate dependencies on DD4T.


Snapshots
---------
DXA publishes SNAPSHOT versions to Sonatype. If you want to use them, you have to configure `https://oss.sonatype.org/content/repositories/snapshots` as a repository in your Maven settings. Read [this](https://maven.apache.org/settings.html#Repositories) for instructions.
DXA publishes SNAPSHOT versions to Sonatype. To use them, configure `https://oss.sonatype.org/content/repositories/snapshots` as a repository in your Maven settings. Read [this](https://maven.apache.org/settings.html#Repositories) for instructions.


License
-------
Copyright (c) 2014-2017 SDL Group.
Copyright (c) 2014-2018 SDL Group.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion dxa-builder/gradle.properties
@@ -1 +1 @@
version=2.0.0-SNAPSHOT
version=2.0.0
2 changes: 1 addition & 1 deletion dxa-dd4t-ms-provider/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>dxa-oss-parent</artifactId>
<groupId>com.sdl.dxa</groupId>
<version>2.0.0-SNAPSHOT</version>
<version>2.0.0</version>
<relativePath>../dxa-oss-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion dxa-framework/dxa-common-api/pom.xml
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-framework</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.0.0</version>
</parent>

<artifactId>dxa-common-api</artifactId>
Expand Down
Expand Up @@ -45,7 +45,12 @@ public static AnchorElementBuilder a() {
}

public static AnchorElementBuilder a(String href) {
return a().withHref(href);
AnchorElementBuilder a = a();
if (href == null) {
return a;
}
String _href = href.trim();
return _href.isEmpty() ? a : a.withHref(_href);
}

public static ButtonElementBuilder button() {
Expand Down
Expand Up @@ -63,7 +63,7 @@ public void shouldDelegateKeyCalculationToConcreteCaches() {
pagesCopyingCache.setKeyGenerator(keyGenerator);
entitiesCache.setKeyGenerator(keyGenerator);
MvcModelData mvcData = new MvcModelData("a", "a", "a", "c", "v", null);
PageModelData pageData = (PageModelData) new PageModelData("1", null, null, null, null, null, null, "/url")
PageModelData pageData = (PageModelData) new PageModelData("1", null, null, null, null, null, "/url")
.setMvcData(mvcData);
EntityModelData entityMvcData = (EntityModelData) new EntityModelData("2", null, null, null, null, mvcData, "1", "/url", null, null, null)
.setMvcData(mvcData);
Expand Down
Expand Up @@ -3,6 +3,7 @@
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;

/**
Expand Down Expand Up @@ -38,6 +39,21 @@ public void testA() {
assertThat(HtmlBuilders.a("http://localhost:8080").build().toHtml(), is("<a href=\"http://localhost:8080\"></a>"));
}

@Test
public void shouldNotAddHref_IfItsEmpty() {
//given

//when
AnchorElementBuilder nullA = HtmlBuilders.a(null);
AnchorElementBuilder emptyA = HtmlBuilders.a("");
AnchorElementBuilder trimA = HtmlBuilders.a(" ");

//then
assertFalse(nullA.build().renderHtml().contains("href"));
assertFalse(emptyA.build().renderHtml().contains("href"));
assertFalse(trimA.build().renderHtml().contains("href"));
}

@Test
public void testButton() {
assertThat(HtmlBuilders.button().build().toHtml(), is("<button></button>"));
Expand Down
2 changes: 1 addition & 1 deletion dxa-framework/dxa-common/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>dxa-framework</artifactId>
<groupId>com.sdl.dxa</groupId>
<version>2.0.0-SNAPSHOT</version>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Expand Up @@ -29,7 +29,7 @@ public final class PathUtils {

private static final Pattern PAGE_TITLE_SEQUENCE = Pattern.compile("^(?<sequence>\\d{3}\\s?)(?<pageName>(?<sequenceStop>[^\\d]).*)$");

private static final Pattern FILE_NAME_PATTERN = Pattern.compile(".*?/?(?<fileName>[^/.]*)\\.(?<extension>[^/.]*)$");
private static final Pattern FILE_NAME_PATTERN = Pattern.compile(".*?/?(?<fileName>[^/.]*)(\\.(?<extension>[^/.]*))?$");

private static final Pattern INDEX_PATH_REGEXP = Pattern.compile("^(?<main>.*)(?<index>/(index(\\.html)?)?)$");

Expand Down
Expand Up @@ -9,6 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;

import java.util.Optional;
Expand All @@ -29,14 +30,20 @@ public abstract class AbstractLinkResolver implements LinkResolver {
@Deprecated
public static final String DEFAULT_PAGE_EXTENSION = PathUtils.getDefaultPageExtension();

@Value("${dxa.web.link-resolver.remove-extension:#{true}}")
private boolean shouldRemoveExtension;

@Value("${dxa.web.link-resolver.strip-index-path:#{true}}")
private boolean shouldStripIndexPath;

@Override
@Cacheable(value = "defaultCache", key = "{ #root.methodName, #url, #localizationId, #resolveToBinary }")
public String resolveLink(@Nullable String url, @Nullable String localizationId, boolean resolveToBinary) {
final int publicationId = !Strings.isNullOrEmpty(localizationId) ? Integer.parseInt(localizationId) : 0;

String resolvedUrl = _resolveLink(url, publicationId, resolveToBinary);

return PathUtils.stripDefaultExtension(PathUtils.stripIndexPath(resolvedUrl));
String resolvedLink = _resolveLink(url, publicationId, resolveToBinary);
String resolvedUrl = shouldStripIndexPath ? PathUtils.stripIndexPath(resolvedLink) : resolvedLink;
return shouldRemoveExtension ? PathUtils.stripDefaultExtension(resolvedUrl) : resolvedUrl;
}

@Contract("null, _, _ -> null; !null, _, _ -> !null")
Expand Down
Expand Up @@ -2,6 +2,7 @@

import org.junit.Test;
import org.springframework.context.annotation.Profile;
import org.springframework.test.util.ReflectionTestUtils;

import java.util.Optional;
import java.util.function.Function;
Expand All @@ -10,11 +11,10 @@

public class AbstractLinkResolverTest {

private TestLinkResolver linkResolver = new TestLinkResolver();

@Test
public void shouldReturnUrlItself_IfNotTcmUri() {
//given
TestLinkResolver linkResolver = new TestLinkResolver();

//when
String index = linkResolver.resolveLink("/index", "1");
Expand All @@ -32,6 +32,7 @@ public void shouldReturnUrlItself_IfNotTcmUri() {
@Test
public void shouldGetPublicationIdFromTcmUri_IfPublicationIdIsNullOrEmpty() {
//given
TestLinkResolver linkResolver = new TestLinkResolver();

//when
String link = linkResolver.resolveLink("tcm:2-3", null);
Expand All @@ -44,9 +45,66 @@ public void shouldGetPublicationIdFromTcmUri_IfPublicationIdIsNullOrEmpty() {
assertEquals("resolved-page-2", linkPage);
}

@Test
public void shouldNotRemoveExtension_IfDisabled() {
//given
TestLinkResolver linkResolver = new TestLinkResolver(false, true);

//when
String indexHtml = linkResolver.resolveLink("/index.html", "1");

//then
assertEquals("/index.html", indexHtml);
}

@Test
public void shouldNotRemoveIndex_IfDisabled() {
//given
TestLinkResolver linkResolver = new TestLinkResolver(true, false);

//when
String indexHtml = linkResolver.resolveLink("/index", "1");

//then
assertEquals("/index", indexHtml);
}

@Test
public void shouldNotRemoveIndex_IfExtensionIsNotRemoved() {
//given
TestLinkResolver linkResolver = new TestLinkResolver(false, true);

//when
String indexHtml = linkResolver.resolveLink("/index.html", "1");

//then
assertEquals("/index.html", indexHtml);
}

@Test
public void shouldNotRemoveIndexOrExtension_IfDisabled() {
//given
TestLinkResolver linkResolver = new TestLinkResolver(false, false);

//when
String indexHtml = linkResolver.resolveLink("/index.html", "1");

//then
assertEquals("/index.html", indexHtml);
}

@Profile("test")
private static class TestLinkResolver extends AbstractLinkResolver {

public TestLinkResolver() {
super();
ReflectionTestUtils.setField(this, "shouldRemoveExtension", true);
ReflectionTestUtils.setField(this, "shouldStripIndexPath", true);
}

public TestLinkResolver(boolean shouldRemoveExtension, boolean shouldStripIndexPath) {
}

@Override
protected Function<ResolvingData, Optional<String>> _binaryResolver() {
return resolvingData -> Optional.of("resolved-binary-" + resolvingData.getPublicationId());
Expand Down

0 comments on commit d7f3004

Please sign in to comment.