public XmlTask updateTask(
      T transaction, Handle<XmlTask> handle, XmlTask partialNewTask, Principal user)
      throws SQLException {
    if (user == null) {
      throw new AuthenticationNeededException("There is no user associated with this request");
    }
    // This needs to be a copy otherwise the cache will interfere with the changes
    XmlTask currentTask;
    {
      final XmlTask t = getTask(transaction, handle);
      if (t == null) {
        return null;
      }
      currentTask = new XmlTask(t);
    }
    for (XmlItem newItem : partialNewTask.getItems()) {
      if (newItem.getName() != null && newItem.getName().length() > 0) {
        XmlItem currentItem = currentTask.getItem(newItem.getName());
        if (currentItem != null) {
          currentItem.setValue(newItem.getValue());
        }
      }
    }
    // Store the data
    getTasks().set(transaction, handle, currentTask);
    transaction.commit(); // the actual state isn't stored anyway.
    // This may update the server.
    currentTask.setState(partialNewTask.getState(), user);

    return currentTask;
  }