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);
}
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;
}
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();
}
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);
}
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;
}
Aggregations