Skip to content

Commit 890c8b3

Browse files
committed
Changed name on some variables. Improved logging.
1 parent bf71ace commit 890c8b3

File tree

5 files changed

+68
-64
lines changed

5 files changed

+68
-64
lines changed

src/main/java/com.ericsson.ei.frontend/EIRequestsController.java

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void setBackendServerPort(int backendServerPort) {
9393
}
9494

9595
public String getEIBackendSubscriptionAddress() {
96-
return "http://" + getBackendServerHost() + ":" + getBackendServerPort();
96+
return "http://" + this.getBackendServerHost() + ":" + this.getBackendServerPort();
9797
}
9898

9999

@@ -113,15 +113,15 @@ public ResponseEntity<String> getRequests(Model model, HttpServletRequest reques
113113
HttpClient client = HttpClients.createDefault();
114114
HttpGet eiRequest = new HttpGet(newRequestUrl);
115115

116-
String JsonContent = "";
116+
String jsonContent = "";
117117
HttpResponse eiResponse = null;
118118
try {
119119
eiResponse = client.execute(eiRequest);
120120

121121
InputStream inStream = eiResponse.getEntity().getContent();
122122
BufferedReader bufReader = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
123123
for (String line = bufReader.readLine(); line != null; line = bufReader.readLine()) {
124-
JsonContent += line;
124+
jsonContent += line;
125125
}
126126
bufReader.close();
127127
inStream.close();
@@ -130,17 +130,18 @@ public ResponseEntity<String> getRequests(Model model, HttpServletRequest reques
130130
LOG.error("Forward Request Errors: " + e);
131131
}
132132

133-
LOG.debug("Http Status Code: " + eiResponse.getStatusLine().getStatusCode());
134-
LOG.debug("Recevied JsonContent:\n" + JsonContent);
133+
LOG.info("EI Http Reponse Status Code: " + eiResponse.getStatusLine().getStatusCode() +
134+
"\nEI Recevied jsonContent:\n" + jsonContent +
135+
"\nForwarding response back to EI Frontend WebUI.");
135136

136-
if (JsonContent.isEmpty()) {
137-
JsonContent="[]";
137+
if (jsonContent.isEmpty()) {
138+
jsonContent="[]";
138139
}
139140

140141
HttpHeaders headers = new HttpHeaders();
141142
headers.setContentType(MediaType.APPLICATION_JSON);
142143

143-
ResponseEntity<String> responseEntity = new ResponseEntity<>(JsonContent,
144+
ResponseEntity<String> responseEntity = new ResponseEntity<>(jsonContent,
144145
headers,
145146
HttpStatus.valueOf(eiResponse.getStatusLine().getStatusCode()));
146147
return responseEntity;
@@ -161,20 +162,20 @@ public ResponseEntity<String> postRequests(Model model, HttpServletRequest reque
161162
LOG.info("Got HTTP Request with method POST.\nUrlSuffix: " + eiBackendAddressSuffix +
162163
"\nForwarding Request to EI Backend with url: " + newRequestUrl);
163164

164-
String inputReqJsonContent = "";
165+
String inputReqjsonContent = "";
165166
try {
166167
BufferedReader inputBufReader = new BufferedReader(request.getReader());
167168
for (String line = inputBufReader.readLine(); line != null; line = inputBufReader.readLine()) {
168-
inputReqJsonContent += line;
169+
inputReqjsonContent += line;
169170
}
170171
inputBufReader.close();
171172
}
172173
catch (IOException e) {
173174
LOG.error("Forward Request Errors: " + e);
174175
}
175176

176-
LOG.debug("Input Request JSON Content to be forwarded:\n" + inputReqJsonContent);
177-
HttpEntity inputReqJsonEntity = new ByteArrayEntity(inputReqJsonContent.getBytes());
177+
LOG.debug("Input Request JSON Content to be forwarded:\n" + inputReqjsonContent);
178+
HttpEntity inputReqJsonEntity = new ByteArrayEntity(inputReqjsonContent.getBytes());
178179

179180

180181
HttpClient client = HttpClients.createDefault();
@@ -183,15 +184,15 @@ public ResponseEntity<String> postRequests(Model model, HttpServletRequest reque
183184
eiRequest.setHeader("Content-type", "application/json");
184185

185186

186-
String JsonContent = "";
187+
String jsonContent = "";
187188
HttpResponse eiResponse = null;
188189
try {
189190
eiResponse = client.execute(eiRequest);
190191

191192
InputStream inStream = eiResponse.getEntity().getContent();
192193
BufferedReader bufReader = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
193194
for (String line = bufReader.readLine(); line != null; line = bufReader.readLine()) {
194-
JsonContent += line;
195+
jsonContent += line;
195196
}
196197
bufReader.close();
197198
inStream.close();
@@ -200,17 +201,18 @@ public ResponseEntity<String> postRequests(Model model, HttpServletRequest reque
200201
LOG.error("Forward Request Errors: " + e);
201202
}
202203

203-
LOG.debug("Http Status Code: " + eiResponse.getStatusLine().getStatusCode());
204-
LOG.debug("Recevied JsonContent: \n" + JsonContent);
204+
LOG.info("EI Http Reponse Status Code: " + eiResponse.getStatusLine().getStatusCode() +
205+
"\nEI Recevied jsonContent:\n" + jsonContent +
206+
"\nForwarding response back to EI Frontend WebUI.");
205207

206-
if (JsonContent.isEmpty()) {
207-
JsonContent="[]";
208+
if (jsonContent.isEmpty()) {
209+
jsonContent="[]";
208210
}
209211

210212

211213
HttpHeaders headers = new HttpHeaders();
212214
headers.setContentType(MediaType.APPLICATION_JSON);
213-
ResponseEntity<String> responseEntity = new ResponseEntity<>(JsonContent,
215+
ResponseEntity<String> responseEntity = new ResponseEntity<>(jsonContent,
214216
headers,
215217
HttpStatus.valueOf(eiResponse.getStatusLine().getStatusCode()));
216218
return responseEntity;
@@ -229,20 +231,20 @@ public ResponseEntity<String> putRequests(Model model, HttpServletRequest reques
229231
LOG.info("Got HTTP Request with method PUT.\nUrlSuffix: " + eiBackendAddressSuffix +
230232
"\nForwarding Request to EI Backend with url: " + newRequestUrl);
231233

232-
String inputReqJsonContent = "";
234+
String inputReqjsonContent = "";
233235
try {
234236
BufferedReader inputBufReader = new BufferedReader(request.getReader());
235237
for (String line = inputBufReader.readLine(); line != null; line = inputBufReader.readLine()) {
236-
inputReqJsonContent += line;
238+
inputReqjsonContent += line;
237239
}
238240
inputBufReader.close();
239241
}
240242
catch (IOException e) {
241243
LOG.error("Forward Request Errors: " + e);
242244
}
243245

244-
LOG.debug("Input Request JSON Content to be forwarded:\n" + inputReqJsonContent);
245-
HttpEntity inputReqJsonEntity = new ByteArrayEntity(inputReqJsonContent.getBytes());
246+
LOG.debug("Input Request JSON Content to be forwarded:\n" + inputReqjsonContent);
247+
HttpEntity inputReqJsonEntity = new ByteArrayEntity(inputReqjsonContent.getBytes());
246248

247249

248250
HttpClient client = HttpClients.createDefault();
@@ -251,15 +253,15 @@ public ResponseEntity<String> putRequests(Model model, HttpServletRequest reques
251253
eiRequest.setHeader("Content-type", "application/json");
252254

253255

254-
String JsonContent = "";
256+
String jsonContent = "";
255257
HttpResponse eiResponse = null;
256258
try {
257259
eiResponse = client.execute(eiRequest);
258260

259261
InputStream inStream = eiResponse.getEntity().getContent();
260262
BufferedReader bufReader = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
261263
for (String line = bufReader.readLine(); line != null; line = bufReader.readLine()) {
262-
JsonContent += line;
264+
jsonContent += line;
263265
}
264266
bufReader.close();
265267
inStream.close();
@@ -268,17 +270,18 @@ public ResponseEntity<String> putRequests(Model model, HttpServletRequest reques
268270
LOG.error("Forward Request Errors: " + e);
269271
}
270272

271-
LOG.debug("Http Status Code: " + eiResponse.getStatusLine().getStatusCode());
272-
LOG.debug("Recevied JsonContent:\n" + JsonContent);
273+
LOG.info("EI Http Reponse Status Code: " + eiResponse.getStatusLine().getStatusCode() +
274+
"\nEI Recevied jsonContent:\n" + jsonContent +
275+
"\nForwarding response back to EI Frontend WebUI.");
273276

274-
if (JsonContent.isEmpty()) {
275-
JsonContent="[]";
277+
if (jsonContent.isEmpty()) {
278+
jsonContent="[]";
276279
}
277280

278281
HttpHeaders headers = new HttpHeaders();
279282
headers.setContentType(MediaType.APPLICATION_JSON);
280283

281-
ResponseEntity<String> responseEntity = new ResponseEntity<String>(JsonContent,
284+
ResponseEntity<String> responseEntity = new ResponseEntity<String>(jsonContent,
282285
headers,
283286
HttpStatus.valueOf(eiResponse.getStatusLine().getStatusCode()));
284287

@@ -301,15 +304,15 @@ public ResponseEntity<String> deleteRequests(Model model, HttpServletRequest req
301304
HttpClient client = HttpClients.createDefault();
302305
HttpDelete eiRequest = new HttpDelete(newRequestUrl);
303306

304-
String JsonContent = "";
307+
String jsonContent = "";
305308
HttpResponse eiResponse = null;
306309
try {
307310
eiResponse = client.execute(eiRequest);
308311

309312
InputStream inStream = eiResponse.getEntity().getContent();
310313
BufferedReader bufReader = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
311314
for (String line = bufReader.readLine(); line != null; line = bufReader.readLine()) {
312-
JsonContent += line;
315+
jsonContent += line;
313316
}
314317
bufReader.close();
315318
inStream.close();
@@ -318,17 +321,18 @@ public ResponseEntity<String> deleteRequests(Model model, HttpServletRequest req
318321
LOG.error("Forward Request Errors: " + e);
319322
}
320323

321-
LOG.debug("Http Status Code: " + eiResponse.getStatusLine().getStatusCode());
322-
LOG.debug("Recevied JsonContent:\n" + JsonContent);
324+
LOG.info("EI Http Reponse Status Code: " + eiResponse.getStatusLine().getStatusCode() +
325+
"\nEI Recevied jsonContent:\n" + jsonContent +
326+
"\nForwarding response back to EI Frontend WebUI.");
323327

324-
if (JsonContent.isEmpty()) {
325-
JsonContent="[]";
328+
if (jsonContent.isEmpty()) {
329+
jsonContent="[]";
326330
}
327331

328332
HttpHeaders headers = new HttpHeaders();
329333
headers.setContentType(MediaType.APPLICATION_JSON);
330334

331-
ResponseEntity<String> responseEntity = new ResponseEntity<>(JsonContent,
335+
ResponseEntity<String> responseEntity = new ResponseEntity<>(jsonContent,
332336
headers,
333337
HttpStatus.valueOf(eiResponse.getStatusLine().getStatusCode()));
334338
return responseEntity;

src/main/java/com.ericsson.ei.frontend/WebController.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,35 @@
2727
@ConfigurationProperties(prefix="ei")
2828
public class WebController {
2929

30-
private String backendServiceHost;
31-
private int backendServicePort;
30+
private String frontendServiceHost;
31+
private int frontendServicePort;
3232

3333

3434
@RequestMapping("/")
3535
public String greeting(Model model) {
3636

37-
String backendServiceUrl = String.format("http://%s:%d", backendServiceHost, backendServicePort);
37+
String frontendServiceUrl = String.format("http://%s:%d", frontendServiceHost, frontendServicePort);
3838

39-
model.addAttribute("backendServiceUrl", backendServiceUrl); // inject in DOM for AJAX etc
39+
model.addAttribute("frontendServiceUrl", frontendServiceUrl); // inject in DOM for AJAX etc
4040

4141
return "index";
4242
}
4343

4444
// Backend host and port (Getter & Setters), application.properties -> greeting.xxx
45-
public String getBackendServiceHost() {
46-
return backendServiceHost;
45+
public String getFrontendServiceHost() {
46+
return frontendServiceHost;
4747
}
4848

49-
public void setBackendServiceHost(String backendServiceHost) {
50-
this.backendServiceHost = backendServiceHost;
49+
public void setFrontendServiceHost(String frontendServiceHost) {
50+
this.frontendServiceHost = frontendServiceHost;
5151
}
5252

53-
public int getBackendServicePort() {
54-
return backendServicePort;
53+
public int getFrontendServicePort() {
54+
return frontendServicePort;
5555
}
5656

57-
public void setBackendServicePort(int backendServicePort) {
58-
this.backendServicePort = backendServicePort;
57+
public void setFrontendServicePort(int frontendServicePort) {
58+
this.frontendServicePort = frontendServicePort;
5959
}
6060

6161
}

src/main/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ spring.application.name=ei-frontend
77
server.port=8080
88

99
######## EI Backend
10-
ei.backendServiceHost=localhost
11-
ei.backendServicePort=8080
10+
ei.frontendServiceHost=localhost
11+
ei.frontendServicePort=8080
1212
ei.backendServerHost=localhost
1313
ei.backendServerPort=8090
1414

src/main/resources/static/js/main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Global vars
22
var save_method;
33
var table;
4-
var backendServiceUrl;
4+
var frontendServiceUrl;
55
var subscriptionTemplateFile;
66

77
jQuery(document).ready(function() {
@@ -26,7 +26,7 @@ jQuery(document).ready(function() {
2626

2727

2828
// Fetch injected URL from DOM
29-
backendServiceUrl = $('#backendServiceUrl').text();
29+
frontendServiceUrl = $('#frontendServiceUrl').text();
3030

3131
// /Start ## Global AJAX Sender function ##################################
3232
var AjaxHttpSender = function () {};
@@ -61,7 +61,7 @@ jQuery(document).ready(function() {
6161
var EIConnBtn = document.getElementById("btnEIConnection");
6262

6363
$.ajax({
64-
url: backendServiceUrl + "/subscriptions/testDummySubscription",
64+
url: frontendServiceUrl + "/subscriptions/testDummySubscription",
6565
contentType : 'application/json; charset=utf-8',
6666
type: 'GET',
6767
error : function (XMLHttpRequest, textStatus, errorThrown) {
@@ -84,7 +84,7 @@ jQuery(document).ready(function() {
8484
function getInstanceInfo() {
8585
var text = document.getElementById('info_text');
8686
$.ajax({
87-
url: backendServiceUrl + "/information",
87+
url: frontendServiceUrl + "/information",
8888
contentType : 'application/json;charset=UTF-8',
8989
type: 'GET',
9090
error : function (XMLHttpRequest, textStatus, errorThrown) {
@@ -261,7 +261,7 @@ jQuery(document).ready(function() {
261261

262262
// Load data for the table's content from an Ajax source
263263
"ajax": {
264-
"url": backendServiceUrl + "/subscriptions",
264+
"url": frontendServiceUrl + "/subscriptions",
265265
"type": "GET",
266266
"dataSrc": "" // Flat structure from EI backend REST API
267267

@@ -401,7 +401,7 @@ jQuery(document).ready(function() {
401401
confirm: function () {
402402
var ajaxHttpSender = new AjaxHttpSender();
403403
for (i=0; i < subScriptionsToDelete.length; i++){
404-
ajaxHttpSender.sendAjax(backendServiceUrl + "/subscriptions/"+subScriptionsToDelete[i], "DELETE", null, callback);
404+
ajaxHttpSender.sendAjax(frontendServiceUrl + "/subscriptions/"+subScriptionsToDelete[i], "DELETE", null, callback);
405405
}
406406
},
407407
cancel: function () {
@@ -485,7 +485,7 @@ jQuery(document).ready(function() {
485485

486486
// Perform AJAX
487487
var ajaxHttpSender = new AjaxHttpSender();
488-
ajaxHttpSender.sendAjax(backendServiceUrl + "/subscriptions", "POST", ko.toJSON(subscriptionJson), callback);
488+
ajaxHttpSender.sendAjax(frontendServiceUrl + "/subscriptions", "POST", ko.toJSON(subscriptionJson), callback);
489489
}
490490

491491
function validateJsonAndCreateSubscriptions(subscriptionFile){
@@ -610,7 +610,7 @@ jQuery(document).ready(function() {
610610

611611
// Perform AJAX
612612
var ajaxHttpSender = new AjaxHttpSender();
613-
ajaxHttpSender.sendAjax(backendServiceUrl + "/subscriptions/"+id, "GET", null, callback);
613+
ajaxHttpSender.sendAjax(frontendServiceUrl + "/subscriptions/"+id, "GET", null, callback);
614614

615615
});
616616
// /Stop ## Edit Subscription ###########################################
@@ -742,11 +742,11 @@ jQuery(document).ready(function() {
742742
var url;
743743
var type;
744744
if(save_method === 'add') { // Add new
745-
url = backendServiceUrl + "/subscriptions";
745+
url = frontendServiceUrl + "/subscriptions";
746746
type = "POST";
747747

748748
} else { // Update existing
749-
url = backendServiceUrl + "/subscriptions";
749+
url = frontendServiceUrl + "/subscriptions";
750750
type = "PUT";
751751
}
752752

@@ -845,7 +845,7 @@ jQuery(document).ready(function() {
845845
buttons: {
846846
confirm: function () {
847847
var ajaxHttpSender = new AjaxHttpSender();
848-
ajaxHttpSender.sendAjax(backendServiceUrl + "/subscriptions/"+id, "DELETE", null, callback);
848+
ajaxHttpSender.sendAjax(frontendServiceUrl + "/subscriptions/"+id, "DELETE", null, callback);
849849
},
850850
cancel: function () {
851851
}

src/main/resources/templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
</head>
3535
<body>
3636

37-
<div class="hidden" id="backendServiceUrl" th:text="${backendServiceUrl}"></div>
37+
<div class="hidden" id="frontendServiceUrl" th:text="${frontendServiceUrl}"></div>
3838
<div class="hidden" id="subscriptionTemplate" th:text="${subscriptionTemplate}"></div>
3939

4040
<script type="text/javascript" src="resources\subscription_templates.js"></script>
4141
<script type="text/javascript" src="js/main.js"></script>
4242

4343
<div class="container">
44-
<h1 style="font-size:20pt">Eiffel Intelligence Subscription Handling (<span th:text="${backendServiceUrl}"></span>)
44+
<h1 style="font-size:20pt">Eiffel Intelligence Subscription Handling (<span th:text="${frontendServiceUrl}"></span>)
4545
<button data-toggle="tooltip" title="EI connection status check is refreshed continuesly. Click button to force check status." type="button" id="btnEIConnection" class="btn btnEIConnectionStatus"><i class="glyphicon"></i>EI Backend Status</button>
4646
<button data-toggle="tooltip" title="Eiffel intelligence instance information" type="button" id="btnInfo" class="btn btnEIInstanceInfo"><i class="glyphicon"></i> EI Backend Instance Info</button>
4747
</h1>

0 commit comments

Comments
 (0)