Search in sources :

Example 11 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 12 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 13 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 14 with ObjectTypes

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

the class AbstractModelIntegrationTest method determineSynchronization.

/**
	 * Returns appropriate object synchronization settings for the class.
	 * Assumes single sync setting for now.
	 */
protected ObjectSynchronizationType determineSynchronization(ResourceType resource, Class<UserType> type, String name) {
    SynchronizationType synchronization = resource.getSynchronization();
    if (synchronization == null) {
        return null;
    }
    List<ObjectSynchronizationType> objectSynchronizations = synchronization.getObjectSynchronization();
    if (objectSynchronizations.isEmpty()) {
        return null;
    }
    for (ObjectSynchronizationType objSyncType : objectSynchronizations) {
        QName focusTypeQName = objSyncType.getFocusType();
        if (focusTypeQName == null) {
            if (type != UserType.class) {
                continue;
            }
        } else {
            ObjectTypes focusType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName);
            if (type != focusType.getClassDefinition()) {
                continue;
            }
        }
        if (name == null) {
            // we got it
            return objSyncType;
        } else {
            if (name.equals(objSyncType.getName())) {
                return objSyncType;
            }
        }
    }
    throw new IllegalArgumentException("Synchronization setting for " + type + " and name " + name + " not found in " + resource);
}
Also used : ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) SynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationType)

Example 15 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)

Aggregations

ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)17 QName (javax.xml.namespace.QName)7 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)3 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ObjectTypeGuiDescriptor (com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor)2 ChangeHook (com.evolveum.midpoint.model.api.hooks.ChangeHook)1 HookOperationMode (com.evolveum.midpoint.model.api.hooks.HookOperationMode)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 S_FilterEntryOrEmpty (com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 RepositoryObjectDataProvider (com.evolveum.midpoint.web.component.data.RepositoryObjectDataProvider)1 Table (com.evolveum.midpoint.web.component.data.Table)1 Search (com.evolveum.midpoint.web.component.search.Search)1 PageRepositoryQuery (com.evolveum.midpoint.web.page.admin.configuration.PageRepositoryQuery)1 DebugSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.DebugSearchDto)1 ConfigurationStorage (com.evolveum.midpoint.web.session.ConfigurationStorage)1