empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1396604 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: pageelements/ pages/ utils/
Date Wed, 10 Oct 2012 13:55:48 GMT
Author: doebele
Date: Wed Oct 10 13:55:47 2012
New Revision: 1396604

URL: http://svn.apache.org/viewvc?rev=1396604&view=rev
Log:
EMPIREDB-157 
JSF2: minor log level and exception adjustments

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/Page.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageELResolver.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageOutcome.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ParameterMap.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java?rev=1396604&r1=1396603&r2=1396604&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
Wed Oct 10 13:55:47 2012
@@ -35,8 +35,11 @@ import org.apache.empire.db.DBCommand;
 import org.apache.empire.db.DBReader;
 import org.apache.empire.db.DBRecordData;
 import org.apache.empire.db.DBRowSet;
+import org.apache.empire.db.exceptions.NoPrimaryKeyException;
 import org.apache.empire.db.expr.order.DBOrderByExpr;
+import org.apache.empire.exceptions.InternalException;
 import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.MiscellaneousErrorException;
 import org.apache.empire.exceptions.NotSupportedException;
 import org.apache.empire.exceptions.ObjectNotValidException;
 import org.apache.empire.exceptions.UnexpectedReturnValueException;
@@ -500,7 +503,7 @@ public class BeanListPageElement<T> exte
     {
         DBColumn[] keyCols = rowset.getKeyColumns();
         if (keyCols == null)
-            throw new RuntimeException("No Primary Key");
+            throw new NoPrimaryKeyException(rowset);
         // generate all
         for (Object item : items)
         {
@@ -512,9 +515,8 @@ public class BeanListPageElement<T> exte
             }
             catch (Exception e)
             {
-                String msg = "Error setting property idparam on bean.";
-                log.error(msg, e);
-                throw new RuntimeException(msg, e);
+                log.error("Error setting property idparam on bean.", e);
+                throw new InternalException(e);
             }
         }
     }
@@ -532,7 +534,7 @@ public class BeanListPageElement<T> exte
             { // Bean Property Name
                 String propName = cols[i].getBeanPropertyName();
                 if (propName == null || propName.length() == 0)
-                    throw new RuntimeException("Invalid Bean Property Name");
+                    throw new MiscellaneousErrorException("Invalid Bean Property Name");
                 // Get Property value
                 try
                 {
@@ -542,7 +544,7 @@ public class BeanListPageElement<T> exte
                 {
                     String msg = "Error getting property '" + propName + "' from bean.";
                     log.error(msg, e);
-                    throw new RuntimeException(msg, e);
+                    throw new InternalException(e);
                 }
             }
         }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/Page.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/Page.java?rev=1396604&r1=1396603&r2=1396604&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/Page.java (original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/Page.java Wed
Oct 10 13:55:47 2012
@@ -36,6 +36,7 @@ import org.apache.empire.db.DBRowSet;
 import org.apache.empire.exceptions.EmpireException;
 import org.apache.empire.exceptions.InternalException;
 import org.apache.empire.exceptions.ItemNotFoundException;
+import org.apache.empire.exceptions.MiscellaneousErrorException;
 import org.apache.empire.jsf2.app.FacesApplication;
 import org.apache.empire.jsf2.app.FacesUtils;
 import org.apache.empire.jsf2.app.TextResolver;
@@ -247,7 +248,12 @@ public abstract class Page implements Se
         // Message
         Page.log.error(msg, e);
         if (!handleActionError(action, e))
-            throw new RuntimeException(msg, e);
+        {   // Not handled. Throw again
+            if (e instanceof EmpireException)
+                throw ((EmpireException)e);
+            else
+                throw new InternalException(e);
+        }    
     }
 
     protected void setSessionMessage(FacesMessage facesMsg)
@@ -314,7 +320,8 @@ public abstract class Page implements Se
 
     protected void redirectTo(PageOutcome outcome)
     {
-        log.error("Redirecting from page {} to page {}.", getPageName(), outcome.toString());
+        if (log.isDebugEnabled())
+            log.debug("Redirecting from page {} to page {}.", getPageName(), outcome.toString());
         // Return to Parent
         FacesContext context = FacesContext.getCurrentInstance();
         // Retrieve the NavigationHandler instance..
@@ -353,7 +360,7 @@ public abstract class Page implements Se
     {
         PageDefinition parentPage = getParentPage();
         if (parentPage == null)
-            throw new RuntimeException("No Parent Page defined for " + getPageName());
+            throw new MiscellaneousErrorException("No Parent Page defined for " + getPageName());
         if (redirect)
             return parentPage.getRedirect(action);
         else

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java?rev=1396604&r1=1396603&r2=1396604&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
Wed Oct 10 13:55:47 2012
@@ -22,6 +22,8 @@ import java.io.Serializable;
 import java.util.LinkedHashMap;
 
 import org.apache.empire.commons.StringUtils;
+import org.apache.empire.exceptions.ItemExistsException;
+import org.apache.empire.exceptions.MiscellaneousErrorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,7 +52,7 @@ public abstract class PageDefinitions im
     {
         if (instance!=null) 
         {
-            throw new RuntimeException("PageDefintions alreday defined. Only one Instance
allowed!");
+            throw new MiscellaneousErrorException("PageDefintions alreday defined. Only one
Instance allowed!");
         }
         // init
         instance = this;
@@ -77,7 +79,7 @@ public abstract class PageDefinitions im
             // check
             if (bm.getRegisteredBeans().containsKey(beanName))
             {
-                throw new RuntimeException("Bean of name "+beanName+" already defined!");
+                throw new ItemExistsException(beanName);
             }
             log.info("Registering managed bean '{}' of class '{}' for page '{}'.", new Object[]
{ beanName, beanClass, v.getPath() });
             /*
@@ -173,7 +175,7 @@ public abstract class PageDefinitions im
         // Check Name
         if (pageMap.containsKey(name))
         {
-            throw new RuntimeException("Page of name "+name+" already defined!");
+            throw new ItemExistsException(name);
         }
         log.info("Registering view '{}'.", name);
         // Register Name

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageELResolver.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageELResolver.java?rev=1396604&r1=1396603&r2=1396604&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageELResolver.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageELResolver.java
Wed Oct 10 13:55:47 2012
@@ -27,6 +27,7 @@ import javax.el.ELResolver;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 
+import org.apache.empire.exceptions.MiscellaneousErrorException;
 import org.apache.empire.jsf2.app.FacesUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -69,7 +70,7 @@ public class PageELResolver extends ELRe
             UIViewRoot vr = FacesContext.getCurrentInstance().getViewRoot();
             if (vr==null)
             {   // Error: No view root     
-                RuntimeException e = new RuntimeException("ViewRoot not available. Unable
to get Page Bean.");
+                RuntimeException e = new MiscellaneousErrorException("ViewRoot not available.
Unable to get Page Bean.");
                 log.error(e.getMessage());
                 throw e; 
             }
@@ -77,7 +78,7 @@ public class PageELResolver extends ELRe
             Page page = (vmap!=null ? (Page)vmap.get("page") : null);
             if (page==null)
             {   // Error: No page bean      
-                RuntimeException e = new RuntimeException("Page bean not available for current
view.");
+                RuntimeException e = new MiscellaneousErrorException("Page bean not available
for current view.");
                 log.error(e.getMessage());
                 throw e; 
             }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageOutcome.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageOutcome.java?rev=1396604&r1=1396603&r2=1396604&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageOutcome.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageOutcome.java
Wed Oct 10 13:55:47 2012
@@ -19,6 +19,7 @@
 package org.apache.empire.jsf2.pages;
 
 import org.apache.empire.commons.StringUtils;
+import org.apache.empire.exceptions.InvalidArgumentException;
 
 public class PageOutcome
 {
@@ -26,14 +27,14 @@ public class PageOutcome
     public PageOutcome(String outcome)
     {
         if (StringUtils.isEmpty(outcome))
-            throw new RuntimeException("Illegal Outcome Value");
+            throw new InvalidArgumentException("outcome", outcome);
         this.outcome = outcome;
     }
     
     public PageOutcome addParamWithValue(String paramWithValue)
     {
         if (paramWithValue==null || paramWithValue.indexOf('=')<0)
-            throw new RuntimeException("Illegal Parameter Value");
+            throw new InvalidArgumentException("paramWithValue", paramWithValue);
         // assemble
         if (outcome.indexOf('?')>0)
             outcome = outcome+"&"+paramWithValue;
@@ -47,7 +48,7 @@ public class PageOutcome
         if (StringUtils.isEmpty(value))
             return this; // Ignore Empty values
         if (StringUtils.isEmpty(param))
-            throw new RuntimeException("Illegal Parameter Name");
+            throw new InvalidArgumentException("param", param);
         String paramWithValue = param + "=" + value;
         return addParamWithValue(paramWithValue);
     }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java?rev=1396604&r1=1396603&r2=1396604&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
Wed Oct 10 13:55:47 2012
@@ -27,6 +27,8 @@ import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
 
 import org.apache.commons.beanutils.BeanUtils;
+import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.exceptions.ObjectNotValidException;
 import org.apache.empire.jsf2.app.FacesUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -153,7 +155,8 @@ public class PagePhaseListener implement
             }
             catch (Exception e)
             {
-                throw new RuntimeException("Error creating instance of page bean " + pageBeanClassName,
e);
+                log.error("Error creating instance of page bean " + pageBeanClassName, e);
+                throw new InternalException(e);
             }
             viewMap.put(pageDef.getPageBeanName(), pageBean);
             viewMap.put("page", pageBean);
@@ -281,7 +284,7 @@ public class PagePhaseListener implement
         if (pageBean != null && !pageBean.isInitialized())
         {
             log.warn("PageBean was not initialized!");
-            throw new RuntimeException("PageBean was not initialized!");
+            throw new ObjectNotValidException(pageBean);
         }
         // FacesUtils.getFin2Application().releaseConnection(true);
         log.trace("PagePhase complete.");

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ParameterMap.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ParameterMap.java?rev=1396604&r1=1396603&r2=1396604&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ParameterMap.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ParameterMap.java
Wed Oct 10 13:55:47 2012
@@ -28,6 +28,7 @@ import java.util.Locale;
 import org.apache.empire.commons.DateUtils;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.db.DBRowSet;
+import org.apache.empire.exceptions.InternalException;
 import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.exceptions.UnexpectedReturnValueException;
 import org.slf4j.Logger;
@@ -55,7 +56,7 @@ public class ParameterMap implements Ser
         catch (NoSuchAlgorithmException e)
         {
             ParameterMap.log.error("MessageDigest NoSuchAlgorithmException.", e);
-            throw new RuntimeException(e);
+            throw new InternalException(e);
         }
     }
     



Mime
View raw message