Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wild fly app server #13

Merged
merged 5 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# install Linux https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
# Docker desktop https://docs.docker.com/desktop/install/ubuntu/
# https://hub.docker.com/_/tomcat/tags
FROM tomcat:9.0-jdk11-corretto-al2
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
# FROM tomcat:8.5.97-jdk11-corretto-al2
# FROM tomcat:8.5.97-jdk8-corretto-al2
# FROM tomcat:8-jdk8-corretto

# https://hub.docker.com/layers/library/tomcat/7.0.109-jdk8-openjdk/images/sha256-489823486120d076cb576640c5819c6fa54948f470b46c54f02b48f462eb2c23

Expand Down
16 changes: 16 additions & 0 deletions Dockerfile.wildfly
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://quay.io/repository/wildfly/wildfly?tab=tags
FROM quay.io/wildfly/wildfly:27.0.0.Final-jdk17

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}"

LABEL org.nz.itlatinos.image.authors="[email protected]"
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/
71 changes: 36 additions & 35 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import org.gradle.api.tasks.testing.logging.TestLogEvent
import java.net.InetAddress

group = "soa.nz.aut"
version = "0.7.8"
description = "Student Attendance WebApp"
// 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
war
id ("jacoco")
id("com.github.bjornvester.wsdl2java") version "2.0.2"
}

repositories {
Expand All @@ -20,18 +24,25 @@ dependencies {
// https://www.primefaces.org
// https://primefaces.github.io/primefaces
// https://mvnrepository.com/artifact/org.primefaces/primefaces
implementation("org.primefaces:primefaces:14.0.0-RC1")
// implementation("org.primefaces:primefaces:primefaces-14.0.0-RC1")
implementation("org.primefaces:primefaces:14.0.0-RC1:jakarta")
// https://mvnrepository.com/artifact/org.primefaces.extensions/primefaces-extensions
implementation("org.primefaces.extensions:primefaces-extensions:14.0.0-RC1")

// JSF runtime
// https://mvnrepository.com/artifact/org.apache.myfaces.core/myfaces-api
// implementation("org.apache.myfaces.core:myfaces-api:4.0.1") // API https://myfaces.apache.org
// implementation("org.apache.myfaces.core:myfaces-impl:4.0.1") // Faces Implementation
// implementation("org.apache.poi:poi:3.17") // apache POI DataExporter (Excel or XML)
// implementation("com.rometools:rome:1.9.0") // FeedReader
// implementation("org.primefaces.extensions:primefaces-extensions:14.0.0-RC1: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
// https://primefaces.github.io/primefaces/14_0_0/#/gettingstarted/dependencies
// https://mvnrepository.com/artifact/org.apache.myfaces.core/myfaces-api Apache myFaces
// implementation("org.apache.myfaces.core:myfaces-api:4.0.2") // API https://myfaces.apache.org
// implementation("org.apache.myfaces.core:myfaces-impl:4.0.2")
// https://mvnrepository.com/artifact/org.glassfish/jakarta.faces
implementation("org.glassfish:jakarta.faces:4.0.5")
// https://mvnrepository.com/artifact/org.apache.bval/bval-jsr
// implementation("org.apache.poi:poi:5.2.5") // apache POI DataExporter (Excel XML)
// implementation("com.rometools:rome:1.15.0") // FeedReader
// Apache Commons FileUpload 1.5
// implementation("net.sf.barcode4j:barcode4j-light:2.3.0") // barcode4j-light
// implementation("net.glxn.qrgen:qrgen:1.4") // qrgen QR Code support for Barcode
// implementation("net.glxn.qrgen:qrgen:1.8.0") // qrgen QR Code support for Barcode
// implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20220608.1")

// Jakarta EE
Expand All @@ -50,12 +61,12 @@ dependencies {
// https://bitbucket.org/snakeyaml/snakeyaml/wiki/Documentation
// https://mavenlibs.com/maven/dependency/org.yaml/snakeyaml
implementation("org.yaml:snakeyaml:2.1")

// QRFunctions
implementation("com.google.zxing:javase:3.5.1")
implementation("com.google.zxing:core:3.5.1")
// dependency below only needed if using the Java 8 version of @Generated (through "jdk8") on Java 9 or later
// implementation("io.github.threeten-jaxb:threeten-jaxb-core:2.1.0") // Use Java Date/Time API. Clunky GregorianCalendar class
// TESTING

// TEST
// JUnit Jupiter API and Engine for unit testing
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
Expand All @@ -70,19 +81,15 @@ dependencies {
implementation("com.kstruct:gethostname4j:1.0.0")
}

group = "soa.nz.aut"
version = "0.7.7"
description = "Student Attendance WebApp"
// java.sourceCompatibility = JavaVersion.VERSION_17

fun setWarVersion() {
// function body
project.version?.let { version ->
println("WAR Version is $version")
System.setProperty("APP_WAR_FILE_VERSION", version.toString())
println("For local testing do \n APP_WAR_FILE_VERSION=" + version)
println("Append to the .env file with \n")
println("printf \"\$APP_WAR_FILE_VERSION \\n\" >> .env")
println("Local testing \n\n")
println("export APP_WAR_FILE_VERSION=" + version.toString())
println("Using .env file \n\n")
println("printf export\"\$APP_WAR_FILE_VERSION \\n\" >> .env")
}
}

Expand Down Expand Up @@ -111,7 +118,6 @@ fun getWarpackageVersion() {
"home.xhtml",
"index.xhtml"
)
// function body
project.version?.let { version ->
println("WAR Version is $version")
println("Set env variable with")
Expand All @@ -129,6 +135,12 @@ tasks.register<DefaultTask>("getProjectInfo") {
getWarpackageVersion()
}

tasks.register<DefaultTask>("getAppVersion") {
description = "Get current App version"
getAppVersion()
}


tasks.war {
archiveBaseName.set("Attendance")
webAppDirectory.set(file("src/main/webapp"))
Expand All @@ -137,6 +149,7 @@ tasks.war {
// classpath(fileTree("additionalLibs")) // adds a file-set to the WEB-INF/lib dir.
// classpath(moreLibs) // adds a configuration to the WEB-INF/lib dir.
// webXml = file("src/someWeb.xml") // copies a file to WEB-INF/web.xml

doLast{
setWarVersion()
}
Expand Down Expand Up @@ -176,15 +189,3 @@ tasks.register<Test>("searchOpenLDAP") {
includeTestsMatching("TestLDAPAuthentication.testOpenLDAPAdminSearch_withOpenLDAP")
}
}
// https://plugins.gradle.org/plugin/com.github.bjornvester.wsdl2java
// https://www.w3schools.com/xml/tempconvert.asmx?WSDL
wsdl2java {
// https://plugins.gradle.org/plugin/com.github.bjornvester.wsdl2java
bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xjb"))

includes.set(
listOf(
"src/main/resources/wsdl/NumberConversion.wsdl"
)
)
}
2 changes: 1 addition & 1 deletion maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<junit.version>4.14</junit.version>
<servlet.version>3.1.0</servlet.version>
<mojarra.version>2.2.12</mojarra.version>
<primefaces.version>8.0</primefaces.version>
<primefaces.version>11.0</primefaces.version>
<maven.compiler.plugin.version>3.3</maven.compiler.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jjwt.version>0.7.0</jjwt.version>
Expand Down
10 changes: 5 additions & 5 deletions runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ version="$APP_WAR_FILE_VERSION"

build() {
gradle clean war --warn || true
docker build --build-arg APP_WAR_FILE_VERSION=$version --tag aleon1220/soa:$version . || true
docker build --build-arg APP_WAR_FILE_VERSION=$version --tag aleon1220/attendance-webapp:$version --file Dockerfile.wildfly . || true
}

run() {
printf "Executing webapp Locally \n\n" || true
docker run --interactive --tty --detach --publish 8080:8080 --name $version aleon1220/soa:$version || true
printf "Executing Java Webapp version %s\n" $version
docker run --interactive --tty --detach --publish 8080:8080 --name $version aleon1220/attendance-webapp:$version || true
printf "Executing Java Webapp Attendance version %s\n" $version
}

clean() {
printf "Executing local CLEAN-UP\n\n"
printf "Executing local CLEAN-UP \n\n"
gradle clean || true
docker kill $version
docker rm $version
docker image rm aleon1220/soa:$version
docker image rm aleon1220/attendance-webapp:$version
printf "docker clean up completed \n\n"
}

Expand Down
47 changes: 12 additions & 35 deletions src/main/webapp/02-attendance.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,32 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html;charset=UTF-8" encoding="UTF-8">
<h:head>

<h:head>
<title>Training Session Attendance</title>
</h:head>

<h:body>
<p:panel>
<f:facet name="footer">
<h:outputText value="Footer Text" />
</f:facet>
</f:facet>

<h:outputText value="App Attendance System Main Menu" />
<h:outputText value="Attendance System Main Menu Center" />

<div id="countdownPanel">
<h:outputText id="countdown" value="30" />
</div>

<p:commandButton value="Attend" action="#{attendanceBean.attend}" update="countdown" />
<p:commandButton value="Cancel" action="index" />
<p:button icon="ui-icon-circle-arrow-w" title="Go back" outcome="index" />
</p:panel>
<p:textEditor />
<script type="text/javascript">
var countdownValue = parseInt(30); //seconds
var countdownInterval = setInterval(function() {
// countdown logic
}, 1000);

function startCountdown() {
var countdownElement = parseInt(document.getElementById("countdown"));
var countdownPanelElement = document.getElementById("countdownPanel");

var countdownInterval = setInterval(function() {
countdownValue--;
countdownElement.innerHTML = countdownValue;
if (countdownValue <= 0) {
countdownPanelElement.style.display = "none";
timeUpElement.innerHTML = "Time is up!"; // Set the content of the new element
timeUpElement.style.color = "red"; // Set the color of the new element
countdownPanelElement.parentNode.appendChild(timeUpElement); // Append the new element to the parent of countdownPanelElement
}
}, 1000);
}
startCountdown();
</script>
</h:body>
</f:view>

<h:outputText value="Attendance System Main Menu Center" />
<div>
<p:button outcome="index" value="Go Back" icon="pi pi-sign-out"/>
</div>
<div>
<p:button outcome="index" value="Confirm Attendance" icon="pi pi-sign-in"/>
</div>
</h:body>
</html>
20 changes: 9 additions & 11 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app
version="4.0"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
>
<!-- https://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html -->
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<display-name>Class Attendance WebApp</display-name>
<!-- JSF mapping -->
<!-- Servlet Mapping for Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>org.apache.myfaces.webapp.FacesServlet</servlet-class>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/404-loginError.xhtml</location>
</error-page>
</web-app>
Loading