Skip to content

Commit

Permalink
Migrate to Jakarta EE 9 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Nov 13, 2024
1 parent 106bb22 commit 48b338d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.86</version>
<version>5.2</version>
<relativePath />
</parent>
<properties>
<revision>1.36</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.440.3</jenkins.version>
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
</properties>

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/hudson/plugins/nested_view/NestedView.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
import org.kohsuke.stapler.export.Exported;
import hudson.security.Permission;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -126,12 +126,12 @@ public boolean contains(TopLevelItem item) {
}

@Override
public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws IOException, JellyException {
public ContextMenu doContextMenu(StaplerRequest2 request, StaplerResponse2 response) throws IOException, JellyException {
return new ContextMenu().from(this, request, response);
}

@Override
public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
public ContextMenu doChildrenContextMenu(StaplerRequest2 request, StaplerResponse2 response) throws Exception {
ContextMenu menu = new ContextMenu();
for (View view : getViews()) {
menu.add(new MenuItem().withContextRelativeUrl(view.getUrl()).withDisplayName(view.getDisplayName()));
Expand Down Expand Up @@ -160,7 +160,7 @@ public List<Action> getViewActions() {
}

@Override
public Item doCreateItem(StaplerRequest req, StaplerResponse rsp)
public Item doCreateItem(StaplerRequest2 req, StaplerResponse2 rsp)
throws IOException, ServletException {
ItemGroup itemGroup = getItemGroup();
if (itemGroup instanceof ModifiableItemGroup) {
Expand Down Expand Up @@ -212,7 +212,7 @@ public synchronized void onJobRenamed(Item item, String oldName, String newName)
v.onJobRenamed(item, oldName, newName);
}

protected synchronized void submit(StaplerRequest req) throws IOException, ServletException, FormException {
protected synchronized void submit(StaplerRequest2 req) throws IOException, ServletException, FormException {
defaultView = Util.fixEmpty(req.getParameter("defaultView"));
if (columns == null) {
columns = new NestedViewColumns();
Expand Down Expand Up @@ -275,7 +275,7 @@ public void save() throws IOException {
}
}

public void doCreateView(StaplerRequest req, StaplerResponse rsp)
public void doCreateView(StaplerRequest2 req, StaplerResponse2 rsp)
throws IOException, ServletException, FormException {
checkPermission(View.CREATE);
addView(View.create(req, rsp, this));
Expand Down Expand Up @@ -470,11 +470,11 @@ public HealthReportContainer getHealth() {

@Override
@WebMethod(name = "config.xml")
public HttpResponse doConfigDotXml(StaplerRequest req) throws IOException {
public HttpResponse doConfigDotXml(StaplerRequest2 req) throws IOException {
if (req.getMethod().equals("GET")) {
checkPermission(READ);
return new HttpResponse() {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
public void generateResponse(StaplerRequest2 req, StaplerResponse2 rsp, Object node) throws IOException, ServletException {

rsp.setContentType("application/xml");
XStream2 xStream2 = new XStream2();
Expand Down Expand Up @@ -596,12 +596,12 @@ public List<HealthReport> getBuildHealthReports() {
public Object getTarget() {
// Proxy to handle redirect when a default subview is configured
return (getDefaultView() != null &&
"".equals(Stapler.getCurrentRequest().getRestOfPath()))
"".equals(Stapler.getCurrentRequest2().getRestOfPath()))
? new DefaultViewProxy() : this;
}

public class DefaultViewProxy {
public void doIndex(StaplerRequest req, StaplerResponse rsp)
public void doIndex(StaplerRequest2 req, StaplerResponse2 rsp)
throws IOException, ServletException {
if (getDefaultView() != null)
rsp.sendRedirect2("view/" + defaultView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import hudson.views.WeatherColumn;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import java.io.IOException;
import java.util.List;
Expand All @@ -23,7 +23,7 @@
public class NestedViewColumns {
private DescribableList<ListViewColumn, Descriptor<ListViewColumn>> columns;

public void updateFromForm(StaplerRequest req, JSONObject formData, String key) throws IOException, Descriptor.FormException {
public void updateFromForm(StaplerRequest2 req, JSONObject formData, String key) throws IOException, Descriptor.FormException {
columns.rebuildHetero(req, formData, getPossibleColumns(), key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerRequest2;

import java.util.logging.Logger;

Expand Down Expand Up @@ -69,7 +69,7 @@ public NestedViewGlobalConfig() {


@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
public boolean configure(StaplerRequest2 req, JSONObject json) throws FormException {
req.bindJSON(this, json);
save();
return super.configure(req, json);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/hudson/plugins/nested_view/NestedViewsSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import jenkins.model.Jenkins;

import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -75,7 +75,7 @@ private void addViewsRecursively(Collection<View> views, String s, List<NamableW
}

@Override
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
public void doIndex(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException {
String query = req.getParameter("q");
hits = new ArrayList<>();
if (query != null) {
Expand Down Expand Up @@ -129,7 +129,7 @@ public List getHistory() {
}

@Override
public SearchResult getSuggestions(final StaplerRequest req, @QueryParameter final String query) {
public SearchResult getSuggestions(final StaplerRequest2 req, @QueryParameter final String query) {
SearchResult suggestedItems = super.getSuggestions(req, query);
this.query = new Query(false, query);
final Set<String> matched = new HashSet<>(); //unusuded for suggestions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import hudson.search.Search;
import hudson.search.SearchFactory;
import hudson.search.SearchableModelObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;


Expand Down Expand Up @@ -36,7 +36,7 @@ public Search createFor(final SearchableModelObject owner) {
if (isTmpSkip()) {
return new Search(){
@Override
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
public void doIndex(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException, ServletException {
//we have to reset it only in search, not during suggestions
super.doIndex(req, rsp);
resetTmpSkip();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/hudson/plugins/nested_view/NestedViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import static hudson.util.FormValidation.Kind.*;

import jakarta.servlet.ServletRequest;
import java.io.IOException;
import java.net.URL;
import java.util.List;
Expand Down Expand Up @@ -176,7 +177,7 @@ public void testUploadXml() throws Exception {
// First try creating a clone of this view (Jenkins.doCreateView → View.create → View.createViewFromXML):
// TODO wc.createCrumbedUrl does not work when you are specifying your own query parameters

Check warning on line 178 in src/test/java/hudson/plugins/nested_view/NestedViewTest.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: wc.createCrumbedUrl does not work when you are specifying your own query parameters
CrumbIssuer issuer = rule.jenkins.getCrumbIssuer();
WebRequest req = new WebRequest(new URL(rule.getURL(), "/createView?name=clone&" + issuer.getDescriptor().getCrumbRequestField() + "=" + issuer.getCrumb(null)), HttpMethod.POST);
WebRequest req = new WebRequest(new URL(rule.getURL(), "/createView?name=clone&" + issuer.getDescriptor().getCrumbRequestField() + "=" + issuer.getCrumb((ServletRequest) null)), HttpMethod.POST);
req.setAdditionalHeader("Content-Type", "application/xml");
req.setRequestBody(xml);
wc.getPage(req);
Expand Down

0 comments on commit 48b338d

Please sign in to comment.