use of com.evolveum.midpoint.schema.result.OperationResultStatus in project midpoint by Evolveum.
the class DefaultGuiProgressListener method updateStatusItemState.
private void updateStatusItemState(ProgressReportActivityDto si, ProgressInformation progressInformation, ModelContext modelContext) {
si.setActivityType(progressInformation.getActivityType());
si.setResourceShadowDiscriminator(progressInformation.getResourceShadowDiscriminator());
if (progressInformation.getResourceShadowDiscriminator() != null) {
String resourceOid = progressInformation.getResourceShadowDiscriminator().getResourceOid();
String resourceName = resourceOid != null ? getResourceName(resourceOid) : "";
si.setResourceName(resourceName);
}
if (progressInformation.getStateType() == null) {
si.setStatus(null);
} else if (progressInformation.getStateType() == ENTERING) {
si.setStatus(OperationResultStatusType.IN_PROGRESS);
} else {
OperationResult result = progressInformation.getOperationResult();
if (result != null) {
OperationResultStatus status = result.getStatus();
if (status == OperationResultStatus.UNKNOWN) {
status = result.getComputeStatus();
}
si.setStatus(status.createStatusType());
} else {
si.setStatus(OperationResultStatusType.UNKNOWN);
}
}
// information about modifications on a resource
if (progressInformation.getActivityType() == RESOURCE_OBJECT_OPERATION && progressInformation.getStateType() == EXITING && progressInformation.getResourceShadowDiscriminator() != null && progressInformation.getResourceShadowDiscriminator().getResourceOid() != null) {
ModelProjectionContext mpc = modelContext.findProjectionContext(progressInformation.getResourceShadowDiscriminator());
if (mpc != null) {
// it shouldn't be null!
// operations performed (TODO aggregate them somehow?)
List<ResourceOperationResult> resourceOperationResultList = new ArrayList<>();
List<? extends ObjectDeltaOperation> executedDeltas = mpc.getExecutedDeltas();
for (ObjectDeltaOperation executedDelta : executedDeltas) {
ObjectDelta delta = executedDelta.getObjectDelta();
if (delta != null) {
OperationResult r = executedDelta.getExecutionResult();
OperationResultStatus status = r.getStatus();
if (status == OperationResultStatus.UNKNOWN) {
status = r.getComputeStatus();
}
resourceOperationResultList.add(new ResourceOperationResult(delta.getChangeType(), status));
}
}
si.setResourceOperationResultList(resourceOperationResultList);
// object name
PrismObject<ShadowType> object = mpc.getObjectNew();
if (object == null) {
object = mpc.getObjectOld();
}
String name = null;
if (object != null) {
if (object.asObjectable().getName() != null) {
name = PolyString.getOrig(object.asObjectable().getName());
} else {
// determine from attributes
ResourceAttribute nameAttribute = ShadowUtil.getNamingAttribute(object);
if (nameAttribute != null) {
name = String.valueOf(nameAttribute.getAnyRealValue());
}
}
}
if (name != null) {
si.setResourceObjectName(name);
}
}
}
}
use of com.evolveum.midpoint.schema.result.OperationResultStatus in project midpoint by Evolveum.
the class AssignmentProcessor method processAssignmentsProjections.
/**
* Processing all the assignments to determine which projections should be added, deleted or kept as they are.
* Generic method for all projection types (theoretically).
*/
@SuppressWarnings("unchecked")
public <O extends ObjectType> void processAssignmentsProjections(LensContext<O> context, XMLGregorianCalendar now, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException, CommunicationException, ConfigurationException, SecurityViolationException {
LensFocusContext<O> focusContext = context.getFocusContext();
if (focusContext == null) {
return;
}
if (!FocusType.class.isAssignableFrom(focusContext.getObjectTypeClass())) {
// We can do this only for FocusType.
return;
}
// if (ModelExecuteOptions.isLimitPropagation(context.getOptions()) && SchemaConstants.CHANGE_CHANNEL_DISCOVERY.equals(QNameUtil.uriToQName(context.getChannel()))){
// //do not execute assignment if the execution was triggered by compensation mechanism and limitPropagation is set
// return;
// }
OperationResult result = parentResult.createSubresult(AssignmentProcessor.class.getName() + ".processAssignmentsProjections");
try {
processAssignmentsProjectionsWithFocus((LensContext<? extends FocusType>) context, now, task, result);
} catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | PolicyViolationException | CommunicationException | ConfigurationException | SecurityViolationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
OperationResultStatus finalStatus = OperationResultStatus.SUCCESS;
String message = null;
int errors = 0;
for (OperationResult subresult : result.getSubresults()) {
if (subresult.isError()) {
errors++;
if (message == null) {
message = subresult.getMessage();
} else {
message = errors + " errors";
}
finalStatus = OperationResultStatus.PARTIAL_ERROR;
}
}
result.setStatus(finalStatus);
result.setMessage(message);
result.cleanupResult();
}
use of com.evolveum.midpoint.schema.result.OperationResultStatus in project midpoint by Evolveum.
the class ReconciliationTaskHandler method performResourceReconciliation.
// returns false in case of execution interruption
private boolean performResourceReconciliation(PrismObject<ResourceType> resource, ObjectClassComplexTypeDefinition objectclassDef, ReconciliationTaskResult reconResult, Task coordinatorTask, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
boolean interrupted;
OperationResult opResult = result.createSubresult(OperationConstants.RECONCILIATION + ".resourceReconciliation");
// Instantiate result handler. This will be called with every search
// result in the following iterative search
SynchronizeAccountResultHandler handler = new SynchronizeAccountResultHandler(resource.asObjectable(), objectclassDef, "reconciliation", coordinatorTask, changeNotificationDispatcher, taskManager);
handler.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_RECON);
handler.setStopOnError(false);
coordinatorTask.setExpectedTotal(null);
try {
ObjectQuery query = objectclassDef.createShadowSearchQuery(resource.getOid());
OperationResult searchResult = new OperationResult(OperationConstants.RECONCILIATION + ".searchIterative");
handler.createWorkerThreads(coordinatorTask, searchResult);
// note that progress is incremented within the handler, as it extends AbstractSearchIterativeResultHandler
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, coordinatorTask, searchResult);
handler.completeProcessing(coordinatorTask, searchResult);
interrupted = !coordinatorTask.canRun();
opResult.computeStatus();
String message = "Processed " + handler.getProgress() + " account(s), got " + handler.getErrors() + " error(s)";
if (interrupted) {
message += "; was interrupted during processing";
}
if (handler.getProgress() > 0) {
message += ". Average time for one object: " + handler.getAverageTime() + " ms (wall clock time average: " + handler.getWallAverageTime() + " ms).";
}
OperationResultStatus resultStatus = OperationResultStatus.SUCCESS;
if (handler.getErrors() > 0) {
resultStatus = OperationResultStatus.PARTIAL_ERROR;
}
opResult.recordStatus(resultStatus, message);
LOGGER.info("Finished resource part of {} reconciliation: {}", resource, message);
reconResult.setResourceReconCount(handler.getProgress());
reconResult.setResourceReconErrors(handler.getErrors());
} catch (ConfigurationException | SecurityViolationException | SchemaException | CommunicationException | ObjectNotFoundException | ExpressionEvaluationException | RuntimeException | Error e) {
opResult.recordFatalError(e);
throw e;
}
return !interrupted;
}
use of com.evolveum.midpoint.schema.result.OperationResultStatus in project midpoint by Evolveum.
the class ResourceController method updateLastAvailabilityState.
public static void updateLastAvailabilityState(ResourceState state, AvailabilityStatusType lastAvailabilityStatus) {
OperationResultStatus lastAvailability = OperationResultStatus.UNKNOWN;
if (lastAvailabilityStatus == null) {
if (state.getOverall().equals(OperationResultStatus.SUCCESS)) {
lastAvailability = OperationResultStatus.SUCCESS;
} else if ((state.getOverall().equals(OperationResultStatus.PARTIAL_ERROR) || state.getOverall().equals(OperationResultStatus.FATAL_ERROR) || state.getOverall().equals(OperationResultStatus.HANDLED_ERROR))) {
lastAvailability = OperationResultStatus.PARTIAL_ERROR;
}
state.setLastAvailability(lastAvailability);
return;
}
if (state.getOverall().equals(OperationResultStatus.SUCCESS) && !lastAvailabilityStatus.equals(AvailabilityStatusType.UP)) {
lastAvailability = OperationResultStatus.SUCCESS;
} else if ((state.getOverall().equals(OperationResultStatus.PARTIAL_ERROR) || state.getOverall().equals(OperationResultStatus.FATAL_ERROR) || state.getOverall().equals(OperationResultStatus.HANDLED_ERROR)) && !lastAvailabilityStatus.equals(AvailabilityStatusType.DOWN)) {
lastAvailability = OperationResultStatus.PARTIAL_ERROR;
}
if (!lastAvailability.equals(OperationResultStatus.UNKNOWN)) {
state.setLastAvailability(lastAvailability);
return;
}
switch(lastAvailabilityStatus) {
case UP:
lastAvailability = OperationResultStatus.SUCCESS;
break;
case DOWN:
lastAvailability = OperationResultStatus.PARTIAL_ERROR;
break;
}
state.setLastAvailability(lastAvailability);
}
use of com.evolveum.midpoint.schema.result.OperationResultStatus in project midpoint by Evolveum.
the class ResourceObjectConverter method refreshOperationStatus.
public OperationResultStatus refreshOperationStatus(ProvisioningContext ctx, PrismObject<ShadowType> shadow, String asyncRef, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
OperationResult result = parentResult.createSubresult(OPERATION_REFRESH_OPERATION_STATUS);
ResourceType resource;
ConnectorInstance connector;
try {
resource = ctx.getResource();
// TODO: not really correct. But good enough for now.
connector = ctx.getConnector(UpdateCapabilityType.class, result);
} catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | ExpressionEvaluationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
OperationResultStatus status = null;
if (connector instanceof AsynchronousOperationQueryable) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("PROVISIONING REFRESH operation on {}, object: {}", resource, shadow);
}
try {
status = ((AsynchronousOperationQueryable) connector).queryOperationStatus(asyncRef, result);
} catch (ObjectNotFoundException | SchemaException e) {
result.recordFatalError(e);
throw e;
}
result.recordSuccess();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("PROVISIONING REFRESH successful, returned status: {}", status);
}
} else {
LOGGER.trace("Ignoring refresh of shadow {}, because the connector is not async");
result.recordNotApplicableIfUnknown();
}
return status;
}
Aggregations