Skip to content

Commit

Permalink
Merge branch 'release-12.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
markdaugherty committed Mar 12, 2019
2 parents 245e363 + 75ae4b2 commit 5b62b29
Show file tree
Hide file tree
Showing 27 changed files with 328 additions and 370 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# AEM Library

[ICF Olson](http://www.olsondigital.com)
[ICF Next](http://www.icfnext.com)

## Overview

The AEM Library contains common utilities, decorators, abstract classes, tag libraries, and JavaScript modules for bootstrapping and simplifying AEM (Adobe CQ) projects.

See the [project site](http://code.digitalatolson.com/aem-library) for the User Guide and project details.
See the [project site](http://icfnext.github.io/aem-library) for the User Guide and project details.

## Compatibility

AEM Library Version(s) | AEM Version
AEM Library Version(s) | AEM Version(s)
------------ | -------------
12.x.x | 6.3, 6.4, 6.5
11.1.x | 6.4.1 (SP1)
11.0.x | 6.4
10.2.x | 6.3.2.2 (SP2 CFP)
Expand Down
13 changes: 6 additions & 7 deletions aem-library-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.icfolson.aem.library</groupId>
<artifactId>aem-library</artifactId>
<version>11.1.0</version>
<version>12.0.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -80,12 +80,6 @@
</build>

<dependencies>
<!-- provided -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
Expand All @@ -94,5 +88,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.icfolson.aem.library.api.link;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
* A link represents the attributes that compose a URL with additional title and
* target properties to encapsulate the typical attributes of an HTML anchor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.icfolson.aem.library.api.link.builders;

import com.google.common.collect.SetMultimap;
import com.icfolson.aem.library.api.link.ImageLink;
import com.icfolson.aem.library.api.link.Link;
import com.icfolson.aem.library.api.link.NavigationLink;
import com.google.common.collect.SetMultimap;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -137,6 +137,26 @@ public interface LinkBuilder {
*/
LinkBuilder setHost(String host);

/**
* Set the scheme (e.g. "ftp" or "tel").
* <p>
* If set, the scheme will override the default value of "http" (or "https" if secure=true).
*
* @param scheme scheme
* @return builder
*/
LinkBuilder setScheme(String scheme);

/**
* Set whether the link URI is opaque (an absolute URI whose scheme-specific part does not begin with a slash
* character).
*
* @param isOpaque if true, ":" instead of "://" will be appended to the scheme for external links (e.g. "mailto:"
* links)
* @return builder
*/
LinkBuilder setOpaque(boolean isOpaque);

/**
* Set an image source. This only applies to image links returned by calling <code>buildImageLink()</code>.
*
Expand Down
39 changes: 25 additions & 14 deletions aem-library-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<groupId>com.icfolson.aem.library</groupId>
<artifactId>aem-library</artifactId>
<version>11.1.0</version>
<version>12.0.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -148,7 +150,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.icfolson.aem.prosper</groupId>
Expand Down Expand Up @@ -176,11 +178,6 @@
</dependency>

<!-- provided -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand All @@ -206,14 +203,16 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>

<!-- third party -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand All @@ -227,12 +226,17 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</dependency>

<!-- aem-library -->
<dependency>
<groupId>com.icfolson.aem.library</groupId>
<artifactId>aem-library-api</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>

<!-- test -->
Expand All @@ -248,5 +252,12 @@
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
</dependency>

<!-- uber jar last to allow overrides for newer dependency versions -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.icfolson.aem.library.core.link.builders.impl

import com.google.common.base.Charsets
import com.google.common.collect.LinkedHashMultimap
import com.google.common.collect.Multimaps
import com.google.common.collect.SetMultimap
import com.icfolson.aem.library.api.link.ImageLink
import com.icfolson.aem.library.api.link.Link
import com.icfolson.aem.library.api.link.NavigationLink
import com.icfolson.aem.library.api.link.builders.LinkBuilder
import com.icfolson.aem.library.api.link.enums.LinkTarget
import com.icfolson.aem.library.core.constants.PathConstants
import com.icfolson.aem.library.core.utils.PathUtils
import com.google.common.base.Charsets
import com.google.common.collect.LinkedHashMultimap
import com.google.common.collect.Multimaps
import com.google.common.collect.SetMultimap
import com.icfolson.aem.library.core.link.impl.DefaultImageLink
import com.icfolson.aem.library.core.link.impl.DefaultLink
import com.icfolson.aem.library.core.link.impl.DefaultNavigationLink
import com.icfolson.aem.library.core.utils.PathUtils
import groovy.util.logging.Slf4j
import org.apache.sling.api.resource.ResourceResolver

Expand Down Expand Up @@ -46,6 +46,10 @@ final class DefaultLinkBuilder implements LinkBuilder {

private String host = null

private String scheme = null

private boolean opaque = false

private String imageSource = ""

private int port = 0
Expand Down Expand Up @@ -206,6 +210,20 @@ final class DefaultLinkBuilder implements LinkBuilder {
this
}

@Override
LinkBuilder setScheme(String scheme) {
this.scheme = scheme

this
}

@Override
LinkBuilder setOpaque(boolean isOpaque) {
this.opaque = isOpaque

this
}

@Override
LinkBuilder setImageSource(String imageSource) {
this.imageSource = imageSource
Expand Down Expand Up @@ -251,9 +269,28 @@ final class DefaultLinkBuilder implements LinkBuilder {
private String buildHost() {
def builder = new StringBuilder()

if (!isExternal && host) {
builder.append(secure ? "https" : "http")
builder.append("://")
if (isExternal) {
// ex: www.icfnext.com
if (scheme && !path.startsWith(scheme)) {
builder.append(scheme).append(":")

if (!opaque) {
builder.append("//")
}
}
} else if (host) {
if (scheme) {
builder.append(scheme)
} else {
builder.append(secure ? "https" : "http")
}

builder.append(":")

if (!opaque) {
builder.append("//")
}

builder.append(host)

if (port > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.regex.Pattern;

import static com.icfolson.aem.library.core.constants.PathConstants.PATH_JCR_CONTENT;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.icfolson.aem.library.core.constants.PathConstants.PATH_JCR_CONTENT;
import static org.apache.sling.api.resource.Resource.RESOURCE_TYPE_NON_EXISTING;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class DefaultLinkBuilderSpec extends AemLibrarySpec {

builder.extension = extension
builder.suffix = suffix
builder.scheme = scheme
builder.host = host
builder.port = port
builder.secure = secure
Expand All @@ -183,16 +184,18 @@ class DefaultLinkBuilderSpec extends AemLibrarySpec {
link.href == href

where:
extension | suffix | host | port | secure | href
null | "" | "localhost" | 0 | false | "http://localhost/content.html"
null | "/suffix" | "localhost" | 0 | false | "http://localhost/content.html/suffix"
"" | "" | "localhost" | 0 | false | "http://localhost/content"
"" | "/suffix" | "localhost" | 0 | false | "http://localhost/content/suffix"
"html" | "" | "localhost" | 0 | false | "http://localhost/content.html"
"html" | "/suffix" | "localhost" | 0 | false | "http://localhost/content.html/suffix"
"json" | "" | "localhost" | 0 | false | "http://localhost/content.json"
null | "" | "localhost" | 4502 | false | "http://localhost:4502/content.html"
null | "" | "localhost" | 0 | true | "https://localhost/content.html"
extension | suffix | scheme | host | port | secure | href
null | "" | null | "localhost" | 0 | false | "http://localhost/content.html"
null | "/suffix" | null | "localhost" | 0 | false | "http://localhost/content.html/suffix"
"" | "" | null | "localhost" | 0 | false | "http://localhost/content"
"" | "/suffix" | null | "localhost" | 0 | false | "http://localhost/content/suffix"
"html" | "" | null | "localhost" | 0 | false | "http://localhost/content.html"
"html" | "/suffix" | null | "localhost" | 0 | false | "http://localhost/content.html/suffix"
"json" | "" | null | "localhost" | 0 | false | "http://localhost/content.json"
null | "" | null | "localhost" | 4502 | false | "http://localhost:4502/content.html"
null | "" | null | "localhost" | 0 | true | "https://localhost/content.html"
null | "" | "ftp" | "localhost" | 0 | false | "ftp://localhost/content.html"
null | "" | "ftp" | "localhost" | 0 | true | "ftp://localhost/content.html"
}

def "build link and set external"() {
Expand Down Expand Up @@ -227,6 +230,45 @@ class DefaultLinkBuilderSpec extends AemLibrarySpec {
"http://www.reddit.com" | ["a", "b"] | "http://www.reddit.com"
}

def "build link for path with scheme"() {
setup:
def link = LinkBuilderFactory.forPath(path)
.setScheme(scheme)
.setOpaque(opaque)
.build()

expect:
link.href == href

where:
path | scheme | opaque | href
"/content" | "http" | false | "/content.html"
"+48957228989" | "tel" | true | "tel:+48957228989"
"http://www.reddit.com" | "" | false | "http://www.reddit.com"
"http://www.reddit.com" | "" | true | "http://www.reddit.com"
"https://reddit.com" | "ftp" | true | "ftp:https://reddit.com"
"https://reddit.com" | "ftp" | false | "ftp://https://reddit.com"
"someone@domain.com" | "mailto" | true | "mailto:someone@domain.com"
}

def "build link for link and set protocol"() {
setup:
def link = LinkBuilderFactory.forPath(path).build()

expect:
LinkBuilderFactory.forLink(link).setScheme(scheme).setOpaque(opaque).build().href == href

where:
path | scheme | opaque | href
"/content" | "http" | false | "/content.html"
"+48957228989" | "tel" | true | "tel:+48957228989"
"http://www.reddit.com" | "" | false | "http://www.reddit.com"
"http://www.reddit.com" | "" | true | "http://www.reddit.com"
"www.reddit.com" | "https" | false | "https://www.reddit.com"
"https://reddit.com" | "ftp" | true | "ftp:https://reddit.com"
"someone@domain.com" | "mailto" | true | "mailto:someone@domain.com"
}

def "build link for path with parameters"() {
setup:
def link = LinkBuilderFactory.forPath("/content").addParameters(parameters).build()
Expand Down
Loading

0 comments on commit 5b62b29

Please sign in to comment.