use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class PageTasks method stopSchedulersPerformed.
private void stopSchedulersPerformed(AjaxRequestTarget target, List<String> identifiers) {
OperationResult result = new OperationResult(OPERATION_STOP_SCHEDULERS);
try {
getTaskService().stopSchedulers(identifiers, result);
result.computeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "Selected node scheduler(s) have been successfully stopped.");
}
} catch (SecurityViolationException | ObjectNotFoundException | SchemaException | RuntimeException e) {
result.recordFatalError("Couldn't stop the scheduler(s)", e);
}
showResult(result);
//refresh feedback and table
refreshTables(target);
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class WebModelServiceUtils method loadObject.
@Nullable
public static <T extends ObjectType> PrismObject<T> loadObject(Class<T> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options, boolean allowNotFound, PageBase page, Task task, OperationResult result) {
LOGGER.debug("Loading {} with oid {}, options {}", type.getSimpleName(), oid, options);
OperationResult subResult;
if (result != null) {
subResult = result.createMinorSubresult(OPERATION_LOAD_OBJECT);
} else {
subResult = new OperationResult(OPERATION_LOAD_OBJECT);
}
PrismObject<T> object = null;
try {
if (options == null) {
options = SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
} else {
GetOperationOptions getOpts = SelectorOptions.findRootOptions(options);
if (getOpts == null) {
options.add(new SelectorOptions<>(GetOperationOptions.createResolveNames()));
} else {
getOpts.setResolveNames(Boolean.TRUE);
}
}
object = page.getModelService().getObject(type, oid, options, task, subResult);
} catch (AuthorizationException e) {
// Not authorized to access the object. This is probably caused by a reference that
// point to an object that the current user cannot read. This is no big deal.
// Just do not display that object.
subResult.recordHandledError(e);
LOGGER.debug("User {} is not authorized to read {} {}", task.getOwner() != null ? task.getOwner().getName() : null, type.getSimpleName(), oid);
return null;
} catch (ObjectNotFoundException e) {
if (allowNotFound) {
// Object does not exist. It was deleted in the meanwhile, or not created yet. This could happen quite often.
subResult.recordHandledError(e);
LOGGER.debug("{} {} does not exist", type.getSimpleName(), oid, e);
return null;
} else {
subResult.recordFatalError("WebModelUtils.couldntLoadObject", e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", e);
}
} catch (Exception ex) {
subResult.recordFatalError("WebModelUtils.couldntLoadObject", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", ex);
} finally {
subResult.computeStatus();
}
// TODO reconsider this part: until recently, the condition was always 'false'
if (WebComponentUtil.showResultInPage(subResult)) {
page.showResult(subResult);
}
LOGGER.debug("Loaded {} with result {}", object, subResult);
return object;
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class WebModelServiceUtils method countObjects.
public static <T extends ObjectType> int countObjects(Class<T> type, ObjectQuery query, PageBase page) {
LOGGER.debug("Count object: type => {}, query => {}", type, query);
Task task = page.createSimpleTask(OPERATION_COUNT_OBJECT);
OperationResult parentResult = new OperationResult(OPERATION_COUNT_OBJECT);
int count = 0;
try {
count = page.getModelService().countObjects(type, query, null, task, parentResult);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | CommunicationException | ExpressionEvaluationException ex) {
parentResult.recordFatalError("WebModelUtils.couldntCountObjects", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
}
LOGGER.debug("Count objects with result {}", new Object[] { parentResult });
return count;
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class AssignmentCatalogPanel method getAssignmentConstraints.
private AssignmentConstraintsType getAssignmentConstraints() {
OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_CONSTRAINTS);
SystemConfigurationType systemConfig = null;
try {
systemConfig = pageBase.getModelInteractionService().getSystemConfiguration(result);
} catch (ObjectNotFoundException | SchemaException e) {
LOGGER.error("Error getting system configuration: {}", e.getMessage(), e);
return null;
}
if (systemConfig != null && systemConfig.getRoleManagement() != null) {
return systemConfig.getRoleManagement().getDefaultAssignmentConstraints();
}
return null;
}
use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.
the class PageAccounts method loadShadowOwner.
private <F extends FocusType> F loadShadowOwner(IModel<SelectableBean> model) {
F owner = null;
ShadowType shadow = getShadow(model);
String shadowOid;
if (shadow != null) {
shadowOid = shadow.getOid();
} else {
return null;
}
Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT_OWNER);
OperationResult result = new OperationResult(OPERATION_LOAD_ACCOUNT_OWNER);
try {
PrismObject prismOwner = getModelService().searchShadowOwner(shadowOid, null, task, result);
if (prismOwner != null) {
owner = (F) prismOwner.asObjectable();
}
} catch (ObjectNotFoundException exception) {
//owner was not found, it's possible and it's ok on unlinked accounts
} catch (Exception ex) {
result.recordFatalError(getString("PageAccounts.message.ownerNotFound", shadowOid), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Could not load owner of account with oid: " + shadowOid, ex);
} finally {
result.computeStatusIfUnknown();
}
if (WebComponentUtil.showResultInPage(result)) {
showResult(result, false);
}
return owner;
}
Aggregations