use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class SystemConfigurationDto method getNewObject.
public SystemConfigurationType getNewObject() throws DatatypeConfigurationException {
SystemConfigurationType newObject = oldObject.clone();
if (StringUtils.isNotBlank(getPassPolicyDto().getOid())) {
ObjectReferenceType globalPassPolicyRef = ObjectTypeUtil.createObjectRef(getPassPolicyDto().getOid(), ObjectTypes.PASSWORD_POLICY);
newObject.setGlobalPasswordPolicyRef(globalPassPolicyRef);
} else {
newObject.setGlobalPasswordPolicyRef(null);
}
if (StringUtils.isNotBlank(getSecurityPolicyDto().getOid())) {
ObjectReferenceType globalSecurityPolicyRef = ObjectTypeUtil.createObjectRef(getSecurityPolicyDto().getOid(), WebComponentUtil.createPolyFromOrigString(getSecurityPolicyDto().getName()), ObjectTypes.SECURITY_POLICY);
newObject.setGlobalSecurityPolicyRef(globalSecurityPolicyRef);
} else {
newObject.setGlobalSecurityPolicyRef(null);
}
AssignmentPolicyEnforcementType globalAEP = AEPlevel.toAEPValueType(getAepLevel());
if (globalAEP != null) {
ProjectionPolicyType projectionPolicy = new ProjectionPolicyType();
projectionPolicy.setAssignmentPolicyEnforcement(globalAEP);
newObject.setGlobalAccountSynchronizationSettings(projectionPolicy);
}
Duration auditCleanupDuration = DatatypeFactory.newInstance().newDuration(getAuditCleanupValue());
Duration cleanupTaskDuration = DatatypeFactory.newInstance().newDuration(getTaskCleanupValue());
CleanupPolicyType auditCleanup = new CleanupPolicyType();
CleanupPolicyType taskCleanup = new CleanupPolicyType();
auditCleanup.setMaxAge(auditCleanupDuration);
taskCleanup.setMaxAge(cleanupTaskDuration);
CleanupPoliciesType cleanupPolicies = new CleanupPoliciesType();
cleanupPolicies.setAuditRecords(auditCleanup);
cleanupPolicies.setClosedTasks(taskCleanup);
newObject.setCleanupPolicy(cleanupPolicies);
SystemConfigurationTypeUtil.setEnableExperimentalCode(newObject, getEnableExperimentalCode());
newObject.setLogging(loggingConfig.getNewObject());
newObject.setNotificationConfiguration(notificationConfig.getNewObject(newObject));
newObject.setProfilingConfiguration(profilingDto.getNewObject());
ClassLoggerConfigurationType profilingClassLogger = profilingDto.getProfilingClassLogerConfig();
if (newObject.getLogging() != null) {
newObject.getLogging().getClassLogger().add(profilingClassLogger);
} else {
LoggingConfigurationType profLogging = new LoggingConfigurationType();
profLogging.getClassLogger().add(profilingClassLogger);
newObject.setLogging(profLogging);
}
return newObject;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method gatherAssociationsFromAbstractRole.
private void gatherAssociationsFromAbstractRole(AbstractRoleType thisRole, PrismContainer<ShadowAssociationType> output, String resourceOid, ShadowKindType kind, String intent, QName assocName, Collection<SelectorOptions<GetOperationOptions>> options, String desc, ExpressionEvaluationContext params) throws SchemaException {
for (ObjectReferenceType linkRef : thisRole.getLinkRef()) {
ShadowType shadowType;
try {
shadowType = objectResolver.resolve(linkRef, ShadowType.class, options, desc, params.getTask(), params.getResult());
} catch (ObjectNotFoundException e) {
// Linked shadow not found. This may happen e.g. if the account is deleted and model haven't got
// the chance to react yet. Just ignore such shadow.
LOGGER.trace("Ignoring shadow " + linkRef.getOid() + " linked in " + thisRole + " because it no longer exists");
continue;
}
if (ShadowUtil.matches(shadowType, resourceOid, kind, intent)) {
PrismContainerValue<ShadowAssociationType> newValue = output.createNewValue();
ShadowAssociationType shadowAssociationType = newValue.asContainerable();
shadowAssociationType.setName(assocName);
ObjectReferenceType shadowRef = new ObjectReferenceType();
shadowRef.setOid(linkRef.getOid());
shadowAssociationType.setShadowRef(shadowRef);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AssociationTargetSearchExpressionEvaluator method createPrismValue.
protected PrismContainerValue<ShadowAssociationType> createPrismValue(String oid, QName targetTypeQName, List<ItemDelta<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>>> additionalAttributeDeltas, ExpressionEvaluationContext params) {
ShadowAssociationType associationType = new ShadowAssociationType();
PrismContainerValue<ShadowAssociationType> associationCVal = associationType.asPrismContainerValue();
associationType.setName(params.getMappingQName());
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(oid);
targetRef.setType(targetTypeQName);
associationType.setShadowRef(targetRef);
try {
if (additionalAttributeDeltas != null) {
ItemDelta.applyTo(additionalAttributeDeltas, associationCVal);
}
getPrismContext().adopt(associationCVal, ShadowType.COMPLEX_TYPE, new ItemPath(ShadowType.F_ASSOCIATION));
if (InternalsConfig.consistencyChecks) {
associationCVal.assertDefinitions("associationCVal in assignment expression in " + params.getContextDescription());
}
} catch (SchemaException e) {
// Should not happen
throw new SystemException(e);
}
return associationCVal;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class GenerateExpressionEvaluator method evaluate.
/*
* (non-Javadoc)
*
* @see
* com.evolveum.midpoint.common.expression.ExpressionEvaluator#evaluate(java
* .util.Collection, java.util.Map, boolean, java.lang.String,
* com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public PrismValueDeltaSetTriple<V> evaluate(ExpressionEvaluationContext context) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
StringPolicyType stringPolicyType = null;
ObjectReferenceType generateEvaluatorValuePolicyRef = generateEvaluatorType.getValuePolicyRef();
if (generateEvaluatorValuePolicyRef != null) {
if (generateEvaluatorType.getValuePolicyRef() != null) {
ValuePolicyType valuePolicyType = objectResolver.resolve(generateEvaluatorValuePolicyRef, ValuePolicyType.class, null, "resolving value policy reference in generateExpressionEvaluator", context.getTask(), context.getResult());
stringPolicyType = valuePolicyType.getStringPolicy();
}
}
// would be generated
if (stringPolicyType == null) {
StringPolicyResolver stringPolicyResolver = context.getStringPolicyResolver();
if (stringPolicyResolver != null) {
stringPolicyType = stringPolicyResolver.resolve();
}
}
elementStringPolicy = stringPolicyType;
// } else {
// stringPolicyType = elementStringPolicy;
// }
//
String stringValue = null;
GenerateExpressionEvaluatorModeType mode = generateEvaluatorType.getMode();
Item<V, D> output = outputDefinition.instantiate();
if (mode == null || mode == GenerateExpressionEvaluatorModeType.POLICY) {
PrismObject<? extends ObjectType> object = getObject(context);
// TODO: generate value based on stringPolicyType (if not null)
if (stringPolicyType != null) {
if (isNotEmptyMinLength(stringPolicyType)) {
stringValue = valuePolicyGenerator.generate(output.getPath(), stringPolicyType, DEFAULT_LENGTH, true, object, context.getContextDescription(), context.getTask(), context.getResult());
} else {
stringValue = valuePolicyGenerator.generate(output.getPath(), stringPolicyType, DEFAULT_LENGTH, false, object, context.getContextDescription(), context.getTask(), context.getResult());
}
context.getResult().computeStatus();
if (context.getResult().isError()) {
throw new ExpressionEvaluationException("Failed to generate value according to policy: " + stringPolicyType.getDescription() + ". " + context.getResult().getMessage());
}
}
if (stringValue == null) {
int length = DEFAULT_LENGTH;
RandomString randomString = new RandomString(length);
stringValue = randomString.nextString();
}
} else if (mode == GenerateExpressionEvaluatorModeType.UUID) {
UUID randomUUID = UUID.randomUUID();
stringValue = randomUUID.toString();
} else {
throw new ExpressionEvaluationException("Unknown mode for generate expression: " + mode);
}
Object value = ExpressionUtil.convertToOutputValue(stringValue, outputDefinition, protector);
if (output instanceof PrismProperty) {
PrismPropertyValue<Object> pValue = new PrismPropertyValue<Object>(value);
((PrismProperty<Object>) output).add(pValue);
} else {
throw new UnsupportedOperationException("Can only generate values of property, not " + output.getClass());
}
return ItemDelta.toDeltaSetTriple(output, null);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class LazyXPathVariableResolver method resolveVariable.
@Override
public Object resolveVariable(QName name) {
if (variables == null) {
return null;
}
if (name != null && (name.getNamespaceURI() == null || name.getNamespaceURI().isEmpty())) {
LOGGER.warn("Using variable without a namespace (" + name + "), possible namespace problem (e.g. missing namespace prefix declaration) in " + contextDescription);
}
// Note: null is a legal variable name here. It corresponds to the root node
Object variableValue = variables.get(name);
if (variableValue == null) {
// TODO: warning ???
return null;
}
QName type = null;
// Attempt to resolve object reference
if (objectResolver != null && variableValue instanceof ObjectReferenceType) {
ObjectReferenceType ref = (ObjectReferenceType) variableValue;
if (ref.getOid() == null) {
SchemaException newEx = new SchemaException("Null OID in reference in variable " + name + " in " + contextDescription, name);
throw new TunnelException(newEx);
} else {
type = ref.getType();
try {
// TODO task
variableValue = objectResolver.resolve(ref, ObjectType.class, null, contextDescription, null, result);
} catch (ObjectNotFoundException e) {
ObjectNotFoundException newEx = new ObjectNotFoundException("Object not found during variable " + name + " resolution in " + contextDescription + ": " + e.getMessage(), e, ref.getOid());
// We have no other practical way how to handle the error
throw new TunnelException(newEx);
} catch (SchemaException e) {
ExpressionSyntaxException newEx = new ExpressionSyntaxException("Schema error during variable " + name + " resolution in " + contextDescription + ": " + e.getMessage(), e, name);
throw new TunnelException(newEx);
}
}
}
try {
return convertToXml(variableValue, name, prismContext, contextDescription);
} catch (SchemaException e) {
throw new TunnelException(e);
}
}
Aggregations