Scarab commit: svn commit: r10807 - trunk/src/java/org/tigris/scarab: om tools

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2009-07-17 15:30:06-0700
New Revision: 10807

Modified:
   trunk/src/java/org/tigris/scarab/om/Issue.java
   trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java

Log:
SCB2982: 

If an issue was in the sealed state (according to the predefined properties as described in the issue)
but the user was the owner of the issue or the active assignee, the issue was always opening in edit mode.
i fixed this and added a nice api method to the Issue.class which allows to ask the issue if
it boolean isSealed()

Modified: trunk/src/java/org/tigris/scarab/om/Issue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/Issue.java?view=diff&pathrev=10807&r1=10806&r2=10807
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/Issue.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/Issue.java	2009-07-17 15:30:06-0700
@@ -4256,7 +4256,44 @@
         
         return new SimpleSkipFiltering(prepend+result);
     }     
+
+    /**
+     * Check if the properties scarab.common.status.id and scarab.common.status.sealed
+     * exist and if the current value of the status attribute matches the sealed
+     * value. Return true, if the issue is in the sealed state, otherwise return false.
+     * This method is used to find out if an issue shoul dbe rendered read-only
+     * because it is in closed (sealed) state and should never be touched again.
+     * @return
+     * @throws TorqueException
+     */
+    public boolean isSealed() throws TorqueException
+    {        
+        boolean result = false;
+        String status = getProperty("scarab.common.status.id", null);
+        if (status != null)
+        {
+            String value = getProperty("scarab.common.status.sealed", null);
+            if(value != null)
+            {
+                AttributeValue attval = getAttributeValue(status);
+                if(attval != null && attval.getValue().equals(value))
+                {
+                    result = true;
+                }
+            }
+        }
+        return result;
+    }
     
+    private String getProperty(String prop, String def)
+    {
+        String result = (String)Turbine.getConfiguration().getProperty(prop);
+        if(result == null)
+        {
+            result = def;
+        }
+        return result;
+    }
     
     
 }

Modified: trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java?view=diff&pathrev=10807&r1=10806&r2=10807
==============================================================================
--- trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java	(original)
+++ trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java	2009-07-17 15:30:06-0700
@@ -158,6 +158,10 @@
                                                   "default");
         if(behaviour.equals("smart"))
         {
+            if(issue.isSealed())
+            {
+                return false; // don't open this issue in edit mode, because it is sealed!
+            }
             // Check if user is assigned to issue.
             // If that is the case, open the issue
             // in edit mode per default.

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