use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageUsers method deleteConfirmedPerformed.
private void deleteConfirmedPerformed(AjaxRequestTarget target, UserType userToDelete) {
List<UserType> users = isAnythingSelected(target, userToDelete);
if (users.isEmpty()) {
return;
}
OperationResult result = new OperationResult(OPERATION_DELETE_USERS);
for (UserType user : users) {
OperationResult subResult = result.createSubresult(OPERATION_DELETE_USER);
try {
Task task = createSimpleTask(OPERATION_DELETE_USER);
ObjectDelta delta = new ObjectDelta(UserType.class, ChangeType.DELETE, getPrismContext());
delta.setOid(user.getOid());
ExecuteChangeOptionsDto executeOptions = executeOptionsModel.getObject();
ModelExecuteOptions options = executeOptions.createOptions();
LOGGER.debug("Using options {}.", new Object[] { executeOptions });
getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), options, task, subResult);
subResult.computeStatus();
} catch (Exception ex) {
subResult.recomputeStatus();
subResult.recordFatalError("Couldn't delete user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete user", ex);
}
}
result.computeStatusComposite();
getTable().clearCache();
showResult(result);
target.add(getFeedbackPanel());
getTable().refreshTable(UserType.class, target);
getTable().clearCache();
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageUsers method unlockPerformed.
private void unlockPerformed(AjaxRequestTarget target, UserType selectedUser) {
List<UserType> users = isAnythingSelected(target, selectedUser);
if (users.isEmpty()) {
return;
}
OperationResult result = new OperationResult(OPERATION_UNLOCK_USERS);
for (UserType user : users) {
OperationResult opResult = result.createSubresult(getString(OPERATION_UNLOCK_USER, user));
try {
Task task = createSimpleTask(OPERATION_UNLOCK_USER + user);
// TODO skip the operation if the user has no password
// credentials specified (otherwise this would create
// almost-empty password container)
ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, user.getOid(), new ItemPath(UserType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), getPrismContext(), LockoutStatusType.NORMAL);
Collection<ObjectDelta<? extends ObjectType>> deltas = WebComponentUtil.createDeltaCollection(delta);
getModelService().executeChanges(deltas, null, task, opResult);
opResult.computeStatusIfUnknown();
} catch (Exception ex) {
opResult.recomputeStatus();
opResult.recordFatalError("Couldn't unlock user " + user + ".", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't unlock user " + user + ".", ex);
}
}
result.recomputeStatus();
showResult(result);
target.add(getFeedbackPanel());
getTable().refreshTable(UserType.class, target);
getTable().clearCache();
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class MergeObjectsPanel method getMergeTypeNames.
private List<String> getMergeTypeNames() {
List<String> mergeTypeNamesList = new ArrayList<>();
Task task = pageBase.createAnonymousTask(OPERATION_LOAD_MERGE_TYPE_NAMES);
OperationResult result = task.getResult();
PrismObject<SystemConfigurationType> config;
try {
config = pageBase.getModelService().getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, task, result);
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
LOGGER.error("Error getting system configuration: {}", e.getMessage(), e);
return null;
}
if (config != null && config.asObjectable() != null) {
List<MergeConfigurationType> list = config.asObjectable().getMergeConfiguration();
if (list != null) {
for (MergeConfigurationType mergeType : list) {
mergeTypeNamesList.add(mergeType.getName());
}
if (mergeTypeNamesList.size() > 0) {
currentMergeType = mergeTypeNamesList.get(0);
}
}
}
return mergeTypeNamesList;
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class MergeObjectsPanel method getMergeObjectsResult.
private PrismObject<F> getMergeObjectsResult() {
OperationResult result = new OperationResult(OPERATION_GET_MERGE_OBJECT_PREVIEW);
PrismObject<F> mergeResultObject = null;
try {
Task task = pageBase.createSimpleTask(OPERATION_GET_MERGE_OBJECT_PREVIEW);
mergeResultObject = pageBase.getModelInteractionService().mergeObjectsPreviewObject(type, mergeObjectModel.getObject().getOid(), mergeWithObjectModel.getObject().getOid(), currentMergeType, task, result);
mergeDeltas = pageBase.getModelInteractionService().mergeObjectsPreviewDeltas(type, mergeObjectModel.getObject().getOid(), mergeWithObjectModel.getObject().getOid(), currentMergeType, task, result);
} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError("Couldn't get merge object for preview.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get merge object for preview", ex);
pageBase.showResult(result);
}
return mergeResultObject;
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class AccessCertificationCampaignCreationTaskHandler method run.
@Override
public TaskRunResult run(Task task) {
LOGGER.trace("Task run starting");
long progress = task.getProgress();
OperationResult opResult = new OperationResult(CLASS_DOT + "run");
opResult.setSummarizeSuccesses(true);
TaskRunResult runResult = new TaskRunResult();
runResult.setOperationResult(opResult);
String definitionOid = task.getObjectOid();
if (definitionOid == null) {
LOGGER.error("No definition OID specified in the task");
opResult.recordFatalError("No definition OID specified in the task");
runResult.setRunResultStatus(TaskRunResultStatus.PERMANENT_ERROR);
return runResult;
}
opResult.addContext("definitionOid", definitionOid);
long started = 0;
String campaignName = null;
String campaignOid = null;
try {
task.startCollectingOperationStatsFromStoredValues(true, false, false);
LOGGER.info("Creating campaign with definition of {}", definitionOid);
AccessCertificationCampaignType campaign = certificationManager.createCampaign(definitionOid, task, opResult);
LOGGER.info("Campaign {} was created.", ObjectTypeUtil.toShortString(campaign));
// TODO split this try-catch to two pieces in order to correctly work with iterative op failure recording
started = System.currentTimeMillis();
campaignName = campaign.getName().getOrig();
campaignOid = campaign.getOid();
task.recordIterativeOperationStart(campaignName, campaignName, AccessCertificationCampaignType.COMPLEX_TYPE, campaignOid);
certificationManager.openNextStage(campaign.getOid(), 1, task, opResult);
LOGGER.info("Campaign {} was started.", ObjectTypeUtil.toShortString(campaign));
task.recordIterativeOperationEnd(campaignName, campaignName, AccessCertificationCampaignType.COMPLEX_TYPE, campaignOid, started, null);
opResult.computeStatus();
runResult.setRunResultStatus(TaskRunResultStatus.FINISHED);
runResult.setProgress(progress + 1);
return runResult;
} catch (Exception e) {
// TODO better error handling
if (campaignOid != null) {
task.recordIterativeOperationEnd(campaignName, campaignName, AccessCertificationCampaignType.COMPLEX_TYPE, campaignOid, started, e);
}
LoggingUtils.logException(LOGGER, "Error while executing 'create campaign' task handler", e);
opResult.recordFatalError("Error while executing 'create campaign' task handler: " + e.getMessage(), e);
runResult.setRunResultStatus(TaskRunResultStatus.PERMANENT_ERROR);
runResult.setProgress(progress);
return runResult;
} finally {
task.storeOperationStats();
}
}
Aggregations