empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject empire-db git commit: EMPIREDB-238 new overloads
Date Wed, 17 Feb 2016 19:17:55 GMT
Repository: empire-db
Updated Branches:
  refs/heads/master d1e69e281 -> 5e314f54c


EMPIREDB-238
new overloads


Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/5e314f54
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/5e314f54
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/5e314f54

Branch: refs/heads/master
Commit: 5e314f54c77e46af4fa77902ee8f7ede31a8b1e6
Parents: d1e69e2
Author: Rainer Döbele <doebele@apache.org>
Authored: Wed Feb 17 20:17:49 2016 +0100
Committer: Rainer Döbele <doebele@apache.org>
Committed: Wed Feb 17 20:17:49 2016 +0100

----------------------------------------------------------------------
 .../org/apache/empire/jsf2/app/FacesUtils.java    | 18 +++++++++++++-----
 .../exceptions/ObjectNotValidException.java       |  7 ++++++-
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/5e314f54/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
----------------------------------------------------------------------
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
index 904cd7d..d26bd72 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
@@ -40,6 +40,7 @@ import org.apache.empire.data.Column;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.exceptions.EmpireException;
 import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.exceptions.ItemNotFoundException;
 import org.apache.empire.jsf2.pages.Page;
 import org.apache.empire.jsf2.pages.PageDefinition;
 import org.apache.empire.jsf2.pages.PageOutcome;
@@ -269,18 +270,25 @@ public class FacesUtils
         return getWebApplication().getFacesImplementation().getManagedBean(name, fc);
     }
     
-    public static <T> T getManagedBean(final FacesContext fc, final Class<T>
cls)
+    public static <T> T getManagedBean(final FacesContext fc, final Class<T>
cls, final String name)
     {
-        String name = cls.getName();
-        int i = name.lastIndexOf('.')+1;
-        name  = name.substring(i, i+1).toLowerCase()+name.substring(i+1);
         @SuppressWarnings("unchecked")
         T bean = (T)getManagedBean(fc, name);
         if (bean==null)
-            log.warn("Managed Bean {} ist not available.", name);
+        {   log.warn("Managed Bean {} ist not available.", name);
+            throw new ItemNotFoundException(name);
+        }    
         return bean;
     }
     
+    public static <T> T getManagedBean(final FacesContext fc, final Class<T>
cls)
+    {
+        String name = cls.getName();
+        int i = name.lastIndexOf('.')+1;
+        name  = name.substring(i, i+1).toLowerCase()+name.substring(i+1);
+        return getManagedBean(fc, cls, name);
+    }
+    
     public static <T> T getManagedBean(final Class<T> cls)
     {
         FacesContext fc = getContext();

http://git-wip-us.apache.org/repos/asf/empire-db/blob/5e314f54/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
b/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
index bac0034..568badb 100644
--- a/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
+++ b/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
@@ -28,10 +28,15 @@ public class ObjectNotValidException extends EmpireException
     private static final long serialVersionUID = 1L;
     
     public static final ErrorType errorType = new ErrorType("error.objectNotValid", "The
object of type {0} has not been initialized.");
+
+    public ObjectNotValidException(Class<?> clazz)
+    {
+        super(errorType, new String[] { (clazz!=null) ? clazz.getName() : "{unknown}" } );
+    }
     
     public ObjectNotValidException(Object obj)
     {
-        super(errorType, new String[] { (obj!=null) ? obj.getClass().getName() : "{unknown}"
} );
+        this((obj!=null) ? obj.getClass() : null);
     }
 
 }


Mime
View raw message