readiness check
parent
c6201496bc
commit
14de8528b5
|
|
@ -0,0 +1,21 @@
|
|||
package com.nttdata.calender;
|
||||
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApplicationStartupListener implements ApplicationListener<ApplicationReadyEvent> {
|
||||
|
||||
private static boolean applicationReady = false;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent event) {
|
||||
System.out.println("Application is ready to service requests.");
|
||||
applicationReady = true;
|
||||
}
|
||||
|
||||
public static boolean isApplicationReady() {
|
||||
return applicationReady;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nttdata.calender;
|
||||
|
||||
public class ReadyStatus {
|
||||
private boolean ready;
|
||||
|
||||
public ReadyStatus(boolean ready) {
|
||||
this.ready = ready;
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
public void setReady(boolean ready) {
|
||||
this.ready = ready;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import org.apache.logging.log4j.Logger;
|
|||
import org.checkerframework.common.util.report.qual.ReportCall;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
|
@ -17,7 +18,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bmc.arsys.api.ARException;
|
||||
import com.bmc.arsys.api.Value;
|
||||
import com.bmc.thirdparty.org.springframework.context.ApplicationListener;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.nttdata.calender.ApplicationStartupListener;
|
||||
import com.nttdata.calender.ReadyStatus;
|
||||
import com.nttdata.calender.approval.Approval;
|
||||
import com.nttdata.calender.approval.ApprovalUpdateRequest;
|
||||
import com.nttdata.calender.changes.Change;
|
||||
|
|
@ -80,6 +84,13 @@ public class KalenderRestController {
|
|||
this.stateChange = stateChange;
|
||||
}
|
||||
|
||||
@CrossOrigin("*")
|
||||
@PostMapping("/setReady")
|
||||
@ResponseBody
|
||||
public ReadyStatus setReady() {
|
||||
return new ReadyStatus(ApplicationStartupListener.isApplicationReady());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles GET request to retrieve all the states and their actual and possible
|
||||
* states and results a JSON array.
|
||||
|
|
@ -102,7 +113,7 @@ public class KalenderRestController {
|
|||
*
|
||||
* @return JSON Array of states with actualState, possibleStates, stateNameEN,
|
||||
* stateNameDE
|
||||
* @throws ARException
|
||||
* @throws ARException
|
||||
* @throws JsonProcessingException if an exception occurs during JSON processing
|
||||
*/
|
||||
@CrossOrigin("*")
|
||||
|
|
@ -114,7 +125,8 @@ public class KalenderRestController {
|
|||
.addFieldId("Name", 1000000017)
|
||||
.build();
|
||||
|
||||
var name = this.javaAPI.queryFieldsById("\'4\'==\"" + javaAPI.getUser() + "\"", query.getFieldIds(), query.getFormName(), null, 0, 0).get(0);
|
||||
var name = this.javaAPI.queryFieldsById("\'4\'==\"" + javaAPI.getUser() + "\"", query.getFieldIds(),
|
||||
query.getFormName(), null, 0, 0).get(0);
|
||||
String jsonString = "{\"userId\": \"" + name.get(query.getFieldId("Name")) + "\"}";
|
||||
return jsonString;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue