use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createExclusionPolicyRule.
protected PolicyRuleType createExclusionPolicyRule(String excludedRoleOid) {
PolicyRuleType policyRule = new PolicyRuleType();
PolicyConstraintsType policyConstraints = new PolicyConstraintsType();
ExclusionPolicyConstraintType exclusionConstraint = new ExclusionPolicyConstraintType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(excludedRoleOid);
targetRef.setType(RoleType.COMPLEX_TYPE);
exclusionConstraint.setTargetRef(targetRef);
policyConstraints.getExclusion().add(exclusionConstraint);
policyRule.setPolicyConstraints(policyConstraints);
return policyRule;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method getLiveLinkRef.
protected <F extends FocusType> PrismReferenceValue getLiveLinkRef(PrismObject<F> focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
F focusType = focus.asObjectable();
for (ObjectReferenceType linkRefType : focusType.getLinkRef()) {
if (!relationRegistry.isMember(linkRefType.getRelation())) {
continue;
}
String linkTargetOid = linkRefType.getOid();
assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid));
PrismObject<ShadowType> account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false);
if (resourceOid.equals(account.asObjectable().getResourceRef().getOid())) {
// This is noFetch. Therefore there is no fetchResult
return linkRefType.asReferenceValue();
}
}
AssertJUnit.fail("Account for resource " + resourceOid + " not found in " + focus);
// Never reached. But compiler complains about missing return
return null;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method unassignAllRoles.
protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException {
Task task = createPlainTask("unassignAllRoles");
OperationResult result = task.getResult();
PrismObject<UserType> user = modelService.getObject(UserType.class, userOid, null, task, result);
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
for (AssignmentType assignment : user.asObjectable().getAssignment()) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef != null) {
if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) {
ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition());
PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue();
cval.setId(assignment.getId());
assignmentDelta.addValueToDelete(cval);
modifications.add(assignmentDelta);
}
}
}
if (modifications.isEmpty()) {
return;
}
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
modelService.executeChanges(deltas, useRawPlusRecompute ? executeOptions().raw() : null, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
if (useRawPlusRecompute) {
recomputeUser(userOid, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createModifyUserAddAccount.
protected ObjectDelta<UserType> createModifyUserAddAccount(String userOid, PrismObject<ResourceType> resource, String intent) throws SchemaException {
PrismObject<ShadowType> account = getAccountShadowDefinition().instantiate();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resource.getOid());
account.asObjectable().setResourceRef(resourceRef);
ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource);
ResourceObjectDefinition rocd;
if (StringUtils.isNotBlank(intent)) {
rocd = refinedSchema.findObjectDefinitionRequired(ShadowKindType.ACCOUNT, intent);
account.asObjectable().setIntent(intent);
} else {
// TODO or findObjectDefinitionRequired as well?
rocd = refinedSchema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
}
account.asObjectable().setObjectClass(rocd.getObjectClassDefinition().getTypeName());
account.asObjectable().setKind(ShadowKindType.ACCOUNT);
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
PrismReferenceValue accountRefVal = itemFactory().createReferenceValue();
accountRefVal.setObject(account);
ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
userDelta.addModification(accountDelta);
return userDelta;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method setConflictResolution.
protected void setConflictResolution(QName objectType, String subType, ConflictResolutionType conflictResolution, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
PrismObject<SystemConfigurationType> systemConfig = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult);
PrismContainerValue<ObjectPolicyConfigurationType> oldValue = null;
for (ObjectPolicyConfigurationType focusPolicyType : systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) {
if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) {
oldValue = focusPolicyType.asPrismContainerValue();
}
}
Collection<ContainerDelta<ObjectPolicyConfigurationType>> modifications = new ArrayList<>();
if (oldValue != null) {
ContainerDelta<ObjectPolicyConfigurationType> deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, SystemConfigurationType.class, oldValue.clone());
modifications.add(deleteDelta);
}
ObjectPolicyConfigurationType newFocusPolicyType = new ObjectPolicyConfigurationType();
newFocusPolicyType.setType(objectType);
newFocusPolicyType.setSubtype(subType);
if (oldValue != null) {
ObjectReferenceType oldObjectTemplateRef = oldValue.asContainerable().getObjectTemplateRef();
if (oldObjectTemplateRef != null) {
newFocusPolicyType.setObjectTemplateRef(oldObjectTemplateRef.clone());
}
}
newFocusPolicyType.setConflictResolution(conflictResolution);
ContainerDelta<ObjectPolicyConfigurationType> addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, SystemConfigurationType.class, newFocusPolicyType);
modifications.add(addDelta);
modifySystemObjectInRepo(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult);
}
Aggregations