Skip to content

Commit

Permalink
Merge branch 'master' into issues/3177-automate-creation-vanity
Browse files Browse the repository at this point in the history
  • Loading branch information
yelouardi committed Sep 14, 2023
2 parents 980d6f3 + ee1179a commit 5723f9b
Show file tree
Hide file tree
Showing 73 changed files with 5,919 additions and 1,043 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,32 @@ The format is based on [Keep a Changelog](http://keepachangelog.com)

## Unreleased ([details][unreleased changes details])

## 6.2.0 - 2023-09-14

## Added

- #3151 - New ContentSync utility
- #3147 - Fixed setting initial content-type when importing CFs from a spreadsheet
- #3166 - New option to suppress status updates in replication workflow processes

## Removed

- #3183 - Removed .wrap package including JackrabbitSessionIWrap and related classes which is no longer supported in Cloud Manager pipelines.

## 6.1.0 - 2023-09-08

## Added

- #3159 - Add PageProperty annotation for Sling Models
- #3170 - Added a new MCP tool to bulk tag AEM content pages via an Excel file input.
## Fixed

- #3147 - Fixed setting initial content-type when importing CFs from a spreadsheet
- #3040 - Fixed bug where namespaced multi-fields would have the namespace 2 times
- #3140 - Fixed issue where malformed MCP process nodes can cause a NPE that breaks the entire MPC reporting UI. Now displays more friendly values in UI to help remove the invalid nodes.
- #3150 - Support for case-insensitive redirect rules ( [NC] flag equivalent of apache)
- #3138 - Re-arrange action removes data from redirect node

## 6.0.14 - 2023-07-11

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons</artifactId>
<version>6.0.15-SNAPSHOT</version>
<version>6.1.1-SNAPSHOT</version>
</parent>

<!-- ====================================================================== -->
Expand Down
8 changes: 7 additions & 1 deletion bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons</artifactId>
<version>6.0.15-SNAPSHOT</version>
<version>6.1.1-SNAPSHOT</version>
</parent>

<!-- ====================================================================== -->
Expand Down Expand Up @@ -736,6 +736,12 @@
<artifactId>gson</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.contentloader</artifactId>
<version>2.2.6</version> <!-- 6.5.10 uses v2.2.6 -->
<scope>test</scope>
</dependency>
<!-- END: test dependencies -->
<!-- ======================== -->
<!-- put UberJar last so that more specific artifacts take precedence -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*-
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2013 - 2022 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.adobe.acs.commons.contentsync;


import javax.json.JsonObject;

import static org.apache.jackrabbit.JcrConstants.JCR_CONTENT;

/**
* A Json object describing a resource to sync.
*
* Required fields:
* - path
* - jcr:primaryType
* - exportUri
*/
public class CatalogItem {
private final JsonObject object;

public CatalogItem(JsonObject object){
this.object = object;
}

public String getPath(){
return object.getString("path");
}

public String getPrimaryType(){
return object.getString("jcr:primaryType");
}

public boolean hasContentResource(){
return getContentUri().endsWith("/" + JCR_CONTENT + ".infinity.json");
}

public String getContentUri(){
return object.getString("exportUri");
}

public String getString(String key){
return object.containsKey(key) ? object.getString(key) : null;
}

public long getLong(String key){
return object.containsKey(key) ? object.getJsonNumber(key).longValue() : 0L;
}

public String getCustomExporter(){
return object.containsKey("renderServlet") ? object.getString("renderServlet") : null;

}

public JsonObject getJsonObject(){
return object;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*-
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2013 - 2022 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.adobe.acs.commons.contentsync;

import com.adobe.acs.commons.contentsync.impl.LastModifiedStrategy;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceUtil;

import java.util.HashMap;
import java.util.Map;

import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
import static org.apache.sling.jcr.resource.api.JcrResourceConstants.NT_SLING_FOLDER;

public class ConfigurationUtils {
public static final String CONFIG_PATH = "/var/acs-commons/contentsync";
public static final String SETTINGS_PATH = CONFIG_PATH + "/settings";
public static final String HOSTS_PATH = CONFIG_PATH + "/hosts";

public static final String UPDATE_STRATEGY_KEY = "update-strategy";
public static final String EVENT_USER_DATA_KEY = "event-user-data";

private ConfigurationUtils(){

}

public static Resource getSettingsResource(ResourceResolver resourceResolver) throws PersistenceException {
Map<String, Object> resourceProperties = new HashMap<>();
resourceProperties.put(JCR_PRIMARYTYPE, NT_UNSTRUCTURED);
resourceProperties.put(UPDATE_STRATEGY_KEY, LastModifiedStrategy.class.getName());
resourceProperties.put(EVENT_USER_DATA_KEY, "changedByPageManagerCopy");
return ResourceUtil.getOrCreateResource(resourceResolver, SETTINGS_PATH, resourceProperties, NT_SLING_FOLDER, true);
}

public static Resource getHostsResource(ResourceResolver resourceResolver) throws PersistenceException {
Map<String, Object> resourceProperties = new HashMap<>();
resourceProperties.put(JCR_PRIMARYTYPE, NT_UNSTRUCTURED);
return ResourceUtil.getOrCreateResource(resourceResolver, HOSTS_PATH, resourceProperties, NT_SLING_FOLDER, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*-
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2013 - 2022 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.adobe.acs.commons.contentsync;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;

import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonValue;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


public class ContentCatalog {

private RemoteInstance remoteInstance;
private final String catalogServlet;

public ContentCatalog(RemoteInstance remoteInstance, String catalogServlet) {
this.remoteInstance = remoteInstance;
this.catalogServlet = catalogServlet;
}

public URI getFetchURI(String path, String updateStrategy) throws URISyntaxException {
return remoteInstance.toURI(catalogServlet, "root", path, "strategy", updateStrategy);
}

public List<CatalogItem> fetch(String path, String updateStrategy) throws IOException, URISyntaxException {
URI uri = getFetchURI(path, updateStrategy);

String json = remoteInstance.getString(uri);

JsonObject response;
try(JsonReader reader = Json.createReader(new StringReader(json))) {
response = reader.readObject();
}
if (!response.containsKey("resources")) {
throw new IOException("Failed to fetch content catalog from " + uri + ", Response: " + json);
}
JsonArray catalog = response.getJsonArray("resources");

return catalog.stream()
.map(JsonValue::asJsonObject)
.map(CatalogItem::new)
.collect(Collectors.toList());
}

public List<CatalogItem> getDelta(List<CatalogItem> catalog, ResourceResolver resourceResolver, UpdateStrategy updateStrategy) {
List<CatalogItem> lst = new ArrayList<>();
for(CatalogItem item : catalog){
Resource resource = resourceResolver.getResource(item.getPath());
if(resource == null || updateStrategy.isModified(item, resource)){
lst.add(item);
}
}
return lst;
}

}
Loading

0 comments on commit 5723f9b

Please sign in to comment.