diff --git a/.gitignore b/.gitignore index d0d28d2b45afd48fb7a11c892cda38b567641906..861db796b3ae4ae0c2e53c823d05f43ca3ae4c1e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,6 @@ utils/src/main/resources/* *.jks *.p12 target/ -.classpath -.project .settings/ Thumbs.db diff --git a/dao/src/main/java/fr/univtln/bruno/samples/jee91/dao/PersonDAO.java b/dao/src/main/java/fr/univtln/bruno/samples/jee91/dao/PersonDAO.java index f05f5a5ca1b4c59901d899a33eae690ed9409b71..87c8588218bea84ab9bd3168cc4089aa554b55b3 100644 --- a/dao/src/main/java/fr/univtln/bruno/samples/jee91/dao/PersonDAO.java +++ b/dao/src/main/java/fr/univtln/bruno/samples/jee91/dao/PersonDAO.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.UUID; public class PersonDAO { - private EntityManager entityManager; + private final EntityManager entityManager; @Inject public PersonDAO(@H2Database EntityManager entityManager) { @@ -16,7 +16,7 @@ public class PersonDAO { } public List<Person> findAll() { - return entityManager.createNamedQuery("Person.findAll").getResultList(); + return entityManager.createNamedQuery("Person.findAll", Person.class).getResultList(); } public UUID persist(Person person) { @@ -25,7 +25,7 @@ public class PersonDAO { } public Person findByUUID(UUID uuid) { - return entityManager.createNamedQuery("Person.findByUUID", Person.class).setParameter("uuid",uuid).getSingleResult(); + return entityManager.createNamedQuery("Person.findByUUID", Person.class).setParameter("uuid", uuid).getSingleResult(); } } diff --git a/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/AddPersonView.java b/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/AddPersonView.java index b1ee601de102ca32027938e2c9b462d9190eb8bc..8aa8588bc36b1147c0083ce86add2e80a5337349 100644 --- a/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/AddPersonView.java +++ b/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/AddPersonView.java @@ -22,14 +22,14 @@ public class AddPersonView implements Serializable { private transient PersonDAO personDAO; @Getter - private Person newPerson = new Person(); + private final Person newPerson = new Person(); @Getter private Person addedPerson = new Person(); @Transactional public void addPerson() { - FacesMessage facesMessage; - personDAO.persist(addedPerson = Person.builder().name(newPerson.getName()).build()); + addedPerson = Person.builder().name(newPerson.getName()).build(); + personDAO.persist(addedPerson); FacesContext.getCurrentInstance().addMessage("growl-id", new FacesMessage(FacesMessage.SEVERITY_INFO, "Person added", addedPerson.getName() + "(" + addedPerson.getUuid() + ")")); } } diff --git a/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/GrowlView.java b/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/GrowlView.java deleted file mode 100644 index 947c219a14fa122895b710e6a7afc9881105228c..0000000000000000000000000000000000000000 --- a/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/GrowlView.java +++ /dev/null @@ -1,38 +0,0 @@ -package fr.univtln.bruno.jee91.jsf; - -import jakarta.enterprise.context.RequestScoped; -import jakarta.faces.application.FacesMessage; -import jakarta.faces.context.FacesContext; -import jakarta.inject.Named; - -@Named -@RequestScoped -public class GrowlView { - - public void addMessage(FacesMessage.Severity severity, String summary, String detail) { - FacesContext.getCurrentInstance(). - addMessage(null, new FacesMessage(severity, summary, detail)); - } - - public void showInfo() { - addMessage(FacesMessage.SEVERITY_INFO, "Info Message", "Message Content"); - } - - public void showWarn() { - addMessage(FacesMessage.SEVERITY_WARN, "Warn Message", "Message Content"); - } - - public void showError() { - addMessage(FacesMessage.SEVERITY_ERROR, "Error Message", "Message Content"); - } - - public void showSticky() { - FacesContext.getCurrentInstance().addMessage("sticky-key", new FacesMessage(FacesMessage.SEVERITY_INFO, "Sticky Message", "Message Content")); - } - - public void showMultiple() { - addMessage(FacesMessage.SEVERITY_INFO, "Message 1", "Message Content"); - addMessage(FacesMessage.SEVERITY_INFO, "Message 2", "Message Content"); - addMessage(FacesMessage.SEVERITY_INFO, "Message 3", "Message Content"); - } -} \ No newline at end of file diff --git a/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/ViewPersonBean.java b/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/ViewPersonBean.java index ac1d482773b1c7c8bab248b238552ed49afc9cdf..75dab8e96c45709abfd94b305504362bfcf67bc5 100644 --- a/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/ViewPersonBean.java +++ b/jsf/src/main/java/fr/univtln/bruno/jee91/jsf/ViewPersonBean.java @@ -15,7 +15,7 @@ public class ViewPersonBean { @Inject PersonDAO personDAO; - private String message = "Hello"; + private final String message = "Hello"; public String getMessage() { return this.message; diff --git a/jsf/src/main/webapp/growl.xhtml b/jsf/src/main/webapp/growl.xhtml deleted file mode 100644 index 32909b8fe32b1f41c1a1918355e318934408bf80..0000000000000000000000000000000000000000 --- a/jsf/src/main/webapp/growl.xhtml +++ /dev/null @@ -1,37 +0,0 @@ -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:p="http://primefaces.org/ui"> - -<h:head> - -</h:head> - -<h:body> - - <p:spinner /> - -<div class="card"> - <h:form> - <p:growl id="growl" showDetail="true"/> - <p:growl id="growl-sticky" for="sticky-key" showDetail="true" sticky="true"/> - - <h5 class="p-mt-0">Severities</h5> - <p:commandButton actionListener="#{growlView.showInfo}" update="growl" value="Info" styleClass="p-mr-2" - style="width: 10rem"/> - <p:commandButton actionListener="#{growlView.showWarn}" update="growl" value="Warn" - styleClass="p-mr-2 ui-button-warning" style="width: 10rem"/> - <p:commandButton actionListener="#{growlView.showError}" update="growl" value="Error" - styleClass="ui-button-danger" style="width: 10rem"/> - - <h5>Multiple</h5> - <p:commandButton actionListener="#{growlView.showMultiple}" update="growl" value="Multiple" style="width: 10rem" - styleClass="ui-button-outlined"/> - - <h5>Sticky</h5> - <p:commandButton actionListener="#{growlView.showSticky}" update="growl-sticky" value="Info" - style="width: 10rem" styleClass="ui-button-help"/> - </h:form> -</div> -</h:body> -</html> \ No newline at end of file diff --git a/jsf/src/main/webapp/index.xhtml b/jsf/src/main/webapp/index.xhtml index 96067ea6fbebfd298b40549fe32a1c3bb3ff9884..f43818fbbdab8bdd6dfaa17173c8bc646063d593 100644 --- a/jsf/src/main/webapp/index.xhtml +++ b/jsf/src/main/webapp/index.xhtml @@ -1,14 +1,16 @@ +<!DOCTYPE html> + <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:p="http://primefaces.org/ui"> + xmlns:p="http://primefaces.org/ui" + xml:lang="en"> <h:head> - + <title>Person list</title> </h:head> <h:body> - <h3 style="text-align: center">#{viewPersonBean.message}</h3> + <h3 style="text-align: center"><h:outputText value="#{viewPersonBean.message}"/></h3> <div class="card"> <p:dataTable var="person" value="#{viewPersonBean.persons}"> diff --git a/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/SampleResource.java b/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/SampleResource.java index 38d9aad39362fc4d5905a952f3a83f1ff57ddd48..63379567b154ea0efb082c7ac07bd825b713c8c8 100644 --- a/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/SampleResource.java +++ b/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/SampleResource.java @@ -32,7 +32,7 @@ public class SampleResource { @Inject PersonDAO personDAO; - private String message = "Hello"; + private final String message = "Hello"; @GET public Response message() { diff --git a/wsClient/pom.xml b/wsClient/pom.xml index e09ffbe737e4ef75ace4864b58689ff5c8af4cbc..378075cd4df7f97f767a9331ba8a4a93522fcd73 100644 --- a/wsClient/pom.xml +++ b/wsClient/pom.xml @@ -25,12 +25,6 @@ <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency> - <dependency> - <groupId>fr.univtln.bruno.samples.jee91</groupId> - <artifactId>utils</artifactId> - <version>1.0-SNAPSHOT</version> - <scope>provided</scope> - </dependency> </dependencies> </project> \ No newline at end of file diff --git a/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java b/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java index d2a47911aa33e1c39205f8e1b73080b333db6777..bf1e350d04622d4c2be010f939b38f0d3151213e 100644 --- a/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java +++ b/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java @@ -19,18 +19,18 @@ public class WsClient { public WsClient(URI endpointURI) { try { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); - - String pathtoCert = getClass().getClassLoader().getResource("mycert-pub.jks").toURI().getPath(); - + var url = getClass().getClassLoader().getResource("mycert-pub.jks"); System.getProperties().put("javax.net.debug", "ssl"); - System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, pathtoCert); - System.getProperties().put(SSLContextConfigurator.KEY_STORE_TYPE, "JKS"); - System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, pathtoCert); - System.getProperties().put(SSLContextConfigurator.TRUST_STORE_TYPE, "JKS"); - System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "storepass"); - System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "storepass"); + if (url != null) { + String pathtoCert = url.toURI().getPath(); + System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, pathtoCert); + System.getProperties().put(SSLContextConfigurator.KEY_STORE_TYPE, "JKS"); + System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, pathtoCert); + System.getProperties().put(SSLContextConfigurator.TRUST_STORE_TYPE, "JKS"); + System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "storepass"); + System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "storepass"); + } final SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); - defaultConfig.retrieve(System.getProperties()); container.connectToServer(this, endpointURI); } catch (Exception e) {