Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2008-06-12 07:41:34 +0000
committerrelves2008-06-12 07:41:34 +0000
commit089969a389703fd20b02613e2948ff1770311d7e (patch)
tree93cf4a8d92b436db5a77c6e0f5f20074c37559bb /org.eclipse.mylyn.bugzilla.core
parentcc75148740a21e42dca398f3a1c6c0b0bcefda46 (diff)
downloadorg.eclipse.mylyn.tasks-089969a389703fd20b02613e2948ff1770311d7e.tar.gz
org.eclipse.mylyn.tasks-089969a389703fd20b02613e2948ff1770311d7e.tar.xz
org.eclipse.mylyn.tasks-089969a389703fd20b02613e2948ff1770311d7e.zip
ASSIGNED - bug 180876: Bugzilla: supporting usevisibilitygroups enabled
https://bugs.eclipse.org/bugs/show_bug.cgi?id=180876
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java67
1 files changed, 64 insertions, 3 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 a7d432e57..143ff11d8 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
@@ -55,6 +55,7 @@ import org.eclipse.core.runtime.CoreException;
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.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
@@ -767,7 +768,7 @@ public class BugzillaClient {
postfix = IBugzillaConstants.FORM_POSTFIX_216;
postfix2 = IBugzillaConstants.FORM_POSTFIX_218;
} else {
- formData = getPairsForExisting(taskData);
+ formData = getPairsForExisting(taskData, new SubProgressMonitor(monitor, 1));
}
String result = null;
@@ -942,8 +943,8 @@ public class BugzillaClient {
}
}
- private NameValuePair[] getPairsForExisting(TaskData model) {
-
+ private NameValuePair[] getPairsForExisting(TaskData model, IProgressMonitor monitor) throws CoreException {
+ boolean groupSecurityEnabled = false;
Map<String, NameValuePair> fields = new HashMap<String, NameValuePair>();
fields.put(KEY_FORM_NAME, new NameValuePair(KEY_FORM_NAME, VAL_PROCESS_BUG));
// go through all of the attributes and add them to the bug post
@@ -964,6 +965,10 @@ public class BugzillaClient {
continue;
}
+ if (a.getId().equals(BugzillaAttribute.GROUP.getKey()) && a.getValue().length() > 0) {
+ groupSecurityEnabled = true;
+ }
+
if (a.getId() != null && a.getId().compareTo("") != 0) {
String value = a.getValue();
if (a.getId().equals(BugzillaAttribute.DELTA_TS.getKey())) {
@@ -1044,10 +1049,66 @@ public class BugzillaClient {
}
}
+ if (groupSecurityEnabled) {
+ // get security info from html and include in post
+ Map<String, String> groupIds = getGroupSecurityInformation(model, monitor);
+ for (String key : groupIds.keySet()) {
+ fields.put(key, new NameValuePair(key, groupIds.get(key)));
+ }
+
+ }
return fields.values().toArray(new NameValuePair[fields.size()]);
}
+ private Map<String, String> getGroupSecurityInformation(TaskData taskData, IProgressMonitor monitor)
+ throws CoreException {
+ Map<String, String> groupSecurityInformation = new HashMap<String, String>();
+ hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
+
+ 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);
+ httpClient.getParams().setParameter("http.protocol.single-cookie-header", true);
+ getMethod.setDoAuthentication(true);
+
+ int code;
+ InputStream inStream = null;
+ try {
+ code = WebUtil.execute(httpClient, hostConfiguration, getMethod, monitor);
+ if (code == HttpURLConnection.HTTP_OK) {
+ inStream = getResponseStream(getMethod, monitor);
+ HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(new BufferedReader(new InputStreamReader(
+ inStream, characterEncoding)), null);
+ for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
+ if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == Tag.INPUT
+ && !((HtmlTag) (token.getValue())).isEndTag()) {
+ HtmlTag tag = (HtmlTag) token.getValue();
+ // String name = tag.getAttribute("name");
+ String id = tag.getAttribute("id");
+ String checkedValue = tag.getAttribute("checked");
+ String type = tag.getAttribute("type");
+ if (type != null && type.equalsIgnoreCase("checkbox") && id != null && id.startsWith("bit-")) {
+ groupSecurityInformation.put(id, checkedValue);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
+ "Unable to retrieve group security information", e));
+ } finally {
+ if (inStream != null) {
+ try {
+ inStream.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+ }
+ return groupSecurityInformation;
+ }
+
public static String stripTimeZone(String longTime) {
String result = longTime;
if (longTime != null) {

Back to the top