Skip to content

Commit

Permalink
Merge branch 'tmp/internet2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 14, 2019
2 parents 503178c + 46c0398 commit 62ef249
Show file tree
Hide file tree
Showing 47 changed files with 1,640 additions and 518 deletions.
Expand Up @@ -571,7 +571,7 @@ public static ObjectType toObjectable(PrismObject object) {
return object != null ? (ObjectType) object.asObjectable() : null;
}

public static <T extends Objectable> PrismObject<T> toPrismObject(T objectable) {
public static <T extends Objectable> PrismObject<T> asPrismObject(T objectable) {
//noinspection unchecked
return objectable != null ? objectable.asPrismObject() : null;
}
Expand Down
Expand Up @@ -813,6 +813,26 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="inputLensContextText" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Lens (model) context at input (text dump).
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0.1</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="outputLensContextText" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Lens (model) context at output (text dump).
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0.1</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Expand Down
Expand Up @@ -2235,7 +2235,7 @@
for activation in these hardcoded states ("undefined" for active and deprecated
states, "archived" for archived state, "disabled" for all other states). To turn off this default behaviour
those hardcoded lifecycle states need to be explicitly defined in the state model
and the forcedActivationStatus property shoule be left undefined.
and the forcedActivationStatus property should be left undefined.
</p>
</xsd:documentation>
<xsd:appinfo>
Expand All @@ -2249,10 +2249,10 @@
<xsd:documentation>
<p>
There are cases when you need to force midpoint thinks that user has assigned some
role. The assignemnt actually doesn't exist but there is a need to preted as it does.
role. The assignment actually doesn't exist but there is a need to pretend as it does.
This can be used e.g. for post-authentication flow. The user has assigned all business,
application, etc. roles but we don't want to consider these roles during his
post-authentication proces. Instead, we want to pretend he has "temporary" role assigned
post-authentication process. Instead, we want to pretend he has "temporary" role assigned
which allows him to perform post-authentication.
</p>
</xsd:documentation>
Expand Down Expand Up @@ -2340,10 +2340,10 @@
<xsd:documentation>
<p>
There are cases when you need to force midpoint thinks that user has assigned some
role. The assignemnt actually doesn't exist but there is a need to preted as it does.
role. The assignment actually doesn't exist but there is a need to pretend as it does.
This can be used e.g. for post-authentication flow. The user has assigned all business,
application, etc. roles but we don't want to consider these roles during his
post-authentication proces. Instead, we want to pretend he has "temporary" role assigned
post-authentication process. Instead, we want to pretend he has "temporary" role assigned
which allows him to perform post-authentication.
</p>
</xsd:documentation>
Expand Down
Expand Up @@ -2309,24 +2309,23 @@ public void notifyChange(ResourceObjectShadowChangeDescriptionType changeDescrip
PrismObject<ShadowType> oldShadow;
LOGGER.trace("resolving old object");
if (!StringUtils.isEmpty(oldShadowOid)) {
// FIXME we should not get object from resource here: it should be sufficient to retrieve object from the repository
// (and even that can be skipped, if identifiers are correctly set) ... MID-5834
oldShadow = getObject(ShadowType.class, oldShadowOid, SelectorOptions.createCollection(GetOperationOptions.createDoNotDiscovery()), task, parentResult);
eventDescription.setOldShadow(oldShadow);
eventDescription.setOldRepoShadow(oldShadow);
LOGGER.trace("old object resolved to: {}", oldShadow.debugDumpLazily());
} else {
LOGGER.trace("Old shadow null");
}

PrismObject<ShadowType> currentShadow = null;
ShadowType currentShadowType = changeDescription.getCurrentShadow();
LOGGER.trace("resolving current shadow");
if (currentShadowType != null) {
prismContext.adopt(currentShadowType);
currentShadow = currentShadowType.asPrismObject();
LOGGER.trace("current shadow resolved to {}", currentShadow.debugDumpLazily());
ShadowType currentResourceObjectBean = changeDescription.getCurrentShadow();
if (currentResourceObjectBean != null) {
PrismObject<ShadowType> currentResourceObject = currentResourceObjectBean.asPrismObject();
prismContext.adopt(currentResourceObject);
LOGGER.trace("current resource object:\n{}", currentResourceObject.debugDumpLazily());
eventDescription.setCurrentResourceObject(currentResourceObject);
}

eventDescription.setCurrentShadow(currentShadow);

ObjectDeltaType deltaType = changeDescription.getObjectDelta();

if (deltaType != null) {
Expand Down
Expand Up @@ -266,10 +266,7 @@ private <F extends ObjectType> boolean startTracingIfRequested(LensContext<F> co
private <F extends ObjectType> ClockworkRunTraceType recordTraceAtStart(LensContext<F> context, Task task,
OperationResult result) throws SchemaException {
ClockworkRunTraceType trace = new ClockworkRunTraceType(prismContext);
TracingLevelType level = result.getTracingLevel(trace.getClass());
if (level.ordinal() >= TracingLevelType.MINIMAL.ordinal()) {
trace.getText().add(context.debugDump()); // todo
}
trace.setInputLensContextText(context.debugDump());
trace.setInputLensContext(context.toLensContextType(getExportTypeTraceOrReduced(trace, result)));
result.addTrace(trace);
return trace;
Expand All @@ -278,6 +275,7 @@ private <F extends ObjectType> ClockworkRunTraceType recordTraceAtStart(LensCont
private <F extends ObjectType> void recordTraceAtEnd(LensContext<F> context, ClockworkRunTraceType trace,
OperationResult result) throws SchemaException {
if (trace != null) {
trace.setOutputLensContextText(context.debugDump());
trace.setOutputLensContext(context.toLensContextType(getExportTypeTraceOrReduced(trace, result)));
if (context.getFocusContext() != null) { // todo reconsider this
PrismObject<F> objectAny = context.getFocusContext().getObjectAny();
Expand Down Expand Up @@ -537,6 +535,9 @@ public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Ta
ClockworkClickTraceType trace;
if (result.isTraced()) {
trace = new ClockworkClickTraceType(prismContext);
if (result.isTracingNormal(ClockworkClickTraceType.class)) {
trace.setInputLensContextText(context.debugDump());
}
trace.setInputLensContext(context.toLensContextType(getExportType(trace, result)));
result.getTraces().add(trace);
} else {
Expand Down Expand Up @@ -627,6 +628,9 @@ public <F extends ObjectType> HookOperationMode click(LensContext<F> context, Ta
throw e;
} finally {
if (trace != null) {
if (result.isTracingNormal(ClockworkClickTraceType.class)) {
trace.setOutputLensContextText(context.debugDump());
}
trace.setOutputLensContext(context.toLensContextType(getExportType(trace, result)));
}
result.computeStatusIfUnknown();
Expand Down
Expand Up @@ -195,6 +195,9 @@ public void partialExecute(String baseComponentName, ProjectorComponentRunnable
ProjectorComponentTraceType trace;
if (result.isTraced()) {
trace = new ProjectorComponentTraceType();
if (result.isTracingNormal(ProjectorComponentTraceType.class)) {
trace.setInputLensContextText(context.debugDump());
}
trace.setInputLensContext(context.toLensContextType(getExportType(trace, result)));
result.addTrace(trace);
} else {
Expand All @@ -215,6 +218,9 @@ public void partialExecute(String baseComponentName, ProjectorComponentRunnable
} finally {
result.computeStatusIfUnknown();
if (trace != null) {
if (result.isTracingNormal(ProjectorComponentTraceType.class)) {
trace.setOutputLensContextText(context.debugDump());
}
trace.setOutputLensContext(context.toLensContextType(getExportType(trace, result)));
}
if (clockworkInspector != null) {
Expand Down
Expand Up @@ -107,6 +107,9 @@ public <F extends ObjectType> void load(LensContext<F> context, String activityD
ProjectorComponentTraceType trace;
if (result.isTraced()) {
trace = new ProjectorComponentTraceType(prismContext);
if (result.isTracingNormal(ProjectorComponentTraceType.class)) {
trace.setInputLensContextText(context.debugDump());
}
trace.setInputLensContext(context.toLensContextType(getExportType(trace, result)));
result.addTrace(trace);
} else {
Expand Down Expand Up @@ -194,6 +197,9 @@ public <F extends ObjectType> void load(LensContext<F> context, String activityD
throw e;
} finally {
if (trace != null) {
if (result.isTracingNormal(ProjectorComponentTraceType.class)) {
trace.setOutputLensContextText(context.debugDump());
}
trace.setOutputLensContext(context.toLensContextType(getExportType(trace, result)));
}
}
Expand Down Expand Up @@ -327,6 +333,9 @@ public <O extends ObjectType> void determineFocusContext(LensContext<O> context,
FocusLoadedTraceType trace;
if (result.isTraced()) {
trace = new FocusLoadedTraceType();
if (result.isTracingNormal(FocusLoadedTraceType.class)) {
trace.setInputLensContextText(context.debugDump());
}
trace.setInputLensContext(context.toLensContextType(getExportType(trace, result)));
result.addTrace(trace);
} else {
Expand Down Expand Up @@ -392,6 +401,9 @@ public <O extends ObjectType> void determineFocusContext(LensContext<O> context,
throw t;
} finally {
if (trace != null) {
if (result.isTracingNormal(FocusLoadedTraceType.class)) {
trace.setOutputLensContextText(context.debugDump());
}
trace.setOutputLensContext(context.toLensContextType(getExportType(trace, result)));
}
result.computeStatusIfUnknown();
Expand Down Expand Up @@ -1450,6 +1462,9 @@ public <F extends ObjectType> void loadFullShadow(LensContext<F> context, LensPr
FullShadowLoadedTraceType trace;
if (result.isTraced()) {
trace = new FullShadowLoadedTraceType(prismContext);
if (result.isTracingNormal(FullShadowLoadedTraceType.class)) {
trace.setInputLensContextText(context.debugDump());
}
trace.setInputLensContext(context.toLensContextType(getExportType(trace, result)));
result.addTrace(trace);
} else {
Expand Down Expand Up @@ -1518,6 +1533,9 @@ public <F extends ObjectType> void loadFullShadow(LensContext<F> context, LensPr
throw t;
} finally {
if (trace != null) {
if (result.isTracingNormal(FullShadowLoadedTraceType.class)) {
trace.setOutputLensContextText(context.debugDump());
}
trace.setOutputLensContext(context.toLensContextType(getExportType(trace, result)));
}
result.computeStatusIfUnknown();
Expand Down
2 changes: 1 addition & 1 deletion model/model-intest/src/test/resources/logback-test.xml
Expand Up @@ -87,7 +87,7 @@
<logger name="com.evolveum.midpoint.provisioning.impl.ConnectorManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ResourceCache" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ShadowCache" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ShadowManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.shadowmanager.ShadowManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.task" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.errorhandling" level="DEBUG" />
<!-- <logger name="com.evolveum.midpoint.provisioning.impl.sync" level="TRACE" />-->
Expand Down
Expand Up @@ -1642,7 +1642,7 @@ protected PrismObject<UserType> getUserFromRepo(String userOid) throws ObjectNot
}

protected <O extends ObjectType> PrismObject<O> findObjectByName(Class<O> type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".findObjectByName");
Task task = getOrCreateTask("findObjectByName");
OperationResult result = task.getResult();
List<PrismObject<O>> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result);
if (objects.isEmpty()) {
Expand Down Expand Up @@ -3601,25 +3601,33 @@ protected void restartTask(String taskOid) throws CommonException {
LOGGER.warn("Sleep interrupted: {}", e.getMessage(), e);
}

final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".restartTask");
Task task = taskManager.getTaskWithResult(taskOid, result);
LOGGER.info("Restarting task {}", taskOid);
if (task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED) {
LOGGER.debug("Task {} is suspended, resuming it", task);
taskManager.resumeTask(task, result);
} else if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) {
LOGGER.debug("Task {} is closed, scheduling it to run now", task);
taskManager.scheduleTasksNow(singleton(taskOid), result);
} else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) {
if (taskManager.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier()) != null) {
// Task is really executing. Let's wait until it finishes; hopefully it won't start again (TODO)
LOGGER.debug("Task {} is running, waiting while it finishes before restarting", task);
waitForTaskFinish(taskOid, false);
OperationResult result = createSubresult("restartTask");
try {
Task task = taskManager.getTaskWithResult(taskOid, result);
LOGGER.info("Restarting task {}", taskOid);
if (task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED) {
LOGGER.debug("Task {} is suspended, resuming it", task);
taskManager.resumeTask(task, result);
} else if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) {
LOGGER.debug("Task {} is closed, scheduling it to run now", task);
taskManager.scheduleTasksNow(singleton(taskOid), result);
} else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) {
if (taskManager.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier()) != null) {
// Task is really executing. Let's wait until it finishes; hopefully it won't start again (TODO)
LOGGER.debug("Task {} is running, waiting while it finishes before restarting", task);
waitForTaskFinish(taskOid, false);
}
LOGGER.debug("Task {} is finished, scheduling it to run now", task);
taskManager.scheduleTasksNow(singleton(taskOid), result);
} else {
throw new IllegalStateException(
"Task " + task + " cannot be restarted, because its state is: " + task.getExecutionStatus());
}
LOGGER.debug("Task {} is finished, scheduling it to run now", task);
taskManager.scheduleTasksNow(singleton(taskOid), result);
} else {
throw new IllegalStateException("Task " + task + " cannot be restarted, because its state is: " + task.getExecutionStatus());
} catch (Throwable t) {
result.recordFatalError(t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}

Expand Down

0 comments on commit 62ef249

Please sign in to comment.