diff options
author | Frank Becker | 2012-08-01 18:36:10 +0000 |
---|---|---|
committer | Frank Becker | 2012-08-01 18:36:10 +0000 |
commit | fe7be2708d01b7e224d724be593ca552a703788b (patch) | |
tree | d4878448510badc06656a905c9589186488c5bab | |
parent | 4e1bf657fd32c2eab2069ecba8a145d97411c629 (diff) | |
download | org.eclipse.mylyn.tasks-fe7be2708d01b7e224d724be593ca552a703788b.tar.gz org.eclipse.mylyn.tasks-fe7be2708d01b7e224d724be593ca552a703788b.tar.xz org.eclipse.mylyn.tasks-fe7be2708d01b7e224d724be593ca552a703788b.zip |
ASSIGNED - bug 382173: user match for cc has changed in Bugzilla
https://bugs.eclipse.org/bugs/show_bug.cgi?id=382173
Change-Id: I92808d8f588b4f147ac0a0f4c073eb6506239709
4 files changed, 154 insertions, 111 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 cf985898c..c88e6eb3d 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 @@ -69,13 +69,13 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.mylyn.commons.core.HtmlStreamTokenizer; +import org.eclipse.mylyn.commons.core.HtmlStreamTokenizer.Token; +import org.eclipse.mylyn.commons.core.HtmlTag; import org.eclipse.mylyn.commons.core.StatusHandler; import org.eclipse.mylyn.commons.net.AbstractWebLocation; import org.eclipse.mylyn.commons.net.AuthenticationCredentials; import org.eclipse.mylyn.commons.net.AuthenticationType; -import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer; -import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token; -import org.eclipse.mylyn.commons.net.HtmlTag; import org.eclipse.mylyn.commons.net.Policy; import org.eclipse.mylyn.commons.net.WebLocation; import org.eclipse.mylyn.commons.net.WebUtil; @@ -1311,6 +1311,7 @@ public class BugzillaClient { } if (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_0) > 0) { TaskAttribute productAttribute = taskData.getRoot().getAttribute(BugzillaAttribute.PRODUCT.getKey()); + token = getTokenInternal( taskData.getRepositoryUrl() + ENTER_BUG_PRODUCT_CGI + URLEncoder.encode(productAttribute.getValue(), IBugzillaConstants.ENCODING_UTF_8), @@ -2037,15 +2038,8 @@ public class BugzillaClient { found = found || title.indexOf(value) != -1; } if (found) { - BugzillaVersion bugzillaVersion = null; - if (repositoryConfiguration != null) { - bugzillaVersion = repositoryConfiguration.getInstallVersion(); - } else { - bugzillaVersion = BugzillaVersion.MIN_VERSION; - } BugzillaUserMatchResponse matchResponse = new BugzillaUserMatchResponse(); - matchResponse.parseResultConfirmMatch(tokenizer, repositoryUrl.toString(), body, - bugzillaVersion.isSmaller(BugzillaVersion.BUGZILLA_4_0)); + matchResponse.parseResultConfirmMatch(tokenizer, repositoryUrl.toString(), body); } found = false; diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java index 0e7a49511..da6001173 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java @@ -13,20 +13,23 @@ package org.eclipse.mylyn.internal.bugzilla.core; import java.io.IOException; import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import javax.swing.text.html.HTML.Tag; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; -import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer; -import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token; -import org.eclipse.mylyn.commons.net.HtmlTag; +import org.eclipse.mylyn.commons.core.HtmlStreamTokenizer; +import org.eclipse.mylyn.commons.core.HtmlStreamTokenizer.Token; +import org.eclipse.mylyn.commons.core.HtmlTag; import org.eclipse.mylyn.tasks.core.RepositoryStatus; public class BugzillaUserMatchResponse { - private final List<String> newCCProposals = new LinkedList<String>(); + private final Map<String, List<String>> newCCProposals = new HashMap<String, List<String>>(); private final List<String> assignedToProposals = new LinkedList<String>(); @@ -38,7 +41,7 @@ public class BugzillaUserMatchResponse { private String qaContactMsg; - public List<String> getNewCCProposals() { + public Map<String, List<String>> getNewCCProposals() { return newCCProposals; } @@ -62,72 +65,14 @@ public class BugzillaUserMatchResponse { return qaContactMsg; } - public void parseResultConfirmMatch(HtmlStreamTokenizer tokenizer, String repositoryURL, String body, - boolean oldStyle) throws IOException, CoreException { - if (oldStyle) { - parseConfirmMatchOld(tokenizer, repositoryURL, body); - } else { - parseConfirmMatchNew(tokenizer, repositoryURL, body); - } + public void parseResultConfirmMatch(HtmlStreamTokenizer tokenizer, String repositoryURL, String body) + throws IOException, CoreException { + parseConfirmMatchInternal(tokenizer, repositoryURL, body); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, BugzillaStatus.ERROR_CONFIRM_MATCH, repositoryURL, "Confirm Match", body, this)); //$NON-NLS-1$ } - private void parseConfirmMatchNew(HtmlStreamTokenizer tokenizer, String repositoryURL, String body) - throws IOException, CoreException { - String name = ""; //$NON-NLS-1$ - String value = ""; //$NON-NLS-1$ - String divClass = null; - try { - for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) { - if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.DIV - && !((HtmlTag) (token.getValue())).isEndTag()) { - divClass = ((HtmlTag) (token.getValue())).getAttribute("class"); //$NON-NLS-1$ - } - if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.DIV - && ((HtmlTag) (token.getValue())).isEndTag()) { - divClass = null; - } - - if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.INPUT - && !((HtmlTag) (token.getValue())).isEndTag() && divClass != null - && divClass.equals("user_match")) { //$NON-NLS-1$ - value = ((HtmlTag) (token.getValue())).getAttribute("value"); //$NON-NLS-1$ - name = ((HtmlTag) (token.getValue())).getAttribute("name"); //$NON-NLS-1$ - value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ - if (name.equals("newcc")) { //$NON-NLS-1$ - newCCProposals.add(value); - } else if (name.equals("assigned_to")) { //$NON-NLS-1$ - assignedToProposals.add(value); - } else if (name.equals("qa_contact")) { //$NON-NLS-1$ - qaContactProposals.add(value); - } - } - if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.SELECT - && !((HtmlTag) (token.getValue())).isEndTag()) { - name = ((HtmlTag) (token.getValue())).getAttribute("id"); //$NON-NLS-1$ - } - if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.OPTION - && !((HtmlTag) (token.getValue())).isEndTag() && divClass != null - && divClass.equals("user_match")) { //$NON-NLS-1$ - value = ((HtmlTag) (token.getValue())).getAttribute("value"); //$NON-NLS-1$ - value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ - if (name.equals("newcc")) { //$NON-NLS-1$ - newCCProposals.add(value); - } else if (name.equals("assigned_to")) { //$NON-NLS-1$ - assignedToProposals.add(value); - } else if (name.equals("qa_contact")) { //$NON-NLS-1$ - qaContactProposals.add(value); - } - } - } - } catch (ParseException e) { - throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryURL + ".")); //$NON-NLS-1$//$NON-NLS-2$ - } - } - - private void parseConfirmMatchOld(HtmlStreamTokenizer tokenizer, String repositoryURL, String body) + private void parseConfirmMatchInternal(HtmlStreamTokenizer tokenizer, String repositoryURL, String body) throws IOException, CoreException { boolean isDT = false; String dtString = ""; //$NON-NLS-1$ @@ -159,16 +104,23 @@ public class BugzillaUserMatchResponse { lastDTValue = "qa_contact"; //$NON-NLS-1$ } - int start = divString.indexOf("</b>"); //$NON-NLS-1$ - int optionValue = divString.indexOf("<option value=\"", start + 4); //$NON-NLS-1$ + int startBold = divString.indexOf("<b>"); //$NON-NLS-1$ + int endBold = divString.indexOf("</b>"); //$NON-NLS-1$ + String name = divString.substring(startBold + 3, endBold).trim(); + int optionValue = divString.indexOf("<option value=\"", endBold + 4); //$NON-NLS-1$ String value = ""; //$NON-NLS-1$ if (optionValue == -1) { - int startText = divString.indexOf("<", start + 4) + 1; //$NON-NLS-1$ + int startText = divString.indexOf("<", endBold + 4) + 1; //$NON-NLS-1$ int endText = divString.indexOf(">", startText + 1); //$NON-NLS-1$ String temp = divString.substring(startText + 3, endText); value = temp.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ if (lastDTValue.equals("newcc")) { //$NON-NLS-1$ - newCCProposals.add(value); + List<String> proposalList = newCCProposals.get(name); + if (proposalList == null) { + proposalList = new ArrayList<String>(); + newCCProposals.put(name, proposalList); + } + proposalList.add(value); } else if (lastDTValue.equals("assigned_to")) { //$NON-NLS-1$ assignedToProposals.add(value); } else if (lastDTValue.equals("qa_contact")) { //$NON-NLS-1$ @@ -180,7 +132,12 @@ public class BugzillaUserMatchResponse { value = divString.substring(optionValue + 15, endText); value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ if (lastDTValue.equals("newcc")) { //$NON-NLS-1$ - newCCProposals.add(value); + List<String> proposalList = newCCProposals.get(name); + if (proposalList == null) { + proposalList = new ArrayList<String>(); + newCCProposals.put(name, proposalList); + } + proposalList.add(value); } else if (lastDTValue.equals("assigned_to")) { //$NON-NLS-1$ assignedToProposals.add(value); } else if (lastDTValue.equals("qa_contact")) { //$NON-NLS-1$ @@ -251,14 +208,16 @@ public class BugzillaUserMatchResponse { lastDTValue = "qa_contact"; //$NON-NLS-1$ } - int start = divString.indexOf("</b>"); //$NON-NLS-1$ - int optionValue = divString.indexOf("<option value=\"", start + 4); //$NON-NLS-1$ + int startBold = divString.indexOf("<b>"); //$NON-NLS-1$ + int endBold = divString.indexOf("</b>"); //$NON-NLS-1$ + String name = divString.substring(startBold + 3, endBold).trim(); + int optionValue = divString.indexOf("<option value=\"", endBold + 4); //$NON-NLS-1$ String value = ""; //$NON-NLS-1$ if (optionValue == -1) { - int startText = divString.indexOf(">", start + 4) + 1; //$NON-NLS-1$ + int startText = divString.indexOf(">", endBold + 4) + 1; //$NON-NLS-1$ int endText = divString.indexOf("<", startText + 1); //$NON-NLS-1$ String temp = divString.substring(startText, endText); - value = divString.substring(5, start) + temp; + value = divString.substring(5, endBold) + temp; value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ if (lastDTValue.equals("newcc")) { //$NON-NLS-1$ newCCMsg = value; @@ -273,7 +232,12 @@ public class BugzillaUserMatchResponse { value = divString.substring(optionValue + 15, endText); value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ if (lastDTValue.equals("newcc")) { //$NON-NLS-1$ - newCCProposals.add(value); + List<String> proposalList = newCCProposals.get(name); + if (proposalList == null) { + proposalList = new ArrayList<String>(); + newCCProposals.put(name, proposalList); + } + proposalList.add(value); } else if (lastDTValue.equals("assigned_to")) { //$NON-NLS-1$ assignedToProposals.add(value); } else if (lastDTValue.equals("qa_contact")) { //$NON-NLS-1$ @@ -306,7 +270,7 @@ public class BugzillaUserMatchResponse { } } throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, - BugzillaStatus.ERROR_MATCH_FAILED, repositoryURL, "Match Failed", body, this)); + BugzillaStatus.ERROR_MATCH_FAILED, repositoryURL, "Match Failed", body, this)); //$NON-NLS-1$ } catch (ParseException e) { throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryURL + ".")); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java index f1b61d4c4..1e6ae71cd 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java @@ -1232,7 +1232,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(0, matchUserResponse.getNewCCProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); @@ -1248,11 +1248,12 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(2, matchUserResponse.getNewCCProposals().size()); + assertEquals(1, matchUserResponse.getNewCCProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); - assertTrue(matchUserResponse.getNewCCProposals().contains("tests@mylyn.eclipse.org")); - assertTrue(matchUserResponse.getNewCCProposals().contains("guest@mylyn.eclipse.org")); + assertNotNull(matchUserResponse.getNewCCProposals().get("est")); + assertTrue(matchUserResponse.getNewCCProposals().get("est").contains("tests@mylyn.eclipse.org")); + assertTrue(matchUserResponse.getNewCCProposals().get("est").contains("guest@mylyn.eclipse.org")); assertNull(matchUserResponse.getNewCCMsg()); assertNull(matchUserResponse.getAssignedToMsg()); assertNull(matchUserResponse.getQaContactMsg()); @@ -1274,7 +1275,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(0, matchUserResponse.getNewCCProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNull(matchUserResponse.getNewCCMsg()); @@ -1290,7 +1291,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(0, matchUserResponse.getNewCCProposals().size()); assertEquals(2, matchUserResponse.getAssignedToProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertTrue(matchUserResponse.getAssignedToProposals().contains("tests@mylyn.eclipse.org")); @@ -1316,7 +1317,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(0, matchUserResponse.getNewCCProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); @@ -1336,7 +1337,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertEquals(1, matchUserResponse.getNewCCProposals().size()); assertEquals(2, matchUserResponse.getAssignedToProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); - assertTrue(matchUserResponse.getNewCCProposals().contains("tests@mylyn.eclipse.org")); + assertNotNull(matchUserResponse.getNewCCProposals().get("test")); + assertTrue(matchUserResponse.getNewCCProposals().get("test").contains("tests@mylyn.eclipse.org")); assertTrue(matchUserResponse.getAssignedToProposals().contains("tests@mylyn.eclipse.org")); assertTrue(matchUserResponse.getAssignedToProposals().contains("guest@mylyn.eclipse.org")); assertNull(matchUserResponse.getNewCCMsg()); @@ -1346,6 +1348,50 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { } } + public void testErrorMatchConfirmMatch4() throws Exception { + try { + doUserMatch("test;guest", null); + fail("CoreException expected but not found"); + } catch (CoreException e) { + if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_6) < 0) { + assertEquals(BugzillaStatus.ERROR_MATCH_FAILED, e.getStatus().getCode()); + BugzillaStatus status = (BugzillaStatus) e.getStatus(); + assertNotNull(status); + BugzillaUserMatchResponse matchUserResponse = status.getUserMatchResponse(); + assertNotNull(matchUserResponse); + assertNotNull(matchUserResponse.getNewCCProposals()); + assertNotNull(matchUserResponse.getAssignedToProposals()); + assertNotNull(matchUserResponse.getQaContactProposals()); + assertEquals(0, matchUserResponse.getNewCCProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); + assertNotNull(matchUserResponse.getNewCCMsg()); + assertNull(matchUserResponse.getAssignedToMsg()); + assertNull(matchUserResponse.getQaContactMsg()); + assertTrue(matchUserResponse.getNewCCMsg().equals("test;guest did not match anything ")); + } else { + assertEquals(BugzillaStatus.ERROR_CONFIRM_MATCH, e.getStatus().getCode()); + BugzillaStatus status = (BugzillaStatus) e.getStatus(); + assertNotNull(status); + BugzillaUserMatchResponse matchUserResponse = status.getUserMatchResponse(); + assertNotNull(matchUserResponse); + assertNotNull(matchUserResponse.getNewCCProposals()); + assertNotNull(matchUserResponse.getAssignedToProposals()); + assertNotNull(matchUserResponse.getQaContactProposals()); + assertEquals(2, matchUserResponse.getNewCCProposals().size()); + assertEquals(0, matchUserResponse.getAssignedToProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); + assertNotNull(matchUserResponse.getNewCCProposals().get("test")); + assertNotNull(matchUserResponse.getNewCCProposals().get("guest")); + assertTrue(matchUserResponse.getNewCCProposals().get("test").contains("tests@mylyn.eclipse.org")); + assertTrue(matchUserResponse.getNewCCProposals().get("guest").contains("guest@mylyn.eclipse.org")); + assertNull(matchUserResponse.getNewCCMsg()); + assertNull(matchUserResponse.getAssignedToMsg()); + assertNull(matchUserResponse.getQaContactMsg()); + } + } + } + public void testErrorMatchFailed() throws Exception { try { doUserMatch("tests1@mylyn.eclipse.org", null); @@ -1359,7 +1405,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(0, matchUserResponse.getNewCCProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); @@ -1383,7 +1429,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(0, matchUserResponse.getNewCCProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); @@ -1400,11 +1446,12 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(2, matchUserResponse.getNewCCProposals().size()); + assertEquals(1, matchUserResponse.getNewCCProposals().size()); assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); - assertTrue(matchUserResponse.getNewCCProposals().contains("tests@mylyn.eclipse.org")); - assertTrue(matchUserResponse.getNewCCProposals().contains("guest@mylyn.eclipse.org")); + assertNotNull(matchUserResponse.getNewCCProposals().get("est")); + assertTrue(matchUserResponse.getNewCCProposals().get("est").contains("tests@mylyn.eclipse.org")); + assertTrue(matchUserResponse.getNewCCProposals().get("est").contains("guest@mylyn.eclipse.org")); assertNull(matchUserResponse.getNewCCMsg()); assertNotNull(matchUserResponse.getAssignedToMsg()); assertNull(matchUserResponse.getQaContactMsg()); diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java index 90a33a433..ce7353c76 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java @@ -630,23 +630,25 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { BugzillaUserMatchResponse response = bugzillaStatus.getUserMatchResponse(); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fieldDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); + FieldDecoration fieldDecorationWarning = registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); StringBuilder fields = new StringBuilder(); StringBuilder detail = new StringBuilder(); count += decorateControlsAndUpdateMessages(response.getAssignedToMsg(), response.getAssignedToProposals(), getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.ASSIGNED_TO.getKey()), fields, - detail, fieldDecoration); + detail, fieldDecoration, fieldDecorationWarning); count += decorateControlsAndUpdateMessages(response.getQaContactMsg(), response.getQaContactProposals(), getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.QA_CONTACT.getKey()), fields, detail, - fieldDecoration); + fieldDecoration, fieldDecorationWarning); count += decorateControlsAndUpdateMessages(response.getNewCCMsg(), response.getNewCCProposals(), getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.NEWCC.getKey()), fields, detail, - fieldDecoration); + fieldDecoration, fieldDecorationWarning); updateTaskEditorPageMessageWithError(bugzillaStatus, detail.toString(), count == 1, fields.toString()); } private int decorateControlsAndUpdateMessages(String message, List<String> proposals, TaskAttribute attribute, - StringBuilder fields, StringBuilder detail, FieldDecoration fieldDecoration) { + StringBuilder fields, StringBuilder detail, FieldDecoration fieldDecoration, + FieldDecoration fieldDecorationWarning) { if (attribute == null || (message == null && proposals.size() == 0)) { return 0; } @@ -669,7 +671,41 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { } AbstractAttributeEditor editor = getEditorForAttribute(attribute); if (editor != null) { - decorateEditorWithError(fieldDecoration, message, newPersonProposalMap, editor); + decorateEditorWithError(fieldDecoration, fieldDecorationWarning, message, newPersonProposalMap, editor); + } + return 1; + } + + private int decorateControlsAndUpdateMessages(String message, Map<String, List<String>> proposals, + TaskAttribute attribute, StringBuilder fields, StringBuilder detail, FieldDecoration fieldDecoration, + FieldDecoration fieldDecorationWarning) { + if (attribute == null || (message == null && proposals.size() == 0)) { + return 0; + } + Map<String, String> newPersonProposalMap = new HashMap<String, String>(); + if (fields.length() > 0) { + fields.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_Error_Label_N, attribute.getMetaData() + .getLabel())); + } else { + fields.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_Error_Label_1, attribute.getMetaData() + .getLabel())); + } + detail.append(attribute.getMetaData().getLabel() + "\n"); //$NON-NLS-1$ + if (message != null && !message.equals("")) { //$NON-NLS-1$ + detail.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_DetailLine, message)); + } else { + for (String key : proposals.keySet()) { + detail.append(MessageFormat.format("\t{0}\n", key)); + + for (String proposalValue : proposals.get(key)) { + detail.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_DetailLine, proposalValue)); + newPersonProposalMap.put(proposalValue, proposalValue); + } + } + } + AbstractAttributeEditor editor = getEditorForAttribute(attribute); + if (editor != null) { + decorateEditorWithError(fieldDecoration, fieldDecorationWarning, message, newPersonProposalMap, editor); } return 1; } @@ -726,12 +762,14 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { * @param newPersonProposalMap * @param editor */ - private void decorateEditorWithError(FieldDecoration fieldDecoration, String message, - Map<String, String> newPersonProposalMap, AbstractAttributeEditor editor) { + private void decorateEditorWithError(FieldDecoration fieldDecoration, FieldDecoration fieldDecorationWarning, + String message, Map<String, String> newPersonProposalMap, AbstractAttributeEditor editor) { final Control control = editor.getControl(); final ControlDecoration decoration = new ControlDecoration(control, SWT.LEFT | SWT.DOWN); - decoration.setImage(fieldDecoration.getImage()); + decoration.setImage(newPersonProposalMap.size() == 1 + ? fieldDecorationWarning.getImage() + : fieldDecoration.getImage()); IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class); if (message != null && !message.equals("")) { //$NON-NLS-1$ decoration.setDescriptionText(message); @@ -742,7 +780,7 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { bindingService.getBestActiveBindingFormattedFor(ContentAssistCommandAdapter.CONTENT_PROPOSAL_COMMAND))); errorDecorations.add(decoration); - PersonAttributeEditor personEditor = ((PersonAttributeEditor) editor); + final PersonAttributeEditor personEditor = ((PersonAttributeEditor) editor); final PersonProposalProvider personProposalProvider = (PersonProposalProvider) personEditor.getContentAssistCommandAdapter() .getContentProposalProvider(); personProposalProvider.setErrorProposals(newPersonProposalMap); |