|
|
@ -26,9 +26,10 @@ import org.apache.commons.fileupload.FileUploadException;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.http.HttpHeaders;
|
|
|
|
import org.apache.hc.core5.http.ClassicHttpRequest;
|
|
|
|
import org.apache.http.HttpStatus;
|
|
|
|
import org.apache.hc.core5.http.HttpHeaders;
|
|
|
|
import org.apache.http.client.methods.*;
|
|
|
|
import org.apache.hc.core5.http.HttpStatus;
|
|
|
|
|
|
|
|
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.annotation.MultipartConfig;
|
|
|
|
import javax.servlet.annotation.MultipartConfig;
|
|
|
|
import javax.servlet.annotation.WebServlet;
|
|
|
|
import javax.servlet.annotation.WebServlet;
|
|
|
@ -58,7 +59,7 @@ public class InvokerHandler extends HttpServlet {
|
|
|
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint));
|
|
|
|
ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)).build();
|
|
|
|
HandlerUtil.generateRequestEntity(req, postRequest);
|
|
|
|
HandlerUtil.generateRequestEntity(req, postRequest);
|
|
|
|
postRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
postRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(postRequest);
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(postRequest);
|
|
|
@ -88,7 +89,8 @@ public class InvokerHandler extends HttpServlet {
|
|
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req, apiEndpoint));
|
|
|
|
ClassicHttpRequest getRequest = ClassicRequestBuilder.get(HandlerUtil.generateBackendRequestURL(req,
|
|
|
|
|
|
|
|
apiEndpoint)).build();
|
|
|
|
HandlerUtil.copyRequestHeaders(req, getRequest, false);
|
|
|
|
HandlerUtil.copyRequestHeaders(req, getRequest, false);
|
|
|
|
getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(getRequest);
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(getRequest);
|
|
|
@ -123,7 +125,8 @@ public class InvokerHandler extends HttpServlet {
|
|
|
|
protected void doHead(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
protected void doHead(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
HttpHead headRequest = new HttpHead(HandlerUtil.generateBackendRequestURL(req, apiEndpoint));
|
|
|
|
ClassicHttpRequest headRequest = ClassicRequestBuilder.head(HandlerUtil.generateBackendRequestURL(req,
|
|
|
|
|
|
|
|
apiEndpoint)).build();
|
|
|
|
HandlerUtil.copyRequestHeaders(req, headRequest, false);
|
|
|
|
HandlerUtil.copyRequestHeaders(req, headRequest, false);
|
|
|
|
headRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
headRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(headRequest);
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(headRequest);
|
|
|
@ -150,7 +153,8 @@ public class InvokerHandler extends HttpServlet {
|
|
|
|
protected void doPut(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
protected void doPut(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
HttpPut putRequest = new HttpPut(HandlerUtil.generateBackendRequestURL(req, apiEndpoint));
|
|
|
|
ClassicHttpRequest putRequest = ClassicRequestBuilder.put(HandlerUtil.generateBackendRequestURL(req,
|
|
|
|
|
|
|
|
apiEndpoint)).build();
|
|
|
|
HandlerUtil.generateRequestEntity(req, putRequest);
|
|
|
|
HandlerUtil.generateRequestEntity(req, putRequest);
|
|
|
|
putRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
putRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(putRequest);
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(putRequest);
|
|
|
@ -180,7 +184,8 @@ public class InvokerHandler extends HttpServlet {
|
|
|
|
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
if (validateRequest(req, resp)) {
|
|
|
|
HttpDelete deleteRequest = new HttpDelete(HandlerUtil.generateBackendRequestURL(req, apiEndpoint));
|
|
|
|
ClassicHttpRequest deleteRequest = ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req,
|
|
|
|
|
|
|
|
apiEndpoint)).build();
|
|
|
|
HandlerUtil.copyRequestHeaders(req, deleteRequest, false);
|
|
|
|
HandlerUtil.copyRequestHeaders(req, deleteRequest, false);
|
|
|
|
deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken());
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest);
|
|
|
|
ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest);
|
|
|
|