Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 289155 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java (-2 / +15 lines)
Lines 40-45 Link Here
40
import org.eclipse.mylyn.commons.core.CoreUtil;
40
import org.eclipse.mylyn.commons.core.CoreUtil;
41
import org.eclipse.mylyn.commons.core.StatusHandler;
41
import org.eclipse.mylyn.commons.core.StatusHandler;
42
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
42
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
43
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
43
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
44
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
44
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
45
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
45
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
46
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
Lines 1244-1252 Link Here
1244
			appendToBuffer(sb, "&target_milestone=", target.getItem(element)); //$NON-NLS-1$
1245
			appendToBuffer(sb, "&target_milestone=", target.getItem(element)); //$NON-NLS-1$
1245
		}
1246
		}
1246
1247
1247
		sb.append("&long_desc_type="); //$NON-NLS-1$
1248
		if (repositoryConfiguration == null
1249
				|| repositoryConfiguration.getInstallVersion().isSmallerOrEquals(BugzillaVersion.BUGZILLA_3_4)) {
1250
			sb.append("&long_desc_type="); //$NON-NLS-1$
1251
		} else {
1252
			sb.append("&longdesc_type="); //$NON-NLS-1$
1253
		}
1254
1248
		sb.append(patternOperationValues[commentOperation.getSelectionIndex()]);
1255
		sb.append(patternOperationValues[commentOperation.getSelectionIndex()]);
1249
		appendToBuffer(sb, "&long_desc=", commentPattern.getText()); //$NON-NLS-1$
1256
1257
		if (repositoryConfiguration == null
1258
				|| repositoryConfiguration.getInstallVersion().isSmallerOrEquals(BugzillaVersion.BUGZILLA_3_4)) {
1259
			appendToBuffer(sb, "&long_desc=", commentPattern.getText()); //$NON-NLS-1$
1260
		} else {
1261
			appendToBuffer(sb, "&longdesc=", commentPattern.getText()); //$NON-NLS-1$
1262
		}
1250
1263
1251
		selected = status.getSelectionIndices();
1264
		selected = status.getSelectionIndices();
1252
		for (int element : selected) {
1265
		for (int element : selected) {
(-)src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java (+72 lines)
Lines 13-18 Link Here
13
13
14
import java.net.InetSocketAddress;
14
import java.net.InetSocketAddress;
15
import java.net.Proxy;
15
import java.net.Proxy;
16
import java.util.HashSet;
17
import java.util.Set;
16
18
17
import junit.framework.TestCase;
19
import junit.framework.TestCase;
18
20
Lines 20-31 Link Here
20
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
22
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
21
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
23
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
22
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
24
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttributeMapper;
23
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
24
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientFactory;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
30
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
26
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
31
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
27
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
32
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
33
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
34
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
35
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
28
import org.eclipse.mylyn.tasks.core.TaskRepository;
36
import org.eclipse.mylyn.tasks.core.TaskRepository;
37
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
38
import org.eclipse.mylyn.tasks.core.data.TaskData;
39
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
40
import org.eclipse.mylyn.tasks.ui.TasksUi;
29
41
30
/**
42
/**
31
 * @author Robert Elves
43
 * @author Robert Elves
Lines 34-41 Link Here
34
46
35
	private BugzillaClient client;
47
	private BugzillaClient client;
36
48
49
	private TaskRepository repository;
50
37
	@Override
51
	@Override
38
	protected void setUp() throws Exception {
52
	protected void setUp() throws Exception {
53
		repository = BugzillaFixture.current().singleRepository();
39
		client = BugzillaFixture.current().client();
54
		client = BugzillaFixture.current().client();
40
	}
55
	}
41
56
Lines 79-84 Link Here
79
		client.validate(new NullProgressMonitor());
94
		client.validate(new NullProgressMonitor());
80
	}
95
	}
81
96
97
	public void testCommentQuery() throws Exception {
98
		BugzillaAttributeMapper mapper = new BugzillaAttributeMapper(repository);
99
		TaskData newData = new TaskData(mapper, BugzillaFixture.current().getConnectorKind(), BugzillaFixture.current()
100
				.getRepositoryUrl(), "");
101
102
		AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(BugzillaFixture.current()
103
				.getConnectorKind());
104
		connector.getTaskDataHandler().initializeTaskData(repository, newData, null, new NullProgressMonitor());
105
		newData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).setValue("testCommentQuery()");
106
		newData.getRoot().getMappedAttribute(TaskAttribute.PRODUCT).setValue("TestProduct");
107
		newData.getRoot().getMappedAttribute(TaskAttribute.COMPONENT).setValue("TestComponent");
108
		newData.getRoot().getMappedAttribute(BugzillaAttribute.VERSION.getKey()).setValue("1");
109
		newData.getRoot().getMappedAttribute(BugzillaAttribute.OP_SYS.getKey()).setValue("All");
110
		long timestamp = System.currentTimeMillis();
111
		newData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION).setValue("" + timestamp);
112
		RepositoryResponse response = client.postTaskData(newData, new NullProgressMonitor());
113
114
		String bugid = response.getTaskId();
115
		RepositoryQuery query = new RepositoryQuery(BugzillaFixture.current().getConnectorKind(), "123");
116
		query.setRepositoryUrl(BugzillaFixture.current().getRepositoryUrl());
117
		query.setUrl("?short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr&long_desc=" + timestamp
118
				+ "&bug_status=NEW");
119
120
		final Set<TaskData> returnedData = new HashSet<TaskData>();
121
122
		TaskDataCollector collector = new TaskDataCollector() {
123
124
			@Override
125
			public void accept(TaskData taskData) {
126
				returnedData.add(taskData);
127
			}
128
		};
129
130
		client.getSearchHits(query, collector, mapper, new NullProgressMonitor());
131
		assertEquals(1, returnedData.size());
132
		assertEquals(bugid, returnedData.iterator().next().getTaskId());
133
		if (!client.getRepositoryConfiguration().getInstallVersion().isSmallerOrEquals(BugzillaVersion.BUGZILLA_3_4)) {
134
			query.setUrl("?short_desc_type=allwordssubstr&short_desc=&longdesc_type=allwordssubstr&longdesc="
135
					+ timestamp + "&bug_status=NEW");
136
137
			returnedData.clear();
138
139
			collector = new TaskDataCollector() {
140
141
				@Override
142
				public void accept(TaskData taskData) {
143
					returnedData.add(taskData);
144
				}
145
			};
146
147
			client.getSearchHits(query, collector, mapper, new NullProgressMonitor());
148
			assertEquals(1, returnedData.size());
149
			assertEquals(bugid, returnedData.iterator().next().getTaskId());
150
		}
151
152
	}
153
82
//	public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException,
154
//	public void testCredentialsEncoding() throws IOException, BugzillaException, KeyManagementException,
83
//			GeneralSecurityException {
155
//			GeneralSecurityException {
84
//		String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "UTF-8",
156
//		String poundSignUTF8 = BugzillaClient.addCredentials(IBugzillaTestConstants.TEST_BUGZILLA_222_URL, "UTF-8",
(-)src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java (-1 / +5 lines)
Lines 22-27 Link Here
22
import org.eclipse.mylyn.bugzilla.tests.BugzillaTestConstants;
22
import org.eclipse.mylyn.bugzilla.tests.BugzillaTestConstants;
23
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
23
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
24
import org.eclipse.mylyn.commons.net.AuthenticationType;
24
import org.eclipse.mylyn.commons.net.AuthenticationType;
25
import org.eclipse.mylyn.context.tests.support.TestUtil;
26
import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
27
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClientManager;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
30
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
Lines 97-103 Link Here
97
	}
100
	}
98
101
99
	public BugzillaClient client() throws CoreException, IOException {
102
	public BugzillaClient client() throws CoreException, IOException {
100
		return client(getRepositoryUrl(), "", "", "", "", "UTF-8");
103
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
104
		return client(getRepositoryUrl(), credentials.username, credentials.password, "", "", "UTF-8");
101
	}
105
	}
102
106
103
	public BugzillaClient client(String hostUrl, String username, String password, String htAuthUser,
107
	public BugzillaClient client(String hostUrl, String username, String password, String htAuthUser,
(-)src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties (-1 / +1 lines)
Lines 97-103 Link Here
97
BugzillaOperation_Resolve_as=Resolve as
97
BugzillaOperation_Resolve_as=Resolve as
98
BugzillaOperation_Reassign_to_default_assignee=Reassign to default assignee
98
BugzillaOperation_Reassign_to_default_assignee=Reassign to default assignee
99
99
100
BugzillaRepositoryConnector_BUGZILLA_SUPPORTS_2_18_TO_3_0=Bugzilla (supports uncustomized 2.18-3.2)
100
BugzillaRepositoryConnector_BUGZILLA_CONNECTOR_LABEL=Bugzilla (supports 3.0 and later)
101
BugzillaRepositoryConnector_Check_repository_configuration=Check repository configuration: {0}
101
BugzillaRepositoryConnector_Check_repository_configuration=Check repository configuration: {0}
102
BugzillaRepositoryConnector_checking_for_changed_tasks=Checking for changed tasks
102
BugzillaRepositoryConnector_checking_for_changed_tasks=Checking for changed tasks
103
BugzillaRepositoryConnector_Query_for_changed_tasks=Query for changed tasks
103
BugzillaRepositoryConnector_Query_for_changed_tasks=Query for changed tasks
(-)src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java (-1 / +1 lines)
Lines 199-205 Link Here
199
199
200
	public static String BugzillaOperation_Reassign_to_default_assignee;
200
	public static String BugzillaOperation_Reassign_to_default_assignee;
201
201
202
	public static String BugzillaRepositoryConnector_BUGZILLA_SUPPORTS_2_18_TO_3_0;
202
	public static String BugzillaRepositoryConnector_BUGZILLA_CONNECTOR_LABEL;
203
203
204
	public static String BugzillaRepositoryConnector_Check_repository_configuration;
204
	public static String BugzillaRepositoryConnector_Check_repository_configuration;
205
205
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java (-1 / +1 lines)
Lines 62-68 Link Here
62
62
63
	private static final String CHANGED_BUGS_CGI_QUERY = "/buglist.cgi?query_format=advanced&chfieldfrom="; //$NON-NLS-1$
63
	private static final String CHANGED_BUGS_CGI_QUERY = "/buglist.cgi?query_format=advanced&chfieldfrom="; //$NON-NLS-1$
64
64
65
	private static final String CLIENT_LABEL = Messages.BugzillaRepositoryConnector_BUGZILLA_SUPPORTS_2_18_TO_3_0;
65
	private static final String CLIENT_LABEL = Messages.BugzillaRepositoryConnector_BUGZILLA_CONNECTOR_LABEL;
66
66
67
	private static final String COMMENT_FORMAT = "yyyy-MM-dd HH:mm"; //$NON-NLS-1$
67
	private static final String COMMENT_FORMAT = "yyyy-MM-dd HH:mm"; //$NON-NLS-1$
68
68
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java (+9 lines)
Lines 446-451 Link Here
446
						if (nameValue.length == 1) {
446
						if (nameValue.length == 1) {
447
							pairs.add(new NameValuePair(nameValue[0].trim(), "")); //$NON-NLS-1$
447
							pairs.add(new NameValuePair(nameValue[0].trim(), "")); //$NON-NLS-1$
448
						} else if (nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
448
						} else if (nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
449
450
							// Hack around bugzilla's change of attribute name for comment search field bug#289155
451
							if (nameValue[0].startsWith("long_desc")
452
									&& getRepositoryConfiguration() != null
453
									&& !getRepositoryConfiguration().getInstallVersion().isSmallerOrEquals(
454
											BugzillaVersion.BUGZILLA_3_4)) {
455
								nameValue[0] = nameValue[0].replace("long_desc", "longdesc");
456
							}
457
449
							pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(),
458
							pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(),
450
									getCharacterEncoding())));
459
									getCharacterEncoding())));
451
						}
460
						}

Return to bug 289155