Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2006-10-13 02:56:34 +0000
committerrelves2006-10-13 02:56:34 +0000
commita5afacf1ca03ddad22ebd22b524fac207d9216ab (patch)
treea872c5c950e9daa43443acb3ea0a4dda4f6567c9 /org.eclipse.mylyn.bugzilla.core
parent6dc3828c5e7772d30bcc584f1fc912e6c97d1908 (diff)
downloadorg.eclipse.mylyn.tasks-a5afacf1ca03ddad22ebd22b524fac207d9216ab.tar.gz
org.eclipse.mylyn.tasks-a5afacf1ca03ddad22ebd22b524fac207d9216ab.tar.xz
org.eclipse.mylyn.tasks-a5afacf1ca03ddad22ebd22b524fac207d9216ab.zip
Progress on: Show server error message when adding existing repository task
https://bugs.eclipse.org/bugs/show_bug.cgi?id=159402
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java17
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaOfflineTaskHandler.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java43
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java17
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryReportFactory.java20
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/UnrecognizedReponseException.java24
7 files changed, 65 insertions, 63 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
index cb31acfc1..6ac5fbaa3 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
@@ -41,6 +41,7 @@ import org.apache.commons.httpclient.params.HttpMethodParams;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.mylar.internal.tasks.core.UnrecognizedReponseException;
import org.eclipse.mylar.internal.tasks.core.WebClientUtil;
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
import org.eclipse.mylar.tasks.core.IAttachmentHandler;
@@ -92,7 +93,7 @@ public class BugzillaAttachmentHandler implements IAttachmentHandler {
RepositoryAttachment attachment, File file, Proxy proxySettings) throws CoreException {
try {
downloadAttachment(repository.getUrl(), repository.getUserName(), repository.getPassword(), proxySettings,
- attachment.getId(), file, true);
+ repository.getCharacterEncoding(), attachment.getId(), file, true);
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, 0, "could not download", e));
}
@@ -177,15 +178,16 @@ public class BugzillaAttachmentHandler implements IAttachmentHandler {
} catch (LoginException e) {
throw new CoreException(new Status(Status.OK, BugzillaCorePlugin.PLUGIN_ID, Status.ERROR,
"Your login name or password is incorrect. Ensure proper repository configuration.", e));
- } catch (IOException e) {
- throw new CoreException(new Status(Status.OK, BugzillaCorePlugin.PLUGIN_ID, Status.ERROR,
- "Check repository credentials and connectivity.", e));
} catch (UnrecognizedReponseException e) {
if (e.getMessage().indexOf(CHANGES_SUBMITTED) > -1) {
return true;
}
throw new CoreException(new Status(Status.OK, BugzillaCorePlugin.PLUGIN_ID, Status.INFO,
"Response from server", e));
+ } catch (IOException e) {
+ throw new CoreException(new Status(Status.OK, BugzillaCorePlugin.PLUGIN_ID, Status.ERROR,
+ "Check repository credentials and connectivity.", e));
+
} catch (BugzillaException e) {
String message = e.getMessage();
throw new CoreException(new Status(Status.OK, BugzillaCorePlugin.PLUGIN_ID, Status.ERROR,
@@ -211,12 +213,13 @@ public class BugzillaAttachmentHandler implements IAttachmentHandler {
}
private boolean downloadAttachment(String repositoryUrl, String userName, String password, Proxy proxySettings,
- int id, File destinationFile, boolean overwrite) throws IOException, GeneralSecurityException {
+ String encoding, int id, File destinationFile, boolean overwrite) throws IOException,
+ GeneralSecurityException {
BufferedInputStream in = null;
FileOutputStream outStream = null;
try {
String url = repositoryUrl + POST_ARGS_ATTACHMENT_DOWNLOAD + id;
- url = BugzillaServerFacade.addCredentials(url, userName, password);
+ url = BugzillaServerFacade.addCredentials(url, encoding, userName, password);
URL downloadUrl = new URL(url);
URLConnection connection = WebClientUtil.openUrlConnection(downloadUrl, proxySettings, false);
if (connection != null) {
@@ -272,7 +275,7 @@ public class BugzillaAttachmentHandler implements IAttachmentHandler {
return true;
}
- public boolean canDeprecate(TaskRepository repository, RepositoryAttachment attachment) {
+ public boolean canDeprecate(TaskRepository repository, RepositoryAttachment attachment) {
return false;
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
index 4824d516a..cbbf690dd 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCorePlugin.java
@@ -39,8 +39,6 @@ public class BugzillaCorePlugin extends Plugin {
public static final String REPOSITORY_KIND = "bugzilla";
- public static final String ENCODING_UTF_8 = "UTF-8";
-
public static final String PLUGIN_ID = "org.eclipse.mylar.bugzilla";
private static BugzillaCorePlugin INSTANCE;
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaOfflineTaskHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaOfflineTaskHandler.java
index de6fc7dd7..4ed71b201 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaOfflineTaskHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaOfflineTaskHandler.java
@@ -24,12 +24,13 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.mylar.internal.tasks.core.UnrecognizedReponseException;
import org.eclipse.mylar.tasks.core.AbstractAttributeFactory;
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
-import org.eclipse.mylar.tasks.core.QueryHitCollector;
import org.eclipse.mylar.tasks.core.IOfflineTaskHandler;
import org.eclipse.mylar.tasks.core.ITask;
+import org.eclipse.mylar.tasks.core.QueryHitCollector;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskList;
import org.eclipse.mylar.tasks.core.TaskRepository;
@@ -176,7 +177,7 @@ public class BugzillaOfflineTaskHandler implements IOfflineTaskHandler {
RepositoryQueryResultsFactory queryFactory = new RepositoryQueryResultsFactory();
QueryHitCollector collector = new QueryHitCollector(taskList);
if (repository.hasCredentials()) {
- urlQueryString = BugzillaServerFacade.addCredentials(urlQueryString, repository.getUserName(), repository
+ urlQueryString = BugzillaServerFacade.addCredentials(urlQueryString, repository.getCharacterEncoding(), repository.getUserName(), repository
.getPassword());
}
try {
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 55b59c82c..e27b82171 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
@@ -11,6 +11,7 @@
package org.eclipse.mylar.internal.bugzilla.core;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
@@ -23,6 +24,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants.BugzillaServerVersion;
+import org.eclipse.mylar.internal.tasks.core.UnrecognizedReponseException;
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
@@ -98,13 +100,22 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
try {
taskData = BugzillaServerFacade.getBug(repository.getUrl(), repository.getUserName(), repository
.getPassword(), proxySettings, repository.getCharacterEncoding(), bugId);
- } catch (Throwable e) {
- return null;
- }
- if (taskData != null) {
- task = new BugzillaTask(handle, taskData.getId() + ": " + taskData.getDescription(), true);
- ((BugzillaTask) task).setTaskData(taskData);
- taskList.addTask(task);
+
+ if (taskData != null) {
+ task = new BugzillaTask(handle, taskData.getId() + ": " + taskData.getDescription(), true);
+ ((BugzillaTask) task).setTaskData(taskData);
+ taskList.addTask(task);
+ }
+ } catch (final UnrecognizedReponseException e) {
+ throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, 0,
+ "Report retrieval failed. Unrecognized response from " + repository.getUrl() + ".", e));
+ } catch (final FileNotFoundException e) {
+ throw new CoreException(
+ new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, 0, "Report download from "
+ + repository.getUrl() + " failed. File not found: " + e.getMessage(), e));
+ } catch (final Exception e) {
+ throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, 0,
+ "Report download from " + repository.getUrl() + " failed, please see details.", e));
}
}
return task;
@@ -141,25 +152,23 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
queryUrl = queryUrl.concat(IBugzillaConstants.CONTENT_TYPE_RDF);
if (repository.hasCredentials()) {
try {
- queryUrl = BugzillaServerFacade.addCredentials(queryUrl, repository.getUserName(), repository
- .getPassword());
+ queryUrl = BugzillaServerFacade.addCredentials(queryUrl, repository.getCharacterEncoding(),
+ repository.getUserName(), repository.getPassword());
} catch (UnsupportedEncodingException e) {
// ignore
}
}
queryFactory.performQuery(taskList, repository.getUrl(), resultCollector, queryUrl, proxySettings, query
.getMaxHits(), repository.getCharacterEncoding());
- } catch (IOException e) {
+ } catch (UnrecognizedReponseException e) {
+ queryStatus = new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, Status.INFO,
+ "Unrecognized response from server", e);
+ } catch (IOException e) {
queryStatus = new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, Status.ERROR,
"Check repository credentials and connectivity.", e);
- } catch (BugzillaException e) {
- if (e instanceof UnrecognizedReponseException) {
- queryStatus = new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, Status.INFO,
- "Unrecognized response from server", e);
- } else {
+ } catch (BugzillaException e) {
queryStatus = new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, IStatus.OK,
- "Unable to perform query due to Bugzilla error", e);
- }
+ "Unable to perform query due to Bugzilla error", e);
} catch (GeneralSecurityException e) {
queryStatus = new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, IStatus.OK,
"Unable to perform query due to repository configuration error", e);
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java
index 5349ec131..65c003c98 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java
@@ -23,8 +23,6 @@ public interface IBugzillaConstants {
static final String ERROR_MSG_COMMENT_REQUIRED = "You have to specify a new comment when making this change. Please comment on the reason for this change.";
- static final String ERROR_INVALID_BUG_ID = "InvalidBugId";
-
static final String ERROR_INVALID_USERNAME_OR_PASSWORD = "Invalid Username or Password";
static final String MOST_RECENT_QUERY = "org.eclipse.mylar.bugzilla.query.last";
@@ -53,6 +51,16 @@ public interface IBugzillaConstants {
public static final String POST_ARGS_LOGIN = "GoAheadAndLogIn=1&Bugzilla_login=";
+ public static final String XML_ERROR_INVALIDBUGID = "invalidbugid";
+
+ public static final String XML_ERROR_NOTFOUND = "notfound";
+
+ public static final String XML_ERROR_NOTPERMITTED = "notpermitted";
+
+ public static final String SHOW_BUG_CGI_XML = "/show_bug.cgi?ctype=xml&id=";
+
+ public static final String ENCODING_UTF_8 = "UTF-8";
+
/** Supported bugzilla repository versions */
static public enum BugzillaServerVersion {
SERVER_218, SERVER_220, SERVER_222;
@@ -185,4 +193,9 @@ public interface IBugzillaConstants {
public static enum BUGZILLA_RESOLUTION {
FIXED, INVALID, WONTFIX, LATER, REMIND, WORKSFORME;
}
+
+ public static final String ERROR_MSG_OP_NOT_PERMITTED = "The requested operation is not permitted.";
+
+ public static final String ERROR_MSG_INVALID_BUG_ID = "Invalid Bug ID. The requested bug id does not exist.";
+
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryReportFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryReportFactory.java
index 31cf91a03..20f0bfacb 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryReportFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryReportFactory.java
@@ -29,23 +29,25 @@ public class RepositoryReportFactory extends AbstractReportFactory {
private static BugzillaAttributeFactory bugzillaAttributeFactory = new BugzillaAttributeFactory();
- private static final String SHOW_BUG_CGI_XML = "/show_bug.cgi?ctype=xml&id=";
-
public void populateReport(RepositoryTaskData bugReport, String repositoryUrl, Proxy proxySettings,
- String userName, String password, String characterEncoding) throws GeneralSecurityException, KeyManagementException,
- NoSuchAlgorithmException, IOException, BugzillaException {
+ String userName, String password, String characterEncoding) throws GeneralSecurityException,
+ KeyManagementException, NoSuchAlgorithmException, IOException, BugzillaException {
SaxBugReportContentHandler contentHandler = new SaxBugReportContentHandler(bugzillaAttributeFactory, bugReport);
- String xmlBugReportUrl = repositoryUrl + SHOW_BUG_CGI_XML + bugReport.getId();
- xmlBugReportUrl = BugzillaServerFacade.addCredentials(xmlBugReportUrl, userName, password);
+ String xmlBugReportUrl = repositoryUrl + IBugzillaConstants.SHOW_BUG_CGI_XML + bugReport.getId();
+ xmlBugReportUrl = BugzillaServerFacade.addCredentials(xmlBugReportUrl, characterEncoding, userName, password);
URL serverURL = new URL(xmlBugReportUrl);
- collectResults(serverURL, proxySettings, characterEncoding, contentHandler, false);
+ collectResults(serverURL, proxySettings, IBugzillaConstants.ENCODING_UTF_8, contentHandler, false);
if (contentHandler.errorOccurred()) {
- throw new IOException(contentHandler.getErrorMessage());
+ String errorResponse = contentHandler.getErrorMessage().toLowerCase();
+ if (errorResponse.equals(IBugzillaConstants.XML_ERROR_NOTFOUND) || errorResponse.equals(IBugzillaConstants.XML_ERROR_INVALIDBUGID)) {
+ throw new BugzillaException(IBugzillaConstants.ERROR_MSG_INVALID_BUG_ID);
+ }if (errorResponse.equals(IBugzillaConstants.XML_ERROR_NOTPERMITTED)) {
+ throw new BugzillaException(IBugzillaConstants.ERROR_MSG_OP_NOT_PERMITTED);
+ }
}
-
}
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/UnrecognizedReponseException.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/UnrecognizedReponseException.java
deleted file mode 100644
index a99baa931..000000000
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/UnrecognizedReponseException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 - 2006 University Of British Columbia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * University Of British Columbia - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylar.internal.bugzilla.core;
-
-
-/**
- * @author Rob Elves
- */
-public class UnrecognizedReponseException extends BugzillaException {
- private static final long serialVersionUID = 8419167415822022988L;
-
- public UnrecognizedReponseException(String message) {
- super(message);
- }
-}

Back to the top