@Override
public void updateCompletedFlag(final TaskDto task) {
try {
final ItemId itemId = new ItemId(task.getExchangeId());
final Item email = Item.bind(service, itemId, createEmailPropertySet());
email.setExtendedProperty(PR_TODO_TITLE, task.getName());
email.setExtendedProperty(PR_TASK_MODE, 0); // Task is not assigned
if (task.isCompleted()) {
email.removeExtendedProperty(PR_FLAG_REQUEST);
email.setExtendedProperty(PR_TASK_COMPLETE, true);
email.setExtendedProperty(PR_PERCENT_COMPLETE, 1d);
email.setExtendedProperty(PR_TASK_DATE_COMPLETED, new Date());
email.setExtendedProperty(PR_TASK_STATUS, 2); // User's work on this task is complete
email.setExtendedProperty(PR_FLAG_STATUS, PR_FLAG_STATUS_FOLLOWUP_COMPLETE);
} else {
email.setExtendedProperty(PR_TASK_START_DATE, new Date());
email.setExtendedProperty(PR_FLAG_REQUEST, "Follow up");
email.setExtendedProperty(PR_TODO_ORDINAL_DATE, new Date());
email.setExtendedProperty(PR_TODO_SUB_ORDINAL, "5555555");
email.setExtendedProperty(PR_TASK_COMPLETE, false);
email.setExtendedProperty(PR_PERCENT_COMPLETE, 0d);
email.removeExtendedProperty(PR_TASK_DATE_COMPLETED);
email.setExtendedProperty(PR_TASK_STATUS, 0);
email.setExtendedProperty(PR_FLAG_STATUS, PR_FLAG_STATUS_FOLLOWUP_FLAGGED);
}
email.update(ConflictResolutionMode.AlwaysOverwrite);
} catch (final Exception e) {
LOG.error("Unable to update email completed flag in Exchange", e);
}
}