Lines 154-159
Link Here
|
154 |
private boolean lastModifiedSupported = true; |
154 |
private boolean lastModifiedSupported = true; |
155 |
|
155 |
|
156 |
private BugzillaLanguageSettings bugzillaLanguageSettings; |
156 |
private BugzillaLanguageSettings bugzillaLanguageSettings; |
|
|
157 |
|
158 |
private RepositoryConfiguration repositoryConfiguration; |
157 |
|
159 |
|
158 |
public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass, |
160 |
public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass, |
159 |
String characterEncoding) { |
161 |
String characterEncoding) { |
Lines 427-433
Link Here
|
427 |
} |
429 |
} |
428 |
} |
430 |
} |
429 |
|
431 |
|
430 |
public RepositoryTaskData getTaskData(int id) throws IOException, CoreException { |
432 |
public RepositoryTaskData getTaskData(int id) throws IOException, |
|
|
433 |
CoreException { |
431 |
final String idString = String.valueOf(id); |
434 |
final String idString = String.valueOf(id); |
432 |
Set<String> data = new HashSet<String>(); |
435 |
Set<String> data = new HashSet<String>(); |
433 |
data.add(idString); |
436 |
data.add(idString); |
Lines 474-505
Link Here
|
474 |
GzipPostMethod postMethod = null; |
477 |
GzipPostMethod postMethod = null; |
475 |
|
478 |
|
476 |
try { |
479 |
try { |
477 |
|
480 |
|
478 |
String queryUrl = query.getUrl(); |
481 |
String queryUrl = query.getUrl(); |
479 |
int start = queryUrl.indexOf('?'); |
482 |
int start = queryUrl.indexOf('?'); |
480 |
|
483 |
|
481 |
List<NameValuePair> pairs = new ArrayList<NameValuePair>(); |
484 |
List<NameValuePair> pairs = new ArrayList<NameValuePair>(); |
482 |
if(start != -1) { |
485 |
if (start != -1) { |
483 |
queryUrl = queryUrl.substring(start + 1); |
486 |
queryUrl = queryUrl.substring(start + 1); |
484 |
String[] result = queryUrl.split("&"); |
487 |
String[] result = queryUrl.split("&"); |
485 |
if(result.length > 0) { |
488 |
if (result.length > 0) { |
486 |
for (String string : result) { |
489 |
for (String string : result) { |
487 |
String[] nameValue = string.split("="); |
490 |
String[] nameValue = string.split("="); |
488 |
if(nameValue.length == 1) { |
491 |
if (nameValue.length == 1) { |
489 |
pairs.add(new NameValuePair(nameValue[0].trim(), "")); |
492 |
pairs.add(new NameValuePair(nameValue[0].trim(), "")); |
490 |
} else if(nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) { |
493 |
} else if (nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) { |
491 |
pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(), characterEncoding))); |
494 |
pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(), |
|
|
495 |
characterEncoding))); |
492 |
} |
496 |
} |
493 |
} |
497 |
} |
494 |
} |
498 |
} |
495 |
} |
499 |
} |
496 |
|
500 |
|
497 |
NameValuePair ctypePair = new NameValuePair("ctype", "rdf"); |
501 |
NameValuePair ctypePair = new NameValuePair("ctype", "rdf"); |
498 |
// Test that we don't specify content type twice. |
502 |
// Test that we don't specify content type twice. |
499 |
if(!pairs.contains(ctypePair)) { |
503 |
if (!pairs.contains(ctypePair)) { |
500 |
pairs.add(ctypePair); |
504 |
pairs.add(ctypePair); |
501 |
} |
505 |
} |
502 |
|
506 |
|
503 |
postMethod = postFormData(IBugzillaConstants.URL_BUGLIST, pairs.toArray(new NameValuePair[pairs.size()])); |
507 |
postMethod = postFormData(IBugzillaConstants.URL_BUGLIST, pairs.toArray(new NameValuePair[pairs.size()])); |
504 |
//System.err.println(postMethod.getResponseBodyAsString()); |
508 |
//System.err.println(postMethod.getResponseBodyAsString()); |
505 |
if (postMethod.getResponseHeader("Content-Type") != null) { |
509 |
if (postMethod.getResponseHeader("Content-Type") != null) { |
Lines 513-519
Link Here
|
513 |
} |
517 |
} |
514 |
} |
518 |
} |
515 |
} |
519 |
} |
516 |
|
520 |
|
517 |
parseHtmlError(new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsUnzippedStream(), |
521 |
parseHtmlError(new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsUnzippedStream(), |
518 |
characterEncoding))); |
522 |
characterEncoding))); |
519 |
} finally { |
523 |
} finally { |
Lines 637-646
Link Here
|
637 |
RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(stream, |
641 |
RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(stream, |
638 |
characterEncoding); |
642 |
characterEncoding); |
639 |
|
643 |
|
640 |
RepositoryConfiguration configuration = configFactory.getConfiguration(); |
644 |
repositoryConfiguration = configFactory.getConfiguration(); |
641 |
if (configuration != null) { |
645 |
if (repositoryConfiguration != null) { |
642 |
configuration.setRepositoryUrl(repositoryUrl.toString()); |
646 |
repositoryConfiguration.setRepositoryUrl(repositoryUrl.toString()); |
643 |
return configuration; |
647 |
return repositoryConfiguration; |
644 |
} |
648 |
} |
645 |
} |
649 |
} |
646 |
} |
650 |
} |
Lines 1180-1192
Link Here
|
1180 |
return null; |
1184 |
return null; |
1181 |
} |
1185 |
} |
1182 |
|
1186 |
|
1183 |
public Map<String, RepositoryTaskData> getTaskData(Set<String> taskIds) throws IOException, CoreException { |
1187 |
public Map<String, RepositoryTaskData> getTaskData(Set<String> taskIds) |
|
|
1188 |
throws IOException, CoreException { |
1184 |
GzipPostMethod method = null; |
1189 |
GzipPostMethod method = null; |
1185 |
HashMap<String, RepositoryTaskData> taskDataMap = new HashMap<String, RepositoryTaskData>(); |
1190 |
HashMap<String, RepositoryTaskData> taskDataMap = new HashMap<String, RepositoryTaskData>(); |
1186 |
while (taskIds.size() > 0) { |
1191 |
while (taskIds.size() > 0) { |
1187 |
|
|
|
1188 |
try { |
1192 |
try { |
1189 |
|
|
|
1190 |
Set<String> idsToRetrieve = new HashSet<String>(); |
1193 |
Set<String> idsToRetrieve = new HashSet<String>(); |
1191 |
Iterator<String> itr = taskIds.iterator(); |
1194 |
Iterator<String> itr = taskIds.iterator(); |
1192 |
for (int x = 0; itr.hasNext() && x < MAX_RETRIEVED_PER_QUERY; x++) { |
1195 |
for (int x = 0; itr.hasNext() && x < MAX_RETRIEVED_PER_QUERY; x++) { |
Lines 1216-1230
Link Here
|
1216 |
if (method == null) { |
1219 |
if (method == null) { |
1217 |
throw new IOException("Could not post form, client returned null method."); |
1220 |
throw new IOException("Could not post form, client returned null method."); |
1218 |
} |
1221 |
} |
1219 |
|
1222 |
|
1220 |
boolean parseable = false; |
1223 |
boolean parseable = false; |
|
|
1224 |
List<BugzillaCustomField> customFields = repositoryConfiguration.getCustomFields(); |
1221 |
if (method.getResponseHeader("Content-Type") != null) { |
1225 |
if (method.getResponseHeader("Content-Type") != null) { |
1222 |
Header responseTypeHeader = method.getResponseHeader("Content-Type"); |
1226 |
Header responseTypeHeader = method.getResponseHeader("Content-Type"); |
1223 |
for (String type : VALID_CONFIG_CONTENT_TYPES) { |
1227 |
for (String type : VALID_CONFIG_CONTENT_TYPES) { |
1224 |
if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) { |
1228 |
if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) { |
1225 |
MultiBugReportFactory factory = new MultiBugReportFactory( |
1229 |
MultiBugReportFactory factory = new MultiBugReportFactory( |
1226 |
method.getResponseBodyAsUnzippedStream(), characterEncoding); |
1230 |
method.getResponseBodyAsUnzippedStream(), characterEncoding); |
1227 |
factory.populateReport(taskDataMap); |
1231 |
factory.populateReport(taskDataMap, customFields); |
1228 |
taskIds.removeAll(idsToRetrieve); |
1232 |
taskIds.removeAll(idsToRetrieve); |
1229 |
parseable = true; |
1233 |
parseable = true; |
1230 |
break; |
1234 |
break; |
Lines 1237-1243
Link Here
|
1237 |
characterEncoding))); |
1241 |
characterEncoding))); |
1238 |
break; |
1242 |
break; |
1239 |
} |
1243 |
} |
1240 |
|
1244 |
|
1241 |
} finally { |
1245 |
} finally { |
1242 |
if (method != null) { |
1246 |
if (method != null) { |
1243 |
method.releaseConnection(); |
1247 |
method.releaseConnection(); |
Lines 1342-1345
Link Here
|
1342 |
+ " failed. Please verify connection and authentication information.")); |
1346 |
+ " failed. Please verify connection and authentication information.")); |
1343 |
} |
1347 |
} |
1344 |
|
1348 |
|
|
|
1349 |
|
1350 |
public void setRepositoryConfiguration(RepositoryConfiguration repositoryConfiguration) { |
1351 |
this.repositoryConfiguration = repositoryConfiguration; |
1352 |
} |
1353 |
|
1345 |
} |
1354 |
} |