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