diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..417cccc --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,10 @@ +# This configuration file was automatically generated by Gitpod. +# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) +# and commit this file to your remote git repository to share the goodness with others. + +# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart + +tasks: + - init: gradle build + + diff --git a/.idea/misc.xml b/.idea/misc.xml index f5db0c5..ba566f2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1e5b279..d93abd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,23 +5,26 @@ FROM tomcat:jdk17 # FROM tomcat:9.0.85-jdk17-corretto-al2 # FROM tomcat:9.0-jdk17-corretto-al2 # FROM tomcat:8.5.97-jdk17-corretto-al2 - # https://hub.docker.com/layers/library/tomcat/7.0.109-jdk8-openjdk/images/sha256-489823486120d076cb576640c5819c6fa54948f470b46c54f02b48f462eb2c23 ARG APP_WAR_FILE_VERSION ENV APP_WAR_FILE_VERSION=$APP_WAR_FILE_VERSION -ENV APP_WAR_FILE="Attendance" -ENV APP_WAR_FILE_PATH="build/libs/$APP_WAR_FILE-${APP_WAR_FILE_VERSION}" +ENV APP_WAR_FILE_NAME="AttendanceTrak" +ENV APP_WAR_FILE_OUTPUT=$APP_WAR_FILE_NAME-${APP_WAR_FILE_VERSION} +ENV APP_FULL_WAR_FILE_PATH="build/libs/$APP_WAR_FILE_OUTPUT" + LABEL org.nz.itlatinos.image.authors="aleonrangel@outlook.co.nz" LABEL maintainer="andres.nz" LABEL war.version="$APP_WAR_FILE_VERSION" LABEL docker.image.build.command="docker build --build-arg APP_WAR_FILE_VERSION=$APP_WAR_FILE_VERSION --tag aleon1220/soa:latest ." -RUN printf "WAR version is $APP_WAR_FILE-$APP_WAR_FILE_VERSION" -RUN printf "Path to war file $APP_WAR_FILE_PATH" -# Tomcat Custom settings +RUN printf "\t\t Docker Engine Build APP_WAR_FILE_VERSION %s" $APP_WAR_FILE_VERSION +RUN printf "\t\t Docker Engine Build APP_WAR_FILE_NAME $APP_WAR_FILE_NAME" +RUN printf "\t\t Docker Engine Build WAR APP_WAR_FILE_OUTPUT $APP_WAR_FILE_OUTPUT" +RUN printf "\t\t Docker Engine Build Path to war file $APP_FULL_WAR_FILE_PATH" + # RUN echo ${PWD} && ls -lR # Debugging # USER 1000 # considered permissions issue -COPY ${APP_WAR_FILE_PATH}.war /usr/local/tomcat/webapps +COPY ${APP_FULL_WAR_FILE_PATH}.war /usr/local/tomcat/webapps # COPY build/libs/AttendanceApp-0.7.2 /usr/local/tomcat/webapps/ # https://forums.docker.com/t/docker-build-multistage-failed-to-compute-cache-key/134316/20 \ No newline at end of file diff --git a/Dockerfile.wildfly b/Dockerfile.wildfly index fcfdade..3c3bbd2 100644 --- a/Dockerfile.wildfly +++ b/Dockerfile.wildfly @@ -1,16 +1,20 @@ # https://quay.io/repository/wildfly/wildfly?tab=tags -FROM quay.io/wildfly/wildfly:27.0.0.Final-jdk17 +FROM quay.io/wildfly/wildfly:29.0.0.Final-jdk20 ARG APP_WAR_FILE_VERSION ENV APP_WAR_FILE_VERSION=$APP_WAR_FILE_VERSION -ENV APP_WAR_FILE="Attendance" -ENV APP_WAR_FILE_PATH="build/libs/$APP_WAR_FILE-${APP_WAR_FILE_VERSION}" +ENV APP_WAR_FILE_NAME="AttendanceTrak" +ENV APP_WAR_FILE_OUTPUT=$APP_WAR_FILE_NAME-${APP_WAR_FILE_VERSION} +ENV APP_FULL_WAR_FILE_PATH="build/libs/$APP_WAR_FILE_OUTPUT.war" LABEL org.nz.itlatinos.image.authors="aleonrangel@outlook.co.nz" LABEL maintainer="www.andres.nz" LABEL war.version="$APP_WAR_FILE_VERSION" LABEL docker.image.build.command="docker build --build-arg APP_WAR_FILE_VERSION=$version --tag aleon1220/attendance-webapp:$version --file Dockerfile.wildfly ." -RUN printf "WAR version is $APP_WAR_FILE-$APP_WAR_FILE_VERSION" -RUN printf "Path to war file $APP_WAR_FILE_PATH" -ADD ${APP_WAR_FILE_PATH}.war /opt/jboss/wildfly/standalone/deployments/ \ No newline at end of file +RUN printf "\t\t Docker Engine Build APP_WAR_FILE_VERSION %s" $APP_WAR_FILE_VERSION +RUN printf "\t\t Docker Engine Build APP_WAR_FILE_NAME $APP_WAR_FILE_NAME" +RUN printf "\t\t Docker Engine Build WAR APP_WAR_FILE_OUTPUT $APP_WAR_FILE_OUTPUT" +RUN printf "\t\t Docker Engine Build Path to war file $APP_FULL_WAR_FILE_PATH" + +ADD ${APP_FULL_WAR_FILE_PATH} /opt/jboss/wildfly/standalone/deployments/ \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 93f300f..da0d03d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,14 +2,15 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent import java.net.InetAddress group = "soa.nz.aut" -version = "0.7.8" +version = "0.8.0" description = "Student Attendance WebApp" +val warDeploymentName = "AttendanceTrak" // java.sourceCompatibility = JavaVersion.VERSION_17 plugins { java // id ("com.adarshr.test-logger") version "3.0.0" - // https://docs.gradle.org/7.3/dsl/org.gradle.api.tasks.bundling.War.html + // https://docs.gradle.org/current/userguide/war_plugin.html war id ("jacoco") } @@ -25,9 +26,9 @@ dependencies { // https://primefaces.github.io/primefaces // https://mvnrepository.com/artifact/org.primefaces/primefaces // implementation("org.primefaces:primefaces:primefaces-14.0.0-RC1") - implementation("org.primefaces:primefaces:14.0.0-RC1:jakarta") + implementation("org.primefaces:primefaces:14.0.0-RC2:jakarta") // https://mvnrepository.com/artifact/org.primefaces.extensions/primefaces-extensions - // implementation("org.primefaces.extensions:primefaces-extensions:14.0.0-RC1:jakarta") + implementation("org.primefaces.extensions:primefaces-extensions:14.0.0-RC2:jakarta") // implementation(files("https://repo.maven.apache.org/maven2/org/primefaces/primefaces/14.0.0-RC1/primefaces-14.0.0-RC1-jakarta.jar")) // implementation(files("https://repo.maven.apache.org/maven2/org/primefaces/extensions/primefaces-extensions/14.0.0-RC1/primefaces-extensions-14.0.0-RC1-jakarta.jar")) // PrimeFaces Dependencies @@ -47,9 +48,11 @@ dependencies { // Jakarta EE // https://mvnrepository.com/artifact/jakarta.enterprise/jakarta.enterprise.cdi-api - // implementation("jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1") + implementation("jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1") // implementation("jakarta.ws.rs:jakarta.ws.rs-api:3.1.0") implementation("org.apache.httpcomponents:httpclient:4.5.13") + // https://mvnrepository.com/artifact/jakarta.platform/jakartaee-api-parent + implementation("jakarta.platform:jakartaee-api-parent:10.0.0") // https://mvnrepository.com/artifact/jakarta.ws.rs/jakarta.ws.rs-api // https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client implementation("org.glassfish.jersey.core:jersey-client:3.1.5") @@ -100,6 +103,7 @@ fun getAppVersion() { fun getWarpackageVersion() { val hostname_local = System.getenv("HOSTNAME") ?: "localhost" val hostname = InetAddress.getLocalHost().getHostName() + val warDeploymentContextName = "$warDeploymentName-$version" // Define the page names val pages = listOf( @@ -113,20 +117,18 @@ fun getWarpackageVersion() { "08-ClassManagement.xhtml", "09-UserManagement.xhtml", "home.xhtml", - "404-attendanceError.xhtml", - "404-loginError.xhtml", - "home.xhtml", - "index.xhtml" - ) + "index.xhtml", + "404-loginError.xhtml" + ) project.version?.let { version -> - println("WAR Version is $version") - println("Set env variable with") + println("\t\t WAR Version is $version") + println("Kotlin hostname variable value " + hostname_local) println("export APP_WAR_FILE_VERSION=" + version.toString()) - println("http://" + hostname + ":8080/Attendance-"+ version.toString()) + println("http://" + hostname + ":8080/$warDeploymentContextName") } // Print URLs for each page pages.forEach { page -> - println("http://$hostname:8080/Attendance-$version/$page") + println("http://$hostname:8080/$warDeploymentContextName/$page") } } @@ -142,9 +144,9 @@ tasks.register("getAppVersion") { tasks.war { - archiveBaseName.set("Attendance") - webAppDirectory.set(file("src/main/webapp")) - // from("src/rootContent") // adds a file-set to the root of the archive + archiveBaseName.set(warDeploymentName) + // webAppDirectory.set(file("src/main/webapp")) + from("src/main/resources/css") // adds a file-set to the root of the archive // webInf { from("src/additionalWebInf") } // adds a file-set to the WEB-INF dir. // classpath(fileTree("additionalLibs")) // adds a file-set to the WEB-INF/lib dir. // classpath(moreLibs) // adds a configuration to the WEB-INF/lib dir. diff --git a/docker-compose.yml b/docker-compose.yml index 313827f..7484256 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: # https://github.com/osixia/docker-openldap # https://www.openldap.org image: osixia/openldap:1.2.4 + env_file: .env environment: LDAP_ORGANISATION: "IT Latinos NZ" LDAP_DOMAIN: "latintech.org" @@ -11,10 +12,11 @@ services: ports: - 389:389 - 636:636 - volumes: - - ./ldap:/var/lib/ldap - - ./ldap:/etc/ldap/slapd.d + # volumes: + # - ./ldap:/var/lib/ldap + # - ./ldap:/etc/ldap/slapd.d webapp: image: aleon1220/soa:latest + env_file: .env ports: - 8080:8080 diff --git a/gradle.properties b/gradle.properties index eca1768..cd94e1c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ log4j_version = 1.2.17 jaxb_version = 2.3.1 junit_version = 5.5.1 +org.gradle.caching=true diff --git a/runme.sh b/runme.sh index 1456c58..54671a0 100755 --- a/runme.sh +++ b/runme.sh @@ -2,7 +2,7 @@ set -e # Array avoids word splitting issues -COMMANDS=(build run clean test help) +COMMANDS=(help build clean run_smoke_test run_stack test_stack) export APP_WAR_FILE_VERSION=$(gradle getAppVersion --quiet) || true command=$1 @@ -26,30 +26,43 @@ export APP_WAR_FILE_VERSION=$(gradle getAppVersion --quiet) || true version="$APP_WAR_FILE_VERSION" build() { - gradle clean war --warn || true + gradle clean assemble war --warn || true docker build --build-arg APP_WAR_FILE_VERSION=$version --tag aleon1220/attendance-webapp:$version --file Dockerfile.wildfly . || true } -run() { +run_smoke_test() { + clean + build printf "Executing webapp Locally \n\n" || true docker run --interactive --tty --detach --publish 8080:8080 --name $version aleon1220/attendance-webapp:$version || true - printf "Executing Java Webapp Attendance version %s\n" $version + source .env + gradle getProjectInfo + printf "\t\tLoaded .env variables file succesfully\n\n" + printf "\t\tExecuting Java Webapp Attendance version %s\n" $APP_WAR_FILE_VERSION || true + printf "\t\tExecuting Java Webapp Attendance version %s\n" $version } clean() { printf "Executing local CLEAN-UP \n\n" - gradle clean || true docker kill $version docker rm $version docker image rm aleon1220/attendance-webapp:$version printf "docker clean up completed \n\n" } -test() { +test_stack() { printf "Executing TESTING \n\n" gradle test || true } +run_stack() { + clean + build + test_stack + run + printf "Executing webapp stack Locally \n\n" || true +} + help() { printf "Help Function Java WebApp Attendance Class \n\n" print_usage diff --git a/src/main/java/bean/AttendanceBean.java b/src/main/java/bean/AttendanceBean.java index f513625..ccc6261 100644 --- a/src/main/java/bean/AttendanceBean.java +++ b/src/main/java/bean/AttendanceBean.java @@ -5,16 +5,26 @@ package bean; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; -public class AttendanceBean { +import jakarta.enterprise.context.RequestScoped; + +import jakarta.faces.application.FacesMessage; +import jakarta.faces.context.FacesContext; +import jakarta.inject.Named; + +@Named("attendance") +@RequestScoped +public class AttendanceBean implements Serializable{ private String attendanceCode; private String selectedUser; private String className; private List classes; private String randomCode; + private static final long serialVersionUID = 1L; public void init() { // invokes service class to populate classes @@ -24,12 +34,26 @@ public void init() { classes.add("Service Based Design"); classes.add("Cloud Computing"); classes.add("Service Deployment"); - // for(int i = 0; i < 10; i++) { // classes.add("Class " + i); // } } + public void button1Action() { + // Implement logic for button 1 + System.out.println("Button 1 has been clicked!"); + } + + public void button2Action() { + // Implement logic for button 2 + System.out.println("Button 2 clicked!"); + } + + public void onTimeout() { + System.out.println("TimingOut Attendance"); + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Time is Out. Talk to your trainer!", null)); + } + public String getClassName() { return className; } @@ -69,5 +93,54 @@ public String getRandomCode() { public void setRandomCode(String randomCode) { this.randomCode = randomCode; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((attendanceCode == null) ? 0 : attendanceCode.hashCode()); + result = prime * result + ((selectedUser == null) ? 0 : selectedUser.hashCode()); + result = prime * result + ((className == null) ? 0 : className.hashCode()); + result = prime * result + ((classes == null) ? 0 : classes.hashCode()); + result = prime * result + ((randomCode == null) ? 0 : randomCode.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AttendanceBean other = (AttendanceBean) obj; + if (attendanceCode == null) { + if (other.attendanceCode != null) + return false; + } else if (!attendanceCode.equals(other.attendanceCode)) + return false; + if (selectedUser == null) { + if (other.selectedUser != null) + return false; + } else if (!selectedUser.equals(other.selectedUser)) + return false; + if (className == null) { + if (other.className != null) + return false; + } else if (!className.equals(other.className)) + return false; + if (classes == null) { + if (other.classes != null) + return false; + } else if (!classes.equals(other.classes)) + return false; + if (randomCode == null) { + if (other.randomCode != null) + return false; + } else if (!randomCode.equals(other.randomCode)) + return false; + return true; + } } // End of AttendanceBean.java \ No newline at end of file diff --git a/src/main/java/bean/UserBean.java b/src/main/java/bean/UserBean.java index 5c1e25b..585195d 100644 --- a/src/main/java/bean/UserBean.java +++ b/src/main/java/bean/UserBean.java @@ -21,6 +21,11 @@ public class UserBean { private String refreshToken; private String tokenType; + public UserBean() { + super(); + setId("userID123"); + } + public String login() { // LdapAuthenticator ldapAuthenticator = new LdapAuthenticator(); // boolean isAuthenticated = ldapAuthenticator.authenticate(username, password); @@ -101,9 +106,6 @@ public void setTokenType(String tokenType) { this.tokenType = tokenType; } - public UserBean() { - } - public String getEmail() { return email; } @@ -159,4 +161,5 @@ public String getLastName() { public void setLastName(String lastName) { this.lastName = lastName; } -}// End of UserBean.java \ No newline at end of file +} +// End of Class UserBean.java \ No newline at end of file diff --git a/src/main/java/entity/LoginReply.java b/src/main/java/entity/LoginReply.java new file mode 100644 index 0000000..2d44978 --- /dev/null +++ b/src/main/java/entity/LoginReply.java @@ -0,0 +1,29 @@ + /** + * Class LoginReply uses gson to create the java object based on JSON + * builds the java object and overrides a toString method for testing purposes + */ + +package entity; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class LoginReply { + @SerializedName("AuthenticationResult") + @Expose + private AuthenticationResult authenticationResult; + + public AuthenticationResult getAuthenticationResult() { + return authenticationResult; + } + + public void setAuthenticationResult(AuthenticationResult authenticationResult) { + this.authenticationResult = authenticationResult; + } + + @Override + public String toString() { + //return getClass()+"challenge"+challengeParameters+"data in authent"+authenticationResult.getIdToken(); + return getClass()+" Overriden method to fetch extra info"; + } +} diff --git a/src/main/resources/attendance.css b/src/main/resources/css/attendance.css similarity index 54% rename from src/main/resources/attendance.css rename to src/main/resources/css/attendance.css index 01cea6a..cccf752 100644 --- a/src/main/resources/attendance.css +++ b/src/main/resources/css/attendance.css @@ -3,4 +3,21 @@ .tg {border-collapse:collapse;border-spacing:0;margin:0px auto;} .tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;} .tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;} -.tg .tg-yw4l{vertical-align:top} \ No newline at end of file +.tg .tg-yw4l{vertical-align:top} + +#rightBlockDiv { + /* style="width: 70%;" */ + background-color: #f9f9f9; + padding: 10px; + border: 5px solid #ddd; + float: right; + width: 80%; +} + +#leftBlockDiv { + background-color: #f9f9f9; + padding: 5px; + border: 1px solid #ddd; + float: left; + width: 10%; +} \ No newline at end of file diff --git a/src/main/webapp/01-login.xhtml b/src/main/webapp/01-login.xhtml index 39d32bc..9b20c90 100644 --- a/src/main/webapp/01-login.xhtml +++ b/src/main/webapp/01-login.xhtml @@ -10,8 +10,8 @@ - Training Session Attendance System - + Training Session Attendance System + diff --git a/src/main/webapp/02-attendance.xhtml b/src/main/webapp/02-attendance.xhtml index bfb796f..6529020 100644 --- a/src/main/webapp/02-attendance.xhtml +++ b/src/main/webapp/02-attendance.xhtml @@ -3,31 +3,65 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" - xmlns:p="http://primefaces.org/ui"> + xmlns:p="http://primefaces.org/ui" + xmlns:pe="http://primefaces.org/ui/extensions" +> - Training Session Attendance + Attendance Training Session + - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + + Register your session attendance + Remember you have time frame for attendance.timeFrameSeconds + + + Welcome student ID + + to the session Room.obtainSessionNumber + + + + + + + + + + + + + + + + + + + + + + + + + +
Training Session Attendance System
+ Welcome student ID + + to the session Room.obtainSessionNumber + + +