Skip to content

Commit

Permalink
Merge pull request #927 from adobe/develop
Browse files Browse the repository at this point in the history
v2.5.6 release
  • Loading branch information
davidjgonzalez authored Apr 24, 2023
2 parents 2bfdf62 + d9b4c3a commit 437e91a
Show file tree
Hide file tree
Showing 37 changed files with 120 additions and 110 deletions.
2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<plugin>
<groupId>com.adobe.aem</groupId>
<artifactId>aemanalyser-maven-plugin</artifactId>
<version>1.4.20</version> <!-- Make sure to use the latest release -->
<version>1.5.8</version> <!-- Make sure to use the latest release -->
<executions>
<execution>
<id>aem-analyser</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface ShareService {
*
* @param request the request that provides context of which Asset Share instance the request is coming to.
* @param response the response
* @param shareParameters a &lt;String, Object&gt; map or parameters; This is initially constructed from the request.getParameterMap() but can be augmented in the ShareService implementationa s needed.
* @param shareParameters a &lt;String, Object&gt; map or parameters; This is initially constructed from the request.getParameterMap() but can be augmented in the ShareService implementation as needed.
* @throws ShareException is thrown if an error occurs with sharing (required share params are missing) or with the sharing initiation itself.
*/
void share(SlingHttpServletRequest request, SlingHttpServletResponse response, ValueMap shareParameters) throws ShareException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.apache.sling.models.factory.ModelFactory;
import org.apache.sling.scripting.core.ScriptHelper;
import org.apache.sling.xss.XSSAPI;
Expand All @@ -66,6 +67,7 @@
import org.slf4j.LoggerFactory;

import javax.jcr.RepositoryException;
import javax.jcr.Value;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -116,6 +118,8 @@ public boolean accepts(final SlingHttpServletRequest request) {

@Override
public final void share(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final ValueMap shareParameters) throws ShareException {
final ValueMap unprotectedShareParameters = new ValueMapDecorator(new HashMap<>());
unprotectedShareParameters.putAll(shareParameters);

/** Work around for regression issue introduced in AEM 6.4 **/
SlingBindings bindings = new SlingBindings();
Expand All @@ -127,10 +131,11 @@ public final void share(final SlingHttpServletRequest request, final SlingHttpSe
final EmailShare emailShare = request.adaptTo(EmailShare.class);

shareParameters.putAll(xssProtectUserData(emailShare.getUserData()));
//shareParameters.putAll(emailShare.getUserData());
unprotectedShareParameters.putAll(emailShare.getUserData());

// Configured data supersedes user data
shareParameters.putAll(emailShare.getConfiguredData());
unprotectedShareParameters.putAll(emailShare.getConfiguredData());

// Except for signature which we may or may not want to use from configured data, depending on flags in configured data
shareParameters.put(SIGNATURE, getSignature(emailShare, userProperties));
Expand All @@ -141,12 +146,13 @@ public final void share(final SlingHttpServletRequest request, final SlingHttpSe
shareParameters.put(EmailService.REPLY_TO, replyToAddress);
}

share(request.adaptTo(Config.class), shareParameters, StringUtils.defaultIfBlank(emailShare.getEmailTemplatePath(), cfg.emailTemplate()));
share(request.adaptTo(Config.class), unprotectedShareParameters, shareParameters, StringUtils.defaultIfBlank(emailShare.getEmailTemplatePath(), cfg.emailTemplate()));
}

private final void share(final Config config, final ValueMap shareParameters, final String emailTemplatePath) throws ShareException {
final String[] emailAddresses = StringUtils.split(shareParameters.get(EMAIL_ADDRESSES, ""), ",");
final String[] assetPaths = Arrays.stream(shareParameters.get(ASSET_PATHS, ArrayUtils.EMPTY_STRING_ARRAY))
private final void share(final Config config, final ValueMap unprotectedShareParameters, final ValueMap shareParameters, final String emailTemplatePath) throws ShareException {
final String[] emailAddresses = StringUtils.split(unprotectedShareParameters.get(EMAIL_ADDRESSES, ""), ",");

final String[] assetPaths = Arrays.stream(unprotectedShareParameters.get(ASSET_PATHS, ArrayUtils.EMPTY_STRING_ARRAY))
.filter(StringUtils::isNotBlank)
.map(path -> config.getResourceResolver().getResource(path))
.filter(Objects::nonNull)
Expand All @@ -155,6 +161,10 @@ private final void share(final Config config, final ValueMap shareParameters, fi
.map(Asset::getPath)
.toArray(String[]::new);

if (log.isDebugEnabled()) {
log.debug("Sharing [ {} ] to [ {} ]", StringUtils.join(unprotectedShareParameters.get(ASSET_PATHS, ArrayUtils.EMPTY_STRING_ARRAY), ", "), StringUtils.join(emailAddresses, ", "));
}

// Check to ensure the minimum set of e-mail parameters are provided; Throw exception if not.
if (emailAddresses == null || emailAddresses.length == 0) {
throw new ShareException("At least one e-mail address is required to share");
Expand All @@ -163,7 +173,7 @@ private final void share(final Config config, final ValueMap shareParameters, fi
}

// Convert provided params to <String, String>; anything that needs to be accessed in its native type should be accessed and manipulated via shareParameters.get(..)
final Map<String, String> emailParameters = new HashMap<String, String>();
final Map<String, String> emailParameters = new HashMap<>();
for (final String key : shareParameters.keySet()) {
emailParameters.put(key, shareParameters.get(key, String.class));
}
Expand Down Expand Up @@ -288,7 +298,6 @@ private boolean isValidUser(SlingHttpServletRequest request) {
private Map<String, Object> xssProtectUserData(Map<String, Object> dirtyUserData) {
Map<String, Object> cleanUserData = new HashMap<String, Object>();
for (final Map.Entry<String, Object> entry : dirtyUserData.entrySet()) {

if (entry.getValue() instanceof String[]) {
cleanUserData.put(entry.getKey(), xssCleanData((String[]) entry.getValue()));
} else if (entry.getValue() instanceof String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private final void share(SlingHttpServletRequest request, SlingHttpServletRespon
try {
shareService.share(request, response,
// Make map write-able
new ValueMapDecorator(new HashMap<String, Object>(request.getParameterMap())));
new ValueMapDecorator(new HashMap<>(request.getParameterMap())));
counter.incrementAndGet();
} catch (ShareException e) {
if (log.isErrorEnabled()) {
Expand All @@ -96,7 +96,7 @@ private final void share(SlingHttpServletRequest request, SlingHttpServletRespon
if (counter.get() == 0) {
defaultShareService.share(request, response,
// Make map write-able
new ValueMapDecorator(new HashMap<String, Object>(request.getParameterMap())));
new ValueMapDecorator(new HashMap<>(request.getParameterMap())));
}
} catch (ShareException ex) {
log.error("Unable to share assets from Asset Share Commons", ex);
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<!-- the minimum AEM 6.5 version being supported -->
<aem.classic.api.version>6.5.7.0003</aem.classic.api.version><!-- actually one of https://repo1.maven.org/maven2/io/wcm/maven/io.wcm.maven.aem-dependencies/ -->
<!-- the minimum AEMaaCS version being supported -->
<aem.sdk.api.version>2022.9.8722.20220912T101352Z-220800</aem.sdk.api.version><!-- actually one of https://repo1.maven.org/maven2/com/adobe/aem/aem-sdk-api/ -->
<aem.sdk.api.version>2023.3.11382.20230315T073850Z-230200</aem.sdk.api.version><!-- actually one of https://repo1.maven.org/maven2/com/adobe/aem/aem-sdk-api/ -->
<core.wcm.components.version>2.17.14</core.wcm.components.version>
<frontend-maven-plugin.version>1.9.0</frontend-maven-plugin.version>
<node.version>v13.7.0</node.version>
Expand Down Expand Up @@ -107,7 +107,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M6</version>
<version>3.0.0</version>
<configuration>
<tagNameFormat>asset-share-commons-@{project.version}</tagNameFormat>
<scmCommentPrefix>[maven-scm] :</scmCommentPrefix>
Expand All @@ -121,7 +121,7 @@
<dependency>
<groupId>org.apache.maven.release</groupId>
<artifactId>maven-release-oddeven-policy</artifactId>
<version>3.0.0-M7</version>
<version>3.0.0</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -254,7 +254,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.1</version>
</plugin>
<!-- Maven Compiler Plugin -->
<plugin>
Expand Down Expand Up @@ -462,7 +462,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
<!-- Maven Javadoc Plugin -->
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<excludePackageNames>
Expand Down Expand Up @@ -546,7 +546,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>7.1.1</version>
<version>8.2.1</version>
<configuration>
<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
~ limitations under the License.
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-use.actionButtons="com.adobe.aem.commons.assetshare.components.details.ActionButtons"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-set.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
data-sly-test.ready="${actionButtons.ready}">

<div class="ui basic segment">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
~ limitations under the License.
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
data-sly-use.editorLinks="com.adobe.aem.commons.assetshare.components.details.EditorLinks"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-test.ready="${editorLinks.ready}">
data-sly-test.ready="${editorLinks.ready}"
>

<h4 class="ui header"
data-sly-test="${!properties['hideLabel']}">${properties['label'] @ i18n}</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
~ limitations under the License.
*/-->

<sly data-sly-use.image="com.adobe.aem.commons.assetshare.components.details.Image"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-test.ready="${image.ready}">
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.image="com.adobe.aem.commons.assetshare.components.details.Image"
data-sly-test.ready="${image.ready}">

<div class="cmp-wrapper image background">
<!--/* Img element with a max height */-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
~ limitations under the License.
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
data-sly-use.field="com.adobe.aem.commons.assetshare.components.details.Metadata"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.fieldTypesTemplate="templates/field-types.html"
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
data-sly-use.field="com.adobe.aem.commons.assetshare.components.details.Metadata"
data-sly-test.ready="${field.ready}">

<div class="ui basic segment">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
~ limitations under the License.
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-set.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
data-sly-use.renditions="com.adobe.aem.commons.assetshare.components.details.Renditions"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-test.ready="${renditions.ready}">

<div class="ui basic segment">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
~ limitations under the License.
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
data-sly-use.field="com.adobe.aem.commons.assetshare.components.details.Tags"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-test.ready="${field.ready}">

<div class="ui basic segment">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
~ limitations under the License.
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"
data-sly-use.title="com.adobe.aem.commons.assetshare.components.details.Title"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-test.ready="${title.ready}">

<h1 class="ui header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
~ limitations under the License.
*/-->

<sly data-sly-use.video="com.adobe.aem.commons.assetshare.components.details.Video"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.playerTemplate="templates/player.html"
<sly data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.playerTemplate="templates/player.html"
data-sly-use.video="com.adobe.aem.commons.assetshare.components.details.Video"
data-sly-test.ready="${video.ready}">

<h4 class="ui header center aligned"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-test.searchConfig="${modelCache['com.adobe.aem.commons.assetshare.components.search.SearchConfig']}"
data-sly-set.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-set.searchConfig="${modelCache['com.adobe.aem.commons.assetshare.components.search.SearchConfig']}"
data-sly-use.cart="com.adobe.aem.commons.assetshare.components.actions.cart.Cart"></sly>

<style data-sly-test="${!wccmode.disabled}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
~ limitations under the License.
*/-->

<sly data-sly-use.download="com.adobe.aem.commons.assetshare.components.actions.download.Download"
data-sly-test.legacyMode="${download.legacyMode}"
data-sly-use.legacyTemplate="templates/legacy.html"></sly>
<sly data-sly-use.legacyTemplate="templates/legacy.html"
data-sly-use.download="com.adobe.aem.commons.assetshare.components.actions.download.Download"
data-sly-set.legacyMode="${download.legacyMode}"></sly>

<style data-sly-test="${!wccmode.disabled}">
.cmp-modal-download .ui.modal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/-->

<sly
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html"
data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-test="${!config.aemClassic}"
data-sly-set.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-use.downloads="com.adobe.aem.commons.assetshare.components.actions.downloads.Downloads"
data-sly-use.downloadTemplate="templates/download.html"
data-sly-use.placeholderTemplate="core/wcm/components/commons/v1/templates.html">
data-sly-test="${!config.aemClassic}">

<sly data-sly-test="${!wccmode.disabled}">
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"></sly>
data-sly-set.asset="${modelCache['com.adobe.aem.commons.assetshare.content.AssetModel']}"></sly>

<style data-sly-test="${!wccmode.disabled}">
.cmp-modal-license .ui.modal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/-->

<sly data-sly-use.modelCache="com.adobe.aem.commons.assetshare.util.ModelCache"
data-sly-test.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-set.config="${modelCache['com.adobe.aem.commons.assetshare.configuration.Config']}"
data-sly-use.share="com.adobe.aem.commons.assetshare.components.actions.share.EmailShare"></sly>

<style data-sly-test="${!wccmode.disabled}">
Expand Down
Loading

0 comments on commit 437e91a

Please sign in to comment.