Search in sources :

Example 1 with CertificationPolicyActionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CertificationPolicyActionType in project midpoint by Evolveum.

the class CertificationHook method invoke.

@Override
public <O extends ObjectType> HookOperationMode invoke(@NotNull ModelContext<O> context, @NotNull Task task, @NotNull OperationResult result) throws PolicyViolationException {
    if (context.getState() != ModelState.FINAL) {
        return HookOperationMode.FOREGROUND;
    }
    LensElementContext<O> focusContext = (LensElementContext<O>) context.getFocusContext();
    if (focusContext == null || !FocusType.class.isAssignableFrom(focusContext.getObjectTypeClass())) {
        return HookOperationMode.FOREGROUND;
    }
    List<CertificationPolicyActionType> actions = new ArrayList<>();
    actions.addAll(getFocusCertificationActions(context));
    actions.addAll(getAssignmentCertificationActions(context));
    try {
        certificationManager.startAdHocCertifications(focusContext.getObjectAny(), actions, task, result);
    } catch (CommonException e) {
        throw new SystemException("Couldn't start ad-hoc campaign(s): " + e.getMessage(), e);
    }
    return HookOperationMode.FOREGROUND;
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) ArrayList(java.util.ArrayList) CommonException(com.evolveum.midpoint.util.exception.CommonException) CertificationPolicyActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CertificationPolicyActionType) LensElementContext(com.evolveum.midpoint.model.impl.lens.LensElementContext)

Aggregations

LensElementContext (com.evolveum.midpoint.model.impl.lens.LensElementContext)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 CertificationPolicyActionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CertificationPolicyActionType)1 ArrayList (java.util.ArrayList)1