Scarab commit: svn commit: r10910 - 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:08:37-0800
New Revision: 10910

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

Log:
ScarabRequestTool.getQuery() the condition handling when to return a new Query instance was not clean. Now the last used query is returned, except when the data instance contains a queryId. In that case a new Query is returned. If no query exists nor a queryId, then a default Query is returned. Hence it is now guaranteed that this method always returns a Query instance!

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=10910&r1=10909&r2=10910
==============================================================================
--- trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java	(original)
+++ trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java	2010-02-17 10:08:37-0800
@@ -822,13 +822,17 @@
     }
 
     /**
-     * A Query object for use within the Scarab API.
+     * A Query object for use within the Scarab API. This method first checks if the
+     * current active data element contains a parameter of name "queryId". If that 
+     * parameter is found, the corresponding query is returned.
+     * Otherwise the last query ever created on this ScarabRequestTool-instance is returned.
+     * If there was no query used before, a default query is returned instead.
      */
     public Query getQuery() throws TorqueException
     {
-        if (query == null)
+        String queryId = data.getParameters().getString("queryId");
+        if (queryId != null || query == null)
         {
-            String queryId = data.getParameters().getString("queryId");
             query = getQuery(queryId);
         }
         return query;
@@ -836,7 +840,8 @@
 
     
     /**
-     * A Query object for use within the Scarab API.
+     * A Query object for use within the Scarab API. If QueryId is null,
+     * then a default Query is returned.
      * Used for shortlink to query (similar to short URL to issueId)
      */
     private Query getQuery(String queryId) throws TorqueException

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2448488
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.