@@ -54,10 +54,7 @@ public class EIRequestsController {
54
54
@ CrossOrigin
55
55
@ RequestMapping (value = "/auth/login" , method = RequestMethod .GET )
56
56
public ResponseEntity <String > getAuthRequests (Model model , HttpServletRequest request ) {
57
- String eiBackendAddressSuffix = request .getServletPath ();
58
- String newRequestUrl = getEIBackendSubscriptionAddress () + eiBackendAddressSuffix ;
59
- LOG .info ("Got HTTP Request with method GET.\n UrlSuffix: " + eiBackendAddressSuffix +
60
- "\n Forwarding Request to EI Backend with url: " + newRequestUrl );
57
+ String eiRequestUrl = getEIRequestURL (request );
61
58
62
59
try {
63
60
client .close ();
@@ -66,7 +63,7 @@ public ResponseEntity<String> getAuthRequests(Model model, HttpServletRequest re
66
63
LOG .error ("Failed to close HTTP Client" );
67
64
}
68
65
69
- HttpGet eiRequest = new HttpGet (newRequestUrl );
66
+ HttpGet eiRequest = new HttpGet (eiRequestUrl );
70
67
71
68
String header = request .getHeader ("Authorization" );
72
69
if (header != null ) {
@@ -81,15 +78,12 @@ public ResponseEntity<String> getAuthRequests(Model model, HttpServletRequest re
81
78
* Subscription by id or all subscriptions and EI Env Info.
82
79
*/
83
80
@ CrossOrigin
84
- @ RequestMapping (value = { "/subscriptions" , "/subscriptions/*" , "/information" , "/auth" ,
85
- "/auth/checkStatus" , "/auth/logout" , "/download/* " }, method = RequestMethod .GET )
81
+ @ RequestMapping (value = { "/subscriptions" , "/subscriptions/*" , "/information" , "/download/*" , "/ auth" ,
82
+ "/auth/checkStatus" , "/auth/logout" , "/queryAggregatedObject" , "/queryMissedNotifications" , "/query " }, method = RequestMethod .GET )
86
83
public ResponseEntity <String > getRequests (Model model , HttpServletRequest request ) {
87
- String eiBackendAddressSuffix = request .getServletPath ();
88
- String newRequestUrl = getEIBackendSubscriptionAddress () + eiBackendAddressSuffix ;
89
- LOG .info ("Got HTTP Request with method GET.\n UrlSuffix: " + eiBackendAddressSuffix
90
- + "\n Forwarding Request to EI Backend with url: " + newRequestUrl );
84
+ String eiRequestUrl = getEIRequestURL (request );
91
85
92
- HttpGet eiRequest = new HttpGet (newRequestUrl );
86
+ HttpGet eiRequest = new HttpGet (eiRequestUrl );
93
87
94
88
return getResponse (eiRequest );
95
89
}
@@ -98,12 +92,9 @@ public ResponseEntity<String> getRequests(Model model, HttpServletRequest reques
98
92
* Bridge all EI Http Requests with POST method.
99
93
*/
100
94
@ CrossOrigin
101
- @ RequestMapping (value = {"/subscriptions" , "/rules/rule-check/aggregation" }, method = RequestMethod .POST )
95
+ @ RequestMapping (value = { "/subscriptions" , "/rules/rule-check/aggregation" , "/query" }, method = RequestMethod .POST )
102
96
public ResponseEntity <String > postRequests (Model model , HttpServletRequest request ) {
103
- String eiBackendAddressSuffix = request .getServletPath ();
104
- String newRequestUrl = getEIBackendSubscriptionAddress () + eiBackendAddressSuffix ;
105
- LOG .info ("Got HTTP Request with method POST.\n UrlSuffix: " + eiBackendAddressSuffix
106
- + "\n Forwarding Request to EI Backend with url: " + newRequestUrl );
97
+ String eiRequestUrl = getEIRequestURL (request );
107
98
108
99
String inputReqJsonContent = "" ;
109
100
try {
@@ -119,7 +110,7 @@ public ResponseEntity<String> postRequests(Model model, HttpServletRequest reque
119
110
LOG .debug ("Input Request JSON Content to be forwarded:\n " + inputReqJsonContent );
120
111
HttpEntity inputReqJsonEntity = new ByteArrayEntity (inputReqJsonContent .getBytes ());
121
112
122
- HttpPost eiRequest = new HttpPost (newRequestUrl );
113
+ HttpPost eiRequest = new HttpPost (eiRequestUrl );
123
114
eiRequest .setEntity (inputReqJsonEntity );
124
115
eiRequest .setHeader ("Content-type" , "application/json" );
125
116
@@ -133,10 +124,7 @@ public ResponseEntity<String> postRequests(Model model, HttpServletRequest reque
133
124
@ CrossOrigin
134
125
@ RequestMapping (value = "/subscriptions" , method = RequestMethod .PUT )
135
126
public ResponseEntity <String > putRequests (Model model , HttpServletRequest request ) {
136
- String eiBackendAddressSuffix = request .getServletPath ();
137
- String newRequestUrl = getEIBackendSubscriptionAddress () + eiBackendAddressSuffix ;
138
- LOG .info ("Got HTTP Request with method PUT.\n UrlSuffix: " + eiBackendAddressSuffix
139
- + "\n Forwarding Request to EI Backend with url: " + newRequestUrl );
127
+ String eiRequestUrl = getEIRequestURL (request );
140
128
141
129
String inputReqJsonContent = "" ;
142
130
try {
@@ -152,7 +140,7 @@ public ResponseEntity<String> putRequests(Model model, HttpServletRequest reques
152
140
LOG .debug ("Input Request JSON Content to be forwarded:\n " + inputReqJsonContent );
153
141
HttpEntity inputReqJsonEntity = new ByteArrayEntity (inputReqJsonContent .getBytes ());
154
142
155
- HttpPut eiRequest = new HttpPut (newRequestUrl );
143
+ HttpPut eiRequest = new HttpPut (eiRequestUrl );
156
144
eiRequest .setEntity (inputReqJsonEntity );
157
145
eiRequest .setHeader ("Content-type" , "application/json" );
158
146
@@ -166,12 +154,9 @@ public ResponseEntity<String> putRequests(Model model, HttpServletRequest reques
166
154
@ CrossOrigin
167
155
@ RequestMapping (value = "/subscriptions/*" , method = RequestMethod .DELETE )
168
156
public ResponseEntity <String > deleteRequests (Model model , HttpServletRequest request ) {
169
- String eiBackendAddressSuffix = request .getServletPath ();
170
- String newRequestUrl = getEIBackendSubscriptionAddress () + eiBackendAddressSuffix ;
171
- LOG .info ("Got HTTP Request with method DELETE.\n UrlSuffix: " + eiBackendAddressSuffix
172
- + "\n Forwarding Request to EI Backend with url: " + newRequestUrl );
157
+ String eiRequestUrl = getEIRequestURL (request );
173
158
174
- HttpDelete eiRequest = new HttpDelete (newRequestUrl );
159
+ HttpDelete eiRequest = new HttpDelete (eiRequestUrl );
175
160
176
161
return getResponse (eiRequest );
177
162
}
@@ -189,6 +174,17 @@ private String getEIBackendSubscriptionAddress() {
189
174
return httpMethod + "://" + backEndInformation .getHost () + ":" + backEndInformation .getPort ();
190
175
}
191
176
177
+ private String getEIRequestURL (HttpServletRequest request ) {
178
+ String eiBackendAddressSuffix = request .getServletPath ();
179
+ String requestQuery = request .getQueryString ();
180
+ String query = (requestQuery != null && !requestQuery .isEmpty ()) ? "?" + requestQuery : "" ;
181
+ String requestUrl = getEIBackendSubscriptionAddress () + eiBackendAddressSuffix + query ;
182
+ LOG .info ("Got HTTP Request with method " + request .getMethod ()
183
+ + "\n UrlSuffix: " + eiBackendAddressSuffix
184
+ + "\n Forwarding Request to EI Backend with url: " + requestUrl );
185
+ return requestUrl ;
186
+ }
187
+
192
188
private ResponseEntity <String > getResponse (HttpRequestBase request ) {
193
189
String jsonContent = "" ;
194
190
int statusCode = 102 ;
0 commit comments