use of com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingTypeType.SKIP in project midpoint by Evolveum.
the class DeleteRepositoryAction method deleteByFilter.
private void deleteByFilter(ObjectTypes type, ObjectQuery query, OperationStatus operation, OperationResult result) throws SchemaException {
ResultHandler<?> handler = (prismObject, operationResult) -> {
try {
State state = options.isAsk() ? askForState(prismObject) : State.DELETE;
switch(state) {
case SKIP:
operation.incrementSkipped();
return true;
case STOP:
return false;
case DELETE:
default:
}
RepositoryService repository = context.getRepository();
repository.deleteObject(prismObject.getCompileTimeClass(), prismObject.getOid(), operationResult);
operation.incrementTotal();
} catch (ObjectNotFoundException ex) {
// object was already gone
} catch (IOException ex) {
context.getLog().error("Couldn't delete object {}, reason: {}", ex, prismObject, ex.getMessage());
operation.incrementError();
}
return true;
};
Collection<SelectorOptions<GetOperationOptions>> opts = new ArrayList<>();
if (options.isRaw()) {
opts.add(new SelectorOptions<>(GetOperationOptions.createRaw()));
}
RepositoryService repository = context.getRepository();
repository.searchObjectsIterative(type.getClassDefinition(), query, handler, opts, true, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingTypeType.SKIP in project midpoint by Evolveum.
the class AbstractScriptEvaluator method prepareScriptVariablesValueMap.
/**
* Returns simple variable map: name -> value.
*/
protected Map<String, Object> prepareScriptVariablesValueMap(ScriptExpressionEvaluationContext context) throws ExpressionSyntaxException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
Map<String, Object> scriptVariableMap = new HashMap<>();
// Functions
if (context.getFunctions() != null) {
for (FunctionLibrary funcLib : context.getFunctions()) {
scriptVariableMap.put(funcLib.getVariableName(), funcLib.getGenericFunctions());
}
}
// Variables
VariablesMap variables = context.getVariables();
if (variables != null) {
for (Entry<String, TypedValue> variableEntry : variables.entrySet()) {
if (variableEntry.getKey() == null) {
// This is the "root" node. We have no use for it in script expressions, just skip it
continue;
}
String variableName = variableEntry.getKey();
ValueVariableModeType valueVariableMode = ObjectUtils.defaultIfNull(context.getExpressionType().getValueVariableMode(), ValueVariableModeType.REAL_VALUE);
// noinspection rawtypes
TypedValue variableTypedValue = ExpressionUtil.convertVariableValue(variableEntry.getValue(), variableName, context.getObjectResolver(), context.getContextDescription(), context.getExpressionType().getObjectVariableMode(), valueVariableMode, prismContext, context.getTask(), context.getResult());
scriptVariableMap.put(variableName, variableTypedValue.getValue());
if (context.getTrace() != null && !variables.isAlias(variableName)) {
ScriptVariableEvaluationTraceType variableTrace = new ScriptVariableEvaluationTraceType(prismContext);
variableTrace.setName(new QName(variableName));
Object clonedValue = cloneIfPossible(variableTypedValue.getValue());
variableTrace.getValue().addAll(TraceUtil.toAnyValueTypeList(clonedValue, prismContext));
variables.getAliases(variableName).forEach(alias -> variableTrace.getAlias().add(new QName(alias)));
context.getTrace().getVariable().add(variableTrace);
}
}
}
putIfMissing(scriptVariableMap, ExpressionConstants.VAR_PRISM_CONTEXT, prismContext);
putIfMissing(scriptVariableMap, ExpressionConstants.VAR_LOCALIZATION_SERVICE, localizationService);
return scriptVariableMap;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingTypeType.SKIP in project midpoint by Evolveum.
the class ShadowedObjectFound method initializeInternal.
/**
* Acquires repo shadow, updates it, and prepares the shadowedObject.
* In emergency does a minimalistic processing aimed at acquiring a shadow.
*/
@Override
public void initializeInternal(Task task, OperationResult result) throws CommonException, NotApplicableException, EncryptionException {
if (!initializationState.isInitialStateOk()) {
// The object is somehow flawed. However, we try to create a shadow.
//
// To avoid any harm, we are minimalistic here: If a shadow can be found, it is used "as is". No updates here.
// If it cannot be found, it is created. We will skip kind/intent/tag determination.
// Most probably these would not be correct anyway.
shadowedObject = acquireRepoShadowInEmergency(result);
return;
}
PrismObject<ShadowType> repoShadow = acquireRepoShadow(result);
try {
// This determines the definitions exactly. Now the repo shadow should have proper kind/intent.
ProvisioningContext preciseCtx = ictx.localBeans.shadowCaretaker.applyAttributesDefinition(ictx.ctx, repoShadow);
ictx.localBeans.shadowCaretaker.updateShadowState(preciseCtx, repoShadow);
PrismObject<ShadowType> updatedRepoShadow = updateRepoShadow(preciseCtx, repoShadow, result);
shadowedObject = createShadowedObject(preciseCtx, updatedRepoShadow, result);
} catch (Exception e) {
// No need to log stack trace now. It will be logged at the place where the exception is processed.
LOGGER.error("Couldn't initialize {}. Continuing with previously acquired repo shadow: {}. Error: {}", resourceObject, repoShadow, getClassWithMessage(e));
shadowedObject = repoShadow;
throw e;
}
}
Aggregations