Search in sources :

Example 11 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class ACAttributeDto method getConstruction.

public ResourceAttributeDefinitionType getConstruction(PrismContext prismContext) throws SchemaException {
    if (isEmpty()) {
        return null;
    }
    ResourceAttributeDefinitionType attrConstruction = new ResourceAttributeDefinitionType();
    if (construction != null && construction.getRef() != null) {
        // preserves original ref (including xmlns prefix!) - in order to avoid false deltas when comparing old and new values
        attrConstruction.setRef(construction.getRef());
    } else {
        attrConstruction.setRef(new ItemPathType(new ItemPath(definition.getName())));
    }
    MappingType outbound;
    if (construction != null && construction.getOutbound() != null) {
        outbound = construction.getOutbound().clone();
    } else {
        outbound = new MappingType();
        outbound.setStrength(MappingStrengthType.STRONG);
    }
    attrConstruction.setOutbound(outbound);
    ExpressionType expression = new ExpressionType();
    outbound.setExpression(expression);
    List<ACValueConstructionDto> values = getValues();
    PrismProperty property = definition.instantiate();
    // needed in serializeValueElements below
    property.revive(prismContext);
    for (ACValueConstructionDto dto : values) {
        if (dto.getValue() == null) {
            continue;
        }
        property.add(new PrismPropertyValue(dto.getValue()));
    }
    List evaluators = expression.getExpressionEvaluator();
    List<JAXBElement<RawType>> collection = StaticExpressionUtil.serializeValueElements(property, null);
    ObjectFactory of = new ObjectFactory();
    for (JAXBElement<RawType> evaluator : collection) {
        evaluators.add(evaluator);
    }
    if (evaluators.isEmpty()) {
        return null;
    }
    return attrConstruction;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) JAXBElement(javax.xml.bind.JAXBElement) ArrayList(java.util.ArrayList) List(java.util.List) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 12 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class ModelInteractionServiceImpl method getRoleSpecEntriesForAllRoles.

private Collection<RoleSelectionSpecEntry> getRoleSpecEntriesForAllRoles(OperationResult result) throws ObjectNotFoundException, SchemaException, ConfigurationException {
    ObjectTemplateType objectTemplateType = schemaTransformer.determineObjectTemplate(RoleType.class, AuthorizationPhaseType.REQUEST, result);
    if (objectTemplateType == null) {
        return null;
    }
    Collection<RoleSelectionSpecEntry> allEntries = new ArrayList();
    for (ObjectTemplateItemDefinitionType itemDef : objectTemplateType.getItem()) {
        ItemPathType ref = itemDef.getRef();
        if (ref == null) {
            continue;
        }
        ItemPath itemPath = ref.getItemPath();
        QName itemName = ItemPath.getName(itemPath.first());
        if (itemName == null) {
            continue;
        }
        if (QNameUtil.match(RoleType.F_ROLE_TYPE, itemName)) {
            ObjectReferenceType valueEnumerationRef = itemDef.getValueEnumerationRef();
            if (valueEnumerationRef == null || valueEnumerationRef.getOid() == null) {
                return allEntries;
            }
            Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
            PrismObject<LookupTableType> lookup = cacheRepositoryService.getObject(LookupTableType.class, valueEnumerationRef.getOid(), options, result);
            for (LookupTableRowType row : lookup.asObjectable().getRow()) {
                PolyStringType polyLabel = row.getLabel();
                String key = row.getKey();
                String label = key;
                if (polyLabel != null) {
                    label = polyLabel.getOrig();
                }
                RoleSelectionSpecEntry roleTypeDval = new RoleSelectionSpecEntry(key, label, null);
                allEntries.add(roleTypeDval);
            }
            return allEntries;
        }
    }
    return allEntries;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 13 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class SchemaTransformer method applyObjectTemplateToDefinition.

public <O extends ObjectType> void applyObjectTemplateToDefinition(PrismObjectDefinition<O> objectDefinition, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException {
    if (objectTemplateType == null) {
        return;
    }
    for (ObjectReferenceType includeRef : objectTemplateType.getIncludeRef()) {
        PrismObject<ObjectTemplateType> subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result);
        applyObjectTemplateToDefinition(objectDefinition, subTemplate.asObjectable(), result);
    }
    for (ObjectTemplateItemDefinitionType templateItemDefType : objectTemplateType.getItem()) {
        ItemPathType ref = templateItemDefType.getRef();
        if (ref == null) {
            throw new SchemaException("No 'ref' in item definition in " + objectTemplateType);
        }
        ItemPath itemPath = ref.getItemPath();
        ItemDefinition itemDef = objectDefinition.findItemDefinition(itemPath);
        if (itemDef != null) {
            applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType);
        } else {
            OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToDefinition");
            subResult.recordPartialError("No definition for item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType);
            continue;
        }
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ObjectTemplateItemDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 14 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class SchemaTransformer method applyObjectTemplateToObject.

private <O extends ObjectType> void applyObjectTemplateToObject(PrismObject<O> object, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException {
    if (objectTemplateType == null) {
        return;
    }
    for (ObjectReferenceType includeRef : objectTemplateType.getIncludeRef()) {
        PrismObject<ObjectTemplateType> subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result);
        applyObjectTemplateToObject(object, subTemplate.asObjectable(), result);
    }
    for (ObjectTemplateItemDefinitionType templateItemDefType : objectTemplateType.getItem()) {
        ItemPathType ref = templateItemDefType.getRef();
        if (ref == null) {
            throw new SchemaException("No 'ref' in item definition in " + objectTemplateType);
        }
        ItemPath itemPath = ref.getItemPath();
        ItemDefinition itemDefFromObject = object.getDefinition().findItemDefinition(itemPath);
        if (itemDefFromObject != null) {
            applyObjectTemplateItem(itemDefFromObject, templateItemDefType, "item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
        } else {
            OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToObject");
            subResult.recordPartialError("No definition for item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
            continue;
        }
        Item<?, ?> item = object.findItem(itemPath);
        if (item != null) {
            ItemDefinition itemDef = item.getDefinition();
            if (itemDef != itemDefFromObject) {
                applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
            }
        }
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ObjectTemplateItemDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 15 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class PageSystemConfiguration method saveObjectPolicies.

private void saveObjectPolicies(SystemConfigurationType systemConfig) {
    if (systemConfigPanel == null) {
        return;
    }
    List<ObjectPolicyConfigurationTypeDto> configList = systemConfigPanel.getModel().getObject().getObjectPolicyList();
    List<ObjectPolicyConfigurationType> confList = new ArrayList<>();
    ObjectPolicyConfigurationType newObjectPolicyConfig;
    for (ObjectPolicyConfigurationTypeDto o : configList) {
        if (o.isEmpty()) {
            continue;
        }
        newObjectPolicyConfig = new ObjectPolicyConfigurationType();
        newObjectPolicyConfig.setType(o.getType());
        newObjectPolicyConfig.setSubtype(o.getSubtype());
        newObjectPolicyConfig.setObjectTemplateRef(o.getTemplateRef());
        List<PropertyConstraintType> constraintList = new ArrayList<>();
        PropertyConstraintType property;
        if (o.getConstraints() != null) {
            for (PropertyConstraintTypeDto c : o.getConstraints()) {
                if (StringUtils.isNotEmpty(c.getPropertyPath())) {
                    property = new PropertyConstraintType();
                    property.setOidBound(c.isOidBound());
                    property.setPath(new ItemPathType(c.getPropertyPath()));
                    constraintList.add(property);
                }
            }
        }
        newObjectPolicyConfig.getPropertyConstraint().addAll(constraintList);
        confList.add(newObjectPolicyConfig);
    }
    if (confList.isEmpty()) {
        if (!systemConfig.getDefaultObjectPolicyConfiguration().isEmpty()) {
            systemConfig.getDefaultObjectPolicyConfiguration().clear();
        }
        return;
    }
    systemConfig.getDefaultObjectPolicyConfiguration().clear();
    systemConfig.getDefaultObjectPolicyConfiguration().addAll(confList);
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ArrayList(java.util.ArrayList)

Aggregations

ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)55 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)36 QName (javax.xml.namespace.QName)20 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)11 ArrayList (java.util.ArrayList)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)10 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)9 Test (org.testng.annotations.Test)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)7 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)6 List (java.util.List)5 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)4 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)4 MappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType)4 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)3