Skip to content

Commit f5e6e85

Browse files
PLUGINAPI-42 Add new methods required by filters in SonarQube
1 parent 945a314 commit f5e6e85

File tree

6 files changed

+68
-1
lines changed

6 files changed

+68
-1
lines changed

plugin-api/src/main/java/org/sonar/api/server/http/HttpRequest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ public interface HttpRequest {
6666
*/
6767
String getQueryString();
6868

69+
/**
70+
* Returns the portion of the request URI that indicates the context of the request. The context path always comes first
71+
* in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the
72+
* default (root) context, this method returns "". The container does not decode this string.
73+
*/
74+
String getContextPath();
75+
6976
/**
7077
* Returns the value of a request parameter as a String, or null if the parameter does not exist.
7178
* You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value,
@@ -74,7 +81,7 @@ public interface HttpRequest {
7481
String getParameter(String name);
7582

7683
/**
77-
* Returns an array containing all of the values the given request parameter has, or null if the parameter does not exist.
84+
* Returns an array containing all the values the given request parameter has, or null if the parameter does not exist.
7885
*/
7986
String[] getParameterValues(String name);
8087

plugin-api/src/main/java/org/sonar/api/server/http/HttpResponse.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.sonar.api.server.http;
2121

2222
import java.io.IOException;
23+
import java.io.PrintWriter;
2324
import java.util.Collection;
2425

2526
/**
@@ -55,6 +56,23 @@ public interface HttpResponse {
5556
*/
5657
int getStatus();
5758

59+
/**
60+
* Sets the content type of the response being sent to the client, if the response has not been committed yet.
61+
*/
62+
void setContentType(String contentType);
63+
64+
/**
65+
* Returns a <code>PrintWriter</code> object that can send character text to the client. Calling flush()
66+
* on the <code>PrintWriter</code> commits the response.
67+
*/
68+
PrintWriter getWriter() throws IOException;
69+
70+
/**
71+
* Sets a response header with the given name and value. If the header had already been set, the new value overwrites
72+
* the previous one.
73+
*/
74+
void setHeader(String name, String value);
75+
5876
/**
5977
* Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.
6078
* The buffer will be replaced with the data set by this method.

plugin-api/src/main/java/org/sonar/api/server/http/JakartaHttpRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public String getQueryString() {
6868
return delegate.getQueryString();
6969
}
7070

71+
@Override
72+
public String getContextPath() {
73+
return delegate.getContextPath();
74+
}
75+
7176
@Override
7277
public String getParameter(String name) {
7378
return delegate.getParameter(name);

plugin-api/src/main/java/org/sonar/api/server/http/JakartaHttpResponse.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import jakarta.servlet.http.HttpServletResponse;
2323
import java.io.IOException;
24+
import java.io.PrintWriter;
2425
import java.util.Collection;
2526

2627
/**
@@ -59,6 +60,21 @@ public int getStatus() {
5960
return delegate.getStatus();
6061
}
6162

63+
@Override
64+
public void setContentType(String contentType) {
65+
delegate.setContentType(contentType);
66+
}
67+
68+
@Override
69+
public PrintWriter getWriter() throws IOException {
70+
return delegate.getWriter();
71+
}
72+
73+
@Override
74+
public void setHeader(String name, String value) {
75+
delegate.setHeader(name, value);
76+
}
77+
6278
@Override
6379
public void sendRedirect(String location) throws IOException {
6480
delegate.sendRedirect(location);

plugin-api/src/main/java/org/sonar/api/server/http/JavaxHttpRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public String getQueryString() {
6868
return delegate.getQueryString();
6969
}
7070

71+
@Override
72+
public String getContextPath() {
73+
return delegate.getContextPath();
74+
}
75+
7176
@Override
7277
public String getParameter(String name) {
7378
return delegate.getParameter(name);

plugin-api/src/main/java/org/sonar/api/server/http/JavaxHttpResponse.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.sonar.api.server.http;
2121

2222
import java.io.IOException;
23+
import java.io.PrintWriter;
2324
import java.util.Collection;
2425
import javax.servlet.http.HttpServletResponse;
2526

@@ -59,6 +60,21 @@ public int getStatus() {
5960
return delegate.getStatus();
6061
}
6162

63+
@Override
64+
public void setContentType(String contentType) {
65+
delegate.setContentType(contentType);
66+
}
67+
68+
@Override
69+
public PrintWriter getWriter() throws IOException {
70+
return delegate.getWriter();
71+
}
72+
73+
@Override
74+
public void setHeader(String name, String value) {
75+
delegate.setHeader(name, value);
76+
}
77+
6278
@Override
6379
public void sendRedirect(String location) throws IOException {
6480
delegate.sendRedirect(location);

0 commit comments

Comments
 (0)