-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A servlet to export redirects to a TXT file to use with pipeline-free redirects #3484
A servlet to export redirects to a TXT file to use with pipeline-free redirects #3484
Conversation
/* | ||
* ACS AEM Commons | ||
* | ||
* Copyright (C) 2013 - 2023 Adobe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YegorKozlov you might want to update the year range to include 2024 as current year, too ;)
/* | ||
* ACS AEM Commons | ||
* | ||
* Copyright (C) 2013 - 2023 Adobe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YegorKozlov you might want to update the year range to include 2024 as current year, too ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YegorKozlov just small note about copyrights year range, otherwise ok - good to see another source for Pipeline-free URL Redirects map data!
@YegorKozlov you might also add an option (e.g. selector or param) to separately generate list of entries for 301 redirection, and separately for 302 ones, so that on Apache HTTPD level they can be treated separately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YegorKozlov super, thanks!
@krystiannowak I added a selector to filter by status code. With this change the yaml configuration would look like
|
@YegorKozlov looks like Windows-based test runs cry now |
@@ -62,16 +62,16 @@ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse r | |||
} | |||
Collection<RedirectRule> rules = RedirectFilter.getRules(request.getResource()); | |||
PrintWriter out = response.getWriter(); | |||
out.printf("# %s Redirects\n", statusCode == 0 ? "All" : "" + statusCode); | |||
out.printf("# %s Redirects%n", statusCode == 0 ? "All" : "" + statusCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YegorKozlov after starting to use %n as line separator, splitting still only by \n
in tests by
String[] lines = response.getOutputAsString().split("\n");
in https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/3484/files#diff-36adc0c81c9585f4cadf9e45117faabfdda5ef6d7e197ade7d39e0a896c6853eR87
might not be precise enough anymore on Windows
Maybe by System.lineSeparator()
as in:
diff --git a/bundle/src/test/java/com/adobe/acs/commons/redirects/servlets/RewriteMapServletTest.java b/bundle/src/test/java/com/adobe/acs/commons/redirects/servlets/RewriteMapServletTest.java
index acb58e9c5..80799fb3f 100755
--- a/bundle/src/test/java/com/adobe/acs/commons/redirects/servlets/RewriteMapServletTest.java
+++ b/bundle/src/test/java/com/adobe/acs/commons/redirects/servlets/RewriteMapServletTest.java
@@ -107,7 +107,7 @@ public class RewriteMapServletTest {
servlet.doGet(request, response);
assertEquals(ContentType.TEXT_PLAIN.getMimeType(), response.getContentType());
- String[] lines = response.getOutputAsString().split("\n");
+ String[] lines = response.getOutputAsString().split(System.lineSeparator());
assertEquals(2, lines.length); // header + 1 rule
assertEquals("# 301 Redirects", lines[0]);
String[] rule1 = lines[1].split(" ");
@@ -124,7 +124,7 @@ public class RewriteMapServletTest {
servlet.doGet(request, response);
assertEquals(ContentType.TEXT_PLAIN.getMimeType(), response.getContentType());
- String[] lines = response.getOutputAsString().split("\n");
+ String[] lines = response.getOutputAsString().split(System.lineSeparator());
assertEquals(3, lines.length); // header + notes + 1st rule
assertEquals("# 302 Redirects", lines[0]);
would do?
* Copyright (C) 2013 - 2024 Adobe | ||
* | ||
* %% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YegorKozlov I'm not sure if that makes sense - or should rather https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/.codeclimate/header.txt be tuned instead? Also the other Java files do not seem to adhere to this pattern.
@kwin @joerghoh @davidjgonzalez WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krystiannowak this %%
thing does not make much sense to me, but I believe we've always had it, since the header check was introduced in #1345 back in 2018
Also the other Java files do not seem to adhere to this pattern.
Yep. We have quite a bit of the header variations across the project.
Look at #2500 for a discussion on license headers. |
@YegorKozlov Probably you need to "touch" it to rerun tests, as I can see there are "status code: 504, reason phrase: Gateway Time-out" errors |
@YegorKozlov looks like checks passed now, but my ack is not strong enough - maybe it needs an ack from other parties like @kwin @joerghoh @davidjgonzalez etc? |
8b89efc
into
Adobe-Consulting-Services:master
@YegorKozlov Don't you want to update https://github.com/Adobe-Consulting-Services/adobe-consulting-services.github.io/blob/master/_acs-aem-commons/features/redirect-manager/index.md as well to reflect those changes? cc: @davidjgonzalez |
Sure thing. I was going to give it shot first, but didn't yet get around. |
@krystiannowak @kwin @joerghoh
the PR adds a servlet to export redirects into a text file, e.g. http://localhost:4502/conf/my-site/settings/redirects.txt
This way Redirect Manager can serve redirects for Pipeline-free URL Redirects
src/opt-in/managed-rewrite-maps.yaml
in the dispatcher configuration would look likeand vhosts can reference redirects like