public static void setParsedResourceSchemaConditional(
     ResourceType resourceType, ResourceSchema parsedSchema) {
   if (hasParsedSchema(resourceType)) {
     return;
   }
   PrismObject<ResourceType> resource = resourceType.asPrismObject();
   resource.setUserData(USER_DATA_KEY_PARSED_RESOURCE_SCHEMA, parsedSchema);
 }
Esempio n. 2
0
  public boolean evaluateConfirmationExpression(
      UserType user,
      ShadowType shadow,
      ExpressionType expressionType,
      Task task,
      OperationResult result)
      throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    Validate.notNull(user, "User must not be null.");
    Validate.notNull(shadow, "Resource object shadow must not be null.");
    Validate.notNull(expressionType, "Expression must not be null.");
    Validate.notNull(result, "Operation result must not be null.");

    ResourceType resource = resolveResource(shadow, result);
    ExpressionVariables variables = getDefaultXPathVariables(user, shadow, resource);
    String shortDesc = "confirmation expression for " + resource.asPrismObject();

    PrismPropertyDefinition<Boolean> outputDefinition =
        new PrismPropertyDefinition<>(
            ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
    Expression<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> expression =
        expressionFactory.makeExpression(expressionType, outputDefinition, shortDesc, task, result);

    ExpressionEvaluationContext params =
        new ExpressionEvaluationContext(null, variables, shortDesc, task, result);
    PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple =
        ModelExpressionThreadLocalHolder.evaluateExpressionInContext(
            expression, params, task, result);
    Collection<PrismPropertyValue<Boolean>> nonNegativeValues = outputTriple.getNonNegativeValues();
    if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
      throw new ExpressionEvaluationException(
          "Expression returned no value (" + nonNegativeValues.size() + ") in " + shortDesc);
    }
    if (nonNegativeValues.size() > 1) {
      throw new ExpressionEvaluationException(
          "Expression returned more than one value ("
              + nonNegativeValues.size()
              + ") in "
              + shortDesc);
    }
    PrismPropertyValue<Boolean> resultpval = nonNegativeValues.iterator().next();
    if (resultpval == null) {
      throw new ExpressionEvaluationException(
          "Expression returned no value (" + nonNegativeValues.size() + ") in " + shortDesc);
    }
    Boolean resultVal = resultpval.getValue();
    if (resultVal == null) {
      throw new ExpressionEvaluationException(
          "Expression returned no value (" + nonNegativeValues.size() + ") in " + shortDesc);
    }
    return resultVal;
  }
Esempio n. 3
0
  public static ExpressionVariables getDefaultXPathVariables(
      UserType user, ShadowType shadow, ResourceType resource) {

    ExpressionVariables variables = new ExpressionVariables();
    if (user != null) {
      variables.addVariableDefinition(ExpressionConstants.VAR_USER, user.asPrismObject());
    }

    if (shadow != null) {
      variables.addVariableDefinition(ExpressionConstants.VAR_ACCOUNT, shadow.asPrismObject());
    }

    if (resource != null) {
      variables.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, resource.asPrismObject());
    }

    return variables;
  }
 public static boolean hasParsedSchema(ResourceType resourceType) {
   PrismObject<ResourceType> resource = resourceType.asPrismObject();
   return resource.getUserData(USER_DATA_KEY_PARSED_RESOURCE_SCHEMA) != null;
 }
 public static ResourceSchema getResourceSchema(
     ResourceType resourceType, PrismContext prismContext) throws SchemaException {
   PrismObject<ResourceType> resource = resourceType.asPrismObject();
   return getResourceSchema(resource, prismContext);
 }
 public static boolean hasRefinedSchema(ResourceType resourceType) {
   PrismObject<ResourceType> resource = resourceType.asPrismObject();
   return resource.getUserData(USER_DATA_KEY_REFINED_SCHEMA) != null;
 }
 public static LayerRefinedResourceSchema getRefinedSchema(
     ResourceType resourceType, LayerType layer, PrismContext prismContext)
     throws SchemaException {
   PrismObject<ResourceType> resource = resourceType.asPrismObject();
   return getRefinedSchema(resource, layer, prismContext);
 }
 public static LayerRefinedResourceSchema getRefinedSchema(
     ResourceType resourceType, LayerType layer) throws SchemaException {
   return getRefinedSchema(resourceType, layer, resourceType.asPrismObject().getPrismContext());
 }