use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class AuditEventRecordProvider method internalSize.
protected int internalSize() {
String query = generateFullQuery(AUDIT_RECORDS_QUERY_COUNT + auditEventQuery, false, true);
long count;
try {
count = getAuditService().countObjects(query, parameters, new OperationResult("internalSize"));
} catch (SecurityViolationException | SchemaException e) {
// TODO: proper error handling (MID-3536)
throw new SystemException(e.getMessage(), e);
}
int providerSize = ((Long) count).intValue();
return !exportSize ? providerSize : (providerSize < MAX_EXPORT_ROWS_COUNT ? providerSize : MAX_EXPORT_ROWS_COUNT);
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageResources method deleteResourceConfirmedPerformed.
private void deleteResourceConfirmedPerformed(AjaxRequestTarget target) {
List<ResourceType> selected = new ArrayList<>();
if (singleDelete != null) {
selected.add(singleDelete);
} else {
selected = getResourceTable().getSelectedObjects();
}
OperationResult result = new OperationResult(OPERATION_DELETE_RESOURCES);
for (ResourceType resource : selected) {
try {
Task task = createSimpleTask(OPERATION_DELETE_RESOURCES);
ObjectDelta<ResourceType> delta = ObjectDelta.createDeleteDelta(ResourceType.class, resource.getOid(), getPrismContext());
getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
} catch (Exception ex) {
result.recordPartialError("Couldn't delete resource.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete resource", ex);
}
}
result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "The resource(s) have been successfully deleted.");
}
getResourceTable().clearCache();
showResult(result);
target.add(getFeedbackPanel(), (Component) getResourceTable());
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageAccount method savePerformed.
private void savePerformed(AjaxRequestTarget target) {
LOGGER.debug("Saving account changes.");
OperationResult result = new OperationResult(OPERATION_SAVE_ACCOUNT);
try {
WebComponentUtil.revive(accountModel, getPrismContext());
ObjectWrapper wrapper = accountModel.getObject();
ObjectDelta<ShadowType> delta = wrapper.getObjectDelta();
if (delta == null) {
return;
}
if (delta.getPrismContext() == null) {
getPrismContext().adopt(delta);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Account delta computed from form:\n{}", new Object[] { delta.debugDump(3) });
}
if (delta.isEmpty()) {
return;
}
WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
Task task = createSimpleTask(OPERATION_SAVE_ACCOUNT);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
deltas.add(delta);
getModelService().executeChanges(deltas, null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't save account.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save account", ex);
}
if (!result.isSuccess()) {
showResult(result);
target.add(getFeedbackPanel());
} else {
showResult(result);
redirectBack();
}
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class ResourceContentRepositoryPanel method createTotalsModel.
private LoadableModel<Integer> createTotalsModel(final SynchronizationSituationType situation) {
return new LoadableModel<Integer>(false) {
private static final long serialVersionUID = 1L;
@Override
protected Integer load() {
ObjectFilter resourceFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_RESOURCE_REF).ref(ResourceContentRepositoryPanel.this.getResourceModel().getObject().getOid()).buildFilter();
if (resourceFilter == null) {
return 0;
}
ObjectFilter filter = createQuery().getFilter();
if (filter == null) {
return 0;
}
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw());
Task task = getPageBase().createSimpleTask(OPERATION_GET_TOTALS);
OperationResult result = new OperationResult(OPERATION_GET_TOTALS);
try {
ObjectFilter situationFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_SYNCHRONIZATION_SITUATION).eq(situation).buildFilter();
ObjectQuery query = ObjectQuery.createObjectQuery(AndFilter.createAnd(filter, situationFilter));
return getPageBase().getModelService().countObjects(ShadowType.class, query, options, task, result);
} catch (CommonException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count shadows", ex);
}
return 0;
}
};
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class TestUtil method assertSuccess.
public static void assertSuccess(String message, OperationResult result, OperationResult originalResult, int stopLevel, int currentLevel, boolean warningOk) {
if (!checkResults) {
return;
}
if (result.getStatus() == null || result.getStatus().equals(OperationResultStatus.UNKNOWN)) {
String logmsg = message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation();
LOGGER.error(logmsg);
LOGGER.trace(logmsg + "\n" + originalResult.debugDump());
System.out.println(logmsg + "\n" + originalResult.debugDump());
fail(logmsg);
}
if (result.isHandledError()) {
// There may be errors deeper in this result, even fatal errors. that's ok, we can ignore them.
return;
} else if (result.isSuccess() || result.isNotApplicable()) {
// OK ... expected error is as good as success
} else if (warningOk && result.getStatus() == OperationResultStatus.WARNING) {
// OK
} else {
String logmsg = message + ": " + result.getStatus() + ": " + result.getMessage();
LOGGER.error(logmsg);
LOGGER.trace(logmsg + "\n" + originalResult.debugDump());
System.out.println(logmsg + "\n" + originalResult.debugDump());
assert false : logmsg;
}
if (stopLevel == currentLevel) {
return;
}
List<OperationResult> partialResults = result.getSubresults();
for (OperationResult subResult : partialResults) {
assertSuccess(message, subResult, originalResult, stopLevel, currentLevel + 1, warningOk);
}
}
Aggregations