Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-09-06 19:19:01 +0000
committerfbecker2010-09-06 19:19:01 +0000
commitee50c8d894165538090c601936ba01201dd4a8b3 (patch)
tree8ffd1eb58ee58e4feb0898a019ad19afc213e806 /org.eclipse.mylyn.bugzilla.core
parent68dcdcbb1621b1be81f7ece47f9bffdae0ebb7f8 (diff)
downloadorg.eclipse.mylyn.tasks-ee50c8d894165538090c601936ba01201dd4a8b3.tar.gz
org.eclipse.mylyn.tasks-ee50c8d894165538090c601936ba01201dd4a8b3.tar.xz
org.eclipse.mylyn.tasks-ee50c8d894165538090c601936ba01201dd4a8b3.zip
ASSIGNED - bug 324525: Repository Settings Page and custom status workflow problems
https://bugs.eclipse.org/bugs/show_bug.cgi?id=324525
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java71
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/CustomTransitionManager.java14
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java24
4 files changed, 97 insertions, 15 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
index 7ef42677c..39f9ef804 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
@@ -19,19 +19,30 @@ 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.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.mylyn.internal.tasks.core.IRepositoryChangeListener;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryChangeEvent;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta.Type;
import org.eclipse.mylyn.tasks.core.IRepositoryListener;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.sync.TaskJob;
/**
* @author Steffen Pingel
* @author Robert Elves (adaption for Bugzilla)
*/
-public class BugzillaClientManager implements IRepositoryListener {
+public class BugzillaClientManager implements IRepositoryListener, IRepositoryChangeListener {
private final Map<String, BugzillaClient> clientByUrl = new HashMap<String, BugzillaClient>();
private final BugzillaRepositoryConnector connector;
+ private JobChangeAdapter repositoryConfigurationUpdateJobChangeAdapter;
+
public BugzillaClientManager(BugzillaRepositoryConnector connector) {
this.connector = connector;
}
@@ -85,4 +96,62 @@ public class BugzillaClientManager implements IRepositoryListener {
public void repositoryUrlChanged(TaskRepository repository, String oldUrl) {
// ignore
}
+
+ @SuppressWarnings("restriction")
+ public void repositoryChanged(TaskRepositoryChangeEvent event) {
+ Type type = event.getDelta().getType();
+ if (type == TaskRepositoryDelta.Type.PROPERTY) {
+ Object key = event.getDelta().getKey();
+ if (IBugzillaConstants.BUGZILLA_USE_XMLRPC.equals(key)
+ || IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE.equals(key)) {
+ final TaskRepository repository = event.getRepository();
+ TaskJob updateJob = new TaskJob("Refreshing repository configuration") {
+ private IStatus error;
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor = SubMonitor.convert(monitor);
+ monitor.beginTask("Receiving_configuration", IProgressMonitor.UNKNOWN);
+ try {
+ try {
+ connector.updateRepositoryConfiguration(repository, null, monitor);
+ } catch (CoreException e) {
+ error = e.getStatus();
+ }
+ } finally {
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return family == repository;
+ }
+
+ @Override
+ public IStatus getStatus() {
+ return error;
+ }
+ };
+ updateJob.setPriority(Job.INTERACTIVE);
+ updateJob.addJobChangeListener(repositoryConfigurationUpdateJobChangeAdapter);
+ updateJob.addJobChangeListener(new JobChangeAdapter() {
+ @Override
+ public void done(IJobChangeEvent event) {
+ synchronized (repository) {
+ repository.setUpdating(false);
+ }
+ }
+ });
+ updateJob.schedule();
+ }
+ }
+ }
+
+ public void setRepositoryConfigurationUpdateJobChangeAdapter(
+ JobChangeAdapter repositoryConfigurationUpdateJobChangeAdapter) {
+ this.repositoryConfigurationUpdateJobChangeAdapter = repositoryConfigurationUpdateJobChangeAdapter;
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
index fea52e2b3..99e7e9332 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java
@@ -782,9 +782,10 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
}
return configuration;
+ } else {
+ throw e;
}
}
- return null;
}
public void addRepositoryConfiguration(RepositoryConfiguration config) {
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 769061f70..9504c8793 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
@@ -23,6 +23,8 @@ import java.util.List;
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.internal.bugzilla.core.service.BugzillaXmlRpcClient;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
@@ -79,7 +81,7 @@ public class CustomTransitionManager implements Serializable {
* @return true if anything was changed, false otherwise.
* @throws CoreException
*/
- public boolean parse(String filePath) {
+ public boolean parse(String filePath) throws CoreException {
if (filePath == null || filePath.length() < 1) {
setValid(false);
return false;
@@ -119,10 +121,10 @@ public class CustomTransitionManager implements Serializable {
}
}
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (IOException e) {
setValid(false);
- return valid;
+ throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 1,
+ "Error parsing transition description file.\n\n" + e.getMessage(), e)); //$NON-NLS-1$
}
return valid;
@@ -312,7 +314,7 @@ public class CustomTransitionManager implements Serializable {
}
}
- public void parse(IProgressMonitor monitor, BugzillaXmlRpcClient xmlClient) {
+ public void parse(IProgressMonitor monitor, BugzillaXmlRpcClient xmlClient) throws CoreException {
this.filePath = ""; //$NON-NLS-1$
operationMapByCurrentStatus.clear();
operationMapByEndStatus.clear();
@@ -357,6 +359,8 @@ public class CustomTransitionManager implements Serializable {
setValid(true);
} catch (XmlRpcException e) {
setValid(false);
+ throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, 1,
+ "Error parsing xmlrpc response.\n\n" + e.getMessage(), e)); //$NON-NLS-1$
}
}
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 9d4eab576..d84a0a184 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,6 +22,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.apache.xmlrpc.XmlRpcException;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_REPORT_STATUS;
import org.eclipse.mylyn.internal.bugzilla.core.service.BugzillaXmlRpcClient;
@@ -360,20 +362,26 @@ public class RepositoryConfiguration implements Serializable {
* invalid.
*
* @param fileName
+ * @throws CoreException
*/
- public void setValidTransitions(IProgressMonitor monitor, String fileName, BugzillaXmlRpcClient xmlClient) {
+ public void setValidTransitions(IProgressMonitor monitor, String fileName, BugzillaXmlRpcClient xmlClient)
+ throws CoreException {
//Custom transitions only possible for newer versions of Bugzilla
if (getInstallVersion() != null && getInstallVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_2) < 0) {
return;
}
- if (validTransitions == null) {
- validTransitions = new CustomTransitionManager();
- }
- if (!validTransitions.parse(fileName) && xmlClient != null) {
- if (getRepositoryUrl().equals("<unknown>")) { //$NON-NLS-1$
- return; //This occurs during testing
+ try {
+ if (validTransitions == null) {
+ validTransitions = new CustomTransitionManager();
+ }
+ if (xmlClient == null) {
+ validTransitions.parse(fileName);
+ } else {
+ validTransitions.parse(monitor, xmlClient);
}
- validTransitions.parse(monitor, xmlClient);
+ } catch (CoreException e) {
+ validTransitions = null;
+ throw e;
}
}

Back to the top