Skip to content

Commit 38586cb

Browse files
author
Anders Breid
authored
Add support to use /status endoint (#259)
- Back-end status check will now be performed on the /status endpoint instead of /auth/checkStatus. - Updated documentation.
1 parent 775aefb commit 38586cb

File tree

5 files changed

+58
-53
lines changed

5 files changed

+58
-53
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class EIRequestsController {
7171
*/
7272
@CrossOrigin
7373
@RequestMapping(value = { "/subscriptions", "/subscriptions/*", "/information", "/download/*", "/auth", "/auth/*",
74-
"/queryAggregatedObject", "/queryMissedNotifications", "/query", "/rules",
74+
"/queryAggregatedObject", "/queryMissedNotifications", "/query", "/rules", "/status",
7575
"/rules/rule-check/testRulePageEnabled" }, method = RequestMethod.GET)
7676
public ResponseEntity<String> getRequests(Model model, HttpServletRequest incomingRequest) {
7777
String eiRequestUrl;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ function checkBackendSecured() {
355355
}
356356
};
357357
var ajaxHttpSender = new AjaxHttpSender();
358-
ajaxHttpSender.sendAjax(backendEndpoints.AUTH, "GET", null, callback);
358+
var data = null;
359+
ajaxHttpSender.sendAjax(backendEndpoints.AUTH, "GET", data, callback);
359360
}
360361

361362
function checkLoggedInUser() {

src/main/resources/static/js/global-variables.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var usernameMaxDisplayLength = 15;
1212
var backendEndpoints = {
1313
AUTH: "/auth",
1414
LOGIN: "/auth/login",
15-
CHECK_STATUS: "/auth/checkStatus",
15+
CHECK_STATUS: "/status",
1616
SUBSCRIPTIONS: "/subscriptions",
1717
DOWNLOAD: "/download/",
1818
DOWNLOAD_SUBSCRIPTIONS_TEMPLATE: "/download/subscriptionsTemplate",
@@ -22,7 +22,6 @@ var backendEndpoints = {
2222
CHECK_AGGREGATION: "/rules/rule-check/aggregation"
2323
};
2424

25-
// Status handling variables
2625
var PAGES_FOR_STATUS_INDICATION = "subscriptions test-rules ei-info login";
2726
var statusType = {
2827
SUCCESS: "alert-success",
@@ -31,7 +30,7 @@ var statusType = {
3130
DANGER: "alert-danger"
3231
};
3332
var statusText = {
34-
BACKEND_DOWN: "<strong>Back-end is down!</strong> Wait for it go up or switch to another back-end before continuing!",
33+
BACKEND_DOWN: "<strong>Back-end, MongoDB and/or RabbitMQ is down!</strong> Wait for them go up or switch to another back-end before continuing!",
3534
UNKNOWN_BACK_END_STATUS: "<strong>Back-end status is unknown!</strong> Wait for it to update or switch to another back-end before continuing!",
3635
TEST_RULES_DISABLED: "<strong>Test Rule service is disabled!</strong> To enable it set the backend property [testaggregated.enabled] as [true]"
3736
};
@@ -40,9 +39,6 @@ var backEndStatus = true;
4039
var backEndStatusUpdated = false;
4140
var previousBackEndStatus;
4241
var backEndStatusTimerInterval;
43-
// End Status variables
44-
45-
// Start ## getters and setters
4642

4743
function isLdapEnabled(){
4844
return Boolean(ldapEnabled);
@@ -69,9 +65,21 @@ function getFrontendServiceBackEndPath() {
6965
return frontendServiceBackEndPath;
7066
}
7167

72-
// End ## getters and setters
68+
function getSubscriptionNameRegex() {
69+
return subscriptionNameRegex;
70+
}
71+
72+
function getNotificationMetaRegex() {
73+
return notificationMetaRegex;
74+
}
7375

74-
// Start ## getters and setters status handling
76+
function getUsernameMaxDisplayLength() {
77+
if (usernameMaxDisplayLength < 4) {
78+
// Minimum leangth is 4 due to ellipsis being 3 long
79+
return 4;
80+
}
81+
return usernameMaxDisplayLength;
82+
}
7583

7684
function isBackEndStatusOk() {
7785
return Boolean(backEndStatus);
@@ -105,21 +113,3 @@ function setBackEndStatusTimerInterval() {
105113
function getWhiteListedPages() {
106114
return String(PAGES_FOR_STATUS_INDICATION);
107115
}
108-
109-
function getSubscriptionNameRegex() {
110-
return subscriptionNameRegex;
111-
}
112-
113-
function getNotificationMetaRegex() {
114-
return notificationMetaRegex;
115-
}
116-
117-
function getUsernameMaxDisplayLength() {
118-
if (usernameMaxDisplayLength < 4) {
119-
// Minimum leangth is 4 due to ellipsis being 3 long
120-
return 4;
121-
}
122-
return usernameMaxDisplayLength;
123-
}
124-
125-
// End ## getters and setters status handling

src/main/resources/static/js/status-handler.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function checkBackendStatus() {
2121
return;
2222
}
2323

24-
if (isBackEndStatusOk()) {
25-
removeStatusIndicator();
26-
} else {
24+
if (!isBackEndStatusOk()) {
2725
addStatusIndicator(statusType.DANGER, statusText.BACKEND_DOWN);
26+
} else {
27+
removeStatusIndicator();
2828
}
2929

3030
routeSpecificFunctions(currentUrl);
@@ -79,26 +79,24 @@ function reloadIfStatusChanged(isStatusChanged) {
7979
function updateBackendStatus() {
8080
var callback = {
8181
error: function (XMLHttpRequest, textStatus, errorThrown) {
82-
if (XMLHttpRequest.status == 401) {
83-
functionsToExecuteIfUserIsLoggedOut();
82+
executeIfLdapIsDeactivated();
83+
setBackEndStatusOk(false);
84+
},
85+
success: function (data, textStatus) {
86+
checkBackendSecured();
87+
if (data.eiffelIntelligenceStatus == "AVAILABLE") {
8488
setBackEndStatusOk(true);
8589
} else {
86-
executeIfLdapIsDeactivated();
8790
setBackEndStatusOk(false);
8891
}
8992
},
90-
success: function (data, textStatus) {
91-
checkBackendSecured();
92-
setBackEndStatusOk(true);
93-
},
9493
complete: function () {
9594
checkBackendStatus();
9695
}
9796
};
9897
var ajaxHttpSender = new AjaxHttpSender();
99-
var contentType = "application/string; charset=utf-8";
100-
var datatype = "text";
101-
ajaxHttpSender.sendAjax(backendEndpoints.CHECK_STATUS, "GET", null, callback, contentType, datatype);
98+
var data = null;
99+
ajaxHttpSender.sendAjax(backendEndpoints.CHECK_STATUS, "GET", data, callback);
102100
}
103101

104102
function addStatusIndicator(statusType, statusText) {

wiki/markdown/curl-examples.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Most endpoints are also documented in the [Eiffel Intelligence backend repositor
1414

1515
#### Quick access to endpoints:
1616
* [/auth](#auth)
17+
* [/status](#status)
1718
* [/backend](#backend)
1819
* [/download](#download)
1920
* [/information](#information)
@@ -44,7 +45,7 @@ This way of entering the `backendurl` may be the easiest way. It works with GET,
4445

4546
<table>
4647
<tr>
47-
<th>Context Path</th>
48+
<th>Endpoint</th>
4849
<th>Type</th>
4950
<th>Explanation</th>
5051
</tr>
@@ -53,11 +54,6 @@ This way of entering the `backendurl` may be the easiest way. It works with GET,
5354
<td>GET</td>
5455
<td>Check if LDAP security is enabled</td>
5556
</tr>
56-
<tr>
57-
<td>/auth/checkStatus</td>
58-
<td>GET</td>
59-
<td>Used to check the back-end status</td>
60-
</tr>
6157
<tr>
6258
<td>/auth/login</td>
6359
<td>GET</td>
@@ -86,12 +82,32 @@ It is possible to provide both username and password directly in the request, as
8682

8783
More information and examples can be found in the [EI back-end documentation](https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/markdown/authentication.md)
8884

85+
## <a id="status" /> /status
86+
87+
<table>
88+
<tr>
89+
<th>Endpoint</th>
90+
<th>Type</th>
91+
<th>Explanation</th>
92+
</tr>
93+
<tr>
94+
<td>/status</td>
95+
<td>GET</td>
96+
<td>Get back-end status including status of services back-end is dependent on.</td>
97+
</tr>
98+
</table>
99+
100+
#### Some curl examples
101+
102+
This command would return a JSON object containing the status of the back-end and servers back-end is dependent on..
103+
104+
curl -X GET -H "Content-type: application/json" http://localhost:8080/status
89105

90106
## <a id="backend" /> /backend
91107

92108
<table>
93109
<tr>
94-
<th>Context Path</th>
110+
<th>Endpoint</th>
95111
<th>Type</th>
96112
<th>Explanation</th>
97113
</tr>
@@ -191,7 +207,7 @@ In the below command the JSON object is put in a file and sent along with the re
191207

192208
<table>
193209
<tr>
194-
<th>Context Path</th>
210+
<th>Endpoint</th>
195211
<th>Type</th>
196212
<th>Explanation</th>
197213
</tr>
@@ -233,7 +249,7 @@ This command returns a list of several subscriptions. It is also possible to spe
233249

234250
<table>
235251
<tr>
236-
<th>Context Path</th>
252+
<th>Endpoint</th>
237253
<th>Type</th>
238254
<th>Explanation</th>
239255
</tr>
@@ -253,7 +269,7 @@ The response is a json object containing all the connected components and data a
253269

254270
<table>
255271
<tr>
256-
<th>Context Path</th>
272+
<th>Endpoint</th>
257273
<th>Type</th>
258274
<th>Explanation</th>
259275
</tr>
@@ -281,7 +297,7 @@ Example curl commands to these endpoints [can be found here](https://github.com/
281297

282298
<table>
283299
<tr>
284-
<th>Context Path</th>
300+
<th>Endpoint</th>
285301
<th>Type</th>
286302
<th>Explanation</th>
287303
</tr>
@@ -314,7 +330,7 @@ Example curl commands to these endpoints [can be found here](https://github.com/
314330

315331
<table>
316332
<tr>
317-
<th>Context Path</th>
333+
<th>Endpoint</th>
318334
<th>Type</th>
319335
<th>Explanation</th>
320336
</tr>

0 commit comments

Comments
 (0)