diff options
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core')
4 files changed, 58 insertions, 32 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 71137806a..68ef0c503 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 @@ -244,8 +244,6 @@ public class BugzillaClient { throw new CoreException(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, "XMLRPC user could not login")); //$NON-NLS-1$ } - int i = 9; - i++; } catch (XmlRpcException e) { throw new CoreException(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, "XMLRPC is not installed")); //$NON-NLS-1$ @@ -1167,6 +1165,46 @@ public class BugzillaClient { public RepositoryResponse postTaskData(TaskData taskData, IProgressMonitor monitor) throws IOException, CoreException { + try { + return postTaskDataInternal(taskData, monitor); + } catch (CoreException e) { + TaskAttribute qaContact = taskData.getRoot().getAttribute(BugzillaAttribute.QA_CONTACT.getKey()); + if (qaContact != null) { + String qaContactValue = qaContact.getValue(); + String message = e.getMessage(); + if ("An unknown repository error has occurred: Bugzilla/Bug.pm line".equals(message) //$NON-NLS-1$ + && qaContactValue != null && !qaContactValue.equals("")) { //$NON-NLS-1$ + if (e.getStatus() instanceof RepositoryStatus) { + RepositoryStatus repositoryStatus = (RepositoryStatus) e.getStatus(); + RepositoryStatus status = RepositoryStatus.createHtmlStatus( + repositoryStatus.getRepositoryUrl(), IStatus.INFO, BugzillaCorePlugin.ID_PLUGIN, + RepositoryStatus.ERROR_REPOSITORY, + "Error may result when QAContact field not enabled.", //$NON-NLS-1$ + repositoryStatus.getHtmlMessage()); + throw new CoreException(status); + } + } + } + try { + if (e.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) { + return postTaskDataInternal(taskData, monitor); + } else if (e.getStatus().getCode() == IBugzillaConstants.REPOSITORY_STATUS_SUSPICIOUS_ACTION) { + taskData.getRoot().removeAttribute(BugzillaAttribute.TOKEN.getKey()); + return postTaskDataInternal(taskData, monitor); + } else { + throw e; + } + } catch (CoreException e1) { + if (e.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) { + throw e; + } + } + } + return null; + } + + public RepositoryResponse postTaskDataInternal(TaskData taskData, IProgressMonitor monitor) throws IOException, + CoreException { NameValuePair[] formData = null; monitor = Policy.monitorFor(monitor); BugzillaRepositoryResponse response; @@ -1201,25 +1239,8 @@ public class BugzillaClient { response = parsePostResponse(taskData.getTaskId(), input); return response; } catch (CoreException e) { - TaskAttribute qaContact = taskData.getRoot().getAttribute(BugzillaAttribute.QA_CONTACT.getKey()); - if (qaContact != null) { - String qaContactValue = qaContact.getValue(); - String message = e.getMessage(); - if ("An unknown repository error has occurred: Bugzilla/Bug.pm line".equals(message) //$NON-NLS-1$ - && qaContactValue != null && !qaContactValue.equals("")) { //$NON-NLS-1$ - if (e.getStatus() instanceof RepositoryStatus) { - RepositoryStatus repositoryStatus = (RepositoryStatus) e.getStatus(); - RepositoryStatus status = RepositoryStatus.createHtmlStatus( - repositoryStatus.getRepositoryUrl(), IStatus.INFO, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_REPOSITORY, - "Error may result when QAContact field not enabled.", //$NON-NLS-1$ - repositoryStatus.getHtmlMessage()); - throw new CoreException(status); - } - } - } - throw e; + } finally { if (input != null) { input.close(); @@ -1790,7 +1811,7 @@ public class BugzillaClient { RepositoryStatus.ERROR_INTERNAL, "Unable to retrieve new task id from: " + title)); //$NON-NLS-1$ throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_INTERNAL, "Unable to retrieve new task.")); //$NON-NLS-1$ + RepositoryStatus.ERROR_INTERNAL, Messages.BugzillaClient_Unable_to_retrieve_new_task)); } } @@ -1801,8 +1822,15 @@ public class BugzillaClient { found = title.indexOf(value) != -1; if (found) { loggedIn = false; - throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), title)); + if (hasAuthenticationCredentials()) { + throw new CoreException(new BugzillaStatus(IStatus.ERROR, + BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_REPOSITORY_LOGIN, + repositoryUrl.toString(), title)); + } else { + throw new CoreException(new BugzillaStatus(IStatus.ERROR, + BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_REPOSITORY_LOGIN, + repositoryUrl.toString(), Messages.BugzillaClient_anonymous_user_not_allowed)); + } } } 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 f704f70a6..db9a8eca2 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 @@ -384,15 +384,7 @@ public class BugzillaTaskDataHandler extends AbstractTaskDataHandler { try { return client.postTaskData(taskData, monitor); } catch (CoreException e) { - // TODO: Move retry handling into client - if (e.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) { - return client.postTaskData(taskData, monitor); - } else if (e.getStatus().getCode() == IBugzillaConstants.REPOSITORY_STATUS_SUSPICIOUS_ACTION) { - taskData.getRoot().removeAttribute(BugzillaAttribute.TOKEN.getKey()); - return client.postTaskData(taskData, monitor); - } else { - throw e; - } + throw e; } } catch (IOException e) { throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java index ed311a5e6..2444ed807 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java @@ -205,10 +205,14 @@ public class Messages extends NLS { public static String BugzillaAttachmentMapper_URL; + public static String BugzillaClient_anonymous_user_not_allowed; + public static String BugzillaClient_could_not_post_form_null_returned; public static String BugzillaClient_description_required_when_submitting_attachments; + public static String BugzillaClient_Unable_to_retrieve_new_task; + public static String BugzillaOperation_Accept_to_ASSIGNED; public static String BugzillaOperation_confirmed; diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties index da3c8c71e..600dfc7ff 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties @@ -100,8 +100,10 @@ BugzillaAttachmentMapper_Size=Size in Bytes: BugzillaAttachmentMapper_Token=Token: BugzillaAttachmentMapper_URL=URL: +BugzillaClient_anonymous_user_not_allowed=Anonymous user not allowed for this operation. BugzillaClient_could_not_post_form_null_returned=Could not post form, client returned null method. BugzillaClient_description_required_when_submitting_attachments=A description is required when submitting attachments. +BugzillaClient_Unable_to_retrieve_new_task=Unable to retrieve new task. BugzillaOperation_Accept_to_ASSIGNED=Accept (change status to ASSIGNED) BugzillaOperation_confirmed=confirm |