Skip to content

Commit

Permalink
Merge pull request #1039 from adobe/develop
Browse files Browse the repository at this point in the history
v3.5.0 release
  • Loading branch information
davidjgonzalez authored Nov 10, 2023
2 parents 506f657 + 2eab299 commit 719d708
Show file tree
Hide file tree
Showing 23 changed files with 651 additions and 114 deletions.
2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core.cloud/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
public abstract class AbstractPredicate implements Predicate {
private static final Logger log = LoggerFactory.getLogger(AbstractPredicate.class);

private static final String REQUEST_ATTR_PREDICATE_GROUP_TRACKER = "asset-share-commons__predicate-group";
private static final String REQUEST_ATTR_LEGACY_PREDICATE_GROUP_TRACKER = "asset-share-commons__legacy_predicate-group";
public static final String REQUEST_ATTR_PREDICATE_GROUP_TRACKER = "asset-share-commons__predicate-group";
public static final String REQUEST_ATTR_LEGACY_PREDICATE_GROUP_TRACKER = "asset-share-commons__legacy_predicate-group";

private static final String REQUEST_ATTR_FORM_ID_TRACKER = "asset-share-commons__form-id";
private static final String PN_GENERATE_PREDICATE_GROUP_ID = "generatePredicateGroupId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ public PredicateGroup getPredicateGroup(ParamTypes... excludeParamTypes) {
}

// Path Predicate
if (!ArrayUtils.contains(excludeParamTypes, ParamTypes.PATH) &&
(!PredicateUtil.isParameterizedSearchRequest(request) && !PredicateUtil.hasPredicate(PredicateConverter.createMap(root), new String[] { PathPredicateEvaluator.PATH }))) {
// Only add the search config path predicate if there isn't one provided by the request OR if there isn't one provided by Default values.
if (!ArrayUtils.contains(excludeParamTypes, ParamTypes.PATH)) {
// The search result component paths are only added when the search is NOT safely parameterized with user defined paths.
addPathAsPredicateGroup(root);
}

Expand Down Expand Up @@ -273,9 +272,22 @@ private void addHiddenPredicatesAsPredicateGroups(final PredicateGroup root) {
}

private void addDefaultValuesAsPredicateGroups(final PredicateGroup root) {
// Capture any existing values, however these should be null
Object predicateGroupTracker = request.getAttribute(AbstractPredicate.REQUEST_ATTR_PREDICATE_GROUP_TRACKER);
Object legacyPredicateGroupTracker = request.getAttribute(AbstractPredicate.REQUEST_ATTR_LEGACY_PREDICATE_GROUP_TRACKER);

// Reset group tracking, as any instantiation of a predicate will increment the group
request.setAttribute(AbstractPredicate.REQUEST_ATTR_PREDICATE_GROUP_TRACKER, null);
request.setAttribute(AbstractPredicate.REQUEST_ATTR_LEGACY_PREDICATE_GROUP_TRACKER, null);

for (final DefaultValuesPredicate defaultValuesPredicate : getDefaultValuesPredicates(currentPage)) {
root.add(defaultValuesPredicate.getPredicateGroup());
}

// Set back any existing values, though these should be null
request.setAttribute(AbstractPredicate.REQUEST_ATTR_PREDICATE_GROUP_TRACKER, predicateGroupTracker);
request.setAttribute(AbstractPredicate.REQUEST_ATTR_LEGACY_PREDICATE_GROUP_TRACKER, legacyPredicateGroupTracker);

}

private void addPathAsPredicateGroup(final PredicateGroup root) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

@Version("4.1.0")
@Version("4.2.0")
package com.adobe.aem.commons.assetshare.components.predicates;

import org.osgi.annotation.versioning.Version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public Results getResults(final SlingHttpServletRequest request) throws UnsafeSe
/**
* Generates the QueryBuilder query params from the Page Predicate settings and the request attributes.
*
* @param request
* @param request the request object.
* @return the QueryBuilder parameter map.
*/
private Map<String, String> getParams(final SlingHttpServletRequest request) {
Expand All @@ -168,6 +168,20 @@ private Map<String, String> getParams(final SlingHttpServletRequest request) {

PagePredicate.ParamTypes[] excludeParamTypes = new PagePredicate.ParamTypes[]{};


// Paths are special case where user provided params must be under atleast 1 configured allowed path (assuming they are configured)
if (isPathsProvidedByRequestParams(pagePredicate, params)) {
String[] allowedPathPrefixes = pagePredicate.getPaths().stream().map(path -> StringUtils.removeEnd(path, "/") + "/").toArray(String[]::new);
Map<String, String> tmpParams = params;

PredicateUtil.findPredicate(params, PathPredicateEvaluator.PATH, PathPredicateEvaluator.PATH).entrySet().stream()
.filter(entry -> !StringUtils.startsWithAny((String) entry.getValue(), allowedPathPrefixes))
.forEach(entry -> tmpParams.remove(entry.getKey()));

params = tmpParams;
}

// Check again after checking the provided paths
if (isPathsProvidedByRequestParams(pagePredicate, params)) {
excludeParamTypes = new PagePredicate.ParamTypes[]{PagePredicate.ParamTypes.PATH};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import com.adobe.aem.commons.assetshare.components.predicates.Predicate;
import com.adobe.cq.wcm.core.components.models.form.OptionItem;
import com.day.cq.search.PredicateConverter;
import com.day.cq.search.PredicateGroup;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
Expand All @@ -45,6 +43,11 @@
public final class PredicateUtil {
private PredicateUtil() { }

/**
* Determines if the request is a parameterized search request.
* @param request the request object.
* @return true if the request is a parameterized search request.
*/
public static boolean isParameterizedSearchRequest(SlingHttpServletRequest request) {
return Arrays.stream(new String[]{"_group.", "?p.", "&p."}).anyMatch(needle -> StringUtils.contains(request.getQueryString(), needle));
}
Expand Down
2 changes: 1 addition & 1 deletion dispatcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<packaging>pom</packaging>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>

<name>Asset Share Commons - Reactor Project</name>
<description>asset-share-commons</description>
Expand Down Expand Up @@ -163,7 +163,7 @@
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.1</version>
<version>1.14.2</version>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<npmVersion>${npm.version}</npmVersion>
Expand Down
2 changes: 1 addition & 1 deletion ui.apps.structure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ui.apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
@import (once) "/apps/asset-share-commons/clientlibs/clientlib-site/less/variables.less";

.cmp-search-results {

.cmp-cards {

display: grid;
grid-template-columns: repeat(auto-fill, minmax(237px, 1fr));
grid-gap: 10px;

&:after {
content: none !important;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
data-asset-share-update-method="replace"
data-asset-share-update-when="search">

<div class="ui special cards cmp-cards"
<div class="cards cmp-cards"
data-sly-test="${search.results.size > 0}"
data-asset-share-id="results-load-more"
data-asset-share-update-method="append"
Expand Down
2 changes: 1 addition & 1 deletion ui.config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ui.content.sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ui.content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Loading

0 comments on commit 719d708

Please sign in to comment.