コード例 #1
0
  @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);
    }
  }
コード例 #2
0
  @Override
  public void add(Partition partition, String configurationName)
      throws IdentityManagementException {
    checkPartitionManagementSupported();

    if (partition == null) {
      throw MESSAGES.nullArgument("Partition");
    }

    if (isNullOrEmpty(configurationName)) {
      configurationName = getDefaultConfigurationName();
    }

    if (getConfigurationByName(configurationName) != null) {
      if (getPartition(partition.getClass(), partition.getName()) != null) {
        throw MESSAGES.partitionAlreadyExistsWithName(partition.getClass(), partition.getName());
      }

      try {
        IdentityContext context = createIdentityContext();

        getStoreForPartitionOperation(context).add(context, partition, configurationName);

        AttributeStore<?> attributeStore = getStoreForAttributeOperation(context);

        if (attributeStore != null) {
          for (Attribute<? extends Serializable> attribute : partition.getAttributes()) {
            attributeStore.setAttribute(context, partition, attribute);
          }
        }
      } catch (Exception e) {
        throw MESSAGES.partitionAddFailed(partition, configurationName, e);
      }
    }
  }