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);
 }
  public static RefinedResourceSchema parse(ResourceType resourceType, PrismContext prismContext)
      throws SchemaException {

    ResourceSchema originalResourceSchema = getResourceSchema(resourceType, prismContext);
    if (originalResourceSchema == null) {
      return null;
    }

    String contextDescription = "definition of " + resourceType;

    RefinedResourceSchemaImpl rSchema = new RefinedResourceSchemaImpl(originalResourceSchema);

    SchemaHandlingType schemaHandling = resourceType.getSchemaHandling();
    if (schemaHandling != null) {
      parseObjectTypeDefsFromSchemaHandling(
          rSchema,
          resourceType,
          schemaHandling,
          schemaHandling.getObjectType(),
          null,
          prismContext,
          contextDescription);
    }

    parseObjectTypesFromSchema(rSchema, resourceType, prismContext, contextDescription);

    // We need to parse associations and auxiliary object classes in a second pass. We need to have
    // all object classes parsed before correctly setting association
    // targets
    for (RefinedObjectClassDefinition rOcDef : rSchema.getRefinedDefinitions()) {
      ((RefinedObjectClassDefinitionImpl) rOcDef).parseAssociations(rSchema);
      ((RefinedObjectClassDefinitionImpl) rOcDef).parseAuxiliaryObjectClasses(rSchema);
    }

    // We can parse attributes only after we have all the object class info parsed (including
    // auxiliary object classes)
    for (RefinedObjectClassDefinition rOcDef : rSchema.getRefinedDefinitions()) {
      ((RefinedObjectClassDefinitionImpl) rOcDef).parseAttributes(rSchema, contextDescription);
    }

    return rSchema;
  }
 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());
 }