Search in sources :

Example 21 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class OrgMemberPanel method refreshTable.

protected void refreshTable(AjaxRequestTarget target) {
    DropDownChoice<ObjectTypes> typeChoice = (DropDownChoice<ObjectTypes>) get(createComponentPath(ID_FORM, ID_SEARCH_BY_TYPE));
    ObjectTypes type = typeChoice.getModelObject();
    target.add(get(createComponentPath(ID_FORM, ID_SEARCH_SCOPE)));
    getMemberTable().clearCache();
    getMemberTable().refreshTable(WebComponentUtil.qnameToClass(getPageBase().getPrismContext(), type.getTypeQName(), ObjectType.class), target);
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 22 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class Clockwork method invokeHooks.

/**
     * Invokes hooks, if there are any.
     *
     * @return
     *  - ERROR, if any hook reported error; otherwise returns
     *  - BACKGROUND, if any hook reported switching to background; otherwise
     *  - FOREGROUND (if all hooks reported finishing on foreground) 
     */
private HookOperationMode invokeHooks(LensContext context, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {
    // TODO: following two parts should be merged together in later versions
    // Execute configured scripting hooks
    PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
    // systemConfiguration may be null in some tests
    if (systemConfiguration != null) {
        ModelHooksType modelHooks = systemConfiguration.asObjectable().getModelHooks();
        if (modelHooks != null) {
            HookListType changeHooks = modelHooks.getChange();
            if (changeHooks != null) {
                for (HookType hookType : changeHooks.getHook()) {
                    String shortDesc;
                    if (hookType.getName() != null) {
                        shortDesc = "hook '" + hookType.getName() + "'";
                    } else {
                        shortDesc = "scripting hook in system configuration";
                    }
                    if (hookType.isEnabled() != null && !hookType.isEnabled()) {
                        // Disabled hook, skip
                        continue;
                    }
                    if (hookType.getState() != null) {
                        if (!context.getState().toModelStateType().equals(hookType.getState())) {
                            continue;
                        }
                    }
                    if (hookType.getFocusType() != null) {
                        if (context.getFocusContext() == null) {
                            continue;
                        }
                        QName hookFocusTypeQname = hookType.getFocusType();
                        ObjectTypes hookFocusType = ObjectTypes.getObjectTypeFromTypeQName(hookFocusTypeQname);
                        if (hookFocusType == null) {
                            throw new SchemaException("Unknown focus type QName " + hookFocusTypeQname + " in " + shortDesc);
                        }
                        Class focusClass = context.getFocusClass();
                        Class<? extends ObjectType> hookFocusClass = hookFocusType.getClassDefinition();
                        if (!hookFocusClass.isAssignableFrom(focusClass)) {
                            continue;
                        }
                    }
                    ScriptExpressionEvaluatorType scriptExpressionEvaluatorType = hookType.getScript();
                    if (scriptExpressionEvaluatorType == null) {
                        continue;
                    }
                    try {
                        evaluateScriptingHook(context, hookType, scriptExpressionEvaluatorType, shortDesc, task, result);
                    } catch (ExpressionEvaluationException e) {
                        LOGGER.error("Evaluation of {} failed: {}", new Object[] { shortDesc, e.getMessage(), e });
                        throw new ExpressionEvaluationException("Evaluation of " + shortDesc + " failed: " + e.getMessage(), e);
                    } catch (ObjectNotFoundException e) {
                        LOGGER.error("Evaluation of {} failed: {}", new Object[] { shortDesc, e.getMessage(), e });
                        throw new ObjectNotFoundException("Evaluation of " + shortDesc + " failed: " + e.getMessage(), e);
                    } catch (SchemaException e) {
                        LOGGER.error("Evaluation of {} failed: {}", new Object[] { shortDesc, e.getMessage(), e });
                        throw new SchemaException("Evaluation of " + shortDesc + " failed: " + e.getMessage(), e);
                    }
                }
            }
        }
    }
    // Execute registered Java hooks
    HookOperationMode resultMode = HookOperationMode.FOREGROUND;
    if (hookRegistry != null) {
        for (ChangeHook hook : hookRegistry.getAllChangeHooks()) {
            HookOperationMode mode = hook.invoke(context, task, result);
            if (mode == HookOperationMode.ERROR) {
                resultMode = HookOperationMode.ERROR;
            } else if (mode == HookOperationMode.BACKGROUND) {
                if (resultMode != HookOperationMode.ERROR) {
                    resultMode = HookOperationMode.BACKGROUND;
                }
            }
        }
    }
    return resultMode;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) QName(javax.xml.namespace.QName) ChangeHook(com.evolveum.midpoint.model.api.hooks.ChangeHook) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) HookOperationMode(com.evolveum.midpoint.model.api.hooks.HookOperationMode) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 23 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class SynchronizationServiceImpl method determineFocusClass.

private <F extends FocusType> Class<F> determineFocusClass(ObjectSynchronizationType synchronizationPolicy, ResourceType resource) throws ConfigurationException {
    if (synchronizationPolicy == null) {
        throw new IllegalStateException("synchronizationPolicy is null");
    }
    QName focusTypeQName = synchronizationPolicy.getFocusType();
    if (focusTypeQName == null) {
        return (Class<F>) UserType.class;
    }
    ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName);
    if (objectType == null) {
        throw new ConfigurationException("Unknown focus type " + focusTypeQName + " in synchronization policy in " + resource);
    }
    return (Class<F>) objectType.getClassDefinition();
}
Also used : ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 24 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class ParamsTypeUtil method setObjectReferenceEntry.

private static void setObjectReferenceEntry(EntryType entryType, ObjectType objectType) {
    ObjectReferenceType objRefType = new ObjectReferenceType();
    objRefType.setOid(objectType.getOid());
    ObjectTypes type = ObjectTypes.getObjectType(objectType.getClass());
    if (type != null) {
        objRefType.setType(type.getTypeQName());
    }
    JAXBElement<ObjectReferenceType> element = new JAXBElement<ObjectReferenceType>(SchemaConstants.C_OBJECT_REF, ObjectReferenceType.class, objRefType);
//		entryType.setAny(element);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) JAXBElement(javax.xml.bind.JAXBElement)

Example 25 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class ModelUtils method determineObjectPolicyConfiguration.

public static <O extends ObjectType> ObjectPolicyConfigurationType determineObjectPolicyConfiguration(Class<O> objectClass, List<String> objectSubtypes, SystemConfigurationType systemConfigurationType) throws ConfigurationException {
    ObjectPolicyConfigurationType applicablePolicyConfigurationType = null;
    for (ObjectPolicyConfigurationType aPolicyConfigurationType : systemConfigurationType.getDefaultObjectPolicyConfiguration()) {
        QName typeQName = aPolicyConfigurationType.getType();
        ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
        if (objectType == null) {
            throw new ConfigurationException("Unknown type " + typeQName + " in default object policy definition in system configuration");
        }
        if (objectType.getClassDefinition() == objectClass) {
            String aSubType = aPolicyConfigurationType.getSubtype();
            if (aSubType == null) {
                if (applicablePolicyConfigurationType == null) {
                    applicablePolicyConfigurationType = aPolicyConfigurationType;
                }
            } else if (objectSubtypes != null && objectSubtypes.contains(aSubType)) {
                applicablePolicyConfigurationType = aPolicyConfigurationType;
            }
        }
    }
    if (applicablePolicyConfigurationType != null) {
        return applicablePolicyConfigurationType;
    }
    // Deprecated
    for (ObjectPolicyConfigurationType aPolicyConfigurationType : systemConfigurationType.getObjectTemplate()) {
        QName typeQName = aPolicyConfigurationType.getType();
        ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
        if (objectType == null) {
            throw new ConfigurationException("Unknown type " + typeQName + " in object template definition in system configuration");
        }
        if (objectType.getClassDefinition() == objectClass) {
            return aPolicyConfigurationType;
        }
    }
    // Deprecated method to specify user template. For compatibility only
    if (objectClass == UserType.class) {
        ObjectReferenceType templateRef = systemConfigurationType.getDefaultUserTemplateRef();
        if (templateRef == null) {
            return null;
        }
        ObjectPolicyConfigurationType policy = new ObjectPolicyConfigurationType();
        policy.setObjectTemplateRef(templateRef.clone());
        return policy;
    }
    return null;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Aggregations

ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)46 QName (javax.xml.namespace.QName)16 ArrayList (java.util.ArrayList)11 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)6 List (java.util.List)6 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)5 AssignmentPopup (com.evolveum.midpoint.gui.api.component.AssignmentPopup)4 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)3 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)3 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)3 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)3