Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-08-13 19:32:56 +0000
committerfbecker2010-08-13 19:32:56 +0000
commit76b454c52bd4114d64dd02c6fc034ae5f3912daa (patch)
treed6fa17913638f43c3e136ce93c95049ba4c3a1a7 /org.eclipse.mylyn.bugzilla.core
parentf764c737fbace31c9f8d0a01ba9e8298ecaa186a (diff)
downloadorg.eclipse.mylyn.tasks-76b454c52bd4114d64dd02c6fc034ae5f3912daa.tar.gz
org.eclipse.mylyn.tasks-76b454c52bd4114d64dd02c6fc034ae5f3912daa.tar.xz
org.eclipse.mylyn.tasks-76b454c52bd4114d64dd02c6fc034ae5f3912daa.zip
ASSIGNED - bug 314744: support defaultmilestone from Product.get XMLRPC
https://bugs.eclipse.org/bugs/show_bug.cgi?id=314744
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java30
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java9
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/CustomTransitionManager.java13
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java36
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/service/BugzillaXmlRpcClient.java43
5 files changed, 101 insertions, 30 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index b3b1cf6e2..565a6489e 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -71,6 +71,7 @@ import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer;
import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token;
import org.eclipse.mylyn.commons.net.HtmlTag;
import org.eclipse.mylyn.commons.net.Policy;
+import org.eclipse.mylyn.commons.net.WebLocation;
import org.eclipse.mylyn.commons.net.WebUtil;
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
@@ -179,7 +180,7 @@ public class BugzillaClient {
private final BugzillaRepositoryConnector connector;
- private BugzillaXmlRpcClient xmlRpcClient;
+ private BugzillaXmlRpcClient xmlRpcClient = null;
public BugzillaClient(AbstractWebLocation location, String characterEncoding, Map<String, String> configParameters,
BugzillaLanguageSettings languageSettings, BugzillaRepositoryConnector connector)
@@ -219,6 +220,14 @@ public class BugzillaClient {
WebUtil.releaseConnection(method, monitor);
}
}
+ CustomTransitionManager validTransitions = new CustomTransitionManager();
+
+ String transitionsFileName = configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE);
+ if (!validTransitions.parse(transitionsFileName)) {
+ throw new CoreException(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN,
+ "Invalide Transition File Content")); //$NON-NLS-1$
+ }
+
}
protected boolean hasAuthenticationCredentials() {
@@ -689,18 +698,20 @@ public class BugzillaClient {
}
if (repositoryConfiguration != null) {
- boolean useXml = Boolean.parseBoolean(configParameters.get(IBugzillaConstants.BUGZILLA_USE_XMLRPC));
+ boolean useXMLRPC = Boolean.parseBoolean(configParameters.get(IBugzillaConstants.BUGZILLA_USE_XMLRPC));
+ if (useXMLRPC && xmlRpcClient == null) {
+ WebLocation webLocation = new WebLocation(this.repositoryUrl + "/xmlrpc.cgi"); //$NON-NLS-1$
+ xmlRpcClient = new BugzillaXmlRpcClient(webLocation);
+
+ }
if (!repositoryConfiguration.getProducts().isEmpty()) {
repositoryConfiguration.setRepositoryUrl(repositoryUrl.toString());
-
- repositoryConfiguration.setValidTransitions(monitor,
- configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE),
- useXml);
+ }
+ xmlRpcClient.updateConfiguration(monitor, repositoryConfiguration,
+ configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE));
+ if (!repositoryConfiguration.getProducts().isEmpty()) {
return repositoryConfiguration;
} else {
- repositoryConfiguration.setValidTransitions(monitor,
- configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE),
- useXml);
if (attempt == 0) {
// empty configuration, retry authenticate
loggedIn = false;
@@ -711,7 +722,6 @@ public class BugzillaClient {
"No products found in repository configuration. Ensure credentials are valid.")); //$NON-NLS-1$
}
}
-
}
}
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
index 20b58548e..14397094f 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java
@@ -507,7 +507,14 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
for (String option : optionValues) {
attributeTargetMilestone.putOption(option, option);
}
- attributeTargetMilestone.setValue(optionValues.get(0));
+ if (repositoryConfiguration != null && product != null && !product.equals("")) { //$NON-NLS-1$
+ String defaultMilestone = repositoryConfiguration.getDefaultMilestones(product);
+ if (defaultMilestone != null) {
+ attributeTargetMilestone.setValue(defaultMilestone);
+ }
+ } else {
+ attributeTargetMilestone.setValue(optionValues.get(0));
+ }
}
}
TaskAttribute attributePlatform = createAttribute(taskData, BugzillaAttribute.REP_PLATFORM);
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/CustomTransitionManager.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/CustomTransitionManager.java
index 87647fa2d..769061f70 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/CustomTransitionManager.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/CustomTransitionManager.java
@@ -55,24 +55,18 @@ public class CustomTransitionManager implements Serializable {
private boolean valid = false;
- private boolean fromFile = false;
-
private String filePath;
private String duplicateStatus;
private String startStatus;
- private boolean usedXml;
-
public CustomTransitionManager() {
operationMapByCurrentStatus = new HashMap<String, List<AbstractBugzillaOperation>>();
operationMapByEndStatus = new HashMap<String, List<AbstractBugzillaOperation>>();
closedStatuses = new ArrayList<String>();
this.valid = false;
this.filePath = ""; //$NON-NLS-1$
- this.fromFile = false;
- this.usedXml = false;
duplicateStatus = DEFAULT_DUPLICATE_STATUS;
startStatus = DEFAULT_START_STATUS;
}
@@ -93,7 +87,6 @@ public class CustomTransitionManager implements Serializable {
//Do nothing, already parsed this file
return false;
}
- fromFile = true;
this.filePath = filePath;
setValid(true);
@@ -320,10 +313,6 @@ public class CustomTransitionManager implements Serializable {
}
public void parse(IProgressMonitor monitor, BugzillaXmlRpcClient xmlClient) {
-// if (usedXml) {
-// //XMLRPC should not change, don't look it up again
-// return;
-// }
this.filePath = ""; //$NON-NLS-1$
operationMapByCurrentStatus.clear();
operationMapByEndStatus.clear();
@@ -366,8 +355,6 @@ public class CustomTransitionManager implements Serializable {
}
setValid(true);
- usedXml = true;
- fromFile = false;
} catch (XmlRpcException e) {
setValid(false);
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
index 8df2b5c7a..a624021ae 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java
@@ -22,7 +22,6 @@ import java.util.Locale;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.mylyn.commons.net.WebLocation;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_REPORT_STATUS;
import org.eclipse.mylyn.internal.bugzilla.core.service.BugzillaXmlRpcClient;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
@@ -271,6 +270,8 @@ public class RepositoryConfiguration implements Serializable {
List<String> milestones = new ArrayList<String>();
+ String defaultMilestone = null;
+
ProductEntry(String name) {
this.productName = name;
}
@@ -302,6 +303,14 @@ public class RepositoryConfiguration implements Serializable {
void addTargetMilestone(String target) {
milestones.add(target);
}
+
+ public String getDefaultMilestone() {
+ return defaultMilestone;
+ }
+
+ public void setDefaultMilestone(String defaultMilestone) {
+ this.defaultMilestone = defaultMilestone;
+ }
}
public List<String> getOpenStatusValues() {
@@ -346,7 +355,7 @@ public class RepositoryConfiguration implements Serializable {
*
* @param fileName
*/
- public void setValidTransitions(IProgressMonitor monitor, String fileName, boolean useXmlRpc) {
+ public void setValidTransitions(IProgressMonitor monitor, String fileName, BugzillaXmlRpcClient xmlClient) {
//Custom transitions only possible for newer versions of Bugzilla
if (getInstallVersion() != null && getInstallVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_2) < 0) {
return;
@@ -354,12 +363,10 @@ public class RepositoryConfiguration implements Serializable {
if (validTransitions == null) {
validTransitions = new CustomTransitionManager();
}
- if (!validTransitions.parse(fileName) && useXmlRpc) {
+ if (!validTransitions.parse(fileName) && xmlClient != null) {
if (getRepositoryUrl().equals("<unknown>")) { //$NON-NLS-1$
return; //This occurs during testing
}
- WebLocation webLocation = new WebLocation(getRepositoryUrl() + "/xmlrpc.cgi"); //$NON-NLS-1$
- BugzillaXmlRpcClient xmlClient = new BugzillaXmlRpcClient(webLocation);
validTransitions.parse(monitor, xmlClient);
}
}
@@ -934,4 +941,23 @@ public class RepositoryConfiguration implements Serializable {
public String getStartStatus() {
return (validTransitions == null) ? "NEW" : validTransitions.getStartStatus(); //$NON-NLS-1$
}
+
+ public String getDefaultMilestones(String product) {
+ ProductEntry entry = products.get(product);
+ if (entry != null) {
+ return entry.getDefaultMilestone();
+ } else {
+ return null;
+ }
+ }
+
+ public void setDefaultMilestone(String product, String defaultMilestone) {
+ ProductEntry entry = products.get(product);
+ if (entry == null) {
+ entry = new ProductEntry(product);
+ products.put(product, entry);
+ }
+ entry.setDefaultMilestone(defaultMilestone);
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/service/BugzillaXmlRpcClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/service/BugzillaXmlRpcClient.java
index c81180b51..708ceb354 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/service/BugzillaXmlRpcClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/service/BugzillaXmlRpcClient.java
@@ -16,10 +16,15 @@ import java.util.HashMap;
import org.apache.commons.httpclient.HttpClient;
import org.apache.xmlrpc.XmlRpcException;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
+import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.commons.xmlrpc.CommonXmlRpcClient;
@SuppressWarnings("restriction")
@@ -284,7 +289,7 @@ public class BugzillaXmlRpcClient extends CommonXmlRpcClient {
}).execute();
}
- public Object[] getProducts(final IProgressMonitor monitor, final Integer[] ids) throws XmlRpcException {
+ public Object[] getProducts(final IProgressMonitor monitor, final Object[] ids) throws XmlRpcException {
return (new BugzillaXmlRpcOperation<Object[]>(this) {
@SuppressWarnings("serial")
@Override
@@ -358,4 +363,40 @@ public class BugzillaXmlRpcClient extends CommonXmlRpcClient {
return result;
}
+ public void updateConfiguration(IProgressMonitor monitor, RepositoryConfiguration repositoryConfiguration,
+ String fileName) throws CoreException {
+ repositoryConfiguration.setValidTransitions(monitor, fileName, this);
+ if (!repositoryConfiguration.getProducts().isEmpty()) {
+ updateProductInfo(monitor, repositoryConfiguration);
+ }
+ }
+
+ public void updateProductInfo(IProgressMonitor monitor, RepositoryConfiguration repositoryConfiguration)
+ throws CoreException {
+ try {
+ Object[] productIDs = getAccessibleProducts(monitor);
+ Object[] products = getProducts(monitor, productIDs);
+ for (Object object : products) {
+ if (object instanceof HashMap<?, ?>) {
+ String defaultMilestone = null;
+ String product = (String) ((HashMap<?, ?>) object).get("name"); //$NON-NLS-1$
+ HashMap<?, ?> values = (HashMap<?, ?>) ((HashMap<?, ?>) object).get("internals"); //$NON-NLS-1$
+ if (values == null) {
+ continue;
+ }
+ if (values instanceof HashMap<?, ?>) {
+ defaultMilestone = (String) ((HashMap<?, ?>) values).get("defaultmilestone"); //$NON-NLS-1$
+ }
+ if (product != null && !product.equals("") //$NON-NLS-1$
+ && defaultMilestone != null && !defaultMilestone.equals("")) { //$NON-NLS-1$
+ repositoryConfiguration.setDefaultMilestone(product, defaultMilestone);
+ }
+ }
+ }
+ } catch (XmlRpcException e) {
+ throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
+ "Can not get the Default Milestons using XMLRPC")); //$NON-NLS-1$
+ }
+
+ }
}

Back to the top