private static String getResolvedStringIfSetOrGetDefault(
     final OperationContext context,
     final ModelNode dataSourceNode,
     final SimpleAttributeDefinition key,
     final String defaultValue)
     throws OperationFailedException {
   if (dataSourceNode.hasDefined(key.getName())) {
     return context.resolveExpressions(dataSourceNode.get(key.getName())).asString();
   } else {
     return defaultValue;
   }
 }
Пример #2
0
 private ModelNode unmaskUsersPasswords(OperationContext context, ModelNode users)
     throws OperationFailedException {
   users = users.clone();
   for (Property property : users.get(USER).asPropertyList()) {
     // Don't use the value from property as it is a clone and does not update the returned users
     // ModelNode.
     ModelNode user = users.get(USER, property.getName());
     if (user.hasDefined(PASSWORD)) {
       // TODO This will be cleaned up once it uses attribute definitions
       user.set(PASSWORD, context.resolveExpressions(user.get(PASSWORD)).asString());
     }
   }
   return users;
 }
Пример #3
0
  /**
   * Creates a copy of unresolvedConfig with all expressions resolved and all undefined attributes
   * that have a default value set to the default.
   *
   * @param context the operation context
   * @param unresolvedConfig the raw configuration model
   * @return the resolved configuration model
   * @throws OperationFailedException if there is a problem resolving an attribute
   */
  private ModelNode resolveConfig(OperationContext context, ModelNode unresolvedConfig)
      throws OperationFailedException {

    final ModelNode resolved = new ModelNode();

    // First the simple core attributes
    for (AttributeDefinition coreAttr : ModClusterConfigResourceDefinition.ATTRIBUTES) {
      resolved
          .get(coreAttr.getName())
          .set(coreAttr.resolveModelAttribute(context, unresolvedConfig));
    }
    // Next SSL
    // Use ModClusterExtension.sslConfigurationPath here so if we change the PathElement components,
    // we don't have to change this code
    final ModelNode unresolvedSSL =
        unresolvedConfig.get(
            ModClusterExtension.sslConfigurationPath.getKey(),
            ModClusterExtension.sslConfigurationPath.getValue());
    if (unresolvedSSL.isDefined()) {
      final ModelNode resolvedSSL =
          resolved.get(
              ModClusterExtension.sslConfigurationPath.getKey(),
              ModClusterExtension.sslConfigurationPath.getValue());
      for (AttributeDefinition sslAttr : ModClusterConfigResourceDefinition.ATTRIBUTES) {
        resolvedSSL
            .get(sslAttr.getName())
            .set(sslAttr.resolveModelAttribute(context, unresolvedSSL));
      }
    }

    // Finally the load-provider stuff
    // TODO AS7-4050 properly handle these
    for (Property property : unresolvedConfig.asPropertyList()) {
      String key = property.getName();
      if (!ModClusterConfigResourceDefinition.ATTRIBUTES_BY_NAME.containsKey(key)
          && !key.equals(ModClusterExtension.sslConfigurationPath.getKey())) {
        resolved.get(key).set(context.resolveExpressions(property.getValue()));
      }
    }

    return resolved;
  }