use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class PageRegistrationConfirmation method assignDefaultRoles.
private OperationResult assignDefaultRoles(final String userOid) {
List<ContainerDelta<AssignmentType>> assignments = new ArrayList<>();
for (ObjectReferenceType defaultRole : getSelfRegistrationConfiguration().getDefaultRoles()) {
AssignmentType assignment = new AssignmentType();
assignment.setTargetRef(defaultRole);
try {
getPrismContext().adopt(assignment);
assignments.add(ContainerDelta.createModificationAdd(UserType.F_ASSIGNMENT, UserType.class, getPrismContext(), assignment));
} catch (SchemaException e) {
//nothing to do
}
}
final ObjectDelta<UserType> delta = ObjectDelta.createModifyDelta(userOid, assignments, UserType.class, getPrismContext());
return runPrivileged(new Producer<OperationResult>() {
@Override
public OperationResult run() {
OperationResult result = new OperationResult(OPERATION_ASSIGN_DEFAULT_ROLES);
Task task = createAnonymousTask(OPERATION_ASSIGN_DEFAULT_ROLES);
WebModelServiceUtils.save(delta, result, task, PageRegistrationConfirmation.this);
result.computeStatusIfUnknown();
return result;
}
});
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class PageSelfRegistration method initDynamicFormLayout.
private void initDynamicFormLayout(final Form<?> mainForm) {
WebMarkupContainer dynamicRegistrationForm = createMarkupContainer(ID_DYNAMIC_FORM, new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getSelfRegistrationConfiguration().getFormRef() != null;
}
}, mainForm);
DynamicFormPanel<UserType> dynamicForm = runPrivileged(() -> {
final ObjectReferenceType ort = getSelfRegistrationConfiguration().getFormRef();
if (ort == null) {
return null;
}
Task task = createAnonymousTask(OPERATION_LOAD_DYNAMIC_FORM);
return new DynamicFormPanel<UserType>(ID_DYNAMIC_FORM_PANEL, userModel, ort.getOid(), mainForm, task, PageSelfRegistration.this);
});
if (dynamicForm != null) {
dynamicRegistrationForm.add(dynamicForm);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class PageAdminResources method deleteSyncTokenPerformed.
protected void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType) {
// ResourceDto dto = model.getObject();
String resourceOid = resourceType.getOid();
String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3";
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resourceOid);
PrismObject<TaskType> oldTask;
OperationResult result = new OperationResult(OPERATION_DELETE_SYNC_TOKEN);
ObjectQuery query = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resourceOid).and().item(TaskType.F_HANDLER_URI).eq(handlerUri).build();
List<PrismObject<TaskType>> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, this);
if (taskList.size() != 1) {
error(getString("pageResource.message.invalidTaskSearch"));
} else {
oldTask = taskList.get(0);
saveTask(oldTask, result);
}
result.recomputeStatus();
showResult(result);
target.add(getFeedbackPanel());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class MidPointAsserts method assertAssignments.
public static <F extends FocusType> void assertAssignments(PrismObject<F> user, Class expectedType, int expectedNumber) {
F userType = user.asObjectable();
int actualAssignments = 0;
List<AssignmentType> assignments = userType.getAssignment();
for (AssignmentType assignment : assignments) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef != null) {
QName type = targetRef.getType();
if (type != null) {
Class<? extends ObjectType> assignmentTargetClass = ObjectTypes.getObjectTypeFromTypeQName(type).getClassDefinition();
if (expectedType.isAssignableFrom(assignmentTargetClass)) {
actualAssignments++;
}
}
}
}
assertEquals("Unexepected number of assignments of type " + expectedType + " in " + user + ": " + userType.getAssignment(), expectedNumber, actualAssignments);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class MidPointAsserts method assertAssignedResource.
public static <F extends FocusType> void assertAssignedResource(PrismObject<F> user, String resourceOid) {
F userType = user.asObjectable();
for (AssignmentType assignmentType : userType.getAssignment()) {
if (assignmentType.getConstruction() == null) {
continue;
}
ObjectReferenceType targetRef = assignmentType.getConstruction().getResourceRef();
if (targetRef != null) {
if (resourceOid.equals(targetRef.getOid())) {
return;
}
}
}
AssertJUnit.fail(user + " does NOT have assigned resource " + resourceOid + " while expecting it");
}
Aggregations