[jboss-svn-commits] JBL Code SVN: r11182 - in labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums: ui and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Apr 20 20:29:43 EDT 2007


Author: dejp
Date: 2007-04-20 20:29:43 -0400 (Fri, 20 Apr 2007)
New Revision: 11182

Modified:
   labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java
   labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java
Log:
JBFORUMS-198

Modified: labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java
===================================================================
--- labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java	2007-04-21 00:29:20 UTC (rev 11181)
+++ labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java	2007-04-21 00:29:43 UTC (rev 11182)
@@ -17,8 +17,10 @@
 import org.jboss.portal.core.modules.ModuleConstants;
 import org.jboss.portal.core.modules.ModuleException;
 import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
 import org.jboss.portal.identity.UserModule;
 import org.jboss.portlet.forums.model.Poster;
+import org.jboss.portlet.forums.ui.PortalUtil;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -70,6 +72,9 @@
             e.printStackTrace();
             return null;
          }
+         catch (NoSuchUserException e) {
+            return PortalUtil.getUserNA();
+         }
          catch (IdentityException e)
          {
             e.printStackTrace();

Modified: labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java
===================================================================
--- labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java	2007-04-21 00:29:20 UTC (rev 11181)
+++ labs/jbossforums/branches/forums101P24/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java	2007-04-21 00:29:43 UTC (rev 11182)
@@ -25,11 +25,13 @@
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
+import java.util.Set;
 import javax.faces.FactoryFinder;
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
@@ -195,8 +197,206 @@
         {
         }
     };
-
 
+    private static User userNA = new User() 
+    {
+        {
+            this.id = new Long(-1);
+            this.userName = "N/A";
+        }
+        
+        protected Object id;
+        
+        protected String userName;
+        
+        public Object getId()
+        {
+            return id;
+        }
+
+        public boolean getEnabled()
+        {
+            return false;
+        }
+
+        public void setEnabled(boolean enabled)
+        {
+        }
+
+        public void updatePassword(String password)
+        {
+        }
+
+        public boolean validatePassword(String password)
+        {
+            return false;
+        }
+
+        public PropertyMap getProperties()
+        {
+            return properties;
+        }
+
+        public String getUserName()
+        {
+            return userName;
+        }
+
+        public String getGivenName()
+        {
+            return null;
+        }
+
+        public void setGivenName(String givenName)
+        {
+        }
+
+        public String getFamilyName()
+        {
+            return null;
+        }
+
+        public void setFamilyName(String familyName)
+        {
+        }
+
+        public String getRealEmail()
+        {
+            return null;
+        }
+
+        public void setRealEmail(String realEmail)
+        {
+        }
+
+        public String getFakeEmail()
+        {
+            return null;
+        }
+
+        public void setFakeEmail(String fakeEmail)
+        {
+        }
+
+        public Date getRegistrationDate()
+        {
+            return null;
+        }
+
+        public boolean getViewRealEmail()
+        {
+            return false;
+        }
+
+        public void setViewRealEmail(boolean viewRealEmail)
+        {
+        }
+
+        public Locale getPreferredLocale()
+        {
+            return null;
+        }
+
+        public void setPreferredLocale(Locale locale)
+        {
+        }
+
+        public String getSignature()
+        {
+            return null;
+        }
+
+        public void setSignature(String signature)
+        {
+        }
+
+        public Date getLastVisitDate()
+        {
+            return null;
+        }
+
+        public void setLastVisitDate(Date date)
+        {
+        }
+
+        public String getTheme()
+        {
+            return null;
+        }
+
+        public void setTheme(String theme)
+        {
+        }
+        
+        protected PropertyMap properties = new PropertyMap()
+        {
+
+           public boolean isReadOnly(Object key)
+           {
+              return true;
+           }
+
+           public int size()
+           {
+              return 0;
+           }
+
+           public boolean isEmpty()
+           {
+              return false;
+           }
+
+           public boolean containsKey(Object key)
+           {
+              return false;
+           }
+
+           public boolean containsValue(Object value)
+           {
+               return false;
+           }
+
+           public Object get(Object key)
+           {
+               return null;
+           }
+
+           public Object put(Object key, Object newValue) throws IllegalArgumentException
+           {
+               return null;
+           }
+
+           public Object remove(Object key) throws IllegalArgumentException
+           {
+               return null;
+           }
+
+           public void clear()
+           {
+           }
+     
+           public Set keySet()
+           {
+               return null;
+           }
+
+           public Collection values()
+           {
+               return null;
+           }
+
+           public Set entrySet()
+           {
+               return null;
+           }
+
+           public void putAll(Map map)
+           {
+           }
+        };
+        
+    };
+
     /**
      * 
      * 
@@ -536,8 +736,10 @@
             }
             String property = PortalUtil.userProperty(user.getProperties(), "INFO_USER_LAST_LOGIN_DATE");
             Calendar calendar = Calendar.getInstance();
-            calendar.setTimeInMillis(Long.parseLong(property));
-            return calendar.getTime();
+            if (property != null) {
+                calendar.setTimeInMillis(Long.parseLong(property));
+                return calendar.getTime();
+            }
         } catch (Exception e)
         {
             JSFUtil.handleException(e);
@@ -778,4 +980,9 @@
     {
         return (TempFileBinding) PortalUtil.uploadedAttachment.get();
     }
+    
+    public static User getUserNA() {
+        return userNA;
+    }
+    
 }




More information about the jboss-svn-commits mailing list