Scarab commit: svn commit: r10762 - trunk/src: java/org/tigris/scarab/actions webapp/WEB-INF/templates/viewIssue
Hussayn Dabbous <[email protected]>
| Newsgroups | gmane.comp.java.scarab.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: dabbous
Date: 2009-06-21 10:00:12-0700
New Revision: 10762
Modified:
trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java
trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm
Log:
SCB2818: Fixed a bug introduced in last commit. The visibility controll of the ReasonField created an NPE during Issue Save.
Modified: trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java?view=diff&pathrev=10762&r1=10761&r2=10762
==============================================================================
--- trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java (original)
+++ trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java 2009-06-21 10:00:12-0700
@@ -56,6 +56,7 @@
import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.fileupload.FileItem;
+import org.apache.fulcrum.ServiceException;
import org.apache.fulcrum.intake.model.Field;
import org.apache.fulcrum.intake.model.Group;
import org.apache.fulcrum.parser.ParameterParser;
@@ -113,6 +114,8 @@
public class ModifyIssue extends BaseModifyIssue
{
+ private static enum REASON_SAVE_MODE { NONE, HISTORY, COMMENT };
+
public void doSubmitattributes(RunData data, TemplateContext context)
throws Exception
{
@@ -146,35 +149,7 @@
// Reason field is required to modify attributes
final Group reasonGroup = intake.get("Attachment", "attCommentKey" + issue.getQueryKey(), false);
- final Field reasonField = reasonGroup.get("Data");
-
- if(isReasonRequired)
- {
- reasonField.setRequired(true);
- }
-
- // make sure to trim the whitespace
- String reasonFieldString = reasonField.toString();
- if (reasonFieldString != null)
- {
- reasonFieldString = reasonFieldString.trim();
- }
- String saveAsFieldString = data.getParameters().get("saveReasonAs");
- if (saveAsFieldString != null)
- {
- saveAsFieldString = saveAsFieldString.trim();
- }
- final boolean saveAsComment = "Comment".equalsIgnoreCase(saveAsFieldString);
-
- if (reasonGroup == null || !reasonField.isValid() ||
- reasonFieldString.length() == 0)
- {
- if (isReasonRequired)
- {
- reasonField.setMessage(
- "ExplanatoryReasonRequiredToModifyAttributes");
- }
- }
+ REASON_SAVE_MODE reasonSaveMode = saveReason(data, isReasonRequired, reasonGroup);
// Set any other required flags
final Map selectedOptions = new HashMap();
@@ -289,7 +264,7 @@
if (intake.isAllValid() && attributeValuesValid && !localFieldErrors)
{
- submitattributesPerform(context, user, saveAsComment);
+ submitattributesPerform(context, user, reasonSaveMode);
}
else
{
@@ -300,6 +275,56 @@
data.getParameters().add("fullcomments", data.getParameters().get("fullcomments"));
}
}
+
+ /**
+ * return
+ * @param data
+ * @param isReasonRequired
+ * @param reasonGroup
+ * @return
+ * @throws ServiceException
+ */
+
+
+ private REASON_SAVE_MODE saveReason(RunData data, final boolean isReasonRequired,
+ final Group reasonGroup) throws ServiceException
+ {
+ REASON_SAVE_MODE saveMode = REASON_SAVE_MODE.NONE;
+ if(reasonGroup != null)
+ {
+ // The reasonField is visible, so we can process it
+ final Field reasonField = reasonGroup.get("Data");
+
+ if(isReasonRequired)
+ {
+ reasonField.setRequired(true);
+ }
+
+ // make sure to trim the whitespace
+ String reasonFieldString = reasonField.toString();
+ if (reasonFieldString != null)
+ {
+ reasonFieldString = reasonFieldString.trim();
+ }
+ String saveAsFieldString = data.getParameters().get("saveReasonAs");
+ if (saveAsFieldString != null)
+ {
+ saveAsFieldString = saveAsFieldString.trim();
+ }
+ final boolean saveAsComment = "Comment".equalsIgnoreCase(saveAsFieldString);
+ saveMode = (saveAsComment)? REASON_SAVE_MODE.COMMENT:REASON_SAVE_MODE.HISTORY;
+
+ if (!reasonField.isValid() || reasonFieldString.length() == 0)
+ {
+ if (isReasonRequired)
+ {
+ reasonField.setMessage(
+ "ExplanatoryReasonRequiredToModifyAttributes");
+ }
+ }
+ }
+ return saveMode;
+ }
/**
* Now that we have all the info, we will force the 'required' status of any field
@@ -377,7 +402,7 @@
private void submitattributesPerform(
final TemplateContext context,
final ScarabUser user,
- final boolean saveAsComment)
+ REASON_SAVE_MODE saveMode)
throws Exception
{
@@ -454,7 +479,8 @@
}
}
}
- if (!modifiedAttribute && !saveAsComment)
+
+ if (!modifiedAttribute && saveMode!=REASON_SAVE_MODE.NONE)
{
scarabR.setAlertMessage(L10NKeySet.MustModifyAttribute);
return;
@@ -469,15 +495,18 @@
final ActivitySet activitySet = issue.setAttributeValues(null,
newAttVals, attachment, user);
// save reason as a comment as well?
- if( saveAsComment )
- {
- issue.addComment(activitySet, attachment, user);
- }
- else
+ if(saveMode!=REASON_SAVE_MODE.NONE)
{
- NotificationManagerFactory.getInstance().addActivityNotification(
- ActivityType.ATTRIBUTE_CHANGED,
- activitySet, issue, user);
+ if( saveMode == REASON_SAVE_MODE.COMMENT )
+ {
+ issue.addComment(activitySet, attachment, user);
+ }
+ else
+ {
+ NotificationManagerFactory.getInstance().addActivityNotification(
+ ActivityType.ATTRIBUTE_CHANGED,
+ activitySet, issue, user);
+ }
}
intake.removeAll();
scarabR.setConfirmMessage(L10NKeySet.ChangesSaved);
Modified: trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm?view=diff&pathrev=10762&r1=10761&r2=10762
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm (original)
+++ trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm 2009-06-21 10:00:12-0700
@@ -140,29 +140,32 @@
</div>
#set ($reasonIsVisible = $module.isIssueReasonVisible() )
- #if ($isEditAttributes && $reasonIsVisible)
- #set ($reasonIsRequired = $module.isIssueReasonRequired() )
- <h4>$l10n.SaveChanges#if($reasonIsRequired) #asterisk()#end</h4>
- <div class="axial">
- #set ($attCommentGroup = $intake.Attachment.setKey("attCommentKey$currentIssue.QueryKey"))
+ #if ($isEditAttributes)
+ #set ($attCommentGroup = $intake.Attachment.setKey("attCommentKey$currentIssue.QueryKey"))
+ #if ($reasonIsVisible)
+ #set ($reasonIsRequired = $module.isIssueReasonRequired() )
+ <h4>$l10n.SaveChanges#if($reasonIsRequired) #asterisk()#end</h4>
+ <div class="axial">
+ <table cellpadding="3" cellspacing="2" border="0" width="100%">
+ <tr>
+ <th nowrap="nowrap">#if($reasonIsRequired)#showAsterisk()#end$l10n.ReasonSavedAs</th>
+ <td>
+ <input type="radio" name="saveReasonAs" value="history" checked="checked"> $l10n.History</input>
+ #if ($canAddComment)
+ <input type="radio" name="saveReasonAs" value="comment" > $l10n.Comment </input>
+ #end
+ $l10n.EnterReasonAs
- <table cellpadding="3" cellspacing="2" border="0" width="100%">
- <tr>
- <th nowrap="nowrap">#if($reasonIsRequired)#showAsterisk()#end$l10n.ReasonSavedAs</th>
- <td>
- <input type="radio" name="saveReasonAs" value="history" checked="checked"> $l10n.History</input>
- #if ($canAddComment)
- <input type="radio" name="saveReasonAs" value="comment" > $l10n.Comment </input>
- #end
- $l10n.EnterReasonAs
-
- #fieldErrorMsg($attCommentGroup.Data "")
- <p>#textAreaMedium("$attCommentGroup.Data.Key" $attCommentGroup.Data.Value)</p>
- <input type="hidden" name="$attCommentGroup.Name.Key" value="comment" />
- </td>
- </tr>
- </table>
- </div>
+ #fieldErrorMsg($attCommentGroup.Data "")
+ <p>#textAreaMedium("$attCommentGroup.Data.Key" $attCommentGroup.Data.Value)</p>
+ </td>
+ </tr>
+ </table>
+ </div>
+ #else
+ <input type="hidden" name="$attCommentGroup.Data.Key" value="" />
+ #end
+ <input type="hidden" name="$attCommentGroup.Name.Key" value="comment" />
#end
#if($canEdit)
------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2363973