diff --git a/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java b/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java index 7d312c5c..ee56b68e 100644 --- a/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java +++ b/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java @@ -94,7 +94,7 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.Stapler; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * {@link Publisher} that sends notification e-mail. @@ -281,7 +281,7 @@ public void setClasspath(List classpath) { // Prepare the classpath for approval ScriptApproval scriptApproval = ScriptApproval.get(); ApprovalContext context = ApprovalContext.create().withCurrentUser(); - StaplerRequest request = Stapler.getCurrentRequest(); + StaplerRequest2 request = Stapler.getCurrentRequest2(); if (request != null) { context = context.withItem(request.findAncestorObject(Item.class)); } @@ -307,7 +307,7 @@ public void setPresendScript(String presendScript) { if (!StringUtils.isBlank(presendScript) && !"$DEFAULT_PRESEND_SCRIPT".equals(presendScript)) { ScriptApproval scriptApproval = ScriptApproval.get(); ApprovalContext context = ApprovalContext.create().withCurrentUser(); - StaplerRequest request = Stapler.getCurrentRequest(); + StaplerRequest2 request = Stapler.getCurrentRequest2(); if (request != null) { Ancestor ancestor = request.findAncestor(Item.class); if (ancestor != null) { @@ -325,7 +325,7 @@ public void setPostsendScript(String postsendScript) { if (!StringUtils.isBlank(postsendScript) && !"$DEFAULT_POSTSEND_SCRIPT".equals(postsendScript)) { ScriptApproval scriptApproval = ScriptApproval.get(); ApprovalContext context = ApprovalContext.create().withCurrentUser(); - StaplerRequest request = Stapler.getCurrentRequest(); + StaplerRequest2 request = Stapler.getCurrentRequest2(); if (request != null) { Ancestor ancestor = request.findAncestor(Item.class); if (ancestor != null) { diff --git a/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java b/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java index b6a9d434..21f801a3 100644 --- a/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java +++ b/src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java @@ -50,7 +50,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * These settings are global configurations @@ -797,7 +797,7 @@ public ListBoxModel doFillDefaultContentTypeItems() { } @Override - public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + public boolean configure(StaplerRequest2 req, JSONObject formData) throws FormException { req.bindJSON(this, formData); save(); return super.configure(req, formData); diff --git a/src/main/java/hudson/plugins/emailext/plugins/EmailTrigger.java b/src/main/java/hudson/plugins/emailext/plugins/EmailTrigger.java index 9bd2cd0f..74580b5d 100644 --- a/src/main/java/hudson/plugins/emailext/plugins/EmailTrigger.java +++ b/src/main/java/hudson/plugins/emailext/plugins/EmailTrigger.java @@ -22,7 +22,7 @@ import net.sf.json.JSONObject; import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted; import org.kohsuke.stapler.Stapler; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; public abstract class EmailTrigger implements Describable, ExtensionPoint { @@ -144,17 +144,17 @@ public EmailTriggerDescriptor getDescriptor() { return (EmailTriggerDescriptor) Jenkins.get().getDescriptor(getClass()); } - public boolean configure(StaplerRequest req, JSONObject formData) { + public boolean configure(StaplerRequest2 req, JSONObject formData) { setEmail(createMailType(req, formData)); return true; } @Deprecated protected EmailType createMailType(JSONObject formData) { - return createMailType(Stapler.getCurrentRequest(), formData); + return createMailType(Stapler.getCurrentRequest2(), formData); } - protected EmailType createMailType(StaplerRequest req, JSONObject formData) { + protected EmailType createMailType(StaplerRequest2 req, JSONObject formData) { return req.bindJSON(EmailType.class, formData); } diff --git a/src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java b/src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java index d77f6dfb..429f04a4 100644 --- a/src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java +++ b/src/main/java/hudson/plugins/emailext/plugins/trigger/AbstractScriptTrigger.java @@ -34,7 +34,7 @@ import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval; import org.jenkinsci.plugins.scriptsecurity.scripts.languages.GroovyLanguage; import org.kohsuke.stapler.Stapler; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; public abstract class AbstractScriptTrigger extends EmailTrigger { @@ -60,7 +60,7 @@ public AbstractScriptTrigger( attachBuildLog, contentType); this.secureTriggerScript = secureTriggerScript; - StaplerRequest request = Stapler.getCurrentRequest(); + StaplerRequest2 request = Stapler.getCurrentRequest2(); ApprovalContext context = ApprovalContext.create().withCurrentUser(); if (request != null) { context = context.withItem(request.findAncestorObject(Item.class)); @@ -135,7 +135,7 @@ private boolean hasScript() { } @Override - public boolean configure(@NonNull StaplerRequest req, @NonNull JSONObject formData) { + public boolean configure(@NonNull StaplerRequest2 req, @NonNull JSONObject formData) { super.configure(req, formData); if (formData.containsKey("secureTriggerScript")) { this.secureTriggerScript = diff --git a/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchAction.java b/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchAction.java index 61654a2b..464794f2 100644 --- a/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchAction.java +++ b/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchAction.java @@ -12,15 +12,15 @@ import hudson.plugins.emailext.plugins.EmailTrigger; import hudson.tasks.Mailer; import hudson.tasks.Publisher; +import jakarta.servlet.ServletException; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.servlet.ServletException; import jenkins.model.Jenkins; import net.sf.json.JSONObject; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.StaplerRequest2; +import org.kohsuke.stapler.StaplerResponse2; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.interceptor.RequirePOST; import org.kohsuke.stapler.verb.POST; @@ -71,7 +71,7 @@ public UserProperty newInstance(User user) { @NonNull @Override - public UserProperty newInstance(StaplerRequest req, @NonNull JSONObject json) throws FormException { + public UserProperty newInstance(StaplerRequest2 req, @NonNull JSONObject json) throws FormException { List triggers = req != null ? req.bindJSONToList(EmailTrigger.class, json) : Collections.emptyList(); return new UserProperty(triggers); @@ -153,7 +153,7 @@ public ExtendedEmailPublisher getPublisher() { } @POST - public void doStopWatching(StaplerRequest req, StaplerResponse rsp) throws IOException { + public void doStopWatching(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException { // See src/main/resources/hudson/plugins/emailext/watching/EmailExtWatchAction/{index,jobMain}.groovy User user = User.current(); if (user != null @@ -174,7 +174,7 @@ public void doStopWatching(StaplerRequest req, StaplerResponse rsp) throws IOExc } @RequirePOST - public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { + public void doConfigSubmit(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException { // See src/main/resources/hudson/plugins/emailext/watching/EmailExtWatchAction/{index,jobMain}.groovy User user = User.current(); if (user != null diff --git a/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchJobProperty.java b/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchJobProperty.java index d26c5f1a..eb70d364 100644 --- a/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchJobProperty.java +++ b/src/main/java/hudson/plugins/emailext/watching/EmailExtWatchJobProperty.java @@ -12,7 +12,7 @@ import java.util.Collections; import java.util.List; import net.sf.json.JSONObject; -import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerRequest2; /** * Created by acearl on 12/4/2014. @@ -76,7 +76,7 @@ public boolean isApplicable(Class jobType) { } @Override - public JobProperty newInstance(StaplerRequest req, JSONObject formData) throws FormException { + public JobProperty newInstance(StaplerRequest2 req, JSONObject formData) throws FormException { return null; } diff --git a/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java b/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java index 931ad855..5976ad46 100644 --- a/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java +++ b/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java @@ -1246,7 +1246,7 @@ public void testNewInstance_shouldGetBasicInformation() throws Exception { form.put("project_replyto", ""); ExtendedEmailPublisherDescriptor descriptor = new ExtendedEmailPublisherDescriptor(); - publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest(), form); + publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest2(), form); assertEquals("default", publisher.contentType); assertEquals("ashlux@gmail.com", publisher.recipientList); @@ -1462,7 +1462,7 @@ public void testAdditionalAccounts() throws Exception { JSONObject form = new JSONObject(); form.put("project_from", "mail@test1.com"); - publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest(), form); + publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest2(), form); assertEquals("mail@test1.com", publisher.from); ExtendedEmailPublisherContext context = new ExtendedEmailPublisherContext(publisher, null, null, null, TaskListener.NULL); @@ -1485,7 +1485,7 @@ public void testAdditionalAccounts() throws Exception { addaccs.add(new MailAccount(dform)); descriptor.setAddAccounts(addaccs); - publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest(), form); + publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest2(), form); assertEquals("mail@test1.com", publisher.from); session = descriptor.createSession(publisher.getMailAccount(context), context); assertEquals("smtp.test1.com", session.getProperty("mail.smtp.host")); @@ -1493,7 +1493,7 @@ public void testAdditionalAccounts() throws Exception { assertEquals("test1.com", session.getProperty("mail.smtp.ssl.trust")); form.put("project_from", "mail@test2.com"); - publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest(), form); + publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest2(), form); assertEquals("mail@test2.com", publisher.from); session = descriptor.createSession(publisher.getMailAccount(context), context); assertEquals("smtp.test2.com", session.getProperty("mail.smtp.host"));