use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class Clockwork method recordOperationExecution.
private <F extends ObjectType> void recordOperationExecution(PrismObject<F> object, boolean deletedOk, List<LensObjectDeltaOperation<F>> executedDeltas, XMLGregorianCalendar now, String channel, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationExecutionType operation = new OperationExecutionType(prismContext);
OperationResult summaryResult = new OperationResult("dummy");
String oid = object.getOid();
for (LensObjectDeltaOperation<F> deltaOperation : executedDeltas) {
operation.getOperation().add(createObjectDeltaOperation(deltaOperation));
if (deltaOperation.getExecutionResult() != null) {
summaryResult.addSubresult(deltaOperation.getExecutionResult());
}
if (oid == null && deltaOperation.getObjectDelta() != null) {
oid = deltaOperation.getObjectDelta().getOid();
}
}
if (oid == null) {
// e.g. if there is an exception in provisioning.addObject method
return;
}
summaryResult.computeStatus();
OperationResultStatusType overallStatus = summaryResult.getStatus().createStatusType();
setOperationContext(operation, overallStatus, now, channel, task);
storeOperationExecution(object, oid, operation, deletedOk, result);
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class LensContext method fromLensContextType.
@SuppressWarnings({ "unchecked", "raw" })
public static LensContext fromLensContextType(LensContextType lensContextType, PrismContext prismContext, ProvisioningService provisioningService, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
OperationResult result = parentResult.createSubresult(DOT_CLASS + "fromLensContextType");
String focusClassString = lensContextType.getFocusClass();
if (StringUtils.isEmpty(focusClassString)) {
throw new SystemException("Focus class is undefined in LensContextType");
}
LensContext lensContext;
try {
lensContext = new LensContext(Class.forName(focusClassString), prismContext, provisioningService);
} catch (ClassNotFoundException e) {
throw new SystemException("Couldn't instantiate LensContext because focus or projection class couldn't be found", e);
}
lensContext.setState(ModelState.fromModelStateType(lensContextType.getState()));
lensContext.setChannel(lensContextType.getChannel());
lensContext.setFocusContext(LensFocusContext.fromLensFocusContextType(lensContextType.getFocusContext(), lensContext, task, result));
for (LensProjectionContextType lensProjectionContextType : lensContextType.getProjectionContext()) {
lensContext.addProjectionContext(LensProjectionContext.fromLensProjectionContextType(lensProjectionContextType, lensContext, task, result));
}
lensContext.setDoReconciliationForAllProjections(lensContextType.isDoReconciliationForAllProjections() != null ? lensContextType.isDoReconciliationForAllProjections() : false);
lensContext.setExecutionPhaseOnly(lensContextType.isExecutionPhaseOnly() != null ? lensContextType.isExecutionPhaseOnly() : false);
lensContext.setProjectionWave(lensContextType.getProjectionWave() != null ? lensContextType.getProjectionWave() : 0);
lensContext.setExecutionWave(lensContextType.getExecutionWave() != null ? lensContextType.getExecutionWave() : 0);
lensContext.setOptions(ModelExecuteOptions.fromModelExecutionOptionsType(lensContextType.getOptions()));
if (lensContextType.isLazyAuditRequest() != null) {
lensContext.setLazyAuditRequest(lensContextType.isLazyAuditRequest());
}
if (lensContextType.isRequestAudited() != null) {
lensContext.setRequestAudited(lensContextType.isRequestAudited());
}
if (lensContextType.isExecutionAudited() != null) {
lensContext.setExecutionAudited(lensContextType.isExecutionAudited());
}
lensContext.setRequestAuthorized(Boolean.TRUE.equals(lensContextType.isRequestAuthorized()));
lensContext.setStats(lensContextType.getStats());
lensContext.setRequestMetadata(lensContextType.getRequestMetadata());
for (LensObjectDeltaOperationType eDeltaOperationType : lensContextType.getRottenExecutedDeltas()) {
LensObjectDeltaOperation objectDeltaOperation = LensObjectDeltaOperation.fromLensObjectDeltaOperationType(eDeltaOperationType, lensContext.getPrismContext());
if (objectDeltaOperation.getObjectDelta() != null) {
lensContext.fixProvisioningTypeInDelta(objectDeltaOperation.getObjectDelta(), task, result);
}
lensContext.rottenExecutedDeltas.add(objectDeltaOperation);
}
if (result.isUnknown()) {
result.computeStatus();
}
return lensContext;
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageTasks method synchronizeTasksPerformed.
private void synchronizeTasksPerformed(AjaxRequestTarget target) {
OperationResult result = new OperationResult(OPERATION_SYNCHRONIZE_TASKS);
try {
getTaskService().synchronizeTasks(result);
result.computeStatus();
if (result.isSuccess()) {
// brutal hack - the subresult's message contains statistics
result.recordStatus(OperationResultStatus.SUCCESS, result.getLastSubresult().getMessage());
}
} catch (RuntimeException | SchemaException | SecurityViolationException e) {
result.recordFatalError("Couldn't synchronize tasks", e);
}
showResult(result);
//refresh feedback and table
refreshTables(target);
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageTasks method deleteNodesPerformed.
private void deleteNodesPerformed(AjaxRequestTarget target, List<NodeDto> nodes) {
OperationResult result = new OperationResult(OPERATION_DELETE_NODES);
Task task = createSimpleTask(OPERATION_DELETE_NODES);
for (NodeDto nodeDto : nodes) {
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
deltas.add(ObjectDelta.createDeleteDelta(NodeType.class, nodeDto.getOid(), getPrismContext()));
try {
getModelService().executeChanges(deltas, null, task, result);
} catch (Exception e) {
// until java 7 we do it in this way
result.recordFatalError("Couldn't delete the node " + nodeDto.getNodeIdentifier(), e);
}
}
result.computeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "Selected node(s) have been successfully deleted.");
}
showResult(result);
NodeDtoProvider provider = (NodeDtoProvider) getNodeTable().getDataTable().getDataProvider();
provider.clearCache();
//refresh feedback and table
refreshTables(target);
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class CertificationManagerImpl method closeCampaign.
@Override
public void closeCampaign(String campaignOid, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, SecurityViolationException, ObjectAlreadyExistsException {
Validate.notNull(campaignOid, "campaignOid");
Validate.notNull(task, "task");
Validate.notNull(parentResult, "parentResult");
OperationResult result = parentResult.createSubresult(OPERATION_CLOSE_CAMPAIGN);
try {
AccessCertificationCampaignType campaign = generalHelper.getCampaign(campaignOid, null, task, result);
securityEnforcer.authorize(ModelAuthorizationAction.CLOSE_CERTIFICATION_CAMPAIGN.getUrl(), null, campaign.asPrismObject(), null, null, null, result);
updateHelper.closeCampaign(campaign, task, result);
} catch (RuntimeException e) {
result.recordFatalError("Couldn't close certification campaign: unexpected exception: " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
Aggregations