summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2017-04-29 10:10:39 -0400
committerFrank Becker2018-06-16 07:26:13 -0400
commit50b259f33cc33e5537be1076e87686102dfb77f2 (patch)
treee23635b0447c24e4e102d68c5be977d3aae98110
parente9f0eea0355ee808dfd2b2ae7ca42a227248d856 (diff)
downloadorg.eclipse.mylyn.tasks-50b259f33cc33e5537be1076e87686102dfb77f2.zip
org.eclipse.mylyn.tasks-50b259f33cc33e5537be1076e87686102dfb77f2.tar.gz
org.eclipse.mylyn.tasks-50b259f33cc33e5537be1076e87686102dfb77f2.tar.xz
515975: Bugzilla REST: add private support to attachments
Change-Id: Ife9db5586ffba8060aefa0f94e32d6c06063eaeb Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=515975
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java21
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java1
-rw-r--r--connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java9
3 files changed, 28 insertions, 3 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java
index 36d0c6f..481adff 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAttachmentMapper.java
@@ -23,6 +23,8 @@ import org.eclipse.mylyn.tasks.core.data.TaskData;
public class BugzillaRestAttachmentMapper extends TaskAttachmentMapper {
private Date deltaDate;
+ private Boolean attachmentIsPrivate;
+
@Override
public void applyTo(TaskAttribute taskAttribute) {
Assert.isNotNull(taskAttribute);
@@ -102,6 +104,13 @@ public class BugzillaRestAttachmentMapper extends TaskAttachmentMapper {
defaults.setLabel("Modification Date");
mapper.setDateValue(child, getDeltaDate());
}
+ if (getAttachmentIsPrivate() != null) {
+ TaskAttribute child = taskAttribute.createMappedAttribute("is_private"); //$NON-NLS-1$
+ TaskAttributeMetaData defaults = child.getMetaData().defaults();
+ defaults.setType(TaskAttribute.TYPE_BOOLEAN);
+ defaults.setLabel("private");
+ mapper.setBooleanValue(child, getAttachmentIsPrivate());
+ }
}
public static BugzillaRestAttachmentMapper createFrom(TaskAttribute taskAttribute) {
@@ -152,6 +161,10 @@ public class BugzillaRestAttachmentMapper extends TaskAttachmentMapper {
if (child != null) {
attachment.setDeltaDate(mapper.getDateValue(child));
}
+ child = taskAttribute.getMappedAttribute("is_private"); //$NON-NLS-1$
+ if (child != null) {
+ attachment.setAttachmentIsPrivate(mapper.getBooleanValue(child));
+ }
return attachment;
}
@@ -164,6 +177,14 @@ public class BugzillaRestAttachmentMapper extends TaskAttachmentMapper {
this.deltaDate = deltaDate;
}
+ public Boolean getAttachmentIsPrivate() {
+ return attachmentIsPrivate;
+ }
+
+ public void setAttachmentIsPrivate(Boolean attachmentIsPrivate) {
+ this.attachmentIsPrivate = attachmentIsPrivate;
+ }
+
public void addMissingFlags(TaskAttribute taskAttribute) {
Assert.isNotNull(taskAttribute);
TaskData taskData = taskAttribute.getTaskData();
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java
index f655847..7b4526d 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestGetTaskAttachments.java
@@ -93,6 +93,7 @@ public class BugzillaRestGetTaskAttachments extends BugzillaRestGetRequest<Array
"Can not parse Date (" + attachmentObject.get("creation_time").getAsString() + ")"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
attachmentMapper.setContentType(attachmentObject.get("content_type").getAsString()); //$NON-NLS-1$
+ attachmentMapper.setAttachmentIsPrivate(attachmentObject.get("is_private").getAsBoolean());
attachmentMapper.setDeprecated(attachmentObject.get("is_obsolete") //$NON-NLS-1$
.getAsBoolean());
attachmentMapper.setDescription(attachmentObject.get("summary").getAsString()); //$NON-NLS-1$
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java
index 893dca5..4804f6a 100644
--- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java
+++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestPostNewAttachment.java
@@ -38,7 +38,6 @@ import org.eclipse.mylyn.commons.repositories.http.core.CommonHttpResponse;
import org.eclipse.mylyn.commons.repositories.http.core.HttpUtil;
import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.BugzillaRestIdsResult;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
-import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.osgi.util.NLS;
@@ -74,9 +73,10 @@ public class BugzillaRestPostNewAttachment extends BugzillaRestPostRequest<Bugzi
String contentType = source.getContentType();
String filename = source.getName();
boolean isPatch = false;
+ boolean isPrivate = false;
if (attachmentAttribute != null) {
- TaskAttachmentMapper mapper = TaskAttachmentMapper.createFrom(attachmentAttribute);
+ BugzillaRestAttachmentMapper mapper = BugzillaRestAttachmentMapper.createFrom(attachmentAttribute);
if (mapper.getDescription() != null) {
description = mapper.getDescription();
@@ -93,6 +93,9 @@ public class BugzillaRestPostNewAttachment extends BugzillaRestPostRequest<Bugzi
if (mapper.isPatch() != null) {
isPatch = mapper.isPatch();
}
+ if (mapper.getAttachmentIsPrivate() != null) {
+ isPrivate = mapper.getAttachmentIsPrivate();
+ }
}
Assert.isNotNull(bugReportID);
Assert.isNotNull(source);
@@ -136,7 +139,7 @@ public class BugzillaRestPostNewAttachment extends BugzillaRestPostRequest<Bugzi
out.name("content_type").value(contentType); //$NON-NLS-1$
out.name("data").value(dataBase64); //$NON-NLS-1$
out.name("file_name").value(filename); //$NON-NLS-1$
- out.name("is_private").value(false); //$NON-NLS-1$
+ out.name("is_private").value(isPrivate); //$NON-NLS-1$
if (attachmentAttribute != null) {
attachmentAttribute.getAttributes().values();
Set<TaskAttribute> changed = new HashSet<TaskAttribute>();