Version2 - Spring Boot 3.2.2 and jakarta EE

version2
tim holloway 3 months ago
parent 9dd7da73c2
commit 8bcd8cb9a1
  1. 22
      .classpath
  2. 8
      .project
  3. 14
      application.properties
  4. 103
      pom.xml
  5. 15
      src/main/java/com/mousetech/gourmetj/AdminMainBean.java
  6. 8
      src/main/java/com/mousetech/gourmetj/CategoryView.java
  7. 6
      src/main/java/com/mousetech/gourmetj/CuisineBean.java
  8. 12
      src/main/java/com/mousetech/gourmetj/EditShopcatBean.java
  9. 8
      src/main/java/com/mousetech/gourmetj/JSFUtils.java
  10. 25
      src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java
  11. 8
      src/main/java/com/mousetech/gourmetj/ShoppingListBean.java
  12. 17
      src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java
  13. 90
      src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java
  14. 6
      src/main/java/com/mousetech/gourmetj/UserSession.java
  15. 2
      src/main/java/com/mousetech/gourmetj/persistence/dao/PantryRepository.java
  16. 2
      src/main/java/com/mousetech/gourmetj/persistence/dao/ShopcatRepository.java
  17. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Category.java
  18. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Convtable.java
  19. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Crossunitdict.java
  20. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Density.java
  21. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Info.java
  22. 4
      src/main/java/com/mousetech/gourmetj/persistence/model/Ingredient.java
  23. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Keylookup.java
  24. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Pantry.java
  25. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/PluginInfo.java
  26. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Recipe.java
  27. 22
      src/main/java/com/mousetech/gourmetj/persistence/model/Shopcat.java
  28. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Shopcatsorder.java
  29. 2
      src/main/java/com/mousetech/gourmetj/persistence/model/Unitdict.java
  30. 6
      src/main/java/com/mousetech/gourmetj/persistence/service/CategoryService.java
  31. 6
      src/main/java/com/mousetech/gourmetj/persistence/service/RecipeService.java
  32. 6
      src/main/java/com/mousetech/gourmetj/springweb/PictureController.java
  33. 17
      src/main/java/com/mousetech/gourmetj/utils/TimeConverter.java
  34. 28
      src/main/java/com/mousetech/gourmetj/utils/YamlShoppingList.java
  35. 6
      src/main/resources/application.yml
  36. 0
      xxx

@ -9,17 +9,11 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar" sourcepath="M2_REPO/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/enterprise/cdi-api/2.0/cdi-api-2.0.jar" sourcepath="M2_REPO/javax/enterprise/cdi-api/2.0/cdi-api-2.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/interceptor/javax.interceptor-api/1.2/javax.interceptor-api-1.2.jar" sourcepath="M2_REPO/javax/interceptor/javax.interceptor-api/1.2/javax.interceptor-api-1.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/inject/javax.inject/1/javax.inject-1.jar" sourcepath="M2_REPO/javax/inject/javax.inject/1/javax.inject-1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/transaction/javax.transaction-api/1.3/javax.transaction-api-1.3.jar" sourcepath="M2_REPO/javax/transaction/javax.transaction-api/1.3/javax.transaction-api-1.3-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar" sourcepath="M2_REPO/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar" sourcepath="M2_REPO/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar" sourcepath="M2_REPO/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -60,14 +54,12 @@
<classpathentry kind="var" path="M2_REPO/org/apache/tomcat/embed/tomcat-embed-jasper/9.0.12/tomcat-embed-jasper-9.0.12.jar" sourcepath="M2_REPO/org/apache/tomcat/embed/tomcat-embed-jasper/9.0.12/tomcat-embed-jasper-9.0.12-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/ecj/3.13.102/ecj-3.13.102.jar" sourcepath="M2_REPO/org/eclipse/jdt/ecj/3.13.102/ecj-3.13.102-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/joinfaces/mojarra-spring-boot-starter/3.3.0-rc2/mojarra-spring-boot-starter-3.3.0-rc2.jar" sourcepath="M2_REPO/org/joinfaces/mojarra-spring-boot-starter/3.3.0-rc2/mojarra-spring-boot-starter-3.3.0-rc2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/glassfish/javax.faces/2.3.7/javax.faces-2.3.7.jar" sourcepath="M2_REPO/org/glassfish/javax.faces/2.3.7/javax.faces-2.3.7-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/joinfaces/omnifaces1-spring-boot-starter/3.3.0-rc2/omnifaces1-spring-boot-starter-3.3.0-rc2.jar" sourcepath="M2_REPO/org/joinfaces/omnifaces1-spring-boot-starter/3.3.0-rc2/omnifaces1-spring-boot-starter-3.3.0-rc2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/omnifaces/omnifaces/1.14.1/omnifaces-1.14.1.jar" sourcepath="M2_REPO/org/omnifaces/omnifaces/1.14.1/omnifaces-1.14.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/joinfaces/spring-security-jsf-taglib/3.3.0-rc2/spring-security-jsf-taglib-3.3.0-rc2.jar" sourcepath="M2_REPO/org/joinfaces/spring-security-jsf-taglib/3.3.0-rc2/spring-security-jsf-taglib-3.3.0-rc2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/primefaces/primefaces/6.2/primefaces-6.2.jar" sourcepath="M2_REPO/org/primefaces/primefaces/6.2/primefaces-6.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/primefaces/extensions/primefaces-extensions/6.2.9/primefaces-extensions-6.2.9.jar" sourcepath="M2_REPO/org/primefaces/extensions/primefaces-extensions/6.2.9/primefaces-extensions-6.2.9-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.8.5/gson-2.8.5-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/boot/spring-boot-starter-data-jpa/2.1.0.RELEASE/spring-boot-starter-data-jpa-2.1.0.RELEASE.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/boot/spring-boot-starter-aop/2.1.0.RELEASE/spring-boot-starter-aop-2.1.0.RELEASE.jar"/>
<classpathentry kind="var" path="M2_REPO/org/aspectj/aspectjweaver/1.9.2/aspectjweaver-1.9.2.jar" sourcepath="M2_REPO/org/aspectj/aspectjweaver/1.9.2/aspectjweaver-1.9.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/boot/spring-boot-starter-jdbc/2.1.0.RELEASE/spring-boot-starter-jdbc-2.1.0.RELEASE.jar"/>
@ -89,16 +81,24 @@
<classpathentry kind="var" path="M2_REPO/com/h2database/h2/1.4.197/h2-1.4.197.jar" sourcepath="M2_REPO/com/h2database/h2/1.4.197/h2-1.4.197-sources.jar"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/glassfish/javax.faces/2.3.7/javax.faces-2.3.7.jar" sourcepath="M2_REPO/org/glassfish/javax.faces/2.3.7/javax.faces-2.3.7-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@ -17,7 +22,8 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

@ -1,13 +1,8 @@
# THIS is the application properties used when testing in the IDE
# The application.yml (production) is ignored.
#joinfaces.jsf.project-stage=development
# They lied. This doesn't work:
joinfaces.primefaces.theme=cupertino
# or running stand-alone from the command line.
# It augments/overrides application.yml in the JAR
joinfaces.jsf.webapp-resources-directory=/resources
# This works. Note that ONLY THE FIRST theme set will work unless
# you delete the old primefaces.THEME from ServletContext
server.servlet.context-parameters.primefaces.THEME=omega
server.servlet.session.timeout=30m
spring.thymeleaf.enabled=false
@ -19,10 +14,11 @@ spring.datasource.username=recipes
pring.datasource.password=yumyumyum
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
#org.sqlite.JDBC
#spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
#Obs, no longer required:
#spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
#org.sqlite.hibernate.dialect.SQLiteDialect
#spring.jpa.show-sql: true
# My special properties
gourmet.password.file=${user.home}/.gourmetpw

@ -7,7 +7,7 @@
<groupId>com.mousetech.gourmet</groupId>
<artifactId>gourmetj</artifactId>
<version>0.1.4-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>GourmetJ</name>
@ -17,7 +17,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<version>3.2.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
@ -30,25 +30,44 @@
</repositories>
<properties>
<!-- compile library versions -->
<jakarta.validation-api.version>3.0.2</jakarta.validation-api.version>
<joinfaces.version>5.2.2</joinfaces.version>
<maven-model.version>3.9.6</maven-model.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<joinfaces.version>3.3.0-rc2</joinfaces.version>
<java.version>17</java.version>
<spring-boot.version>3.2.2</spring-boot.version>
<faces.version>4.0.5</faces.version>
<joinfaces.version>5.2.2</joinfaces.version>
<twelvemonkeys.version>3.10.1</twelvemonkeys.version>
<junit.jupiter.version>5.4.0</junit.jupiter.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${jakarta.validation-api.version}</version>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-dependencies</artifactId>
<artifactId>joinfaces-bom</artifactId>
<version>${joinfaces.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven-model.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
@ -59,10 +78,10 @@
<artifactId>all-themes</artifactId>
<version>1.0.10</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
@ -71,55 +90,72 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--
https://mvnrepository.com/artifact/jakarta.persistence/jakarta.persistence-api -->
<!-- <dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>-->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
<!--
https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<!--
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<!-- <dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
</dependency>-->
<!-- <dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<!-- <dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<artifactId>jakarta.el</artifactId>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-core -->
<!--
https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-core -->
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-core</artifactId>
<version>3.8.1</version>
<version>${twelvemonkeys.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-webp -->
<!--
https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-webp -->
<!-- In Core??? -->
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-webp</artifactId>
<version>3.8.1</version>
<version>${twelvemonkeys.version}</version>
<scope>compile</scope>
</dependency>
<!-- Needed only if you deploy ImageIO plugins as part of a web app.
@ -128,7 +164,7 @@
<dependency>
<groupId>com.twelvemonkeys.servlet</groupId>
<artifactId>servlet</artifactId>
<version>3.8.1</version>
<version>${twelvemonkeys.version}</version>
<scope>compile</scope>
</dependency>
@ -141,21 +177,15 @@
<version>8.0.30</version>
</dependency>
<!-- SQLite DB -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.github.gwenn</groupId>
<artifactId>sqlite-dialect</artifactId>
<version>0.1.2</version>
</dependency>
<!-- <dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.faces</artifactId>
<version>${com.sun.faces.version}</version>
</dependency>-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@ -164,7 +194,6 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

@ -2,13 +2,13 @@ package com.mousetech.gourmetj;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.annotation.PostConstruct;
import jakarta.faces.event.AjaxBehaviorEvent;
import jakarta.faces.model.DataModel;
import jakarta.faces.model.ListDataModel;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -177,6 +177,7 @@ public class AdminMainBean implements Serializable {
*/
public String doFind() {
List<Recipe> recipes = null;
searchText = searchText.trim();
switch (this.getUserSession().getSearchType()) {
case rst_BY_NAME:

@ -2,10 +2,10 @@ package com.mousetech.gourmetj;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.annotation.PostConstruct;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -8,9 +8,9 @@ package com.mousetech.gourmetj;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import com.mousetech.gourmetj.persistence.service.RecipeService;

@ -3,12 +3,12 @@ package com.mousetech.gourmetj;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.annotation.PostConstruct;
import jakarta.faces.event.AjaxBehaviorEvent;
import jakarta.faces.event.ValueChangeEvent;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import com.mousetech.gourmetj.persistence.dao.ShopcatRepository;

@ -2,10 +2,10 @@ package com.mousetech.gourmetj;
import java.io.InputStream;
import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.Flash;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import jakarta.faces.context.Flash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -7,24 +7,23 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.Part;
import jakarta.faces.model.DataModel;
import jakarta.faces.model.ListDataModel;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.servlet.http.Part;
import jakarta.faces.event.AjaxBehaviorEvent;
import org.apache.commons.lang3.StringUtils;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;
import org.primefaces.model.file.UploadedFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.mousetech.gourmetj.IngredientUI;
import com.mousetech.gourmetj.UserSession;
import com.mousetech.gourmetj.persistence.model.Category;
import com.mousetech.gourmetj.persistence.model.Ingredient;
import com.mousetech.gourmetj.persistence.model.Recipe;
@ -391,7 +390,7 @@ public class RecipeDetailBean implements Serializable {
*
* @param event Unused
*/
public void ajaxAddIngredient(AjaxBehaviorEvent event) {
public void ajaxAddIngredient(jakarta.faces.event.AjaxBehaviorEvent event) {
doAddIngredient();
}
@ -1088,7 +1087,7 @@ public class RecipeDetailBean implements Serializable {
public void ajaxUploadImage(FileUploadEvent event) {
UploadedFile foo = event.getFile();
PictureController.importImage(recipe, foo.getContents());
PictureController.importImage(recipe, foo.getContent());
}
/**

@ -6,10 +6,10 @@ import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.annotation.PostConstruct;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.apache.commons.lang3.StringUtils;
import org.primefaces.model.StreamedContent;

@ -1,8 +1,8 @@
package com.mousetech.gourmetj;
import javax.faces.application.ViewExpiredException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import jakarta.faces.application.ViewExpiredException;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import org.primefaces.application.resource.PrimeResourceHandler;
import org.primefaces.renderkit.HeadRenderer;
@ -41,18 +41,19 @@ public class SpringPrimeFacesApplication {
/* Note that we cannot set theme here since it was
* already set earlier. Default value is "aristo".
*/
// servletContext.setInitParameter(
// "primefaces.THEME", "bluesky");
servletContext.setInitParameter(
"javax.faces.FACELETS_SKIP_COMMENTS",
"joinfaces.primefaces.theme", "vela");
servletContext.setInitParameter(
"primefaces.THEME", "overcast");
servletContext.setInitParameter(
"jakarta.faces.FACELETS_SKIP_COMMENTS",
"true");
servletContext.setInitParameter(
"com.sun.faces.expressionFactory",
"com.sun.el.ExpressionFactoryImpl");
servletContext.setInitParameter(
"primefaces.UPLOADER", "native");
servletContext.addListener(IMAGE_IIO_PROVIDER_CONTEXT_LISTENER);
////servletContext.addListener(IMAGE_IIO_PROVIDER_CONTEXT_LISTENER);
}
};
}

@ -2,7 +2,6 @@ package com.mousetech.gourmetj;
import java.io.File;
import java.io.FileReader;
import java.io.LineNumberInputStream;
import java.io.LineNumberReader;
import java.util.Arrays;
@ -10,52 +9,43 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configurers.provisioning.InMemoryUserDetailsManagerConfigurer;
import org.springframework.security.config.annotation.authentication.configurers.provisioning.UserDetailsManagerConfigurer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import jakarta.servlet.DispatcherType;
@Configuration
@EnableWebSecurity
public class SpringSecurityConfig
extends WebSecurityConfigurerAdapter {
public class SpringSecurityConfig {
//extends WebSecurityConfigurerAdapter {
/* Logger */
private static final Logger log =
LoggerFactory.getLogger(SpringSecurityConfig.class);
@Override
protected void configure(HttpSecurity http)
throws Exception {
// require all requests to be authenticated except
// for the resources
http.authorizeRequests()
.antMatchers("/javax.faces.resource/**",
"/",
"/index.jsf",
"/main.jsf",
"/img/**",
"/recipeDetails.jsf",
"/recipePrint.jsf")
.permitAll().anyRequest().authenticated();
// login
http.formLogin()// .loginPage("/login.xhtml")
.permitAll();
// .failureUrl("/login.xhtml?error=true");
// logout
// http.logout().logoutSuccessUrl("/login.xhtml");
// not needed as JSF 2.2 is implicitly protected
// against CSRF
http.csrf().disable();
}
@Value("${gourmet.password.file}")
private String passwordFile;
/**
* Load in config file with in-memory credentials.
* For practical use, this should probably be
* replace with JdbcUserDetailsManager and credentials in
* the recipe database.
*
* @param auth Builder for the authenticator
* @throws Exception
*/
@Autowired
public void configureGlobal(
AuthenticationManagerBuilder auth) throws Exception {
@ -72,17 +62,21 @@ public class SpringSecurityConfig
LineNumberReader rdr =
new LineNumberReader(new FileReader(pwFile));
String pwLine;
InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> authenticator =
InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>
authenticator =
auth.inMemoryAuthentication();
while ((pwLine = rdr.readLine()) != null) {
pwLine = pwLine.trim();
if (( pwLine.length() == 0) || (pwLine.charAt(0) == '#')) {
if ((pwLine.length() == 0)
|| (pwLine.charAt(0) == '#')) {
continue;
}
String[] creds = parseCreds(pwLine);
UserDetailsManagerConfigurer<AuthenticationManagerBuilder, InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>.UserDetailsBuilder bar =
UserDetailsManagerConfigurer<AuthenticationManagerBuilder,
InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>
.UserDetailsBuilder bar =
authenticator.withUser(creds[0])
.password("{noop}"+creds[1]);
.password("{noop}" + creds[1]);
int credlen = creds.length;
for (int i = 2; i < credlen; i++) {
bar.roles(creds[i]);
@ -104,4 +98,36 @@ public class SpringSecurityConfig
.toArray(String[]::new);
return ocreds;
}
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.cors(AbstractHttpConfigurer::disable)
.formLogin(Customizer.withDefaults())
.authorizeHttpRequests((authorize)-> authorize
.dispatcherTypeMatchers(DispatcherType.FORWARD, DispatcherType.ERROR).permitAll()
.anyRequest().authenticated()
);
return http.build();
}
/**
* Replaces old antMatchers for determining secured URLs.
* @return customizer
*/
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring().requestMatchers(
"/javax.faces.resource/**",
"/",
"/index.jsf",
"/index.xhtml",
"/main.jsf",
"/img/**",
"/recipeDetails.jsf",
"/recipePrint.jsf");
}
}

@ -4,9 +4,9 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.faces.model.SelectItem;
import javax.inject.Named;
import jakarta.enterprise.context.SessionScoped;
import jakarta.faces.model.SelectItem;
import jakarta.inject.Named;
import org.primefaces.PrimeFaces;
import org.slf4j.Logger;

@ -2,7 +2,7 @@ package com.mousetech.gourmetj.persistence.dao;
import java.util.List;
import javax.transaction.Transactional;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;

@ -2,7 +2,7 @@ package com.mousetech.gourmetj.persistence.dao;
import java.util.List;
import javax.transaction.Transactional;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -1,8 +1,8 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
/**
* The persistent class for the "ingredients" database table. The

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**
* The persistent class for the "pantry" database table.

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -6,7 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.*;
import jakarta.persistence.*;
/**
* The persistent class for the "recipe" database table.

@ -4,17 +4,17 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.NamedQueries;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
/**
* The persistent class for the "shopcats" database table.

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -1,7 +1,7 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import jakarta.persistence.*;
/**

@ -2,9 +2,9 @@ package com.mousetech.gourmetj.persistence.service;
import java.io.Serializable;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.springframework.transaction.annotation.Transactional;

@ -4,9 +4,9 @@ import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -17,9 +17,9 @@ import java.io.InputStream;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.Part;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -6,13 +6,13 @@
*/
package com.mousetech.gourmetj.utils;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
import javax.faces.validator.ValidatorException;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.component.UIComponent;
import jakarta.faces.context.FacesContext;
import jakarta.faces.convert.Converter;
import jakarta.faces.convert.ConverterException;
import jakarta.faces.convert.FacesConverter;
import jakarta.faces.validator.ValidatorException;
import org.apache.commons.lang3.StringUtils;
@ -48,6 +48,9 @@ public class TimeConverter implements Converter<Integer> {
@Override
public String getAsString(FacesContext context,
UIComponent component, Integer value) {
if ( value == null ) {
return "--";
}
return TimeFormatter.formatTime(Long.valueOf(value));
}
}

@ -1,18 +1,22 @@
package com.mousetech.gourmetj.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.primefaces.model.ByteArrayContent;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.primefaces.util.SerializableSupplier;
import com.mousetech.gourmetj.ShopIngredient;
/**
* Construct a Primefaces file output content for an ingredient
* list in YAML format.
* @see ShoppingListBean
*
* @author timh
* @since Jan 15, 2022
@ -20,18 +24,30 @@ import com.mousetech.gourmetj.ShopIngredient;
public class YamlShoppingList {
/**
* Create "file" to download in YAML format
* @param ingredientList Ingredient list to format
* @return Http response for file download
*/
public static StreamedContent createDownload(
List<ShopIngredient> ingredientList) {
StreamedContent file;
ByteArrayOutputStream ary = new ByteArrayOutputStream();
PrintWriter wtr = new PrintWriter(ary);
wtr.println("---");
formatContent(wtr, ingredientList);
wtr.close();
byte[] bas = ary.toByteArray();
StreamedContent dlList = new ByteArrayContent(bas,
"text/text", "shopping_list.yml");
return dlList;
InputStream airy = new ByteArrayInputStream(ary.toByteArray());
file = DefaultStreamedContent.
builder().contentEncoding("text/text")
.name("shopping_list.yml")
.stream(() -> airy)
.build();
return file;
}
/**

@ -20,7 +20,7 @@ spring:
hibernate:
ddl-auto: none
#database-platform: org.sqlite.hibernate.dialect.SQLiteDialect
database-platform: org.hibernate.dialect.MySQLDialect
###database-platform: org.hibernate.dialect.MySQLDialect
server:
servlet:
@ -30,3 +30,7 @@ server:
gourmet:
password:
file: .gourmetpw
joinfaces:
primefaces:
theme: saga

Loading…
Cancel
Save