From e1fa55829a59bb776bd4be198e8864ad812abafa Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Sat, 4 Jan 2025 16:45:25 +0100 Subject: [PATCH 1/2] redirect config should be orderable and replicatable --- CHANGELOG.md | 5 +++++ .../CreateRedirectConfigurationServlet.java | 2 +- .../utilities/manage-redirects/replicate.POST.jsp | 13 +++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c36cadb265..0fafa2f844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com) ## Unreleased ([details][unreleased changes details]) +### Fixed +- # - Redirect Manager: ensure redirect configurations are orderable + +## 6.10.0 - 2024-12-13 + - #3484 - Redirect Manager: A servlet to export redirects to a TXT file to use with pipeline-free redirects - #3480 - AEM Sites Copy Publish URLs diff --git a/bundle/src/main/java/com/adobe/acs/commons/redirects/servlets/CreateRedirectConfigurationServlet.java b/bundle/src/main/java/com/adobe/acs/commons/redirects/servlets/CreateRedirectConfigurationServlet.java index b92cf63280..5c314ae585 100755 --- a/bundle/src/main/java/com/adobe/acs/commons/redirects/servlets/CreateRedirectConfigurationServlet.java +++ b/bundle/src/main/java/com/adobe/acs/commons/redirects/servlets/CreateRedirectConfigurationServlet.java @@ -98,7 +98,7 @@ protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse if (config == null) { String contextPrefix = StringUtils.defaultString(request.getParameter(REQ_PARAM_CTX_PREFIX)); config = resolver.create(bucket, configName, - ImmutableMap.of(JcrConstants.JCR_PRIMARYTYPE, JcrResourceConstants.NT_SLING_FOLDER, + ImmutableMap.of(JcrConstants.JCR_PRIMARYTYPE, JcrResourceConstants.NT_SLING_ORDERED_FOLDER, ResourceResolver.PROPERTY_RESOURCE_TYPE, REDIRECTS_RESOURCE_PATH, REQ_PARAM_CTX_PREFIX, contextPrefix)); log.info("created {} with context prefix '{}'", config.getPath(), contextPrefix); diff --git a/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp index 4e1bd9e6cd..d0c177026c 100755 --- a/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp +++ b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp @@ -21,6 +21,7 @@ import=" javax.jcr.Session, javax.jcr.Node, + javax.jcr.nodetype.NodeType, java.util.*, java.io.PrintWriter, com.day.cq.replication.Replicator, @@ -28,11 +29,19 @@ com.day.cq.replication.ReplicationActionType" %>
<%
 
     String path = request.getParameter("path");
+    Resource configResource = resourceResolver.getResource(path);
 
     Replicator replicator = sling.getService(Replicator.class);
     ReplicationOptions opts = new ReplicationOptions();
     opts.setSuppressVersions(true);
-    replicator.replicate(resourceResolver.adaptTo(Session.class), ReplicationActionType.ACTIVATE, path, null);
+    Session session = resourceResolver.adaptTo(Session.class);
+    replicator.replicate(session, ReplicationActionType.ACTIVATE, path, null);
 	out.println("Replicating: " + path);
 
-%>
+ if(!configResource.adaptTo(Node.class).isNodeType(NodeType.NT_HIERARCHY_NODE)){ + for(Resource res : configResource.getChildren()){ + replicator.replicate(session, ReplicationActionType.ACTIVATE, res.getPath(), null); + out.println("Replicating: " + res.getPath()); + } + } +%> \ No newline at end of file From 4f50dd49d50890e8970fd607c2564522c711bd8e Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Sat, 4 Jan 2025 16:49:32 +0100 Subject: [PATCH 2/2] code climate issues --- .../components/utilities/manage-redirects/replicate.POST.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp index d0c177026c..16b8c0b8a6 100755 --- a/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp +++ b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/replicate.POST.jsp @@ -44,4 +44,4 @@ out.println("Replicating: " + res.getPath()); } } -%> \ No newline at end of file +%>