@Override
  public void update(Partition partition) throws IdentityManagementException {
    checkPartitionManagementSupported();
    checkIfPartitionExists(partition);

    try {
      IdentityContext context = createIdentityContext();
      getStoreForPartitionOperation(context).update(context, partition);

      AttributeStore<?> attributeStore = getStoreForAttributeOperation(context);

      if (attributeStore != null) {
        Partition storedType = lookupById(partition.getClass(), partition.getId());

        for (Attribute<? extends Serializable> attribute : storedType.getAttributes()) {
          if (partition.getAttribute(attribute.getName()) == null) {
            attributeStore.removeAttribute(context, partition, attribute.getName());
          }
        }

        for (Attribute<? extends Serializable> attribute : partition.getAttributes()) {
          attributeStore.setAttribute(context, partition, attribute);
        }
      }
    } catch (Exception e) {
      throw MESSAGES.partitionUpdateFailed(partition, e);
    }
  }