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;
}
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;
}
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;
}
}
}
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);
}
}
}
}
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);
}
Aggregations