未验证 提交 b0eee6d6 编写于 作者: J Jeff Thompson 提交者: GitHub

[JENKINS-60848] Improve RSS title wording + Add more RSS tests (#4442)

* Add more tests.

Also a little cleanup of RSS.
Fix the broken "All all ..." title and description.
Remove a long unused bit for never implemented trackback.

* Increase date time checks.

* Copy and paste error.
Co-Authored-By: NWadeck Follonier <Wadeck@users.noreply.github.com>

* Assert not empty.
Co-Authored-By: NWadeck Follonier <Wadeck@users.noreply.github.com>

* Add a bunch more tests and clarify title.

Add a number of more tests. Test the various places that RSS is used.
Improve title wording to something consistent and somewhat sensible.
Co-authored-by: NWadeck Follonier <Wadeck@users.noreply.github.com>
上级 53ee8fa7
......@@ -157,6 +157,7 @@ public class LogRecorderManager extends AbstractModelObject implements ModelObje
*/
/*package*/ static void doRss(StaplerRequest req, StaplerResponse rsp, List<LogRecord> logs) throws IOException, ServletException {
// filter log records based on the log level
String entryType = "all";
String level = req.getParameter("level");
if(level!=null) {
Level threshold = Level.parse(level);
......@@ -166,9 +167,10 @@ public class LogRecorderManager extends AbstractModelObject implements ModelObje
filtered.add(r);
}
logs = filtered;
entryType = level;
}
RSS.forwardToRss("Hudson log","", logs, new FeedAdapter<LogRecord>() {
RSS.forwardToRss("Jenkins:log (" + entryType + " entries)","", logs, new FeedAdapter<LogRecord>() {
public String getEntryTitle(LogRecord entry) {
return entry.getMessage();
}
......
......@@ -1371,12 +1371,12 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
//
@Restricted(DoNotUse.class)
public void doRssAll( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " all builds", getUrl(), getBuilds());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (all builds)", getUrl(), getBuilds());
}
@Restricted(DoNotUse.class)
public void doRssFailed(StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " failed builds", getUrl(), getBuilds().failureOnly());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (failed builds)", getUrl(), getBuilds().failureOnly());
}
/**
......@@ -1398,7 +1398,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
}
}
RSS.rss(req, rsp, getDisplayName() + " last builds only", getUrl(), RunList.fromRuns(lastBuilds));
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (latest builds)", getUrl(), RunList.fromRuns(lastBuilds));
}
@RequirePOST
......
......@@ -1566,12 +1566,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
public void doRssAll(StaplerRequest req, StaplerResponse rsp)
throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " all builds", getUrl(), getBuilds().newBuilds());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (all builds)", getUrl(), getBuilds().newBuilds());
}
public void doRssFailed(StaplerRequest req, StaplerResponse rsp)
throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " failed builds", getUrl(), getBuilds().failureOnly().newBuilds());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (failed builds)", getUrl(), getBuilds().failureOnly().newBuilds());
}
/**
......
......@@ -32,7 +32,6 @@ import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
/**
......@@ -42,25 +41,6 @@ import java.util.Collection;
*/
public final class RSS {
/**
* Parses trackback ping.
*/
public static void doTrackback( Object it, StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
String url = req.getParameter("url");
rsp.setStatus(HttpServletResponse.SC_OK);
rsp.setContentType("application/xml; charset=UTF-8");
try (PrintWriter pw = rsp.getWriter()) {
pw.println("<response>");
pw.println("<error>" + (url != null ? 0 : 1) + "</error>");
if (url == null) {
pw.println("<message>url must be specified</message>");
}
pw.println("</response>");
}
}
/**
* Sends the RSS feed to the client.
*
......
......@@ -871,11 +871,11 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
}
public void doRssAll(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " all builds", getUrl(), getBuilds().newBuilds());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (all builds)", getUrl(), getBuilds().newBuilds());
}
public void doRssFailed(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " regression builds", getUrl(), getBuilds().regressionOnly());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (failed builds)", getUrl(), getBuilds().regressionOnly());
}
public void doRssLatest(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
......@@ -891,7 +891,7 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
// historically these have been reported sorted by project name, we switched to the lazy iteration
// so we only have to sort the sublist of runs rather than the full list of irrelevant projects
lastBuilds.sort((o1, o2) -> Items.BY_FULL_NAME.compare(o1.getParent(), o2.getParent()));
RSS.rss(req, rsp, getDisplayName() + " latest build", getUrl(), RunList.fromRuns(lastBuilds), Run.FEED_ADAPTER_LATEST);
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (latest builds)", getUrl(), RunList.fromRuns(lastBuilds), Run.FEED_ADAPTER_LATEST);
}
@Override
......
......@@ -1143,11 +1143,11 @@ public abstract class View extends AbstractModelObject implements AccessControll
}
public void doRssAll( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " all builds", getUrl(), getBuilds().newBuilds());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (all builds)", getUrl(), getBuilds().newBuilds());
}
public void doRssFailed( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
RSS.rss(req, rsp, getDisplayName() + " failed builds", getUrl(), getBuilds().failureOnly().newBuilds());
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (failed builds)", getUrl(), getBuilds().failureOnly().newBuilds());
}
public RunList getBuilds() {
......@@ -1167,7 +1167,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
if(lb!=null) lastBuilds.add(lb);
}
}
RSS.rss(req, rsp, getDisplayName() + " last builds only", getUrl(), RunList.fromRuns(lastBuilds), Run.FEED_ADAPTER_LATEST);
RSS.rss(req, rsp, "Jenkins:" + getDisplayName() + " (latest builds)", getUrl(), RunList.fromRuns(lastBuilds), Run.FEED_ADAPTER_LATEST);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册