use of org.eclipse.mylyn.tasks.core.RepositoryResponse in project linuxtools by eclipse.
the class OSIORestClient method postTaskData.
public RepositoryResponse postTaskData(TaskData taskData, Set<TaskAttribute> oldAttributes, TaskRepository repository, IOperationMonitor monitor) throws OSIORestException {
Space space = null;
if (taskData.isNew()) {
TaskAttribute spaceAttribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SPACE.getKey());
Map<String, Space> spaces = getCachedSpaces(new NullOperationMonitor());
space = spaces.get(spaceAttribute.getValue());
String id = null;
try {
id = restRequestProvider.postNewTask(monitor, client, taskData, space, connector, repository);
} catch (CoreException e1) {
throw new OSIORestException(e1);
}
return new RepositoryResponse(ResponseKind.TASK_CREATED, id);
} else {
TaskAttribute spaceIdAttribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey());
String spaceId = spaceIdAttribute.getValue();
try {
space = getSpaceById(spaceId, repository);
} catch (CoreException e1) {
throw new OSIORestException(e1);
}
TaskAttribute newComment = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().NEW_COMMENT.getKey());
if (newComment != null) {
String value = newComment.getValue();
if (value != null && !value.isEmpty()) {
restRequestProvider.postNewCommentTask(monitor, client, taskData, oldAttributes);
newComment.setValue("");
}
}
TaskAttribute removeLinks = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().REMOVE_LINKS.getKey());
if (removeLinks != null) {
List<String> links = removeLinks.getValues();
TaskAttributeMetaData metadata = removeLinks.getMetaData();
TaskAttribute widAttr = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().UUID.getKey());
String wid = widAttr.getValue();
for (String link : links) {
try {
String id = metadata.getValue(link);
restRequestProvider.deleteLink(monitor, client, wid, id);
} catch (Exception e) {
StatusHandler.log(new Status(IStatus.ERROR, OSIORestCore.ID_PLUGIN, // $NON-NLS-1$
NLS.bind(// $NON-NLS-1$
"Unexpected error during deletion of work item link: <{0}>", link), e));
}
}
}
TaskAttribute addLink = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().ADD_LINK.getKey());
TaskAttributeMetaData metadata = addLink.getMetaData();
// $NON-NLS-1$
String linkid = metadata.getValue("linkid");
String sourceid = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().UUID.getKey()).getValue();
// $NON-NLS-1$
String targetid = metadata.getValue("targetWid");
// $NON-NLS-1$
String direction = metadata.getValue("direction");
boolean isForward = true;
if (direction != null && !direction.isEmpty()) {
// $NON-NLS-1$
isForward = direction.equals("forward");
}
if (linkid != null && targetid != null) {
restRequestProvider.postNewLink(monitor, client, linkid, sourceid, targetid, isForward);
}
restRequestProvider.patchUpdateTask(monitor, client, taskData, oldAttributes, space);
return new RepositoryResponse(ResponseKind.TASK_UPDATED, taskData.getTaskId());
}
}
use of org.eclipse.mylyn.tasks.core.RepositoryResponse in project linuxtools by eclipse.
the class OSIORestHarness method submitNewTask.
public String submitNewTask(TaskData taskData) throws OSIORestException, CoreException {
RepositoryResponse reposonse = connector().getClient(repository()).postTaskData(taskData, null, null, null);
assertThat(reposonse.getReposonseKind(), is(ResponseKind.TASK_CREATED));
return reposonse.getTaskId();
}
Aggregations