Scarab commit: svn commit: r10853 - branches/release/0.22/src/java/org/tigris/scarab/screens/ViewIssue.java

Johannes Höchstädter <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: jhoech
Date: 2009-09-23 05:19:58-0700
New Revision: 10853

Modified:
   branches/release/0.22/src/java/org/tigris/scarab/screens/ViewIssue.java

Log:
FIX - SCB2998 Proper suffix (and prefix) handling for entered issue ids in quick access field.

Modified: branches/release/0.22/src/java/org/tigris/scarab/screens/ViewIssue.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/release/0.22/src/java/org/tigris/scarab/screens/ViewIssue.java?view=diff&pathrev=10853&r1=10852&r2=10853
==============================================================================
--- branches/release/0.22/src/java/org/tigris/scarab/screens/ViewIssue.java	(original)
+++ branches/release/0.22/src/java/org/tigris/scarab/screens/ViewIssue.java	2009-09-23 05:19:58-0700
@@ -122,19 +122,51 @@
         }
     }
     
+    /**
+     * Returns issue according to given issue id,
+     * which can be a simple number or an id including module's prefix.
+     * @param id : id of issue
+     * @param module : module for issue
+     * @return : Issue. Value is null if no issue was found.
+     */
     private Issue getReferredIssue(String id, ScarabModule module)
     {
-        if (module != null)
-        { // Will prefix with module's code if ID is just a number
-            try
+    	Issue issue = null;
+    	
+    	//get simple number from id
+    	StringBuffer idCount = new StringBuffer();
+    	for (int i = 0; i < id.length(); i++)
+        {
+            char c = id.charAt(i);
+            if (c >= '0' && c <= '9')
             {
-                Integer.parseInt(id);
-                id = module.getCode().concat(id);
+            	idCount.append(c);
             }
-            catch (NumberFormatException nfe) {}
         }
-        
-        Issue issue = IssueManager.getIssueById(id);
+    	
+        if (module != null)
+        { // Will prefix with module's code if ID is just a number
+        	if(!idCount.toString().equals(id)){
+        		if(module.getCode().concat(idCount.toString()).equals(id)){
+        			//id is full qualified issue id (includes prefix)
+        			issue = IssueManager.getIssueById(id);
+        		}
+        		else{
+        			//invalid suffix in issue id
+        			issue = null;
+        		}
+        	}
+        	else{
+        		//id is number only
+            	issue = IssueManager.getIssueById(id, module.getCode());
+        	}
+        	
+        }
+        else{
+        	//no module is given, business of hope
+        	issue = IssueManager.getIssueById(id);
+        }
+
         return issue;
     }

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