コード例 #1
0
 @Override
 public RefinedObjectClassDefinition getRefinedDefinition(
     ShadowKindType kind, Collection<String> intents) throws SchemaException {
   RefinedObjectClassDefinition found = null;
   for (RefinedObjectClassDefinition acctDef : getRefinedDefinitions(kind)) {
     RefinedObjectClassDefinition foundCurrent = null;
     if (intents == null || intents.isEmpty()) {
       if (acctDef.isDefault()) {
         foundCurrent = acctDef;
       }
     } else {
       if (intents.contains(acctDef.getIntent())) {
         foundCurrent = acctDef;
       }
     }
     if (foundCurrent != null) {
       if (found != null) {
         if (!QNameUtil.match(found.getTypeName(), foundCurrent.getTypeName())) {
           throw new SchemaException(
               "More than one ObjectClass found for kind "
                   + kind
                   + ", intents: "
                   + intents
                   + ": "
                   + found.getTypeName()
                   + ", "
                   + foundCurrent.getTypeName());
         }
       } else {
         found = foundCurrent;
       }
     }
   }
   return found;
 }
コード例 #2
0
  @Override
  public CompositeRefinedObjectClassDefinition determineCompositeObjectClassDefinition(
      PrismObject<ShadowType> shadow, Collection<QName> additionalAuxiliaryObjectClassQNames)
      throws SchemaException {
    ShadowType shadowType = shadow.asObjectable();

    RefinedObjectClassDefinition structuralObjectClassDefinition = null;
    ShadowKindType kind = shadowType.getKind();
    String intent = shadowType.getIntent();
    QName structuralObjectClassQName = shadowType.getObjectClass();

    if (kind != null) {
      structuralObjectClassDefinition = getRefinedDefinition(kind, intent);
    }

    if (structuralObjectClassDefinition == null) {
      // Fallback to objectclass only
      if (structuralObjectClassQName == null) {
        return null;
      }
      structuralObjectClassDefinition = getRefinedDefinition(structuralObjectClassQName);
    }

    if (structuralObjectClassDefinition == null) {
      return null;
    }
    List<QName> auxiliaryObjectClassQNames = shadowType.getAuxiliaryObjectClass();
    if (additionalAuxiliaryObjectClassQNames != null) {
      auxiliaryObjectClassQNames.addAll(additionalAuxiliaryObjectClassQNames);
    }
    Collection<RefinedObjectClassDefinition> auxiliaryObjectClassDefinitions =
        new ArrayList<>(auxiliaryObjectClassQNames.size());
    for (QName auxiliaryObjectClassQName : auxiliaryObjectClassQNames) {
      RefinedObjectClassDefinition auxiliaryObjectClassDef =
          getRefinedDefinition(auxiliaryObjectClassQName);
      if (auxiliaryObjectClassDef == null) {
        throw new SchemaException(
            "Auxiliary object class "
                + auxiliaryObjectClassQName
                + " specified in "
                + shadow
                + " does not exist");
      }
      auxiliaryObjectClassDefinitions.add(auxiliaryObjectClassDef);
    }

    return new CompositeRefinedObjectClassDefinitionImpl(
        structuralObjectClassDefinition, auxiliaryObjectClassDefinitions);
  }