diff --git a/src/main/java/bean/AttendanceRegister.java b/src/main/java/bean/AttendanceRegister.java deleted file mode 100644 index f53a98b..0000000 --- a/src/main/java/bean/AttendanceRegister.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Class AttendanceRegister - * sends invocation to webservice for confirmation of attendance. Includes prime faces UI functionality. - */ - -package bean; - -import javax.faces.application.FacesMessage; -import javax.faces.bean.ManagedBean; -import javax.faces.context.FacesContext; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; - -import com.google.gson.JsonObject; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -import service.UserService; - -@ManagedBean -public class AttendanceRegister { - - private String inputCode; - private Integer progress; - - public String confirmAttendance() { - - String replyFromMS = null; - - UserService tok = new UserService(); - String token = tok.obtainIdToken("10295765", "Value!12"); - // 1-open connection and send user and password as a POST method - ClientConfig config = new DefaultClientConfig(); - - Client client = Client.create(config); - WebResource webResource = client.resource(UriBuilder - .fromUri("https://xgdeevdwh1.execute-api.us-east-1.amazonaws.com").path("addAttendance").build()); - // Passing parameters - // {"studentId": "246810","paperId": "COMP101","status": "present"} - - MultivaluedMap formData = new MultivaluedMapImpl(); - formData.add("studentId", "246810"); - formData.add("paperId", "COMP101"); - formData.add("status", "present"); - - JsonObject jsonPayLoad = new JsonObject(); - jsonPayLoad.addProperty("studentId", "246810"); - jsonPayLoad.addProperty("paperId", "COMP101"); - jsonPayLoad.addProperty("status", "present"); - - // ClientResponse response = - // webResource.accept(MediaType.APPLICATION_JSON).header("Authorization", - // token).post(ClientResponse.class, jsonPayLoad.toString()); - ClientResponse response = webResource.header("Authorization", token).post(ClientResponse.class, - jsonPayLoad.toString()); - replyFromMS = response.getEntity(String.class); - // String replyFromMS = - // webResource.path("addAttendance").accept(MediaType.APPLICATION_JSON).header("Authorization", - // token).post(String.class, jsonPayLoad.toString()); - - System.out.println("AttendanceRegisterResponse:" + response); - - // invoke WS to confirm Attendance and validate - FacesContext context = FacesContext.getCurrentInstance(); - context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "CORRECT", "Attendance Registered!!!")); - - if (replyFromMS.isEmpty()) { - return "attendanceNOK.xhtml"; - } else { - return "attendanceOK.xhtml"; - } - } - - public Integer getProgress() { - if (progress == null) { - progress = 0; - } else { - progress = progress + (int) (Math.random() * 35); - - if (progress > 100) - progress = 100; - } - return progress; - } - - public void setProgress(Integer progress) { - this.progress = progress; - } - - public void onComplete() { - FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Time Ended")); - } - - public String onTimeout() { - FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Time Out")); - return "main.xhtml"; - } - - public void cancel() { - progress = null; - } - - public String getInputCode() { - return inputCode; - } - - public void setInputCode(String inputCode) { - this.inputCode = inputCode; - } -} \ No newline at end of file diff --git a/src/main/java/bean/Main.java b/src/main/java/bean/Main.java deleted file mode 100644 index 9b4379d..0000000 --- a/src/main/java/bean/Main.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Class Main connects to main.xhtml - * calls Web services to obtain data from random Free services online - * obtains IP and Random Bible Verse - */ - -package bean; - -import javax.annotation.PostConstruct; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; - -import service.MainService; - -@ManagedBean(name = "main") -@SessionScoped - -public class Main { - - private String bibleVerse; - private String linkedPage; - private String geoIpWS; - - @PostConstruct - public void init() { - MainService invoker = new MainService(); - // invoke web services - setGeoIpWS(invoker.invokeWSDLForIP()); - setBibleVerse(invoker.invokeRestForBibleVerse()); - } - - public String getGeoIpWS() { - return geoIpWS; - } - - public void setGeoIpWS(String geoIpWS) { - this.geoIpWS = geoIpWS; - } - - public String getBibleVerse() { - return bibleVerse; - } - - public void setBibleVerse(String bibleVerse) { - this.bibleVerse = bibleVerse; - } - - public void setLinkedPage(String linkedPage) { - this.linkedPage = linkedPage; - } - - public String getlinkedPage() { - if (linkedPage == "1") { - linkedPage = "attendance"; - System.out.println("this block page is-->" + linkedPage); - } else { - linkedPage = "registerAttendance"; - System.out.println("this else block page is-->" + linkedPage); - } - return linkedPage; - } -} \ No newline at end of file diff --git a/src/main/java/bean/Room.java b/src/main/java/bean/Room.java deleted file mode 100644 index 097d58e..0000000 --- a/src/main/java/bean/Room.java +++ /dev/null @@ -1,23 +0,0 @@ - /** - * Class Room reflects paper management UI for Lectures Rooms - * class template - */ - -package bean; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import javax.faces.bean.ManagedBean; - -@ManagedBean -// (name = "room") -public class Room { - - public String obtainSessionNumber() { - - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); - LocalDateTime now = LocalDateTime.now(); - - return dtf.format(now); - } -} diff --git a/src/test/attendance/Authorization.java b/src/test/attendance/Authorization.java deleted file mode 100644 index 069fc82..0000000 --- a/src/test/attendance/Authorization.java +++ /dev/null @@ -1,32 +0,0 @@ -/*-- com.leo.json.Authorization.java -- */ - -package com.leo.json; - -import com.google.gson.annotations.SerializedName; - -public class Authorization { - - // names have to be the same from JSON to Java Object so that it works fine. - - private ChallengeParameters challengeParameters; - // @SerializedName("AuthenticationResult") - // @Expose - private AuthenticationResult authenticationResult; - - public ChallengeParameters getChallengeParameters() { - return challengeParameters; - } - - public void setChallengeParameters(ChallengeParameters challengeParameters) { - this.challengeParameters = challengeParameters; - } - - public AuthenticationResult getAuthenticationResult() { - return authenticationResult; - } - - public void setAuthenticationResult(AuthenticationResult authenticationResult) { - this.authenticationResult = authenticationResult; - } - -} \ No newline at end of file diff --git a/src/test/attendance/TestAuthenticationResult.java b/src/test/attendance/TestAuthenticationResult.java deleted file mode 100644 index 3b9c801..0000000 --- a/src/test/attendance/TestAuthenticationResult.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.json; - -import com.google.gson.annotations.SerializedName; - -public class AuthenticationResult { - - public AuthenticationResult(String accessToken, Integer expiresIn, String tokenType, String refreshToken, - String idToken) { - this.accessToken = accessToken; - this.expiresIn = expiresIn; - this.tokenType = tokenType; - this.refreshToken = refreshToken; - this.idToken = idToken; - } - - @SerializedName("AccessToken") - private String accessToken; - - @SerializedName("ExpiresIn") - private Integer expiresIn; - - @SerializedName("TokenType") - private String tokenType; - - @SerializedName("RefreshToken") - private String refreshToken; - - @SerializedName("IdToken") - private String idToken; - - // Setters and getters - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - public Integer getExpiresIn() { - return expiresIn; - } - - public void setExpiresIn(Integer expiresIn) { - this.expiresIn = expiresIn; - } - - public String getTokenType() { - return tokenType; - } - - public void setTokenType(String tokenType) { - this.tokenType = tokenType; - } - - public String getRefreshToken() { - return refreshToken; - } - - public void setRefreshToken(String refreshToken) { - this.refreshToken = refreshToken; - } - - public String getIdToken() { - return idToken; - } - - public void setIdToken(String idToken) { - this.idToken = idToken; - } -}