}
private RepositoryResponse updateIssue(TaskRepository repository, TaskData taskData,
Set<TaskAttribute> oldAttributes, IProgressMonitor monitor) throws CoreException {
IGoogleCodeClient client = getClient(repository);
IssueCommentsEntry entry = new IssueCommentsEntry();
Updates updates = new Updates();
String summary = getStringValue(taskData, GoogleCodeAttribute.SUMMARY);
updates.setSummary(new Summary(summary));
String issueId = getIssueId(taskData);
String comment = getNewComment(taskData);
String currentPriority = getPriority(taskData);
String oldPriority = getOldPriority(oldAttributes);
if (!currentPriority.equals(oldPriority)) {
if (oldPriority != null) {
updates.addLabel(new Label('-' + oldPriority));
}
updates.addLabel(new Label(currentPriority));
}
String ownerName = getStringValue(taskData, GoogleCodeAttribute.USER_ASSIGNED);
String oldOwner = getOldOwner(oldAttributes);
if (!(ObjectUtils.equals(ownerName, oldOwner) || (StringUtils.isEmpty(ownerName) && StringUtils
.isEmpty(oldOwner)))) {
OwnerUpdate ownerUpdate;
if (!StringUtils.isEmpty(ownerName)) {
ownerUpdate = new OwnerUpdate(ownerName);
} else {
// remove the owner
// FIXME broken, doesn't work, null doesn't work as well
ownerUpdate = new OwnerUpdate(StringUtils.EMPTY);
}
updates.setOwnerUpdate(ownerUpdate);
}
updates.setStatus(new Status(getStringValue(taskData, GoogleCodeAttribute.STATUS)));
computeBlockedOnDifference(taskData, oldAttributes, updates);
entry.getAuthors().add(client.getCurrentUser());
if (!StringUtils.isEmpty(comment)) {
entry.setContent(new HtmlTextConstruct(comment));
}
entry.setSendEmail(new SendEmail("False"));
entry.setUpdates(updates);
client.updateIssue(issueId, entry, monitor);
return new RepositoryResponse(ResponseKind.TASK_UPDATED, issueId);
}