Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla')
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java3
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java62
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java11
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java10
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java10
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java16
6 files changed, 110 insertions, 2 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
index f70778574..e4d09a9f8 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java
@@ -127,6 +127,9 @@ public class BugzillaRestConfiguration implements Serializable {
TaskAttribute attribute = data.getRoot().getAttribute(key);
if (!key.equals(SCHEMA.PRODUCT.getKey())) {
String configName = mapTaskAttributeKey2ConfigurationFields(key);
+ if ("addCC".equals(configName) || "removeCC".equals(configName)) {
+ continue;
+ }
Field configField = getFieldWithName(configName);
if (configField == null) {
continue;
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
index 9d1b8f57b..b2927a800 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGsonUtil.java
@@ -11,7 +11,44 @@
package org.eclipse.mylyn.internal.bugzilla.rest.core;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.common.collect.Sets;
+import com.google.gson.Gson;
+import com.google.gson.stream.JsonWriter;
+
public class BugzillaRestGsonUtil {
+
+ private class RemoveAddStringHelper {
+ Set<String> add;
+
+ Set<String> remove;
+
+ public RemoveAddStringHelper(Set<String> removeSet, Set<String> addSet) {
+ add = new HashSet<String>(addSet);
+ remove = new HashSet<String>(removeSet);
+ if (remove.contains("")) { //$NON-NLS-1$
+ remove.remove(""); //$NON-NLS-1$
+ }
+ if (add.contains("")) { //$NON-NLS-1$
+ add.remove(""); //$NON-NLS-1$
+ }
+ Set<String> intersection = Sets.intersection(addSet, removeSet);
+ remove.removeAll(intersection);
+ add.removeAll(intersection);
+ if (remove.isEmpty()) {
+ remove = null;
+ }
+ if (add.isEmpty()) {
+ add = null;
+ }
+ }
+ }
+
+ private static Gson gson = new Gson();
+
public static String convertString2GSonString(String str) {
str = str.replace("\"", "\\\"").replace("\n", "\\\n"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
StringBuffer ostr = new StringBuffer();
@@ -31,4 +68,29 @@ public class BugzillaRestGsonUtil {
return (new String(ostr));
}
+ private static BugzillaRestGsonUtil instance;
+
+ public static BugzillaRestGsonUtil getDefault() {
+ if (instance == null) {
+ instance = new BugzillaRestGsonUtil();
+ }
+ return instance;
+ }
+
+ public static void buildArrayFromHash(JsonWriter out, String id, Set<String> setNew) throws IOException {
+ if (!setNew.isEmpty()) {
+ out.name(id).beginArray();
+ for (String string : setNew) {
+ out.value(string);
+ }
+ out.endArray();
+ }
+ }
+
+ public void buildAddRemoveHash(JsonWriter out, String id, Set<String> setOld, Set<String> setNew)
+ throws IOException {
+ RemoveAddStringHelper test = new RemoveAddStringHelper(setOld, setNew);
+ out.name(id);
+ gson.toJson(test, RemoveAddStringHelper.class, out);
+ }
} \ No newline at end of file
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java
index d693cd298..aaed696b7 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewTask.java
@@ -16,6 +16,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import org.apache.http.HttpStatus;
@@ -78,6 +80,14 @@ public class BugzillaRestPostNewTask extends BugzillaRestAuthenticatedPostReques
continue;
}
}
+
+ if (id.equals("cc")) { //$NON-NLS-1$
+ HashSet<String> setNew = new HashSet<String>(
+ Arrays.asList(taskAttribute.getValue().split("\\s*,\\s*"))); //$NON-NLS-1$
+ BugzillaRestGsonUtil.buildArrayFromHash(out, id, setNew);
+ continue;
+ }
+
if (taskAttribute.getMetaData().getType() != null
&& taskAttribute.getMetaData().getType().equals(TaskAttribute.TYPE_MULTI_SELECT)) {
List<String> values = taskAttribute.getValues();
@@ -167,6 +177,7 @@ public class BugzillaRestPostNewTask extends BugzillaRestAuthenticatedPostReques
.add(BugzillaRestCreateTaskSchema.getDefault().QA_CONTACT.getKey())
.add(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.add(TaskAttribute.OPERATION)
+ .add(BugzillaRestCreateTaskSchema.getDefault().CC.getKey())
.build();
@Override
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
index 6a790f358..a3e5d1a02 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPutUpdateTask.java
@@ -14,6 +14,8 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -142,6 +144,14 @@ public class BugzillaRestPutUpdateTask extends BugzillaRestAuthenticatedPutReque
}
}
}
+ TaskAttribute addCC = taskData.getRoot().getAttribute(BugzillaRestTaskSchema.getDefault().ADD_CC.getKey());
+ TaskAttribute removeCC = taskData.getRoot()
+ .getAttribute(BugzillaRestTaskSchema.getDefault().REMOVE_CC.getKey());
+ if (addCC.getValues().size() > 0 || removeCC.getValues().size() > 0) {
+ Set<String> setOld = new HashSet<String>(removeCC.getValues());
+ HashSet<String> setNew = new HashSet<String>(Arrays.asList(addCC.getValue().split("\\s*,\\s*"))); //$NON-NLS-1$
+ BugzillaRestGsonUtil.getDefault().buildAddRemoveHash(out, "cc", setOld, setNew); //$NON-NLS-1$
+ }
out.endObject();
}
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
index ed96ad889..b0aefe9b0 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestTaskSchema.java
@@ -28,7 +28,7 @@ public class BugzillaRestTaskSchema extends AbstractTaskSchema {
.put("status", getDefault().STATUS.getKey()) //$NON-NLS-1$
.put("product", getDefault().PRODUCT.getKey()) //$NON-NLS-1$
.put("component", getDefault().COMPONENT.getKey()) //$NON-NLS-1$
- .put("CC", getDefault().CC.getKey()) //$NON-NLS-1$
+ .put("cc", getDefault().CC.getKey()) //$NON-NLS-1$
.put("severity", getDefault().SEVERITY.getKey()) //$NON-NLS-1$
.put("priority", getDefault().PRIORITY.getKey()) //$NON-NLS-1$
.put("assigned_to", getDefault().ASSIGNED_TO.getKey()) //$NON-NLS-1$
@@ -108,7 +108,13 @@ public class BugzillaRestTaskSchema extends AbstractTaskSchema {
.dependsOn(COMPONENT.getKey())
.create();
- public final Field CC = createField(TaskAttribute.USER_CC, "CC", TaskAttribute.TYPE_PERSON, Flag.PEOPLE);
+ public final Field ADD_CC = createField("addCC", "Add CC", TaskAttribute.TYPE_PERSON, Flag.PEOPLE);
+
+ public final Field CC = createField(TaskAttribute.USER_CC, "Remove CC\n(Selet to remove)",
+ IBugzillaRestConstants.EDITOR_TYPE_CC, Flag.PEOPLE);
+
+ public final Field REMOVE_CC = createField("removeCC", "CC selected for remove",
+ IBugzillaRestConstants.EDITOR_TYPE_CC);
public final Field ADD_SELF_CC = inheritFrom(parent.ADD_SELF_CC).addFlags(Flag.PEOPLE).create();
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java
new file mode 100644
index 000000000..2bb566a21
--- /dev/null
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/IBugzillaRestConstants.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Frank Becker and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.rest.core;
+
+public interface IBugzillaRestConstants {
+ public static final String EDITOR_TYPE_CC = "bugzilla.editor.cc"; //$NON-NLS-1$
+}

Back to the top