### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.tasks.ui Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java,v retrieving revision 1.107 diff -u -r1.107 AbstractTaskEditorPage.java --- src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java 8 May 2009 02:16:07 -0000 1.107 +++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java 9 May 2009 20:08:37 -0000 @@ -224,9 +224,8 @@ migrator.setEditor(getTaskEditor()); migrator.execute(newTask); } - } else { - handleSubmitError(job); } + handleTaskSubmitted(new SubmitJobEvent(job)); } finally { showEditorBusy(false); } @@ -1089,6 +1088,15 @@ } } + /** + * @since 3.2 + */ + protected void handleTaskSubmitted(SubmitJobEvent event) { + if (event.getJob().getStatus() != null) { + handleSubmitError(event.getJob()); + } + } + @Override public void init(IEditorSite site, IEditorInput input) { super.init(site, input); #P org.eclipse.mylyn.bugzilla.ui Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties,v retrieving revision 1.3 diff -u -r1.3 messages.properties --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties 10 Jan 2009 04:15:15 -0000 1.3 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties 9 May 2009 20:08:38 -0000 @@ -7,6 +7,16 @@ BugzillaPlanningEditorPart_Current_Estimate=Current Estimate: BugzillaPlanningEditorPart_Team_Planning=Team Planning +BugzillaTaskEditorPage_Confirm=Confirm +BugzillaTaskEditorPage_Error=Error +BugzillaTaskEditorPage_Error_Label_1="{0}" +BugzillaTaskEditorPage_Error_Label_N=, "{0}" +BugzillaTaskEditorPage_Legal_Value_1={0} +BugzillaTaskEditorPage_Legal_Value_N=, \n{0} +BugzillaTaskEditorPage_Legal_Values_More=legal values are:\n{0} +BugzillaTaskEditorPage_Legal_Values_One=legal value is\n{0} +BugzillaTaskEditorPage_Message_more={0} match for fields {1} +BugzillaTaskEditorPage_Message_one={0} match for field {1} BugzillaTaskEditorPage_Please_enter_a_description_before_submitting=Please enter a description before submitting BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting=Please enter a short summary before submitting BugzillaTaskEditorPage_Please_select_a_component_before_submitting=Please select a component before submitting Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java,v retrieving revision 1.3 diff -u -r1.3 Messages.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java 10 Jan 2009 04:15:15 -0000 1.3 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java 9 May 2009 20:08:38 -0000 @@ -37,6 +37,26 @@ public static String BugzillaPlanningEditorPart_Team_Planning; + public static String BugzillaTaskEditorPage_Confirm; + + public static String BugzillaTaskEditorPage_Error; + + public static String BugzillaTaskEditorPage_Error_Label_1; + + public static String BugzillaTaskEditorPage_Error_Label_N; + + public static String BugzillaTaskEditorPage_Legal_Value_1; + + public static String BugzillaTaskEditorPage_Legal_Value_N; + + public static String BugzillaTaskEditorPage_Legal_Values_More; + + public static String BugzillaTaskEditorPage_Legal_Values_One; + + public static String BugzillaTaskEditorPage_Message_more; + + public static String BugzillaTaskEditorPage_Message_one; + public static String BugzillaTaskEditorPage_Please_enter_a_description_before_submitting; public static String BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting; Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java,v retrieving revision 1.28 diff -u -r1.28 BugzillaTaskEditorPage.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 29 Apr 2009 21:16:16 -0000 1.28 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 9 May 2009 20:08:38 -0000 @@ -11,6 +11,8 @@ package org.eclipse.mylyn.internal.bugzilla.ui.editor; +import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -25,6 +27,7 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaStatus; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler; import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration; @@ -36,6 +39,7 @@ import org.eclipse.mylyn.tasks.core.data.TaskDataModel; import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent; import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener; +import org.eclipse.mylyn.tasks.core.sync.SubmitJobEvent; import org.eclipse.mylyn.tasks.ui.TasksUi; import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor; import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage; @@ -45,6 +49,8 @@ import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Display; /** * @author Rob Elves @@ -58,8 +64,14 @@ private final Map attributeEditorMap; + private final List editorsWithErrors = new ArrayList(); + private TaskDataModelListener productListener; + private final Color normalForegroundColor = new Color(Display.getDefault(), 0, 0, 0); + + private final Color errorForegroundColor = new Color(Display.getDefault(), 225, 0, 0); + public BugzillaTaskEditorPage(TaskEditor editor) { this(editor, BugzillaCorePlugin.CONNECTOR_KIND); } @@ -226,6 +238,12 @@ attrToken.setValue(getModel().getTask().getAttribute(BugzillaAttribute.TOKEN.getKey())); } + for (AbstractAttributeEditor errorEditor : editorsWithErrors) { + errorEditor.getLabelControl().setToolTipText(""); //$NON-NLS-1$ + errorEditor.getLabelControl().setForeground(normalForegroundColor); + } + editorsWithErrors.clear(); + getTaskEditor().setMessage("", IMessageProvider.NONE); //$NON-NLS-1$ super.doSubmit(); } @@ -364,4 +382,105 @@ } } + private void presentErrorToUI(BugzillaStatus bugzillaStatus) { + String resultString; + int count = 0; + String fieldString = ""; //$NON-NLS-1$ + Map> response = bugzillaStatus.getResponseData(); + + for (String string : response.keySet()) { + TaskAttribute attribute = getModel().getTaskData().getRoot().getAttribute(string); + if (count++ > 0) { + fieldString += MessageFormat.format(Messages.BugzillaTaskEditorPage_Error_Label_N, + attribute.getMetaData().getLabel()); + } else { + fieldString += MessageFormat.format(Messages.BugzillaTaskEditorPage_Error_Label_1, + attribute.getMetaData().getLabel()); + } + AbstractAttributeEditor editor = getEditorForAttribute(attribute); + if (editor != null) { + editorsWithErrors.add(editor); + String legalResult = ""; //$NON-NLS-1$ + String legalValues = ""; //$NON-NLS-1$ + int countValues = 0; + for (String responseValue : response.get(string)) { + if (countValues++ > 0) { + legalValues += MessageFormat.format(Messages.BugzillaTaskEditorPage_Legal_Value_N, + responseValue); + } else { + legalValues += MessageFormat.format(Messages.BugzillaTaskEditorPage_Legal_Value_1, + responseValue); + } + } + switch (bugzillaStatus.getCode()) { + case BugzillaStatus.ERROR_CONFIRM_MATCH: + if (countValues > 1) { + legalResult = MessageFormat.format(Messages.BugzillaTaskEditorPage_Legal_Values_More, + legalValues); + } else { + legalResult = MessageFormat.format(Messages.BugzillaTaskEditorPage_Legal_Values_One, + legalValues); + } + break; + case BugzillaStatus.ERROR_MATCH_FAILED: + if (countValues > 1) { + legalResult = MessageFormat.format(Messages.BugzillaTaskEditorPage_Legal_Values_More, + legalValues); + } else { + legalResult = legalValues; + } + break; + default: + legalResult = ""; //$NON-NLS-1$ + break; + } + editor.getLabelControl().setToolTipText(legalResult); + editor.getLabelControl().setForeground(errorForegroundColor); + } + } + String codeString; + switch (bugzillaStatus.getCode()) { + case BugzillaStatus.ERROR_CONFIRM_MATCH: + codeString = Messages.BugzillaTaskEditorPage_Confirm; + break; + case BugzillaStatus.ERROR_MATCH_FAILED: + codeString = Messages.BugzillaTaskEditorPage_Error; + break; + default: + codeString = ""; //$NON-NLS-1$ + break; + } + if (count > 1) { + resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_more, codeString, fieldString); + } else { + resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_one, codeString, fieldString); + } + + getTaskEditor().setMessage(resultString, IMessageProvider.ERROR); + } + + @Override + protected void handleTaskSubmitted(SubmitJobEvent event) { + if (event.getJob().getStatus() != null) { + switch (event.getJob().getStatus().getCode()) { + case BugzillaStatus.ERROR_CONFIRM_MATCH: + case BugzillaStatus.ERROR_MATCH_FAILED: + presentErrorToUI((BugzillaStatus) event.getJob().getStatus()); + break; + default: + super.handleTaskSubmitted(event); + break; + } + } else { + super.handleTaskSubmitted(event); + } + } + + @Override + public void dispose() { + normalForegroundColor.dispose(); + errorForegroundColor.dispose(); + super.dispose(); + } + } Index: plugin.xml =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/plugin.xml,v retrieving revision 1.106 diff -u -r1.106 plugin.xml --- plugin.xml 16 Feb 2009 16:38:12 -0000 1.106 +++ plugin.xml 9 May 2009 20:08:38 -0000 @@ -62,6 +62,8 @@ + + #P org.eclipse.mylyn.bugzilla.core Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaLanguageSettings.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaLanguageSettings.java,v retrieving revision 1.10 diff -u -r1.10 BugzillaLanguageSettings.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaLanguageSettings.java 16 Feb 2009 16:38:14 -0000 1.10 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaLanguageSettings.java 9 May 2009 20:08:40 -0000 @@ -43,6 +43,10 @@ public static final String COMMAND_SUSPICIOUS_ACTION = "suspicious_action"; //$NON-NLS-1$ + public static final String COMMAND_ERROR_CONFIRM_MATCH = "error_confirm_match"; //$NON-NLS-1$ + + public static final String COMMAND_ERROR_MATCH_FAILED = "error_match_failed"; //$NON-NLS-1$ + public static final String COMMAND_BUG = "bug"; //$NON-NLS-1$ public static final String COMMAND_SUBMITTED = "submitted"; //$NON-NLS-1$ Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java,v retrieving revision 1.15 diff -u -r1.15 BugzillaStatus.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java 16 Dec 2008 20:55:49 -0000 1.15 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java 9 May 2009 20:08:40 -0000 @@ -11,12 +11,18 @@ package org.eclipse.mylyn.internal.bugzilla.core; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + import org.eclipse.core.runtime.Status; import org.eclipse.mylyn.tasks.core.RepositoryStatus; import org.eclipse.osgi.util.NLS; /** * @author Rob Elves + * @author Frank Becker */ public class BugzillaStatus extends Status { @@ -24,26 +30,38 @@ private String repositoryUrl = ""; //$NON-NLS-1$ + public final static int ERROR_CONFIRM_MATCH = 1024; + + public final static int ERROR_MATCH_FAILED = 1025; + + private final String htmlMessage; + + private Map> responseData = new LinkedHashMap>(); + public BugzillaStatus(int severity, String pluginId, int code) { super(severity, pluginId, code, "MylynStatus", null); //$NON-NLS-1$ this.errorMessage = null; + this.htmlMessage = null; } public BugzillaStatus(int severity, String pluginId, int code, String errorMessage) { super(severity, pluginId, code, "MylynStatus", null); //$NON-NLS-1$ this.errorMessage = errorMessage; + this.htmlMessage = null; } public BugzillaStatus(int severity, String pluginId, int code, String repositoryUrl, Throwable e) { super(severity, pluginId, code, "MylynStatus", e); //$NON-NLS-1$ this.repositoryUrl = repositoryUrl; this.errorMessage = e.getMessage(); + this.htmlMessage = null; } public BugzillaStatus(int severity, String pluginId, int code, String repositoryUrl, String errorMessage) { super(severity, pluginId, code, "MylynStatus", null); //$NON-NLS-1$ this.errorMessage = errorMessage; this.repositoryUrl = repositoryUrl; + this.htmlMessage = null; } public BugzillaStatus(int severity, String pluginId, int code, String repositoryUrl, String errorMessage, @@ -51,6 +69,15 @@ super(severity, pluginId, code, "MylynStatus", e); //$NON-NLS-1$ this.errorMessage = errorMessage; this.repositoryUrl = repositoryUrl; + this.htmlMessage = null; + } + + public BugzillaStatus(int severity, String pluginId, int code, String repositoryUrl, String errorMessage, + String body) { + super(severity, pluginId, code, "MylynStatus", null); //$NON-NLS-1$ + this.errorMessage = errorMessage; + this.repositoryUrl = repositoryUrl; + this.htmlMessage = body; } /** @@ -108,4 +135,25 @@ public void setRepositoryUrl(String repositoryUrl) { this.repositoryUrl = repositoryUrl; } + + public String getHtmlMessage() { + return htmlMessage; + } + + public Map> getResponseData() { + return responseData; + } + + public void setResponseData(Map> responseData) { + this.responseData = responseData; + } + + public void addResponseData(String name, String response) { + List responseList = responseData.get(name); + if (responseList == null) { + responseList = new LinkedList(); + responseData.put(name.toLowerCase(), responseList); + } + responseList.add(response); + } } Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java,v retrieving revision 1.163 diff -u -r1.163 BugzillaRepositoryConnector.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java 30 Mar 2009 23:11:59 -0000 1.163 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java 9 May 2009 20:08:40 -0000 @@ -411,6 +411,8 @@ enSetting.addLanguageAttribute("submitted", "Submitted"); //$NON-NLS-1$ //$NON-NLS-2$ enSetting.addLanguageAttribute("submitted", "posted"); //$NON-NLS-1$ //$NON-NLS-2$ enSetting.addLanguageAttribute("suspicious_action", "Suspicious action"); //$NON-NLS-1$ //$NON-NLS-2$ + enSetting.addLanguageAttribute("error_confirm_match", "confirm match"); //$NON-NLS-1$//$NON-NLS-2$ + enSetting.addLanguageAttribute("error_match_failed", "match failed"); //$NON-NLS-1$ //$NON-NLS-2$ languages.add(enSetting); } Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java,v retrieving revision 1.181 diff -u -r1.181 BugzillaClient.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java 8 May 2009 19:17:14 -0000 1.181 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java 9 May 2009 20:08:40 -0000 @@ -550,13 +550,13 @@ // provide a solution for bug 196056 by allowing a (cached) gzipped configuration to be sent // modified to also accept "application/x-gzip" as results from a 302 redirect to a previously gzipped file. if (method == null) { - throw new IOException("Could not retrieve configuratoin. HttpClient return null method."); + throw new IOException("Could not retrieve configuratoin. HttpClient return null method."); //$NON-NLS-1$ } InputStream stream = getResponseStream(method, monitor); try { if (method.getResponseHeader("Content-Type") != null) { //$NON-NLS-1$ - Header responseTypeHeader = method.getResponseHeader("Content-Type"); + Header responseTypeHeader = method.getResponseHeader("Content-Type"); //$NON-NLS-1$ for (String type : VALID_CONFIG_CONTENT_TYPES) { if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) { RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory( @@ -576,7 +576,7 @@ } else { throw new CoreException( new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN, - "Unable to retrieve repository configuration. Ensure credentials are valid.")); + "Unable to retrieve repository configuration. Ensure credentials are valid.")); //$NON-NLS-1$ } } } @@ -704,13 +704,13 @@ Iterator itr = attributes.iterator(); while (itr.hasNext()) { TaskAttribute a = itr.next(); - if (a.getId().startsWith("task.common.kind.flag_type")) { + if (a.getId().startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$ List flags = repositoryConfiguration.getFlags(); TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$ - a = a.getAttribute("state"); + a = a.getAttribute("state"); //$NON-NLS-1$ String value = a.getValue(); String id = ""; //$NON-NLS-1$ - if (value.equals(" ")) { + if (value.equals(" ")) { //$NON-NLS-1$ continue; } String flagname = a.getMetaData().getLabel(); @@ -723,28 +723,28 @@ } if (theFlag != null) { int flagTypeNumber = theFlag.getFlagId(); - id = "flag_type-" + flagTypeNumber; + id = "flag_type-" + flagTypeNumber; //$NON-NLS-1$ value = a.getValue(); if (value.equals("?") && requestee != null) { //$NON-NLS-1$ - parts.add(new StringPart("requestee_type-" + flagTypeNumber, - requestee.getValue() != null ? requestee.getValue() : "")); + parts.add(new StringPart("requestee_type-" + flagTypeNumber, //$NON-NLS-1$ + requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$ } } parts.add(new StringPart(id, value != null ? value : "")); //$NON-NLS-1$ - } else if (a.getId().startsWith("task.common.kind.flag")) { - TaskAttribute flagnumber = a.getAttribute("number"); + } else if (a.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + TaskAttribute flagnumber = a.getAttribute("number"); //$NON-NLS-1$ TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$ a = a.getAttribute("state"); //$NON-NLS-1$ - String id = "flag-" + flagnumber.getValue(); + String id = "flag-" + flagnumber.getValue(); //$NON-NLS-1$ String value = a.getValue(); if (value.equals(" ")) { //$NON-NLS-1$ - value = "X"; + value = "X"; //$NON-NLS-1$ } if (value.equals("?") && requestee != null) { //$NON-NLS-1$ - parts.add(new StringPart("requestee-" + flagnumber.getValue(), - requestee.getValue() != null ? requestee.getValue() : "")); + parts.add(new StringPart("requestee-" + flagnumber.getValue(), //$NON-NLS-1$ + requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$ } - parts.add(new StringPart(id, value != null ? value : "")); + parts.add(new StringPart(id, value != null ? value : "")); //$NON-NLS-1$ } } } @@ -823,32 +823,32 @@ boolean existingBugPosted = false; formData.add(new NameValuePair("action", action)); //$NON-NLS-1$ - formData.add(new NameValuePair("contenttypemethod", "manual")); + formData.add(new NameValuePair("contenttypemethod", "manual")); //$NON-NLS-1$ //$NON-NLS-2$ - formData.add(new NameValuePair("id", taskAttribute.getValue())); + formData.add(new NameValuePair("id", taskAttribute.getValue())); //$NON-NLS-1$ Collection attributes = taskAttribute.getAttributes().values(); Iterator itr = attributes.iterator(); while (itr.hasNext()) { TaskAttribute a = itr.next(); String id = a.getId(); String value = a.getValue(); - if (id.equals(TaskAttribute.ATTACHMENT_AUTHOR) || id.equals("date") || id.equals("size") + if (id.equals(TaskAttribute.ATTACHMENT_AUTHOR) || id.equals("date") || id.equals("size") //$NON-NLS-1$ //$NON-NLS-2$ || id.equals(TaskAttribute.ATTACHMENT_URL)) { continue; } if (id.equals("desc")) { //$NON-NLS-1$ - id = "description"; + id = "description"; //$NON-NLS-1$ } if (id.equals("ctype")) { //$NON-NLS-1$ - id = "contenttypeentry"; + id = "contenttypeentry"; //$NON-NLS-1$ } if (id.equals(TaskAttribute.ATTACHMENT_IS_DEPRECATED)) { - id = "isobsolete"; + id = "isobsolete"; //$NON-NLS-1$ } if (id.equals(TaskAttribute.ATTACHMENT_IS_PATCH)) { - id = "ispatch"; + id = "ispatch"; //$NON-NLS-1$ } formData.add(new NameValuePair(id, value)); } @@ -883,7 +883,7 @@ if (isTitle) { // get all of the data in the title tag if (token.getType() != Token.TAG) { - title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " "; + title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " "; //$NON-NLS-1$ continue; } else if (token.getType() == Token.TAG && ((HtmlTag) token.getValue()).getTagType() == Tag.TITLE && ((HtmlTag) token.getValue()).isEndTag()) { @@ -913,7 +913,7 @@ } catch (ParseException e) { loggedIn = false; throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); + RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); //$NON-NLS-1$ //$NON-NLS-2$ } finally { if (input != null) { input.close(); @@ -950,7 +950,7 @@ } if (method == null) { - throw new IOException("Could not post form, client returned null method."); + throw new IOException("Could not post form, client returned null method."); //$NON-NLS-1$ } input = getResponseStream(method, monitor); @@ -975,7 +975,7 @@ if (isTitle) { // get all of the data in the title tag if (token.getType() != Token.TAG) { - title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " "; + title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " "; //$NON-NLS-1$ continue; } else if (token.getType() == Token.TAG && ((HtmlTag) token.getValue()).getTagType() == Tag.TITLE && ((HtmlTag) token.getValue()).isEndTag()) { @@ -1037,7 +1037,7 @@ } catch (ParseException e) { loggedIn = false; throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); + RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); //$NON-NLS-1$//$NON-NLS-2$ } finally { if (input != null) { input.close(); @@ -1058,7 +1058,7 @@ Iterator itr = attributes.iterator(); while (itr.hasNext()) { TaskAttribute a = itr.next(); - if (a != null && a.getId() != null && a.getId().compareTo("") != 0) { + if (a != null && a.getId() != null && a.getId().compareTo("") != 0) { //$NON-NLS-1$ String value = null; value = a.getValue(); if (value == null) { @@ -1084,7 +1084,7 @@ } TaskAttribute descAttribute = taskData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION); - if (descAttribute != null && !descAttribute.getValue().equals("")) { + if (descAttribute != null && !descAttribute.getValue().equals("")) { //$NON-NLS-1$ BugzillaVersion bugzillaVersion = null; if (repositoryConfiguration != null) { bugzillaVersion = repositoryConfiguration.getInstallVersion(); @@ -1111,7 +1111,7 @@ } private void cleanIfShortLogin(TaskAttribute a) { - if ("true".equals(configParameters.get(IBugzillaConstants.REPOSITORY_SETTING_SHORT_LOGIN))) { + if ("true".equals(configParameters.get(IBugzillaConstants.REPOSITORY_SETTING_SHORT_LOGIN))) { //$NON-NLS-1$ if (a.getValue() != null && a.getValue().length() > 0) { int atIndex = a.getValue().indexOf("@"); //$NON-NLS-1$ if (atIndex != -1) { @@ -1168,19 +1168,19 @@ List values = a.getValues(); int i = 0; for (String string : values) { - fields.put(id + i++, new NameValuePair(id, string != null ? string : "")); + fields.put(id + i++, new NameValuePair(id, string != null ? string : "")); //$NON-NLS-1$ } - } else if (id != null && id.compareTo("") != 0) { + } else if (id != null && id.compareTo("") != 0) { //$NON-NLS-1$ String value = a.getValue(); if (id.equals(BugzillaAttribute.DELTA_TS.getKey())) { value = stripTimeZone(value); } - if (id.startsWith("task.common.kind.flag_type")) { + if (id.startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$ List flags = repositoryConfiguration.getFlags(); TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$ - a = a.getAttribute("state"); + a = a.getAttribute("state"); //$NON-NLS-1$ value = a.getValue(); - if (value.equals(" ")) { + if (value.equals(" ")) { //$NON-NLS-1$ continue; } String flagname = a.getMetaData().getLabel(); @@ -1193,31 +1193,31 @@ } if (theFlag != null) { int flagTypeNumber = theFlag.getFlagId(); - id = "flag_type-" + flagTypeNumber; + id = "flag_type-" + flagTypeNumber; //$NON-NLS-1$ value = a.getValue(); if (value.equals("?") && requestee != null) { //$NON-NLS-1$ - fields.put("requestee_type-" + flagTypeNumber, new NameValuePair("requestee_type-" //$NON-NLS-2$ - + flagTypeNumber, requestee.getValue() != null ? requestee.getValue() : "")); + fields.put("requestee_type-" + flagTypeNumber, new NameValuePair("requestee_type-" //$NON-NLS-1$ //$NON-NLS-2$ + + flagTypeNumber, requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$ } } } else if (id.startsWith("task.common.kind.flag")) { //$NON-NLS-1$ - TaskAttribute flagnumber = a.getAttribute("number"); + TaskAttribute flagnumber = a.getAttribute("number"); //$NON-NLS-1$ TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$ a = a.getAttribute("state"); //$NON-NLS-1$ - id = "flag-" + flagnumber.getValue(); + id = "flag-" + flagnumber.getValue(); //$NON-NLS-1$ value = a.getValue(); if (value.equals(" ")) { //$NON-NLS-1$ - value = "X"; + value = "X"; //$NON-NLS-1$ } if (value.equals("?") && requestee != null) { //$NON-NLS-1$ - fields.put("requestee-" + flagnumber.getValue(), new NameValuePair("requestee-" //$NON-NLS-2$ - + flagnumber.getValue(), requestee.getValue() != null ? requestee.getValue() : "")); + fields.put("requestee-" + flagnumber.getValue(), new NameValuePair("requestee-" //$NON-NLS-1$//$NON-NLS-2$ + + flagnumber.getValue(), requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$ } - } else if (id.startsWith("task.common.")) { + } else if (id.startsWith("task.common.")) { //$NON-NLS-1$ // Don't post any remaining non-bugzilla specific attributes continue; } - fields.put(id, new NameValuePair(id, value != null ? value : "")); + fields.put(id, new NameValuePair(id, value != null ? value : "")); //$NON-NLS-1$ } } } @@ -1249,7 +1249,7 @@ } else { String inputAttributeId = originalOperation.getMetaData().getValue( TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID); - if (inputAttributeId == null || inputAttributeId.equals("")) { + if (inputAttributeId == null || inputAttributeId.equals("")) { //$NON-NLS-1$ String sel = attributeOperation.getValue(); fields.put(KEY_KNOB, new NameValuePair(KEY_KNOB, sel)); } else { @@ -1282,7 +1282,7 @@ } else if (attributeOperation != null && attributeOperation.getValue().equals(BugzillaOperation.duplicate.toString())) { // fix for bug#198677 - fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, "")); + fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, "")); //$NON-NLS-1$ } } } else { @@ -1306,32 +1306,32 @@ fields.put(fieldName, new NameValuePair(fieldName, attributeStatus.getValue())); } else { String selOp = attributeOperation.getValue().toUpperCase(); - if (selOp.equals("NONE")) { + if (selOp.equals("NONE")) { //$NON-NLS-1$ selOp = attributeStatus.getValue(); } if (selOp.equals("ACCEPT")) { //$NON-NLS-1$ - selOp = "ASSIGNED"; + selOp = "ASSIGNED"; //$NON-NLS-1$ } if (selOp.equals("RESOLVE")) { //$NON-NLS-1$ - selOp = "RESOLVED"; + selOp = "RESOLVED"; //$NON-NLS-1$ } if (selOp.equals("VERIFY")) { //$NON-NLS-1$ - selOp = "VERIFIED"; + selOp = "VERIFIED"; //$NON-NLS-1$ } if (selOp.equals("CLOSE")) { //$NON-NLS-1$ - selOp = "CLOSED"; + selOp = "CLOSED"; //$NON-NLS-1$ } if (selOp.equals("REOPEN")) { //$NON-NLS-1$ - selOp = "REOPENED"; + selOp = "REOPENED"; //$NON-NLS-1$ } if (selOp.equals("DUPLICATE")) { //$NON-NLS-1$ - selOp = "RESOLVED"; + selOp = "RESOLVED"; //$NON-NLS-1$ String knob = BugzillaAttribute.RESOLUTION.getKey(); - fields.put(knob, new NameValuePair(knob, "DUPLICATE")); + fields.put(knob, new NameValuePair(knob, "DUPLICATE")); //$NON-NLS-1$ } fields.put(fieldName, new NameValuePair(fieldName, selOp)); - if (inputAttributeId != null && !inputAttributeId.equals("")) { + if (inputAttributeId != null && !inputAttributeId.equals("")) { //$NON-NLS-1$ TaskAttribute inputAttribute = attributeOperation.getTaskData().getRoot().getAttribute( inputAttributeId); if (inputAttribute != null) { @@ -1345,7 +1345,7 @@ } else { String sel = inputAttribute.getValue(); String knob = attributeOperation.getValue(); - if (knob.equals("duplicate")) { + if (knob.equals("duplicate")) { //$NON-NLS-1$ knob = inputAttributeId; } if (knob.equals(BugzillaOperation.reassign.toString())) { @@ -1414,8 +1414,8 @@ String bugUrl = taskData.getRepositoryUrl() + IBugzillaConstants.URL_GET_SHOW_BUG + taskData.getTaskId(); GzipGetMethod getMethod = new GzipGetMethod(WebUtil.getRequestPath(bugUrl), false); - getMethod.setRequestHeader("Content-Type", "text/xml; charset=" + characterEncoding); //$NON-NLS-1$ - httpClient.getParams().setParameter("http.protocol.single-cookie-header", true); + getMethod.setRequestHeader("Content-Type", "text/xml; charset=" + characterEncoding); //$NON-NLS-1$ //$NON-NLS-2$ + httpClient.getParams().setParameter("http.protocol.single-cookie-header", true); //$NON-NLS-1$ getMethod.setDoAuthentication(true); int code; @@ -1577,6 +1577,41 @@ } found = false; for (Iterator iterator = bugzillaLanguageSettings.getResponseForCommand( + BugzillaLanguageSettings.COMMAND_ERROR_CONFIRM_MATCH).iterator(); iterator.hasNext() + && !found;) { + String value = iterator.next().toLowerCase(Locale.ENGLISH); + found = found || title.indexOf(value) != -1; + } + if (found) { + BugzillaStatus status = new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, + BugzillaStatus.ERROR_CONFIRM_MATCH, repositoryUrl.toString(), "Confirm Match", body); //$NON-NLS-1$ + try { + in.reset(); + } catch (IOException e) { + // ignore + } + parseResultConfirmMatch(in, status); + } + + found = false; + for (Iterator iterator = bugzillaLanguageSettings.getResponseForCommand( + BugzillaLanguageSettings.COMMAND_ERROR_MATCH_FAILED).iterator(); iterator.hasNext() + && !found;) { + String value = iterator.next().toLowerCase(Locale.ENGLISH); + found = found || title.indexOf(value) != -1; + } + if (found) { + BugzillaStatus status = new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, + BugzillaStatus.ERROR_MATCH_FAILED, repositoryUrl.toString(), "Match Failed", body); //$NON-NLS-1$ + try { + in.reset(); + } catch (IOException e) { + // ignore + } + parseResultMatchFailed(in, status); + } + found = false; + for (Iterator iterator = bugzillaLanguageSettings.getResponseForCommand( BugzillaLanguageSettings.COMMAND_CHANGES_SUBMITTED).iterator(); iterator.hasNext() && !found;) { String value = iterator.next().toLowerCase(Locale.ENGLISH); @@ -1898,4 +1933,129 @@ } + private void parseResultConfirmMatch(BufferedReader in, BugzillaStatus status) throws IOException, CoreException { + HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null); + + boolean isSelect = false; + String select = ""; //$NON-NLS-1$ + String body = ""; //$NON-NLS-1$ + String name = ""; //$NON-NLS-1$ + String value = ""; //$NON-NLS-1$ + try { + for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { + body += token.toString(); + if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.SELECT + && !((HtmlTag) (token.getValue())).isEndTag()) { + isSelect = true; + select += token.toString().toLowerCase(Locale.ENGLISH); + name = ((HtmlTag) (token.getValue())).getAttribute("id"); //$NON-NLS-1$ + continue; + } + + if (isSelect) { + if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.OPTION + && !((HtmlTag) (token.getValue())).isEndTag()) { + value = ((HtmlTag) (token.getValue())).getAttribute("value"); //$NON-NLS-1$ + status.addResponseData(name, value); + } + if (token.getType() == Token.TAG && ((HtmlTag) token.getValue()).getTagType() == Tag.SELECT + && ((HtmlTag) token.getValue()).isEndTag()) { + isSelect = false; + } + } + } + throw new CoreException(status); + } catch (ParseException e) { + throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, + RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); //$NON-NLS-1$//$NON-NLS-2$ + } finally { + in.close(); + } + } + + private void parseResultMatchFailed(BufferedReader in, BugzillaStatus status) throws IOException, CoreException { + HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null); + + boolean isDT = false; + String dtString = ""; //$NON-NLS-1$ + String body = ""; //$NON-NLS-1$ + String lastDTValue = ""; //$NON-NLS-1$ + boolean isDiv = false; + String divString = ""; //$NON-NLS-1$ + try { + for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { + body += token.toString(); + if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.TD + && ((HtmlTag) (token.getValue())).isEndTag()) { + isDT = false; + if (!dtString.equals("")) { //$NON-NLS-1$ + lastDTValue = dtString; + } + dtString = ""; //$NON-NLS-1$ + continue; + } + if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.DIV + && ((HtmlTag) (token.getValue())).isEndTag()) { + isDiv = false; + if (divString.length() > 4) { + if (lastDTValue.equals("CC:")) { //$NON-NLS-1$ + lastDTValue = "newcc"; //$NON-NLS-1$ + } + if (lastDTValue.equals("Assignee:")) { //$NON-NLS-1$ + lastDTValue = "assigned_to"; //$NON-NLS-1$ + } + if (lastDTValue.equals("QAContact:")) { //$NON-NLS-1$ + lastDTValue = "qa_contact"; //$NON-NLS-1$ + } + + int start = divString.indexOf(""); //$NON-NLS-1$ + int optionValue = divString.indexOf("