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 165072 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java (-67 / +136 lines)
Lines 550-562 Link Here
550
				// provide a solution for bug 196056 by allowing a (cached) gzipped configuration to be sent
550
				// provide a solution for bug 196056 by allowing a (cached) gzipped configuration to be sent
551
				// modified to also accept "application/x-gzip" as results from a 302 redirect to a previously gzipped file.
551
				// modified to also accept "application/x-gzip" as results from a 302 redirect to a previously gzipped file.
552
				if (method == null) {
552
				if (method == null) {
553
					throw new IOException("Could not retrieve configuratoin. HttpClient return null method.");
553
					throw new IOException("Could not retrieve configuratoin. HttpClient return null method."); //$NON-NLS-1$
554
				}
554
				}
555
555
556
				InputStream stream = getResponseStream(method, monitor);
556
				InputStream stream = getResponseStream(method, monitor);
557
				try {
557
				try {
558
					if (method.getResponseHeader("Content-Type") != null) { //$NON-NLS-1$
558
					if (method.getResponseHeader("Content-Type") != null) { //$NON-NLS-1$
559
						Header responseTypeHeader = method.getResponseHeader("Content-Type");
559
						Header responseTypeHeader = method.getResponseHeader("Content-Type"); //$NON-NLS-1$
560
						for (String type : VALID_CONFIG_CONTENT_TYPES) {
560
						for (String type : VALID_CONFIG_CONTENT_TYPES) {
561
							if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
561
							if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
562
								RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(
562
								RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(
Lines 576-582 Link Here
576
										} else {
576
										} else {
577
											throw new CoreException(
577
											throw new CoreException(
578
													new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN,
578
													new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN,
579
															"Unable to retrieve repository configuration. Ensure credentials are valid."));
579
															"Unable to retrieve repository configuration. Ensure credentials are valid.")); //$NON-NLS-1$
580
										}
580
										}
581
									}
581
									}
582
								}
582
								}
Lines 704-716 Link Here
704
				Iterator<TaskAttribute> itr = attributes.iterator();
704
				Iterator<TaskAttribute> itr = attributes.iterator();
705
				while (itr.hasNext()) {
705
				while (itr.hasNext()) {
706
					TaskAttribute a = itr.next();
706
					TaskAttribute a = itr.next();
707
					if (a.getId().startsWith("task.common.kind.flag_type")) {
707
					if (a.getId().startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$
708
						List<BugzillaFlag> flags = repositoryConfiguration.getFlags();
708
						List<BugzillaFlag> flags = repositoryConfiguration.getFlags();
709
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
709
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
710
						a = a.getAttribute("state");
710
						a = a.getAttribute("state"); //$NON-NLS-1$
711
						String value = a.getValue();
711
						String value = a.getValue();
712
						String id = ""; //$NON-NLS-1$
712
						String id = ""; //$NON-NLS-1$
713
						if (value.equals(" ")) {
713
						if (value.equals(" ")) { //$NON-NLS-1$
714
							continue;
714
							continue;
715
						}
715
						}
716
						String flagname = a.getMetaData().getLabel();
716
						String flagname = a.getMetaData().getLabel();
Lines 723-750 Link Here
723
						}
723
						}
724
						if (theFlag != null) {
724
						if (theFlag != null) {
725
							int flagTypeNumber = theFlag.getFlagId();
725
							int flagTypeNumber = theFlag.getFlagId();
726
							id = "flag_type-" + flagTypeNumber;
726
							id = "flag_type-" + flagTypeNumber; //$NON-NLS-1$
727
							value = a.getValue();
727
							value = a.getValue();
728
							if (value.equals("?") && requestee != null) { //$NON-NLS-1$
728
							if (value.equals("?") && requestee != null) { //$NON-NLS-1$
729
								parts.add(new StringPart("requestee_type-" + flagTypeNumber,
729
								parts.add(new StringPart("requestee_type-" + flagTypeNumber, //$NON-NLS-1$
730
										requestee.getValue() != null ? requestee.getValue() : ""));
730
										requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$
731
							}
731
							}
732
						}
732
						}
733
						parts.add(new StringPart(id, value != null ? value : "")); //$NON-NLS-1$
733
						parts.add(new StringPart(id, value != null ? value : "")); //$NON-NLS-1$
734
					} else if (a.getId().startsWith("task.common.kind.flag")) {
734
					} else if (a.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$
735
						TaskAttribute flagnumber = a.getAttribute("number");
735
						TaskAttribute flagnumber = a.getAttribute("number"); //$NON-NLS-1$
736
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
736
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
737
						a = a.getAttribute("state"); //$NON-NLS-1$
737
						a = a.getAttribute("state"); //$NON-NLS-1$
738
						String id = "flag-" + flagnumber.getValue();
738
						String id = "flag-" + flagnumber.getValue(); //$NON-NLS-1$
739
						String value = a.getValue();
739
						String value = a.getValue();
740
						if (value.equals(" ")) { //$NON-NLS-1$
740
						if (value.equals(" ")) { //$NON-NLS-1$
741
							value = "X";
741
							value = "X"; //$NON-NLS-1$
742
						}
742
						}
743
						if (value.equals("?") && requestee != null) { //$NON-NLS-1$
743
						if (value.equals("?") && requestee != null) { //$NON-NLS-1$
744
							parts.add(new StringPart("requestee-" + flagnumber.getValue(),
744
							parts.add(new StringPart("requestee-" + flagnumber.getValue(), //$NON-NLS-1$
745
									requestee.getValue() != null ? requestee.getValue() : ""));
745
									requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$
746
						}
746
						}
747
						parts.add(new StringPart(id, value != null ? value : ""));
747
						parts.add(new StringPart(id, value != null ? value : "")); //$NON-NLS-1$
748
					}
748
					}
749
				}
749
				}
750
			}
750
			}
Lines 823-854 Link Here
823
		boolean existingBugPosted = false;
823
		boolean existingBugPosted = false;
824
824
825
		formData.add(new NameValuePair("action", action)); //$NON-NLS-1$
825
		formData.add(new NameValuePair("action", action)); //$NON-NLS-1$
826
		formData.add(new NameValuePair("contenttypemethod", "manual"));
826
		formData.add(new NameValuePair("contenttypemethod", "manual")); //$NON-NLS-1$ //$NON-NLS-2$
827
827
828
		formData.add(new NameValuePair("id", taskAttribute.getValue()));
828
		formData.add(new NameValuePair("id", taskAttribute.getValue())); //$NON-NLS-1$
829
		Collection<TaskAttribute> attributes = taskAttribute.getAttributes().values();
829
		Collection<TaskAttribute> attributes = taskAttribute.getAttributes().values();
830
		Iterator<TaskAttribute> itr = attributes.iterator();
830
		Iterator<TaskAttribute> itr = attributes.iterator();
831
		while (itr.hasNext()) {
831
		while (itr.hasNext()) {
832
			TaskAttribute a = itr.next();
832
			TaskAttribute a = itr.next();
833
			String id = a.getId();
833
			String id = a.getId();
834
			String value = a.getValue();
834
			String value = a.getValue();
835
			if (id.equals(TaskAttribute.ATTACHMENT_AUTHOR) || id.equals("date") || id.equals("size")
835
			if (id.equals(TaskAttribute.ATTACHMENT_AUTHOR) || id.equals("date") || id.equals("size") //$NON-NLS-1$ //$NON-NLS-2$
836
					|| id.equals(TaskAttribute.ATTACHMENT_URL)) {
836
					|| id.equals(TaskAttribute.ATTACHMENT_URL)) {
837
				continue;
837
				continue;
838
			}
838
			}
839
839
840
			if (id.equals("desc")) { //$NON-NLS-1$
840
			if (id.equals("desc")) { //$NON-NLS-1$
841
				id = "description";
841
				id = "description"; //$NON-NLS-1$
842
			}
842
			}
843
			if (id.equals("ctype")) { //$NON-NLS-1$
843
			if (id.equals("ctype")) { //$NON-NLS-1$
844
				id = "contenttypeentry";
844
				id = "contenttypeentry"; //$NON-NLS-1$
845
			}
845
			}
846
846
847
			if (id.equals(TaskAttribute.ATTACHMENT_IS_DEPRECATED)) {
847
			if (id.equals(TaskAttribute.ATTACHMENT_IS_DEPRECATED)) {
848
				id = "isobsolete";
848
				id = "isobsolete"; //$NON-NLS-1$
849
			}
849
			}
850
			if (id.equals(TaskAttribute.ATTACHMENT_IS_PATCH)) {
850
			if (id.equals(TaskAttribute.ATTACHMENT_IS_PATCH)) {
851
				id = "ispatch";
851
				id = "ispatch"; //$NON-NLS-1$
852
			}
852
			}
853
			formData.add(new NameValuePair(id, value));
853
			formData.add(new NameValuePair(id, value));
854
		}
854
		}
Lines 883-889 Link Here
883
				if (isTitle) {
883
				if (isTitle) {
884
					// get all of the data in the title tag
884
					// get all of the data in the title tag
885
					if (token.getType() != Token.TAG) {
885
					if (token.getType() != Token.TAG) {
886
						title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " ";
886
						title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " "; //$NON-NLS-1$
887
						continue;
887
						continue;
888
					} else if (token.getType() == Token.TAG && ((HtmlTag) token.getValue()).getTagType() == Tag.TITLE
888
					} else if (token.getType() == Token.TAG && ((HtmlTag) token.getValue()).getTagType() == Tag.TITLE
889
							&& ((HtmlTag) token.getValue()).isEndTag()) {
889
							&& ((HtmlTag) token.getValue()).isEndTag()) {
Lines 913-919 Link Here
913
		} catch (ParseException e) {
913
		} catch (ParseException e) {
914
			loggedIn = false;
914
			loggedIn = false;
915
			throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
915
			throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
916
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
916
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); //$NON-NLS-1$ //$NON-NLS-2$
917
		} finally {
917
		} finally {
918
			if (input != null) {
918
			if (input != null) {
919
				input.close();
919
				input.close();
Lines 928-934 Link Here
928
			CoreException {
928
			CoreException {
929
		NameValuePair[] formData = null;
929
		NameValuePair[] formData = null;
930
		monitor = Policy.monitorFor(monitor);
930
		monitor = Policy.monitorFor(monitor);
931
931
		RepositoryResponse response;
932
		authenticate(new SubProgressMonitor(monitor, 1));
932
		authenticate(new SubProgressMonitor(monitor, 1));
933
933
934
		if (taskData == null) {
934
		if (taskData == null) {
Lines 950-956 Link Here
950
			}
950
			}
951
951
952
			if (method == null) {
952
			if (method == null) {
953
				throw new IOException("Could not post form, client returned null method.");
953
				throw new IOException("Could not post form, client returned null method."); //$NON-NLS-1$
954
			}
954
			}
955
955
956
			input = getResponseStream(method, monitor);
956
			input = getResponseStream(method, monitor);
Lines 975-981 Link Here
975
				if (isTitle) {
975
				if (isTitle) {
976
					// get all of the data in the title tag
976
					// get all of the data in the title tag
977
					if (token.getType() != Token.TAG) {
977
					if (token.getType() != Token.TAG) {
978
						title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " ";
978
						title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " "; //$NON-NLS-1$
979
						continue;
979
						continue;
980
					} else if (token.getType() == Token.TAG && ((HtmlTag) token.getValue()).getTagType() == Tag.TITLE
980
					} else if (token.getType() == Token.TAG && ((HtmlTag) token.getValue()).getTagType() == Tag.TITLE
981
							&& ((HtmlTag) token.getValue()).isEndTag()) {
981
							&& ((HtmlTag) token.getValue()).isEndTag()) {
Lines 1017-1023 Link Here
1017
					}
1017
					}
1018
				}
1018
				}
1019
			}
1019
			}
1020
1020
			if (taskData.isNew()) {
1021
				response = new RepositoryResponse(ResponseKind.TASK_CREATED, result);
1022
			} else {
1023
				response = new RepositoryResponse(ResponseKind.TASK_UPDATED, taskData.getTaskId());
1024
			}
1021
			if ((!taskData.isNew() && existingBugPosted != true) || (taskData.isNew() && result == null)) {
1025
			if ((!taskData.isNew() && existingBugPosted != true) || (taskData.isNew() && result == null)) {
1022
				try {
1026
				try {
1023
					if (in.markSupported()) {
1027
					if (in.markSupported()) {
Lines 1027-1043 Link Here
1027
					// ignore
1031
					// ignore
1028
				}
1032
				}
1029
				parseHtmlError(in);
1033
				parseHtmlError(in);
1030
			}
1031
1032
			if (taskData.isNew()) {
1033
				return new RepositoryResponse(ResponseKind.TASK_CREATED, result);
1034
			} else {
1034
			} else {
1035
				return new RepositoryResponse(ResponseKind.TASK_UPDATED, taskData.getTaskId());
1035
				try {
1036
					if (in.markSupported()) {
1037
						in.reset();
1038
					}
1039
				} catch (IOException e) {
1040
					// ignore
1041
				}
1042
				parseResultOK(in, response);
1036
			}
1043
			}
1044
			return response;
1037
		} catch (ParseException e) {
1045
		} catch (ParseException e) {
1038
			loggedIn = false;
1046
			loggedIn = false;
1039
			throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
1047
			throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
1040
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
1048
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); //$NON-NLS-1$//$NON-NLS-2$
1041
		} finally {
1049
		} finally {
1042
			if (input != null) {
1050
			if (input != null) {
1043
				input.close();
1051
				input.close();
Lines 1058-1064 Link Here
1058
		Iterator<TaskAttribute> itr = attributes.iterator();
1066
		Iterator<TaskAttribute> itr = attributes.iterator();
1059
		while (itr.hasNext()) {
1067
		while (itr.hasNext()) {
1060
			TaskAttribute a = itr.next();
1068
			TaskAttribute a = itr.next();
1061
			if (a != null && a.getId() != null && a.getId().compareTo("") != 0) {
1069
			if (a != null && a.getId() != null && a.getId().compareTo("") != 0) { //$NON-NLS-1$
1062
				String value = null;
1070
				String value = null;
1063
				value = a.getValue();
1071
				value = a.getValue();
1064
				if (value == null) {
1072
				if (value == null) {
Lines 1084-1090 Link Here
1084
		}
1092
		}
1085
1093
1086
		TaskAttribute descAttribute = taskData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION);
1094
		TaskAttribute descAttribute = taskData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION);
1087
		if (descAttribute != null && !descAttribute.getValue().equals("")) {
1095
		if (descAttribute != null && !descAttribute.getValue().equals("")) { //$NON-NLS-1$
1088
			BugzillaVersion bugzillaVersion = null;
1096
			BugzillaVersion bugzillaVersion = null;
1089
			if (repositoryConfiguration != null) {
1097
			if (repositoryConfiguration != null) {
1090
				bugzillaVersion = repositoryConfiguration.getInstallVersion();
1098
				bugzillaVersion = repositoryConfiguration.getInstallVersion();
Lines 1111-1117 Link Here
1111
	}
1119
	}
1112
1120
1113
	private void cleanIfShortLogin(TaskAttribute a) {
1121
	private void cleanIfShortLogin(TaskAttribute a) {
1114
		if ("true".equals(configParameters.get(IBugzillaConstants.REPOSITORY_SETTING_SHORT_LOGIN))) {
1122
		if ("true".equals(configParameters.get(IBugzillaConstants.REPOSITORY_SETTING_SHORT_LOGIN))) { //$NON-NLS-1$
1115
			if (a.getValue() != null && a.getValue().length() > 0) {
1123
			if (a.getValue() != null && a.getValue().length() > 0) {
1116
				int atIndex = a.getValue().indexOf("@"); //$NON-NLS-1$
1124
				int atIndex = a.getValue().indexOf("@"); //$NON-NLS-1$
1117
				if (atIndex != -1) {
1125
				if (atIndex != -1) {
Lines 1168-1186 Link Here
1168
					List<String> values = a.getValues();
1176
					List<String> values = a.getValues();
1169
					int i = 0;
1177
					int i = 0;
1170
					for (String string : values) {
1178
					for (String string : values) {
1171
						fields.put(id + i++, new NameValuePair(id, string != null ? string : ""));
1179
						fields.put(id + i++, new NameValuePair(id, string != null ? string : "")); //$NON-NLS-1$
1172
					}
1180
					}
1173
				} else if (id != null && id.compareTo("") != 0) {
1181
				} else if (id != null && id.compareTo("") != 0) { //$NON-NLS-1$
1174
					String value = a.getValue();
1182
					String value = a.getValue();
1175
					if (id.equals(BugzillaAttribute.DELTA_TS.getKey())) {
1183
					if (id.equals(BugzillaAttribute.DELTA_TS.getKey())) {
1176
						value = stripTimeZone(value);
1184
						value = stripTimeZone(value);
1177
					}
1185
					}
1178
					if (id.startsWith("task.common.kind.flag_type")) {
1186
					if (id.startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$
1179
						List<BugzillaFlag> flags = repositoryConfiguration.getFlags();
1187
						List<BugzillaFlag> flags = repositoryConfiguration.getFlags();
1180
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
1188
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
1181
						a = a.getAttribute("state");
1189
						a = a.getAttribute("state"); //$NON-NLS-1$
1182
						value = a.getValue();
1190
						value = a.getValue();
1183
						if (value.equals(" ")) {
1191
						if (value.equals(" ")) { //$NON-NLS-1$
1184
							continue;
1192
							continue;
1185
						}
1193
						}
1186
						String flagname = a.getMetaData().getLabel();
1194
						String flagname = a.getMetaData().getLabel();
Lines 1193-1223 Link Here
1193
						}
1201
						}
1194
						if (theFlag != null) {
1202
						if (theFlag != null) {
1195
							int flagTypeNumber = theFlag.getFlagId();
1203
							int flagTypeNumber = theFlag.getFlagId();
1196
							id = "flag_type-" + flagTypeNumber;
1204
							id = "flag_type-" + flagTypeNumber; //$NON-NLS-1$
1197
							value = a.getValue();
1205
							value = a.getValue();
1198
							if (value.equals("?") && requestee != null) { //$NON-NLS-1$
1206
							if (value.equals("?") && requestee != null) { //$NON-NLS-1$
1199
								fields.put("requestee_type-" + flagTypeNumber, new NameValuePair("requestee_type-" //$NON-NLS-2$
1207
								fields.put("requestee_type-" + flagTypeNumber, new NameValuePair("requestee_type-" //$NON-NLS-1$ //$NON-NLS-2$
1200
										+ flagTypeNumber, requestee.getValue() != null ? requestee.getValue() : ""));
1208
										+ flagTypeNumber, requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$
1201
							}
1209
							}
1202
						}
1210
						}
1203
					} else if (id.startsWith("task.common.kind.flag")) { //$NON-NLS-1$
1211
					} else if (id.startsWith("task.common.kind.flag")) { //$NON-NLS-1$
1204
						TaskAttribute flagnumber = a.getAttribute("number");
1212
						TaskAttribute flagnumber = a.getAttribute("number"); //$NON-NLS-1$
1205
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
1213
						TaskAttribute requestee = a.getAttribute("requestee"); //$NON-NLS-1$
1206
						a = a.getAttribute("state"); //$NON-NLS-1$
1214
						a = a.getAttribute("state"); //$NON-NLS-1$
1207
						id = "flag-" + flagnumber.getValue();
1215
						id = "flag-" + flagnumber.getValue(); //$NON-NLS-1$
1208
						value = a.getValue();
1216
						value = a.getValue();
1209
						if (value.equals(" ")) { //$NON-NLS-1$
1217
						if (value.equals(" ")) { //$NON-NLS-1$
1210
							value = "X";
1218
							value = "X"; //$NON-NLS-1$
1211
						}
1219
						}
1212
						if (value.equals("?") && requestee != null) { //$NON-NLS-1$
1220
						if (value.equals("?") && requestee != null) { //$NON-NLS-1$
1213
							fields.put("requestee-" + flagnumber.getValue(), new NameValuePair("requestee-" //$NON-NLS-2$
1221
							fields.put("requestee-" + flagnumber.getValue(), new NameValuePair("requestee-" //$NON-NLS-1$//$NON-NLS-2$
1214
									+ flagnumber.getValue(), requestee.getValue() != null ? requestee.getValue() : ""));
1222
									+ flagnumber.getValue(), requestee.getValue() != null ? requestee.getValue() : "")); //$NON-NLS-1$
1215
						}
1223
						}
1216
					} else if (id.startsWith("task.common.")) {
1224
					} else if (id.startsWith("task.common.")) { //$NON-NLS-1$
1217
						// Don't post any remaining non-bugzilla specific attributes
1225
						// Don't post any remaining non-bugzilla specific attributes
1218
						continue;
1226
						continue;
1219
					}
1227
					}
1220
					fields.put(id, new NameValuePair(id, value != null ? value : ""));
1228
					fields.put(id, new NameValuePair(id, value != null ? value : "")); //$NON-NLS-1$
1221
				}
1229
				}
1222
			}
1230
			}
1223
		}
1231
		}
Lines 1249-1255 Link Here
1249
				} else {
1257
				} else {
1250
					String inputAttributeId = originalOperation.getMetaData().getValue(
1258
					String inputAttributeId = originalOperation.getMetaData().getValue(
1251
							TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID);
1259
							TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID);
1252
					if (inputAttributeId == null || inputAttributeId.equals("")) {
1260
					if (inputAttributeId == null || inputAttributeId.equals("")) { //$NON-NLS-1$
1253
						String sel = attributeOperation.getValue();
1261
						String sel = attributeOperation.getValue();
1254
						fields.put(KEY_KNOB, new NameValuePair(KEY_KNOB, sel));
1262
						fields.put(KEY_KNOB, new NameValuePair(KEY_KNOB, sel));
1255
					} else {
1263
					} else {
Lines 1282-1288 Link Here
1282
				} else if (attributeOperation != null
1290
				} else if (attributeOperation != null
1283
						&& attributeOperation.getValue().equals(BugzillaOperation.duplicate.toString())) {
1291
						&& attributeOperation.getValue().equals(BugzillaOperation.duplicate.toString())) {
1284
					// fix for bug#198677
1292
					// fix for bug#198677
1285
					fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, ""));
1293
					fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, "")); //$NON-NLS-1$
1286
				}
1294
				}
1287
			}
1295
			}
1288
		} else {
1296
		} else {
Lines 1306-1337 Link Here
1306
						fields.put(fieldName, new NameValuePair(fieldName, attributeStatus.getValue()));
1314
						fields.put(fieldName, new NameValuePair(fieldName, attributeStatus.getValue()));
1307
					} else {
1315
					} else {
1308
						String selOp = attributeOperation.getValue().toUpperCase();
1316
						String selOp = attributeOperation.getValue().toUpperCase();
1309
						if (selOp.equals("NONE")) {
1317
						if (selOp.equals("NONE")) { //$NON-NLS-1$
1310
							selOp = attributeStatus.getValue();
1318
							selOp = attributeStatus.getValue();
1311
						}
1319
						}
1312
						if (selOp.equals("ACCEPT")) { //$NON-NLS-1$
1320
						if (selOp.equals("ACCEPT")) { //$NON-NLS-1$
1313
							selOp = "ASSIGNED";
1321
							selOp = "ASSIGNED"; //$NON-NLS-1$
1314
						}
1322
						}
1315
						if (selOp.equals("RESOLVE")) { //$NON-NLS-1$
1323
						if (selOp.equals("RESOLVE")) { //$NON-NLS-1$
1316
							selOp = "RESOLVED";
1324
							selOp = "RESOLVED"; //$NON-NLS-1$
1317
						}
1325
						}
1318
						if (selOp.equals("VERIFY")) { //$NON-NLS-1$
1326
						if (selOp.equals("VERIFY")) { //$NON-NLS-1$
1319
							selOp = "VERIFIED";
1327
							selOp = "VERIFIED"; //$NON-NLS-1$
1320
						}
1328
						}
1321
						if (selOp.equals("CLOSE")) { //$NON-NLS-1$
1329
						if (selOp.equals("CLOSE")) { //$NON-NLS-1$
1322
							selOp = "CLOSED";
1330
							selOp = "CLOSED"; //$NON-NLS-1$
1323
						}
1331
						}
1324
						if (selOp.equals("REOPEN")) { //$NON-NLS-1$
1332
						if (selOp.equals("REOPEN")) { //$NON-NLS-1$
1325
							selOp = "REOPENED";
1333
							selOp = "REOPENED"; //$NON-NLS-1$
1326
						}
1334
						}
1327
						if (selOp.equals("DUPLICATE")) { //$NON-NLS-1$
1335
						if (selOp.equals("DUPLICATE")) { //$NON-NLS-1$
1328
							selOp = "RESOLVED";
1336
							selOp = "RESOLVED"; //$NON-NLS-1$
1329
							String knob = BugzillaAttribute.RESOLUTION.getKey();
1337
							String knob = BugzillaAttribute.RESOLUTION.getKey();
1330
							fields.put(knob, new NameValuePair(knob, "DUPLICATE"));
1338
							fields.put(knob, new NameValuePair(knob, "DUPLICATE")); //$NON-NLS-1$
1331
						}
1339
						}
1332
1340
1333
						fields.put(fieldName, new NameValuePair(fieldName, selOp));
1341
						fields.put(fieldName, new NameValuePair(fieldName, selOp));
1334
						if (inputAttributeId != null && !inputAttributeId.equals("")) {
1342
						if (inputAttributeId != null && !inputAttributeId.equals("")) { //$NON-NLS-1$
1335
							TaskAttribute inputAttribute = attributeOperation.getTaskData().getRoot().getAttribute(
1343
							TaskAttribute inputAttribute = attributeOperation.getTaskData().getRoot().getAttribute(
1336
									inputAttributeId);
1344
									inputAttributeId);
1337
							if (inputAttribute != null) {
1345
							if (inputAttribute != null) {
Lines 1345-1351 Link Here
1345
								} else {
1353
								} else {
1346
									String sel = inputAttribute.getValue();
1354
									String sel = inputAttribute.getValue();
1347
									String knob = attributeOperation.getValue();
1355
									String knob = attributeOperation.getValue();
1348
									if (knob.equals("duplicate")) {
1356
									if (knob.equals("duplicate")) { //$NON-NLS-1$
1349
										knob = inputAttributeId;
1357
										knob = inputAttributeId;
1350
									}
1358
									}
1351
									if (knob.equals(BugzillaOperation.reassign.toString())) {
1359
									if (knob.equals(BugzillaOperation.reassign.toString())) {
Lines 1414-1421 Link Here
1414
1422
1415
		String bugUrl = taskData.getRepositoryUrl() + IBugzillaConstants.URL_GET_SHOW_BUG + taskData.getTaskId();
1423
		String bugUrl = taskData.getRepositoryUrl() + IBugzillaConstants.URL_GET_SHOW_BUG + taskData.getTaskId();
1416
		GzipGetMethod getMethod = new GzipGetMethod(WebUtil.getRequestPath(bugUrl), false);
1424
		GzipGetMethod getMethod = new GzipGetMethod(WebUtil.getRequestPath(bugUrl), false);
1417
		getMethod.setRequestHeader("Content-Type", "text/xml; charset=" + characterEncoding); //$NON-NLS-1$ 
1425
		getMethod.setRequestHeader("Content-Type", "text/xml; charset=" + characterEncoding); //$NON-NLS-1$ //$NON-NLS-2$ 
1418
		httpClient.getParams().setParameter("http.protocol.single-cookie-header", true);
1426
		httpClient.getParams().setParameter("http.protocol.single-cookie-header", true); //$NON-NLS-1$
1419
		getMethod.setDoAuthentication(true);
1427
		getMethod.setDoAuthentication(true);
1420
1428
1421
		int code;
1429
		int code;
Lines 1898-1901 Link Here
1898
1906
1899
	}
1907
	}
1900
1908
1909
	private void parseResultOK(BufferedReader in, RepositoryResponse response) throws IOException, CoreException {
1910
		HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null);
1911
1912
		boolean isDT = false;
1913
		String dtString = ""; //$NON-NLS-1$
1914
		String body = ""; //$NON-NLS-1$
1915
		String lastDTValue = ""; //$NON-NLS-1$
1916
		boolean isCode = false;
1917
		String codeString = ""; //$NON-NLS-1$
1918
		try {
1919
			for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
1920
				body += token.toString();
1921
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.DT
1922
						&& ((HtmlTag) (token.getValue())).isEndTag()) {
1923
					isDT = false;
1924
					if (!dtString.equals("")) { //$NON-NLS-1$
1925
						lastDTValue = dtString;
1926
					}
1927
					dtString = ""; //$NON-NLS-1$
1928
					continue;
1929
				}
1930
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.CODE
1931
						&& ((HtmlTag) (token.getValue())).isEndTag()) {
1932
					isCode = false;
1933
					if (codeString.length() > 0) {
1934
						codeString = codeString.replace("&#64;", "@"); //$NON-NLS-1$ //$NON-NLS-2$
1935
						response.addResponseData(lastDTValue, codeString);
1936
					}
1937
					dtString = ""; //$NON-NLS-1$
1938
					codeString = ""; //$NON-NLS-1$
1939
					continue;
1940
				}
1941
				if (isCode) {
1942
					codeString += (" " + token.getValue()); //$NON-NLS-1$
1943
				}
1944
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.CODE
1945
						&& !((HtmlTag) (token.getValue())).isEndTag()) {
1946
					isCode = true;
1947
					codeString = ""; //$NON-NLS-1$
1948
				}
1949
				if (isDT) {
1950
					if (dtString.length() > 0) {
1951
						dtString += (" " + token.getValue()); //$NON-NLS-1$
1952
					} else {
1953
						dtString += token.getValue();
1954
					}
1955
				}
1956
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.DT
1957
						&& !((HtmlTag) (token.getValue())).isEndTag()) {
1958
					isDT = true;
1959
					continue;
1960
				}
1961
			}
1962
		} catch (ParseException e) {
1963
			throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
1964
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + ".")); //$NON-NLS-1$ //$NON-NLS-2$
1965
		} finally {
1966
			in.close();
1967
		}
1968
	}
1969
1901
}
1970
}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties (+4 lines)
Lines 7-12 Link Here
7
BugzillaPlanningEditorPart_Current_Estimate=Current Estimate:
7
BugzillaPlanningEditorPart_Current_Estimate=Current Estimate:
8
BugzillaPlanningEditorPart_Team_Planning=Team Planning
8
BugzillaPlanningEditorPart_Team_Planning=Team Planning
9
9
10
BugzillaTaskEditorPage_Changes_Submitted_Action_Line={0}\n
11
BugzillaTaskEditorPage_Changes_Submitted_Email_Line=\ \ \ \ \ \ \ \ {0}\n
12
BugzillaTaskEditorPage_Changes_Submitted_Message=Changes submitted
13
BugzillaTaskEditorPage_Changes_Submitted_Titel=Changes submitted
10
BugzillaTaskEditorPage_Please_enter_a_description_before_submitting=Please enter a description before submitting
14
BugzillaTaskEditorPage_Please_enter_a_description_before_submitting=Please enter a description before submitting
11
BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting=Please enter a short summary before submitting
15
BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting=Please enter a short summary before submitting
12
BugzillaTaskEditorPage_Please_select_a_component_before_submitting=Please select a component before submitting
16
BugzillaTaskEditorPage_Please_select_a_component_before_submitting=Please select a component before submitting
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java (+8 lines)
Lines 37-42 Link Here
37
37
38
	public static String BugzillaPlanningEditorPart_Team_Planning;
38
	public static String BugzillaPlanningEditorPart_Team_Planning;
39
39
40
	public static String BugzillaTaskEditorPage_Changes_Submitted_Action_Line;
41
42
	public static String BugzillaTaskEditorPage_Changes_Submitted_Email_Line;
43
44
	public static String BugzillaTaskEditorPage_Changes_Submitted_Message;
45
46
	public static String BugzillaTaskEditorPage_Changes_Submitted_Titel;
47
40
	public static String BugzillaTaskEditorPage_Please_enter_a_description_before_submitting;
48
	public static String BugzillaTaskEditorPage_Please_enter_a_description_before_submitting;
41
49
42
	public static String BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting;
50
	public static String BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting;
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java (+33 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.mylyn.internal.bugzilla.ui.editor;
12
package org.eclipse.mylyn.internal.bugzilla.ui.editor;
13
13
14
import java.text.MessageFormat;
14
import java.util.Collections;
15
import java.util.Collections;
15
import java.util.HashMap;
16
import java.util.HashMap;
16
import java.util.List;
17
import java.util.List;
Lines 20-26 Link Here
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.NullProgressMonitor;
23
import org.eclipse.core.runtime.NullProgressMonitor;
24
import org.eclipse.jface.dialogs.IDialogConstants;
23
import org.eclipse.jface.dialogs.IMessageProvider;
25
import org.eclipse.jface.dialogs.IMessageProvider;
26
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.mylyn.commons.core.StatusHandler;
27
import org.eclipse.mylyn.commons.core.StatusHandler;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
Lines 29-34 Link Here
29
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
32
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
30
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
33
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
31
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
34
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
35
import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
36
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
32
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
37
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
33
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
38
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
34
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
39
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
Lines 36-41 Link Here
36
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
41
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
37
import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
42
import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
38
import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener;
43
import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener;
44
import org.eclipse.mylyn.tasks.core.sync.SubmitJobEvent;
39
import org.eclipse.mylyn.tasks.ui.TasksUi;
45
import org.eclipse.mylyn.tasks.ui.TasksUi;
40
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
46
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
41
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
47
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
Lines 45-50 Link Here
45
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
51
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
46
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
52
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
47
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
53
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
54
import org.eclipse.ui.forms.events.HyperlinkAdapter;
55
import org.eclipse.ui.forms.events.HyperlinkEvent;
48
56
49
/**
57
/**
50
 * @author Rob Elves
58
 * @author Rob Elves
Lines 226-231 Link Here
226
			attrToken.setValue(getModel().getTask().getAttribute(BugzillaAttribute.TOKEN.getKey()));
234
			attrToken.setValue(getModel().getTask().getAttribute(BugzillaAttribute.TOKEN.getKey()));
227
		}
235
		}
228
236
237
		getTaskEditor().setMessage("", IMessageProvider.NONE); //$NON-NLS-1$
229
		super.doSubmit();
238
		super.doSubmit();
230
	}
239
	}
231
240
Lines 364-367 Link Here
364
		}
373
		}
365
	}
374
	}
366
375
376
	@Override
377
	protected void handleTaskSubmitted(SubmitJobEvent event) {
378
		if (event.getJob().getResponse() != null) {
379
			final RepositoryResponse response = event.getJob().getResponse();
380
			getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Changes_Submitted_Message, IMessageProvider.INFORMATION, new HyperlinkAdapter() {
381
				@Override
382
				public void linkActivated(HyperlinkEvent event) {
383
					String mes = ""; //$NON-NLS-1$
384
					for (String iterable_element : response.getResponseData().keySet()) {
385
						mes += MessageFormat.format(Messages.BugzillaTaskEditorPage_Changes_Submitted_Action_Line, iterable_element);
386
						List<String> o = response.getResponseData().get(iterable_element);
387
						for (String string : o) {
388
							mes += MessageFormat.format(Messages.BugzillaTaskEditorPage_Changes_Submitted_Email_Line, string);
389
						}
390
					}
391
					new MessageDialog(WorkbenchUtil.getShell(), Messages.BugzillaTaskEditorPage_Changes_Submitted_Titel, null, mes,
392
							MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0).open();
393
				}
394
			});
395
		} else {
396
			super.handleTaskSubmitted(event);
397
		}
398
	}
399
367
}
400
}
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java (-2 / +10 lines)
Lines 224-232 Link Here
224
								migrator.setEditor(getTaskEditor());
224
								migrator.setEditor(getTaskEditor());
225
								migrator.execute(newTask);
225
								migrator.execute(newTask);
226
							}
226
							}
227
						} else {
228
							handleSubmitError(job);
229
						}
227
						}
228
						handleTaskSubmitted(new SubmitJobEvent(job));
230
					} finally {
229
					} finally {
231
						showEditorBusy(false);
230
						showEditorBusy(false);
232
					}
231
					}
Lines 1089-1094 Link Here
1089
		}
1088
		}
1090
	}
1089
	}
1091
1090
1091
	/**
1092
	 * @since 3.2
1093
	 */
1094
	protected void handleTaskSubmitted(SubmitJobEvent event) {
1095
		if (event.getJob().getStatus() != null) {
1096
			handleSubmitError(event.getJob());
1097
		}
1098
	}
1099
1092
	@Override
1100
	@Override
1093
	public void init(IEditorSite site, IEditorInput input) {
1101
	public void init(IEditorSite site, IEditorInput input) {
1094
		super.init(site, input);
1102
		super.init(site, input);
(-)src/org/eclipse/mylyn/tasks/core/RepositoryResponse.java (+24 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.mylyn.tasks.core;
12
package org.eclipse.mylyn.tasks.core;
13
13
14
import java.util.LinkedHashMap;
15
import java.util.LinkedList;
16
import java.util.List;
17
import java.util.Map;
18
14
/**
19
/**
15
 * Clients may subclass.
20
 * Clients may subclass.
16
 * 
21
 * 
Lines 27-32 Link Here
27
32
28
	private final ResponseKind reposonseKind;
33
	private final ResponseKind reposonseKind;
29
34
35
	private Map<String, List<String>> responseData = new LinkedHashMap<String, List<String>>();
36
30
	public RepositoryResponse(ResponseKind reposonseKind, String taskId) {
37
	public RepositoryResponse(ResponseKind reposonseKind, String taskId) {
31
		this.reposonseKind = reposonseKind;
38
		this.reposonseKind = reposonseKind;
32
		this.taskId = taskId;
39
		this.taskId = taskId;
Lines 44-47 Link Here
44
		return reposonseKind;
51
		return reposonseKind;
45
	}
52
	}
46
53
54
	public Map<String, List<String>> getResponseData() {
55
		return responseData;
56
	}
57
58
	public void setResponseData(Map<String, List<String>> responseData) {
59
		this.responseData = responseData;
60
	}
61
62
	public void addResponseData(String name, String response) {
63
		List<String> responseList = responseData.get(name);
64
		if (responseList == null) {
65
			responseList = new LinkedList<String>();
66
			responseData.put(name, responseList);
67
		}
68
		responseList.add(response);
69
	}
70
47
}
71
}

Return to bug 165072