use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class Mapping method parseSource.
private <IV extends PrismValue, ID extends ItemDefinition> Source<IV, ID> parseSource(VariableBindingDefinitionType sourceType, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
ItemPathType itemPathType = sourceType.getPath();
if (itemPathType == null) {
throw new SchemaException("No path in source definition in " + getMappingContextDescription());
}
ItemPath path = itemPathType.getItemPath();
if (path.isEmpty()) {
throw new SchemaException("Empty source path in " + getMappingContextDescription());
}
QName name = sourceType.getName();
if (name == null) {
name = ItemPath.getName(path.last());
}
ItemPath resolvePath = path;
Object sourceObject = ExpressionUtil.resolvePath(path, variables, sourceContext, objectResolver, "source definition in " + getMappingContextDescription(), task, result);
Item<IV, ID> itemOld = null;
ItemDelta<IV, ID> delta = null;
Item<IV, ID> itemNew = null;
ItemPath residualPath = null;
Collection<? extends ItemDelta<?, ?>> subItemDeltas = null;
if (sourceObject != null) {
if (sourceObject instanceof ItemDeltaItem<?, ?>) {
itemOld = ((ItemDeltaItem<IV, ID>) sourceObject).getItemOld();
delta = ((ItemDeltaItem<IV, ID>) sourceObject).getDelta();
itemNew = ((ItemDeltaItem<IV, ID>) sourceObject).getItemNew();
residualPath = ((ItemDeltaItem<IV, ID>) sourceObject).getResidualPath();
resolvePath = ((ItemDeltaItem<IV, ID>) sourceObject).getResolvePath();
subItemDeltas = ((ItemDeltaItem<IV, ID>) sourceObject).getSubItemDeltas();
} else if (sourceObject instanceof Item<?, ?>) {
itemOld = (Item<IV, ID>) sourceObject;
itemNew = (Item<IV, ID>) sourceObject;
} else {
throw new IllegalStateException("Unknown resolve result " + sourceObject);
}
}
// apply domain
ValueSetDefinitionType domainSetType = sourceType.getSet();
if (domainSetType != null) {
ValueSetDefinition setDef = new ValueSetDefinition(domainSetType, name, "domain of " + name.getLocalPart() + " in " + getMappingContextDescription(), task, result);
setDef.init(expressionFactory);
try {
if (itemOld != null) {
itemOld = itemOld.clone();
itemOld.filterValues(val -> setDef.containsTunnel(val));
}
if (itemNew != null) {
itemNew = itemNew.clone();
itemNew.filterValues(val -> setDef.containsTunnel(val));
}
if (delta != null) {
delta = delta.clone();
delta.filterValues(val -> setDef.containsTunnel(val));
}
} catch (TunnelException te) {
Throwable cause = te.getCause();
if (cause instanceof SchemaException) {
throw (SchemaException) cause;
} else if (cause instanceof ExpressionEvaluationException) {
throw (ExpressionEvaluationException) cause;
} else if (cause instanceof ObjectNotFoundException) {
throw (ObjectNotFoundException) cause;
}
}
}
Source<IV, ID> source = new Source<>(itemOld, delta, itemNew, name);
source.setResidualPath(residualPath);
source.setResolvePath(resolvePath);
source.setSubItemDeltas(subItemDeltas);
return source;
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class Mapping method evaluateBody.
// TODO: rename to evaluate
public void evaluateBody(Task task, OperationResult parentResult) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
assertState(MappingEvaluationState.PREPARED);
OperationResult result = parentResult.createMinorSubresult(Mapping.class.getName() + ".evaluate");
traceEvaluationStart();
try {
// We may need to re-parse the sources here
evaluateTimeConstraintValid(task, result);
if (!timeConstraintValid) {
outputTriple = null;
result.recordNotApplicableIfUnknown();
traceDeferred();
return;
}
evaluateCondition(task, result);
boolean conditionOutputOld = computeConditionResult(conditionOutputTriple.getNonPositiveValues());
boolean conditionResultOld = conditionOutputOld && conditionMaskOld;
boolean conditionOutputNew = computeConditionResult(conditionOutputTriple.getNonNegativeValues());
boolean conditionResultNew = conditionOutputNew && conditionMaskNew;
if (!conditionResultOld && !conditionResultNew) {
outputTriple = null;
transitionState(MappingEvaluationState.EVALUATED);
result.recordNotApplicableIfUnknown();
traceNotApplicable("condition is false");
return;
}
// TODO: input filter
evaluateExpression(task, result, conditionResultOld, conditionResultNew);
fixDefinition();
recomputeValues();
setOrigin();
// TODO: output filter
checkRange(task, result);
transitionState(MappingEvaluationState.EVALUATED);
result.recordSuccess();
traceSuccess(conditionResultOld, conditionResultNew);
} catch (ExpressionEvaluationException | ObjectNotFoundException | RuntimeException | SchemaException | Error e) {
result.recordFatalError(e);
traceFailure(e);
throw e;
}
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class ObjectWrapperFactory method createObjectWrapper.
public <O extends ObjectType> ObjectWrapper<O> createObjectWrapper(String displayName, String description, PrismObject<O> object, ContainerStatus status, boolean delayContainerCreation, AuthorizationPhaseType authorizationPhase, Task task) {
if (authorizationPhase == null) {
authorizationPhase = AuthorizationPhaseType.REQUEST;
}
try {
// Task task = modelServiceLocator.createSimpleTask(CREATE_OBJECT_WRAPPER);
OperationResult result = task.getResult();
PrismObjectDefinition<O> objectDefinitionForEditing = modelServiceLocator.getModelInteractionService().getEditObjectDefinition(object, authorizationPhase, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Edit definition for {}:\n{}", object, objectDefinitionForEditing.debugDump(1));
}
RefinedObjectClassDefinition objectClassDefinitionForEditing = null;
if (isShadow(object)) {
PrismReference resourceRef = object.findReference(ShadowType.F_RESOURCE_REF);
PrismObject<ResourceType> resource = resourceRef.getValue().getObject();
Validate.notNull(resource, "No resource object in the resourceRef");
objectClassDefinitionForEditing = modelServiceLocator.getModelInteractionService().getEditObjectClassDefinition((PrismObject<ShadowType>) object, resource, authorizationPhase);
}
return createObjectWrapper(displayName, description, object, objectDefinitionForEditing, objectClassDefinitionForEditing, status, delayContainerCreation, result);
} catch (SchemaException | ConfigurationException | ObjectNotFoundException ex) {
throw new SystemException(ex);
}
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class SampleFormFocusTabPanel method initLayout.
private void initLayout(final LoadableModel<ObjectWrapper<F>> focusModel, LoadableModel<List<AssignmentEditorDto>> assignmentsModel, PageBase pageBase) {
add(new Label(ID_HEADER, "Object details"));
WebMarkupContainer body = new WebMarkupContainer("body");
add(body);
addPrismPropertyPanel(body, ID_PROP_NAME, FocusType.F_NAME);
addPrismPropertyPanel(body, ID_PROP_FULL_NAME, UserType.F_FULL_NAME);
// TODO: create proxy for these operations
Task task = pageBase.createSimpleTask(OPERATION_SEARCH_ROLES);
List<PrismObject<RoleType>> availableRoles;
try {
availableRoles = pageBase.getModelService().searchObjects(RoleType.class, null, null, task, task.getResult());
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
task.getResult().recordFatalError(e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load roles", e);
availableRoles = new ArrayList<>();
// TODO: better errror reporting
}
add(new SimpleRoleSelector<F, RoleType>(ID_ROLES, assignmentsModel, availableRoles));
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class DefaultGuiProgressListener method getResourceName.
private String getResourceName(@NotNull String oid) {
String name = nameCache.get(oid);
if (name != null) {
return name;
}
Task task = parentPage.createSimpleTask("getResourceName");
OperationResult result = new OperationResult("getResourceName");
// todo what about security?
Collection<SelectorOptions<GetOperationOptions>> raw = SelectorOptions.createCollection(GetOperationOptions.createRaw());
try {
PrismObject<ResourceType> object = parentPage.getModelService().getObject(ResourceType.class, oid, raw, task, result);
name = PolyString.getOrig(object.asObjectable().getName());
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't determine the name of resource {}", e, oid);
name = "(" + oid + ")";
}
nameCache.put(oid, name);
return name;
}
Aggregations