Migrate from deprecated EE 8 methods to non-deprecated equivalents (#10233)

* Migrate from deprecated EE 8 methods to non-deprecated equivalents

* Clean up `GlobalComputerRetentionCheckIntervalConfiguration` as well
This commit is contained in:
Basil Crow authored and GitHub committed 2025-02-08 07:37:48 -07:00
1 parent f8c9f3753c
commit e61ecca4fc
35 files changed
+57 -57

No files matched your search

+1 -1
View File
@@ -1989,7 +1989,7 @@ public class Functions {
*/
public static @CheckForNull String getConsoleUrl(WithConsoleUrl withConsoleUrl) {
String consoleUrl = withConsoleUrl.getConsoleUrl();
return consoleUrl != null ? Stapler.getCurrentRequest().getContextPath() + '/' + consoleUrl : null;
return consoleUrl != null ? Stapler.getCurrentRequest2().getContextPath() + '/' + consoleUrl : null;
}
/**
@@ -80,7 +80,7 @@ public interface ConsoleUrlProvider extends Describable<ConsoleUrlProvider> {
* @return the URL for the console for the specified build, relative to the web server root
*/
static @NonNull String getRedirectUrl(Run<?, ?> run) {
return Stapler.getCurrentRequest().getContextPath() + '/' + run.getConsoleUrl();
return Stapler.getCurrentRequest2().getContextPath() + '/' + run.getConsoleUrl();
}
static List<ConsoleUrlProvider> all() {
@@ -6,7 +6,7 @@ import java.util.logging.Logger;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;
/**
* Configures check interval for computer retention.
@@ -56,7 +56,7 @@ public class GlobalComputerRetentionCheckIntervalConfiguration extends GlobalCon
}
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
public boolean configure(StaplerRequest2 req, JSONObject json) throws FormException {
try {
final int interval = json.getInt("computerRetentionCheckInterval");
setComputerRetentionCheckInterval(interval);
@@ -67,7 +67,7 @@ public abstract class GlobalConfiguration extends Descriptor<GlobalConfiguration
@Override
public boolean configure(StaplerRequest2 req, JSONObject json) throws FormException {
if (Util.isOverridden(GlobalConfiguration.class, getClass(), "configure", StaplerRequest.class, JSONObject.class)) {
return configure(StaplerRequest.fromStaplerRequest2(req), json);
return configure(req != null ? StaplerRequest.fromStaplerRequest2(req) : null, json);
} else {
return configureImpl(req, json);
}
@@ -38,7 +38,7 @@ THE SOFTWARE.
placeholder="${%Search available plugins}"
id="filter-box"
autofocus="true"
value="${request.getParameter('filter')}" />
value="${request2.getParameter('filter')}" />
</div>
<div class="jenkins-app-bar__controls">
<l:isAdmin>
@@ -43,7 +43,7 @@ THE SOFTWARE.
placeholder="${%Search installed plugins}"
id="filter-box"
autofocus="true"
value="${request.getParameter('filter')}"
value="${request2.getParameter('filter')}"
enabled="${!noPlugins}" />
</div>
</div>
@@ -41,7 +41,7 @@ THE SOFTWARE.
placeholder="${%Search plugin updates}"
id="filter-box"
autofocus="true"
value="${request.getParameter('filter')}"
value="${request2.getParameter('filter')}"
enabled="${!empty(list)}" />
</div>
<div class="jenkins-app-bar__controls">
@@ -31,7 +31,7 @@ THE SOFTWARE.
<h1>
${%JVM Memory Usage}
</h1>
<j:set var="type" value="${request.getParameter('type') ?: 'min'}" />
<j:set var="type" value="${request2.getParameter('type') ?: 'min'}" />
<div>
${%Timespan}:
<j:choose>
@@ -30,14 +30,14 @@ THE SOFTWARE.
<j:if test="${it.getPrimaryView() != null}">
<j:set var="it" value="${it.getPrimaryView()}"/>
</j:if>
<j:set var="submissionUrl" value="${request.getParameter('submissionUrl')}" defaultValue="submitDescription"/>
<j:set var="submissionUrl" value="${request2.getParameter('submissionUrl')}" defaultValue="submitDescription"/>
<j:invokeStatic className="hudson.Util" method="isSafeToRedirectTo" var="isSafeToRedirectTo">
<j:arg value="${submissionUrl}"/>
</j:invokeStatic>
<j:if test="${!isSafeToRedirectTo}">
<j:set var="submissionUrl" value="submitDescription"/>
</j:if>
<j:set var="initialDescription" value="${request.getParameter('description')}" defaultValue="${it.description}"/>
<j:set var="initialDescription" value="${request2.getParameter('description')}" defaultValue="${it.description}"/>
<l:ajax>
<form action="${submissionUrl}" method="post">
<table>
@@ -31,8 +31,8 @@ THE SOFTWARE.
<st:include page="sidepanel.jelly" />
<l:breadcrumb title="${%Changes}" />
<l:main-panel>
<j:set var="from" value="${request.getParameter('from')}"/>
<j:set var="to" value="${request.getParameter('to')}"/>
<j:set var="from" value="${request2.getParameter('from')}"/>
<j:set var="to" value="${request2.getParameter('to')}"/>
<j:set var="browser" value="${it.scm.effectiveBrowser}"/> <!-- for compatibility; newer project-changes.jelly override this -->
<h1>
@@ -111,7 +111,7 @@ div {
section(class: "empty-state-section") {
ul(class: "empty-state-section-list") {
li(class: "content-block") {
a(href: "${rootURL}/${app.securityRealm.loginUrl}?from=${request.requestURI}",
a(href: "${rootURL}/${app.securityRealm.loginUrl}?from=${request2.requestURI}",
class: "content-block__link") {
span(_("Log in to Jenkins"))
span(class: "trailing-icon") {
@@ -32,7 +32,7 @@ THE SOFTWARE.
<l:main-panel>
<f:form method="post" action="doCreateItem" name="config" class="jenkins-form">
<f:entry title="${%Name}" help="${requestScope.descriptor.getHelpFile('name')}">
<f:textbox name="name" value="${request.getParameter('name')}" clazz="required" checkMessage="${%Name is mandatory}"/>
<f:textbox name="name" value="${request2.getParameter('name')}" clazz="required" checkMessage="${%Name is mandatory}"/>
</f:entry>
<!-- main body of the configuration -->
@@ -40,7 +40,7 @@ THE SOFTWARE.
<st:include class="${requestScope.descriptor.clazz}" page="configure-entries.jelly" />
<f:bottomButtonBar>
<input type="hidden" name="type" value="${request.getParameter('mode')}"/>
<input type="hidden" name="type" value="${request2.getParameter('mode')}"/>
<f:submit value="${%Save}"/>
</f:bottomButtonBar>
@@ -30,7 +30,7 @@ THE SOFTWARE.
<j:invoke var="buildClass" on="${currentThread.contextClassLoader}" method="loadClass">
<j:arg value="hudson.model.Run" />
</j:invoke>
<j:set var="build" value="${request.findAncestorObject(buildClass)}" />
<j:set var="build" value="${request2.findAncestorObject(buildClass)}" />
<st:include page="sidepanel.jelly" it="${build}" />
<l:main-panel>
<t:buildCaption it="${build}">${title}</t:buildCaption>
@@ -40,7 +40,7 @@ THE SOFTWARE.
<l:main-panel>
<h1>${it.job.pronoun} ${it.job.displayName}</h1>
<p class="jenkins-description">${%description}</p>
<j:set var="delay" value="${request.getParameter('delay')}" />
<j:set var="delay" value="${request2.getParameter('delay')}" />
<f:form method="post" action="build${empty(delay)?'':'?delay='+delay}" name="parameters"
tableClass="parameters" class="jenkins-form">
<j:forEach var="parameterDefinition" items="${it.parameterDefinitions}">
@@ -20,7 +20,7 @@
<tr><td>
<div id="delete-error" style="display: none">
<pre>
${request.getAttribute('stackTraces')}
${request2.getAttribute('stackTraces')}
</pre>
</div>
</td></tr>
@@ -44,7 +44,7 @@ THE SOFTWARE.
</l:main-panel>
<l:header>
<!-- for screen resolution detection -->
<script id="screenResolution-script" data-use-secure-cookie="${request.secure}"/>
<script id="screenResolution-script" data-use-secure-cookie="${request2.secure}"/>
<st:adjunct includes="hudson.model.View.screen-resolution"/>
</l:header>
</l:layout>
@@ -27,7 +27,7 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<j:set var="q" value="${request.getParameter('q')}"/>
<j:set var="q" value="${request2.getParameter('q')}"/>
<j:new var="h" className="hudson.Functions" /><!-- needed for printing title. -->
<l:layout title="${%Search for} '${q}'">
<l:main-panel>
@@ -48,7 +48,7 @@ THE SOFTWARE.
</j:forEach>
</ol>
<j:if test="${items.hasMoreResults()}">
<j:set var="max" value="${request.hasParameter('max')?request.getParameter('max'):100}"/>
<j:set var="max" value="${request2.hasParameter('max')?request2.getParameter('max'):100}"/>
<j:choose>
<j:when test="${max &gt; it.getMaxSearchSize()}">
<em>Only showing the first ${it.getMaxSearchSize()} results,
@@ -10,7 +10,7 @@ def f=namespace(lib.FormTagLib)
def l=namespace(lib.LayoutTagLib)
def st=namespace("jelly:stapler")
l.layout(permission:app.SYSTEM_READ, title:my.displayName, cssclass:request.getParameter('decorate'), type:"one-column") {
l.layout(permission:app.SYSTEM_READ, title:my.displayName, cssclass:request2.getParameter('decorate'), type:"one-column") {
l.main_panel {
l.app_bar(title: my.displayName)
@@ -34,13 +34,13 @@ THE SOFTWARE.
needed to generate a session if non exists,
without it we would add ";jsessionid=" to the url which will result in a 404
-->
<j:set var="_" value="${request.getSession()}"/>
<j:set var="_" value="${request2.getSession()}"/>
<x:doctype name="html"/>
<!-- in case of error we want to surround the form elements with an error hint -->
<j:set var="inputClass" value="${data.errorMessage!=null ? 'jenkins-input--error' : ''}"/>
<j:set var="simpleDecorator" value="${h.simplePageDecorator}"/>
<j:set var="simpleDecorators" value="${h.simplePageDecorators}"/>
<html lang="${request.getLocale().toLanguageTag()}">
<html lang="${request2.getLocale().toLanguageTag()}">
<head data-rooturl="${rootURL}" data-resurl="${resURL}" data-imagesurl="${imagesURL}" resURL="${resURL}">
<title>${%Register} - Jenkins</title>
<!-- we do not want bots on this page -->
@@ -65,7 +65,7 @@ THE SOFTWARE.
<h2>Request Headers</h2>
<table>
<j:forEach var="n" items="${request.getHeaderNames()}">
<j:forEach var="n" items="${request2.getHeaderNames()}">
<j:choose>
<j:when test="${it.isHeaderDangerous(n)}" >
<tr>
@@ -32,7 +32,7 @@ THE SOFTWARE.
<!-- get default/common page variable -->
${h.initPageVariables(context)}
<x:doctype name="html" />
<html lang="${request.getLocale().toLanguageTag()}">
<html lang="${request2.getLocale().toLanguageTag()}">
<head data-rooturl="${rootURL}" data-resurl="${resURL}" data-imagesurl="${imagesURL}" resURL="${resURL}">
<title>${%Starting Jenkins}</title>
<!-- we do not want bots on this page -->
@@ -32,7 +32,7 @@ THE SOFTWARE.
<!-- get default/common page variable -->
${h.initPageVariables(context)}
<x:doctype name="html" />
<html lang="${request.getLocale().toLanguageTag()}">
<html lang="${request2.getLocale().toLanguageTag()}">
<head data-rooturl="${rootURL}" data-resurl="${resURL}" data-imagesurl="${imagesURL}" resURL="${resURL}">
<title>${%Restarting Jenkins}</title>
<!-- we do not want bots on this page -->
@@ -37,7 +37,7 @@ THE SOFTWARE.
<st:include it="${requestScope.instance}" class="${requestScope.descriptor.clazz}" page="config.jelly" optional="true" />
<f:bottomButtonBar>
<input type="hidden" name="cloudDescriptorName" value="${request.getParameter('mode')}"/>
<input type="hidden" name="cloudDescriptorName" value="${request2.getParameter('mode')}"/>
<f:submit value="${%Save}"/>
</f:bottomButtonBar>
@@ -5,7 +5,7 @@
<l:main-panel>
<st:include page="client-scripts" />
<form action="${app.instance.securityRealm.authenticationGatewayUrl}" method="POST">
<input type="hidden" name="from" value="${request.getParameter('from')}" />
<input type="hidden" name="from" value="${request2.getParameter('from')}" />
<div class="plugin-setup-wizard bootstrap-3">
<div class="modal fade in" style="display: block;">
<div class="modal-dialog">
@@ -28,8 +28,8 @@ THE SOFTWARE.
This is the page designated by web.xml to handle 404 errors. Show a nice error message and suggest logging in if applicable.
Generally kept very similar to 'oops.jelly'.
-->
<st:statusCode value="${response.getStatus()}" />
${request.session.setAttribute('from', request.getAttribute('jakarta.servlet.error.request_uri'))}
<st:statusCode value="${response2.getStatus()}" />
${request2.session.setAttribute('from', request2.getAttribute('jakarta.servlet.error.request_uri'))}
<l:layout title="${%title(jakarta.servlet.error.message?:'Not Found')}" type="one-column">
<l:header />
<l:main-panel>
@@ -39,7 +39,7 @@ THE SOFTWARE.
</h1>
<div id="error-description" style="text-align: center">
<h2>${%title(jakarta.servlet.error.message?:'Not Found')}</h2>
<j:if test="${!request.getAttribute('jenkins.security.ResourceDomainRootAction.error')}">
<j:if test="${!request2.getAttribute('jenkins.security.ResourceDomainRootAction.error')}">
<p>
<j:choose>
<j:when test="${app.useSecurity}">
@@ -36,7 +36,7 @@ THE SOFTWARE.
<st:setHeader name="Referrer-Policy" value="same-origin" />
<st:setHeader name="Cross-Origin-Opener-Policy" value="same-origin" />
<x:doctype name="html" />
<st:statusCode value="${response.getStatus()}" />
<st:statusCode value="${response2.getStatus()}" />
<html>
<head>
<title>${%title(jakarta.servlet.error.message?:'Not Found')}</title>
@@ -29,7 +29,7 @@ THE SOFTWARE.
<st:setHeader name="Expires" value="0" />
<st:setHeader name="Cache-Control" value="no-cache,no-store,must-revalidate" />
<!-- needed for cli -->
<j:if test="${request.servletPath=='/' || request.servletPath==''}">
<j:if test="${request2.servletPath=='/' || request2.servletPath==''}">
${h.advertiseHeaders(response)}
<j:forEach var="pd" items="${h.pageDecorators}">
<st:include it="${pd}" page="httpHeaders.jelly" optional="true"/>
@@ -39,19 +39,19 @@ THE SOFTWARE.
needed to generate a session if non exists,
without it we would add ";jsessionid=" to the url which will result in a 404
-->
<j:set var="_" value="${request.getSession()}"/>
<j:set var="_" value="${request2.getSession()}"/>
<!-- get default/common page variable -->
${h.initPageVariables(context)}
<x:doctype name="html" />
<!-- needed for the redirect after login -->
<j:set var="from" value="${error ? request.session.getAttribute('from') : request.getParameter('from')}"/>
<j:set var="from" value="${error ? request2.session.getAttribute('from') : request2.getParameter('from')}"/>
<!-- in case of error we want to surround the form elements with an error hint -->
<j:set var="inputClass" value="${error ? 'jenkins-input--error' : ''}"/>
<j:set var="simpleDecorator" value="${h.simplePageDecorator}"/>
<j:set var="simpleDecorators" value="${h.simplePageDecorators}"/>
<!-- real deal starting here -->
<html lang="${request.getLocale().toLanguageTag()}">
<html lang="${request2.getLocale().toLanguageTag()}">
<head data-rooturl="${rootURL}" data-resurl="${resURL}" data-imagesurl="${imagesURL}" resURL="${resURL}">
<title>${%signIn} - Jenkins</title>
<!-- we do not want bots on this page -->
@@ -27,7 +27,7 @@ THE SOFTWARE.
<!--
This is the page designated by web.xml and UncaughtExceptionHandler to process an exception thrown by us.
-->
<st:statusCode value="${response.getStatus()}" />
<st:statusCode value="${response2.getStatus()}" />
<l:layout title="Jenkins" type="one-column">
<l:header />
<l:main-panel>
@@ -36,12 +36,12 @@ THE SOFTWARE.
</h1>
<div id="error-description">
<h2 style="text-align: center">${%problemHappened}</h2>
<p style="text-align: center">Logging ID=${request.getAttribute('jenkins.exception.id')}</p>
<p style="text-align: center">Logging ID=${request2.getAttribute('jenkins.exception.id')}</p>
</div>
<j:if test="${app.shouldShowStackTrace()}">
<p>${%checkJIRA} ${%vote} ${%pleaseReport} ${%stackTracePlease} ${%checkML}</p>
<h2>${%Stack trace}</h2>
<pre style="margin:2em; clear:both">${h.printThrowable(request.getAttribute('jakarta.servlet.error.exception'))}</pre>
<pre style="margin:2em; clear:both">${h.printThrowable(request2.getAttribute('jakarta.servlet.error.exception'))}</pre>
</j:if>
</l:main-panel>
</l:layout>
@@ -44,25 +44,25 @@ THE SOFTWARE.
<form action="projectRelationship" method="get">
<div class="jenkins-form-item">
<label class="jenkins-form-label" for="lhs">${%upstream project}:</label>
<f:combobox id="lhs" fillUrl="fillJobNameItems" name="lhs" value="${request.getParameter('lhs')}"/>
<f:combobox id="lhs" fillUrl="fillJobNameItems" name="lhs" value="${request2.getParameter('lhs')}"/>
</div>
<div class="jenkins-form-item">
<label class="jenkins-form-label" for="rhs">${%downstream project}:</label>
<f:combobox id="rhs" fillUrl="fillJobNameItems" name="rhs" value="${request.getParameter('rhs')}"/>
<f:combobox id="rhs" fillUrl="fillJobNameItems" name="rhs" value="${request2.getParameter('rhs')}"/>
</div>
<f:submit value="${%Compare}"/>
<j:if test="${!empty(request.getParameter('lhs')) and !empty(request.getParameter('rhs'))}">
<j:set var="jl" value="${app.getItemByFullName(request.getParameter('lhs'))}"/>
<j:set var="jr" value="${app.getItemByFullName(request.getParameter('rhs'))}"/>
<j:if test="${!empty(request2.getParameter('lhs')) and !empty(request2.getParameter('rhs'))}">
<j:set var="jl" value="${app.getItemByFullName(request2.getParameter('lhs'))}"/>
<j:set var="jr" value="${app.getItemByFullName(request2.getParameter('rhs'))}"/>
<j:choose>
<j:when test="${jl==null}">
<p class="error">No such project '${request.getParameter('lhs')}'</p>
<p class="error">No such project '${request2.getParameter('lhs')}'</p>
</j:when>
<j:when test="${jr==null}">
<p class="error">No such project '${request.getParameter('rhs')}'</p>
<p class="error">No such project '${request2.getParameter('rhs')}'</p>
</j:when>
<j:otherwise>
<table width="100%">
@@ -13,7 +13,7 @@
id="user-seed-property-reset-seed"
data-target-url="${descriptor.descriptorFullUrl}/renewSessionSeed"
data-confirm="${%resetSeed.confirmation}"
data-redirect-url="${request.contextPath}/"
data-redirect-url="${request2.contextPath}/"
data-confirm-title="${%resetSeed.confirmationTitle}">
${%resetSeed.button}
</button>
@@ -41,8 +41,8 @@ THE SOFTWARE.
</st:documentation>
<st:once>
<script type="text/javascript" src="${request.contextPath}/scripts/utilities.js"/>
<script type="text/javascript" src="${request.contextPath}/scripts/combobox.js"/>
<script type="text/javascript" src="${request2.contextPath}/scripts/utilities.js"/>
<script type="text/javascript" src="${request2.contextPath}/scripts/combobox.js"/>
</st:once>
<f:prepareDatabinding/>
@@ -46,7 +46,7 @@ THE SOFTWARE.
</p>
<form action="script" method="post">
<textarea id="script" name="script" class="script">${request.getParameter('script')}</textarea>
<textarea id="script" name="script" class="script">${request2.getParameter('script')}</textarea>
<div align="right">
<f:submit value="${%Run}"/>
</div>
@@ -41,7 +41,7 @@ THE SOFTWARE.
<div id="breadcrumbBar" class="jenkins-breadcrumbs" aria-label="breadcrumb">
<ol class="jenkins-breadcrumbs__list" id="breadcrumbs">
<j:forEach var="anc" items="${request.ancestors}" indexVar="index">
<j:forEach var="anc" items="${request2.ancestors}" indexVar="index">
<j:if test="${h.isModel(anc.object) and anc.prev.url!=anc.url}">
<j:set var="mode" value="breadcrumbs" />
<l:breadcrumb title="${anc.object == app ? '%Dashboard' : anc.object.displayName}"
@@ -90,9 +90,9 @@ THE SOFTWARE.
<j:set var="layoutType" value="${attrs.type}"/>
</j:if>
<j:set var="_" value="${request.getSession()}"/>
<j:set var="_" value="${request2.getSession()}"/>
<j:set var="extensionsAvailable" value="${h.extensionsAvailable}"/>
<j:if test="${request.servletPath=='/' || request.servletPath==''}">
<j:if test="${request2.servletPath=='/' || request2.servletPath==''}">
${h.advertiseHeaders(response)}
<j:if test="${extensionsAvailable}">
<j:forEach var="pd" items="${h.pageDecorators}">
@@ -102,7 +102,7 @@ public class GlobalComputerRetentionCheckIntervalConfigurationTest {
JSONObject json = new JSONObject();
json.element("computerRetentionCheckInterval", 5);
try {
c.configure(Stapler.getCurrentRequest(), json);
c.configure(Stapler.getCurrentRequest2(), json);
} catch (Descriptor.FormException e) {
throw new RuntimeException(e);
}
@@ -121,7 +121,7 @@ public class GlobalComputerRetentionCheckIntervalConfigurationTest {
JSONObject json = new JSONObject();
json.element("computerRetentionCheckInterval", interval);
try {
c.configure(Stapler.getCurrentRequest(), json);
c.configure(Stapler.getCurrentRequest2(), json);
throw new RuntimeException("expected .configure() to throw");
} catch (Descriptor.FormException e) {
assertEquals(e.getMessage(), message);