From 77121f9a791310454b31ca51690f686f4ebbb0dd Mon Sep 17 00:00:00 2001 From: tim holloway Date: Thu, 15 Feb 2024 20:53:26 -0500 Subject: [PATCH] Database error reporting improvement --- pom.xml | 2 +- .../mousetech/gourmetj/RecipeDetailBean.java | 19 ++++++++++++++----- .../gourmetj/SpringSecurityConfig.java | 3 --- .../META-INF/resources/detailEdit.xhtml | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 9722fdb..be4577f 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.mousetech.gourmet gourmetj - 0.2.2 + 0.2.4 jar GourmetJ diff --git a/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java b/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java index cb97e78..a25d0da 100644 --- a/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java +++ b/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java @@ -20,7 +20,7 @@ import org.apache.commons.lang3.StringUtils; import org.primefaces.event.FileUploadEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import org.springframework.orm.jpa.JpaSystemException; import com.mousetech.gourmetj.persistence.model.Category; import com.mousetech.gourmetj.persistence.model.Ingredient; @@ -649,15 +649,24 @@ public class RecipeDetailBean implements Serializable { String ingkey = ing.getIngkey(); if (!StringUtils.isEmpty(ingkey)) { - Shopcat scat = this.recipeService - .findShopcatForIngredientKey(ingkey); - ing.setShopCat(scat); + try { + Shopcat scat = this.recipeService + .findShopcatForIngredientKey(ingkey); + ing.setShopCat(scat); + } catch (JpaSystemException ex) { + String msg = String.format( + "Database Error: Unable to fetch info on \"%s\".", + ingkey); + log.error(msg); + JSFUtils.addErrorMessage(msg); + + } } // get ing list size, set ing position, append List ingredients = getWrappedIngredients(); int lsize = ingredients.size(); ing.setPosition(lsize + 1); - ingredients.add(new IngredientUI(ing)); + ingredients.add(new IngredientUI(ing)); } // === diff --git a/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java b/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java index b9c5467..5386fdc 100644 --- a/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java +++ b/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java @@ -20,9 +20,6 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe 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 org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; - -import jakarta.servlet.DispatcherType; @Configuration @EnableWebSecurity diff --git a/src/main/resources/META-INF/resources/detailEdit.xhtml b/src/main/resources/META-INF/resources/detailEdit.xhtml index 3fa0217..d16fe3b 100644 --- a/src/main/resources/META-INF/resources/detailEdit.xhtml +++ b/src/main/resources/META-INF/resources/detailEdit.xhtml @@ -362,8 +362,8 @@ id="ctlAddIng" value="+ Add" onclick="ingButton(); return false;" - > - + update=":growl" + />