1 package org.tigris.scarab.actions.base; 2 3 48 49 import java.util.Iterator ; 50 import java.util.List ; 51 import java.util.ArrayList ; 52 53 import org.apache.turbine.TemplateContext; 55 import org.apache.turbine.RunData; 56 57 import org.tigris.scarab.om.IssueManager; 59 import org.tigris.scarab.om.Issue; 60 import org.tigris.scarab.om.ActivitySet; 61 import org.tigris.scarab.tools.ScarabRequestTool; 62 import org.tigris.scarab.tools.ScarabLocalizationTool; 63 64 71 public class BaseModifyIssue extends RequireLoginFirstAction 72 { 73 protected boolean isCollision(RunData data, TemplateContext context) 74 throws Exception 75 { 76 boolean isCollision = false; 77 ScarabRequestTool scarabR = getScarabRequestTool(context); 78 ScarabLocalizationTool l10n = getLocalizationTool(context); 79 long modTimestamp = data.getParameters().getLong("mod_ts"); 80 81 String id = data.getParameters().getString("id"); 82 if (id == null) 83 { 84 List issues = scarabR.getIssues(); 85 List conflictIssues = new ArrayList (issues.size()); 86 Iterator iter = issues.iterator(); 87 while (iter.hasNext()) 88 { 89 Issue issue = (Issue)iter.next(); 90 long lastModTime = issue.getModifiedDate().getTime(); 91 boolean isSingleCollision = modTimestamp < lastModTime; 92 if (isSingleCollision) 93 { 94 isCollision = true; 95 scarabR.setAlertMessage( 96 l10n.get("MultiIssueChangeCollision")); 97 ActivitySet lastActivitySet = issue.getLastActivitySet(); 98 ArrayList objs = new ArrayList (2); 99 objs.add(issue); 100 objs.add(lastActivitySet); 101 conflictIssues.add(objs); 102 } 103 } 104 context.put("lastActivities", conflictIssues); 105 } 106 else 107 { 108 Issue issue = IssueManager.getIssueById(id); 109 List conflictIssues = new ArrayList (1); 110 long lastModTime = issue.getModifiedDate().getTime(); 111 isCollision = modTimestamp < lastModTime; 112 if (isCollision) 113 { 114 scarabR.setAlertMessage(l10n.get("IssueChangeCollision")); 115 ActivitySet lastActivitySet = issue.getLastActivitySet(); 116 ArrayList objs = new ArrayList (2); 117 objs.add(issue); 118 objs.add(lastActivitySet); 119 conflictIssues.add(objs); 120 context.put("lastActivities", conflictIssues); 121 } 122 } 123 return isCollision; 124 } 125 } 126 | Popular Tags |