|
From: <lac...@us...> - 2007-10-04 11:17:46
|
Revision: 44
http://td2jira.svn.sourceforge.net/td2jira/?rev=44&view=rev
Author: lacostej
Date: 2007-10-04 04:17:49 -0700 (Thu, 04 Oct 2007)
Log Message:
-----------
allow to switch TD from read-only to read-write (defaults to read-only).
Modified Paths:
--------------
trunk/td2jira/docs/ReleaseNotes.txt
trunk/td2jira/etc/td2jira.properties.example
trunk/td2jira/src/td2jira/Config.java
trunk/td2jira/src/td2jira/sync/SyncUtils.java
Modified: trunk/td2jira/docs/ReleaseNotes.txt
===================================================================
--- trunk/td2jira/docs/ReleaseNotes.txt 2007-10-04 11:12:18 UTC (rev 43)
+++ trunk/td2jira/docs/ReleaseNotes.txt 2007-10-04 11:17:49 UTC (rev 44)
@@ -11,5 +11,6 @@
to latest jacob to I am not sure these problems affect the v9 of the td API implementation.
The fixes in dcomv8/Bug.java might need to be backported to v9 support.
* FEATURE Create JIRA issues with the right assignee
+* FEATURE allow to switch TD from read-only to read-write (defaults to read-only).
Old release
Modified: trunk/td2jira/etc/td2jira.properties.example
===================================================================
--- trunk/td2jira/etc/td2jira.properties.example 2007-10-04 11:12:18 UTC (rev 43)
+++ trunk/td2jira/etc/td2jira.properties.example 2007-10-04 11:17:49 UTC (rev 44)
@@ -23,6 +23,8 @@
td.domain=FILLME
td.project=FILLME
td.lead=FILLME
+# comment this out to make td read-write.
+# td.readonly=false
# JIRA connection data (td2jira account won't probably exist; you'll need to Signup first!)
jira.url=http://FILLME:FILLME
Modified: trunk/td2jira/src/td2jira/Config.java
===================================================================
--- trunk/td2jira/src/td2jira/Config.java 2007-10-04 11:12:18 UTC (rev 43)
+++ trunk/td2jira/src/td2jira/Config.java 2007-10-04 11:17:49 UTC (rev 44)
@@ -34,6 +34,7 @@
public static String TD_DOMAIN = "td.domain";
public static String TD_PROJECT = "td.project";
public static String TD_USER = "td.user";
+ public static String TD_READ_ONLY = "td.readonly";
public static String TD_PASSWORD = "td.password";
public static String JIRA_ASSIGN_NEW_ISSUE_TO = "jira.assign.to";
public static String TD_LEAD = "td.lead";
Modified: trunk/td2jira/src/td2jira/sync/SyncUtils.java
===================================================================
--- trunk/td2jira/src/td2jira/sync/SyncUtils.java 2007-10-04 11:12:18 UTC (rev 43)
+++ trunk/td2jira/src/td2jira/sync/SyncUtils.java 2007-10-04 11:17:49 UTC (rev 44)
@@ -1,11 +1,11 @@
package td2jira.sync;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.List;
import java.util.Set;
+import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.text.SimpleDateFormat;
import org.apache.log4j.Logger;
@@ -22,7 +22,13 @@
public class SyncUtils {
private static Logger logger = Logger.getLogger(SyncUtils.class);
+ /**
+ * only update TD is this is false
+ */
+ private static boolean readOnlyTD = true; // TODO parametrize this
+
public static void sync(ITDConnector tc, IJIRAConnector jc, IssuePair pair) throws Exception {
+ initTDReadOnly();
List<Comment> tdComments = tc.getComments(pair.getTdIssue());
List<JIRAComment> jiraComments = jc.getComments(pair.getJiraIssue());
@@ -34,6 +40,14 @@
syncAssigneeToTD(tc, pair);
}
+ /**
+ * only enable writing to TD if user really marked Config.TD_READ_ONLY as 'false'
+ */
+ private static void initTDReadOnly() {
+ readOnlyTD = !Config.TD_READ_ONLY.equals("false");
+ logger.info("TD is " + (readOnlyTD ? "read-only" : "read-write"));
+ }
+
public static void syncAttachmentsToJIRA(ITDConnector tc, IJIRAConnector jc, IssuePair pair) {
if (!tc.hasAttachments(pair.getTdIssue())) return;
@@ -71,6 +85,8 @@
// tell TD users up-to-date information on developers assignments
private static void syncAssigneeToTD(ITDConnector tc, IssuePair pair) {
+ if (readOnlyTD)
+ return;
IBug tdIssue = pair.getTdIssue();
if (!tdIssue.getStatus().equals("Assigned")) return;
@@ -93,6 +109,8 @@
}
private static void syncCommentsToTD(ITDConnector tc, IssuePair pair, List<JIRAComment> jiraComments, List<Comment> tdComments) throws Exception {
+ if (readOnlyTD)
+ return;
IBug tdIssue = pair.getTdIssue();
for (JIRAComment jiraComment : jiraComments) {
@@ -205,6 +223,8 @@
pair.setTdIssue(tdIssue);
sync(tdConnector, jiraConnector, pair);
+ if (readOnlyTD)
+ return jt;
Comment tdc = new Comment();
tdc.setAuthor(Config.TD_ROBOT_NAME);
tdc.setCreated(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|