Skip to content

Commit

Permalink
background taskOid to operationRest for newly created tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Mar 23, 2020
1 parent 1d8d70c commit e2ca89d
Show file tree
Hide file tree
Showing 7 changed files with 2,380 additions and 2,346 deletions.
Expand Up @@ -18,14 +18,12 @@
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.delta.DeltaFactory;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.schema.ObjectDeltaOperation;
import com.evolveum.midpoint.schema.ResourceShadowDiscriminator;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.security.api.HttpConnectionInformation;
import com.evolveum.midpoint.security.api.MidPointPrincipal;
import com.evolveum.midpoint.security.api.SecurityContextManager;
Expand All @@ -34,7 +32,6 @@
import com.evolveum.midpoint.task.api.TaskExecutionStatus;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand All @@ -43,7 +40,6 @@
import com.evolveum.midpoint.web.component.AjaxSubmitButton;
import com.evolveum.midpoint.web.component.SecurityContextAwareCallable;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties;
import com.evolveum.midpoint.web.page.login.PageLogin;
import com.evolveum.midpoint.web.security.MidPointApplication;
Expand All @@ -52,8 +48,6 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;

import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
Expand All @@ -78,9 +72,6 @@
import static com.evolveum.midpoint.model.api.ProgressInformation.ActivityType.RESOURCE_OBJECT_OPERATION;
import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef;
import static com.evolveum.midpoint.web.component.progress.ProgressReportActivityDto.ResourceOperationResult;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType.RUNNABLE;

import static java.util.Collections.singleton;

/**
* @author mederly
Expand Down Expand Up @@ -429,7 +420,7 @@ public void executeChanges(Collection<ObjectDelta<? extends ObjectType>> deltas,

if (!reporter.isAsynchronousExecution() && page instanceof ProgressReportingAwarePage) {
ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
aware.finishProcessing(target, result, reporter.isAsynchronousExecution());
aware.finishProcessing(target, reporter.getObjectDeltaOperation(), reporter.isAsynchronousExecution(), result);
}
}

Expand Down Expand Up @@ -484,7 +475,7 @@ public void executeChangesInBackground(Collection<ObjectDelta<? extends ObjectTy
}
if (page instanceof ProgressReportingAwarePage) {
ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
aware.finishProcessing(target, result, reporter.isAsynchronousExecution());
aware.finishProcessing(target, reporter.getObjectDeltaOperation(), reporter.isAsynchronousExecution(), result);
}
}

Expand Down Expand Up @@ -566,7 +557,7 @@ protected void onPostProcessTarget(AjaxRequestTarget target) {

if (page instanceof ProgressReportingAwarePage) {
ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
aware.finishProcessing(target, asyncOperationResult, true);
aware.finishProcessing(target, reporter.getObjectDeltaOperation() , true, asyncOperationResult);
}

reporter.setAsyncOperationResult(null);
Expand Down Expand Up @@ -623,6 +614,7 @@ public void abortPerformed(AjaxRequestTarget target) {

private void executeChangesSync(ProgressReporter reporter, Collection<ObjectDelta<? extends ObjectType>> deltas,
boolean previewOnly, ModelExecuteOptions options, Task task, OperationResult result) {

try {
MidPointApplication application = MidPointApplication.get();

Expand All @@ -632,7 +624,8 @@ private void executeChangesSync(ProgressReporter reporter, Collection<ObjectDelt
reporter.setPreviewResult(previewResult);
} else {
ModelService service = application.getModel();
service.executeChanges(deltas, options, task, result);
Collection<ObjectDeltaOperation<? extends ObjectType>>executedDeltas = service.executeChanges(deltas, options, task, result);
reporter.setObjectDeltaOperation(executedDeltas);
}
result.computeStatusIfUnknown();
} catch (CommonException | RuntimeException e) {
Expand Down Expand Up @@ -670,7 +663,8 @@ public Void callWithContextPrepared() throws Exception {
.previewChanges(deltas, options, task, Collections.singleton(reporter), result);
reporter.setPreviewResult(previewResult);
} else if (deltas != null && deltas.size() > 0){
model.executeChanges(deltas, options, task, Collections.singleton(reporter), result);
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = model.executeChanges(deltas, options, task, Collections.singleton(reporter), result);
reporter.setObjectDeltaOperation(executedDeltas);
}
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error executing changes", e);
Expand Down
Expand Up @@ -58,6 +58,7 @@ public class ProgressReporter implements ProgressListener {
// Operation result got from the asynchronous operation (null if async op not yet finished)
private OperationResult asyncOperationResult;
private ModelContext<? extends ObjectType> previewResult;
private Collection<ObjectDeltaOperation<? extends ObjectType>> objectDeltaOperation;

private long operationStartTime; // if 0, operation hasn't start yet
private long operationDurationTime; // if >0, operation has finished
Expand Down Expand Up @@ -95,6 +96,14 @@ public void setAsyncOperationResult(OperationResult asyncOperationResult) {
this.asyncOperationResult = asyncOperationResult;
}

public Collection<ObjectDeltaOperation<? extends ObjectType>> getObjectDeltaOperation() {
return objectDeltaOperation;
}

public void setObjectDeltaOperation(Collection<ObjectDeltaOperation<? extends ObjectType>> objectDeltaOperation) {
this.objectDeltaOperation = objectDeltaOperation;
}

public void setPreviewResult(ModelContext<? extends ObjectType> previewResult) {
this.previewResult = previewResult;
}
Expand Down
Expand Up @@ -7,9 +7,14 @@

package com.evolveum.midpoint.web.component.progress;

import com.evolveum.midpoint.schema.ObjectDeltaOperation;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.wicket.ajax.AjaxRequestTarget;

import java.util.Collection;

/**
* A page that supports progress reporting, e.g. page for editing users, orgs, roles.
* <p>
Expand All @@ -22,7 +27,7 @@ public interface ProgressReportingAwarePage {

void startProcessing(AjaxRequestTarget target, OperationResult result);

void finishProcessing(AjaxRequestTarget target, OperationResult result, boolean returningFromAsync);
void finishProcessing(AjaxRequestTarget target, Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas, boolean returningFromAsync, OperationResult result);

void continueEditing(AjaxRequestTarget target);
}

0 comments on commit e2ca89d

Please sign in to comment.