Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2007-06-22 19:41:14 +0000
committerrelves2007-06-22 19:41:14 +0000
commit29176824f4d2ded21745569b2ba6c973031626f0 (patch)
tree6373e2e88b471c23d20199f08af6d384e8206c58
parentf93f376d5acd6297e0048574dfff7ff480dbc2bc (diff)
downloadorg.eclipse.mylyn.tasks-29176824f4d2ded21745569b2ba6c973031626f0.tar.gz
org.eclipse.mylyn.tasks-29176824f4d2ded21745569b2ba6c973031626f0.tar.xz
org.eclipse.mylyn.tasks-29176824f4d2ded21745569b2ba6c973031626f0.zip
NEW - bug 193876: query synchronization is missing hits
https://bugs.eclipse.org/bugs/show_bug.cgi?id=193876
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java63
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java1
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryQueryResultsFactory.java32
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxBugzillaQueryContentHandler.java28
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java14
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskCollector.java6
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/QueryHitCollector.java9
7 files changed, 55 insertions, 98 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 54b838344..89836e6c6 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
@@ -51,7 +51,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
-import org.eclipse.mylyn.internal.monitor.core.util.StatusManager;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.ITaskCollector;
@@ -310,8 +309,7 @@ public class BugzillaClient {
} catch (ParseException e) {
authenticated = false;
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
- RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString()
- + "."));
+ RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
} finally {
if (method != null) {
method.releaseConnection();
@@ -357,8 +355,8 @@ public class BugzillaClient {
"HTTP authentication failed."));
}
if (hasAuthenticationCredentials()) {
- BufferedReader responseReader = new BufferedReader(new InputStreamReader(postMethod
- .getResponseBodyAsStream(), characterEncoding));
+ BufferedReader responseReader = new BufferedReader(new InputStreamReader(
+ postMethod.getResponseBodyAsStream(), characterEncoding));
HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(responseReader, null);
for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
@@ -383,8 +381,7 @@ public class BugzillaClient {
} catch (ParseException e) {
authenticated = false;
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
- RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString()
- + "."));
+ RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
} catch (IOException e) {
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
@@ -400,7 +397,7 @@ public class BugzillaClient {
public RepositoryTaskData getTaskData(int id) throws IOException, CoreException {
GetMethod method = null;
try {
-
+
method = getConnect(repositoryUrl + IBugzillaConstants.URL_GET_SHOW_BUG_XML + id);
RepositoryTaskData taskData = null;
if (method.getResponseHeader("Content-Type") != null) {
@@ -411,8 +408,8 @@ public class BugzillaClient {
BugzillaCorePlugin.REPOSITORY_KIND, repositoryUrl.toString(), "" + id,
IBugzillaConstants.BUGZILLA_TASK_KIND);
setupExistingBugAttributes(repositoryUrl.toString(), taskData);
- RepositoryReportFactory reportFactory = new RepositoryReportFactory(method
- .getResponseBodyAsStream(), characterEncoding);
+ RepositoryReportFactory reportFactory = new RepositoryReportFactory(
+ method.getResponseBodyAsStream(), characterEncoding);
reportFactory.populateReport(taskData);
return taskData;
@@ -438,9 +435,8 @@ public class BugzillaClient {
// }
// }
- public boolean getSearchHits(AbstractRepositoryQuery query, ITaskCollector
- collector)
- throws IOException, CoreException {
+ public boolean getSearchHits(AbstractRepositoryQuery query, ITaskCollector collector) throws IOException,
+ CoreException {
GetMethod method = null;
try {
String queryUrl = query.getUrl();
@@ -454,14 +450,11 @@ public class BugzillaClient {
if (method.getResponseHeader("Content-Type") != null) {
Header responseTypeHeader = method.getResponseHeader("Content-Type");
for (String type : VALID_CONFIG_CONTENT_TYPES) {
- if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type))
- {
- RepositoryQueryResultsFactory queryFactory = new
- RepositoryQueryResultsFactory(method
- .getResponseBodyAsStream(), characterEncoding);
- queryFactory.performQuery(repositoryUrl.toString(), collector,
- QueryHitCollector.MAX_HITS);
- return !queryFactory.getHits().isEmpty();
+ if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
+ RepositoryQueryResultsFactory queryFactory = new RepositoryQueryResultsFactory(
+ method.getResponseBodyAsStream(), characterEncoding);
+ queryFactory.performQuery(repositoryUrl.toString(), collector, QueryHitCollector.MAX_HITS);
+ return !collector.getTaskHits().isEmpty();
}
}
}
@@ -573,8 +566,8 @@ public class BugzillaClient {
GetMethod method = null;
try {
method = getConnect(repositoryUrl + IBugzillaConstants.URL_GET_CONFIG_RDF);
- RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(method
- .getResponseBodyAsStream(), characterEncoding);
+ RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(
+ method.getResponseBodyAsStream(), characterEncoding);
RepositoryConfiguration configuration = configFactory.getConfiguration();
if (configuration != null) {
configuration.setRepositoryUrl(repositoryUrl.toString());
@@ -637,8 +630,8 @@ public class BugzillaClient {
// httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(CONNECT_TIMEOUT);
int status = httpClient.executeMethod(postMethod);
if (status == HttpStatus.SC_OK) {
- InputStreamReader reader = new InputStreamReader(postMethod.getResponseBodyAsStream(), postMethod
- .getResponseCharSet());
+ InputStreamReader reader = new InputStreamReader(postMethod.getResponseBodyAsStream(),
+ postMethod.getResponseCharSet());
BufferedReader bufferedReader = new BufferedReader(reader);
parseHtmlError(bufferedReader);
@@ -659,8 +652,7 @@ public class BugzillaClient {
}
/**
- * calling method must release the connection on the returned PostMethod
- * once finished. TODO: refactor
+ * calling method must release the connection on the returned PostMethod once finished. TODO: refactor
*
* @throws CoreException
*/
@@ -726,8 +718,8 @@ public class BugzillaClient {
if (method == null) {
throw new IOException("Could not post form, client returned null method.");
}
- BufferedReader in = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream(), method
- .getRequestCharSet()));
+ BufferedReader in = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream(),
+ method.getRequestCharSet()));
in.mark(10);
HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null);
@@ -790,8 +782,7 @@ public class BugzillaClient {
} catch (ParseException e) {
authenticated = false;
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
- RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString()
- + "."));
+ RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
} finally {
if (method != null) {
method.releaseConnection();
@@ -869,8 +860,8 @@ public class BugzillaClient {
}
// when posting the bug id is encoded in a hidden field named 'id'
- fields.put(KEY_ID, new NameValuePair(KEY_ID, model.getAttributeValue(BugzillaReportElement.BUG_ID
- .getKeyString())));
+ fields.put(KEY_ID, new NameValuePair(KEY_ID,
+ model.getAttributeValue(BugzillaReportElement.BUG_ID.getKeyString())));
// add the operation to the bug post
RepositoryOperation o = model.getSelectedOperation();
@@ -930,8 +921,7 @@ public class BugzillaClient {
}
/**
- * Utility method for determining what potential error has occurred from a
- * bugzilla html reponse page
+ * Utility method for determining what potential error has occurred from a bugzilla html reponse page
*/
public void parseHtmlError(BufferedReader in) throws IOException, CoreException {
HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null);
@@ -992,8 +982,7 @@ public class BugzillaClient {
} catch (ParseException e) {
authenticated = false;
throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
- RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString()
- + "."));
+ RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
} finally {
in.close();
}
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 d7d7e494f..3c4d6ceaa 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
@@ -106,6 +106,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler {
public Set<RepositoryTaskData> getMultiTaskData(TaskRepository repository, Set<String> taskIds,
IProgressMonitor monitor) throws CoreException {
try {
+
Set<RepositoryTaskData> result = new HashSet<RepositoryTaskData>();
BugzillaClient client = connector.getClientManager().getClient(repository);
try {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryQueryResultsFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryQueryResultsFactory.java
index 795f6c1c4..f364275d7 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryQueryResultsFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryQueryResultsFactory.java
@@ -14,8 +14,6 @@ package org.eclipse.mylyn.internal.bugzilla.core;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
-import java.util.HashSet;
-import java.util.Set;
import org.eclipse.mylyn.tasks.core.ITaskCollector;
@@ -24,33 +22,17 @@ import org.eclipse.mylyn.tasks.core.ITaskCollector;
*/
public class RepositoryQueryResultsFactory extends AbstractReportFactory {
- Set<String> hits = new HashSet<String>();
-
public RepositoryQueryResultsFactory(InputStream inStream, String encoding) {
super(inStream, encoding);
}
-// /**
-// * expects rdf returned from repository (ctype=rdf in url)
-// *
-// * @throws GeneralSecurityException
-// */
-// public void performQuery(String repositoryUrl, int maxHits) throws IOException {
-//
-// SaxBugzillaQueryContentHandler contentHandler = new SaxBugzillaQueryContentHandler(repositoryUrl, hits, maxHits);
-// collectResults(contentHandler, false);
-// }
-
- /** expects rdf returned from repository (ctype=rdf in url)
- * @throws GeneralSecurityException */
- public void performQuery(String repositoryUrl, ITaskCollector collector, int maxHits) throws IOException {
-
- SaxBugzillaQueryContentHandler contentHandler = new SaxBugzillaQueryContentHandler(repositoryUrl,
- collector, hits, maxHits);
+ /**
+ * expects rdf returned from repository (ctype=rdf in url)
+ *
+ * @throws GeneralSecurityException
+ */
+ public void performQuery(String repositoryUrl, ITaskCollector collector, int maxHits) throws IOException {
+ SaxBugzillaQueryContentHandler contentHandler = new SaxBugzillaQueryContentHandler(repositoryUrl, collector);
collectResults(contentHandler, false);
}
-
- public Set<String> getHits() {
- return hits;
- }
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxBugzillaQueryContentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxBugzillaQueryContentHandler.java
index ee093fde4..ef5700a94 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxBugzillaQueryContentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxBugzillaQueryContentHandler.java
@@ -12,7 +12,6 @@
package org.eclipse.mylyn.internal.bugzilla.core;
import java.util.Locale;
-import java.util.Set;
import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.ITaskCollector;
@@ -43,17 +42,9 @@ public class SaxBugzillaQueryContentHandler extends DefaultHandler {
private String repositoryUrl;
- private Set<String> bugIds;
-
- private int maxHits = 100;
-
- private int numCollected = 0;
-
- public SaxBugzillaQueryContentHandler(String repositoryUrl, ITaskCollector collector, Set<String> hits, int maxHits) {
+ public SaxBugzillaQueryContentHandler(String repositoryUrl, ITaskCollector collector) {
this.repositoryUrl = repositoryUrl;
- this.maxHits = maxHits;
this.collector = collector;
- this.bugIds = hits;
}
@Override
@@ -94,10 +85,6 @@ public class SaxBugzillaQueryContentHandler extends DefaultHandler {
switch (tag) {
case ID:
id = parsedText;
- if (numCollected < maxHits || maxHits == IBugzillaConstants.RETURN_ALL_HITS) {
- bugIds.add(id);
- numCollected++;
- }
break;
// case BUG_SEVERITY:
// severity = parsedText;
@@ -124,15 +111,10 @@ public class SaxBugzillaQueryContentHandler extends DefaultHandler {
description = parsedText;
break;
case LI:
- if (numCollected < maxHits || maxHits == IBugzillaConstants.RETURN_ALL_HITS) {
- BugzillaTask task = new BugzillaTask(repositoryUrl, id, description);
- task.setPriority(priority);
- // TODO set state
- collector.accept(task);
- numCollected++;
- } else {
- break;
- }
+ BugzillaTask task = new BugzillaTask(repositoryUrl, id, description);
+ task.setPriority(priority);
+ // TODO set state
+ collector.accept(task);
}
} catch (RuntimeException e) {
if (e instanceof IllegalArgumentException) {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
index 6eccd0b8c..294260535 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
@@ -52,7 +52,7 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
private AbstractAttributeFactory attributeFactory;
- private int retrieved = 0;
+ //private int retrieved = 1;
public SaxMultiBugReportContentHandler(AbstractAttributeFactory factory, Map<String, RepositoryTaskData> taskDataMap) {
this.attributeFactory = factory;
@@ -67,9 +67,9 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
return errorMessage;
}
- public RepositoryTaskData getReport() {
- return repositoryTaskData;
- }
+// public RepositoryTaskData getReport() {
+// return repositoryTaskData;
+// }
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
@@ -250,7 +250,6 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
attachment.setRepositoryUrl(repositoryTaskData.getRepositoryUrl());
attachment.setTaskId(repositoryTaskData.getId());
}
- retrieved++;
break;
case BLOCKED:
@@ -300,9 +299,4 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
}
}
}
-
- public int getNumRetrieved() {
- return retrieved;
- }
-
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskCollector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskCollector.java
index 2aad2db65..a950c22b7 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskCollector.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskCollector.java
@@ -11,12 +11,18 @@
package org.eclipse.mylyn.tasks.core;
+import java.util.Set;
+
import org.eclipse.core.runtime.CoreException;
+/**
+ * @author Rob Elves
+ */
public interface ITaskCollector {
void accept(AbstractTask task);
void accept(RepositoryTaskData taskData) throws CoreException;
+ public Set<AbstractTask> getTaskHits();
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/QueryHitCollector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/QueryHitCollector.java
index d1134a538..b22fba5e1 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/QueryHitCollector.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/QueryHitCollector.java
@@ -41,8 +41,9 @@ public class QueryHitCollector implements ITaskCollector {
if (task == null) {
throw new IllegalArgumentException();
}
-
- taskResults.add(task);
+ if (taskResults.size() < MAX_HITS) {
+ taskResults.add(task);
+ }
}
public void accept(RepositoryTaskData taskData) throws CoreException {
@@ -51,7 +52,9 @@ public class QueryHitCollector implements ITaskCollector {
}
AbstractTask task = taskFactory.createTask(taskData, new NullProgressMonitor());
- taskResults.add(task);
+ if (taskResults.size() < MAX_HITS) {
+ taskResults.add(task);
+ }
}
public Set<AbstractTask> getTaskHits() {

Back to the top