Scarab commit: svn commit: r10911 - trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2010-02-17 10:24:30-0800
New Revision: 10911

Modified:
   trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java

Log:
ScarabRequestTool.getRModuleUserAttributes() sometimes throws an NPE if the current Query does not belong to a user or belongs to an unknown user (deleted from the database(?) Now the method returns an empty List if the Query owner could not be determined.

Modified: trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java?view=diff&pathrev=10911&r1=10910&r2=10911
==============================================================================
--- trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java	(original)
+++ trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java	2010-02-17 10:24:30-0800
@@ -81,6 +81,7 @@
 import org.apache.turbine.Turbine;
 import org.apache.turbine.services.pull.ApplicationTool;
 import org.apache.turbine.tool.IntakeTool;
+import org.radeox.util.logging.Logger;
 import org.tigris.scarab.attribute.DateAttribute;
 import org.tigris.scarab.om.Attachment;
 import org.tigris.scarab.om.AttachmentManager;
@@ -738,6 +739,20 @@
             ScarabUser me       = (ScarabUser)data.getUser();  // the userId of the current user
             MITList currentList = q.getMITList();              // The query MIT-list
             ScarabUser owner    = q.getScarabUser();           // The originator of the query
+            if(owner==null)
+            {
+                Log.get().warn("Current Query does not contain a User");
+                owner = me;
+                if(owner == null)
+                {
+                    owner = this.getCurrentUser();
+                    if(owner == null)
+                    {
+                        Log.get().warn("Current session has no user assigned. Can not retrieve RModuleUserAttributes.");
+                        return result;
+                    }
+                }
+            }
             Module module       = me.getCurrentModule();       // The current module
             IssueType theIssueType = this.getIssueType();      // The current issue Type
             currentList = currentList.copy();                  // Here we make a physical copy

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2448498
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.