Class OperationResult
java.lang.Object
com.evolveum.midpoint.schema.result.OperationResult
- All Implemented Interfaces:
Visitable<OperationResult>
,OperationResultBuilder
,DebugDumpable
,ShortDumpable
,Serializable
,Cloneable
public class OperationResult
extends Object
implements Serializable, DebugDumpable, ShortDumpable, Cloneable, OperationResultBuilder, Visitable<OperationResult>
Provides rich information about an operation being executed; mainly for the sake of error reporting and functional/performance troubleshooting.
== Information Collected
There is a lot of information collected, but the following properties are the most important:
- result *status* (
OperationResultStatus
): success, partial/fatal error, warning, ..., along with
an optional *message* and *Java exception*,
- operation invocation *parameters*, *return value(s)*, and sometimes information about the execution *context* (e.g. implementation
class name),
- *performance-related information*, like start/end timestamps, or duration (for performance diagnostics),
- TraceType
records (for troubleshooting),
- *logfile lines* produced during the operation execution (for troubleshooting).
The structure is hierarchical, i.e. an OperationResult
instance contains a set of results of inner operations.
== Typical Uses
- This object can be used by GUI to display smart (and interactive) error information.
- It can also be used by the client code (Java or REST) to detect deeper problems in the invocations, retry or otherwise
compensate for the errors or decide how severe the error was and whether it is possible to proceed.
- The performance information collected is recorded in tasks (see OperationsPerformanceInformationType
) and shown in GUI.
See also OperationsPerformanceMonitorImpl
class.
- The functional and performance data collected are used for (experimental)
link:https://docs.evolveum.com/midpoint/reference/diag/troubleshooting/troubleshooting-with-traces/[troubleshooting
with traces].
== Developer's Guidelines
In order to ensure that all necessary information is correctly captured, a developer of any method that writes into
OperationResult
instances has to follow a couple of basic principles:
=== Principle 1: Correct Closure
Any operation result created has to be correctly _closed_. This means that its status
should be changed from
the initial OperationResultStatus.UNKNOWN
value to a more specific one. (Otherwise, a run-time exception is
thrown in cleanupResult(Throwable)
method.) Also, to ensure correct fulfillment of the other duties,
recordEnd()
method has be - directly or indirectly - called as well (see below).
=== Principle 2: Single Result Per Thread
At any instant, in any thread, there should be at most one OperationResult
"active", i.e. opened by
createSubresult(String)
or its variants (e.g. createMinorSubresult(String)
, subresult(String)
, ...),
and not yet closed nor "superseded" by creating its own child result. This is to ensure that logfile lines will be correctly
captured, if tracing is enabled. It is also required for correct collection of performance data.
=== Principle 3: Opening-Closure Pairing
Because the operation result is used also to troubleshoot performance issues, it should be clear where (in the code)
the result is created and where it is closed.
When is result closed, anyway? The result is automatically closed when the status is recorded: either _explicitly_
(like in recordSuccess()
) or _implicitly_ (e.g. in computeStatus()
). All those methods invoke
recordEnd()
that does all the magic related to performance information capturing, log records capturing,
and (occasionally used) method call logging.
To ensure easy, clear and unambiguous interpretation of the performance data, the developer should make sure that
for each OperationResult
created, it is obvious _where_ the result is closed. The best way how to ensure
this is to create the result at the beginning (or near the beginning) of a related method, and close it - including writing
the status - at the end (or near the end) of the same method. No recording of the status should be done between these points.
If there's a need to set the value of status
somewhere during the operation execution (assuming that
there's non-negligible processing after that point), setStatus(OperationResultStatus)
method or its variants
(like setSuccess()
) can be used. These fill-in status
field without closing the whole operation result.
=== Note: Recording Exceptions
The Correct Closure Principle (#1) dictates that the operation result has to be correctly closed even in the case
of exception occurring. That is why we usually create a "try-catch" block for the code covered by a single operation result.
Traditionally, the recordFatalError(Throwable)
call was put into the `catch` code.
However, there may be situations where a different handling is required:
. If the exception is non-fatal or even completely benign. This may be the case of e.g. expected ("allowed")
object-not-found conditions. See ObjectNotFoundException.getSeverity()
.
. If the exception was processed by other means. For example, a custom error message was already provided.
To handle these cases, recordException(Throwable)
should be used instead of recordFatalError(Throwable)
.
The difference is that the former checks the exceptionRecorded
flag to see if the exception was already
processed. See also markExceptionRecorded()
.
NOTE: This mechanism is *experimental*.
=== Suggested Use
Stemming from the above, the following can be seen as a suggested way how to use the operation result:
[source,java]
----
private static final OP_SOME_METHOD = ThisClass.class.getName() + ".someMethod";
void someMethod(String param1, Object param2, OperationResult parentResult) throws SomeException {
OperationResult result = parentResult.subresult(OP_SOME_METHOD)
.addParam("param1", param1)
.addArbitraryObjectAsParam("param2", param2)
.build();
try {
// ... some meat here ...
} catch (SomeException | RuntimeException e) {
result.recordException(e);
throw e;
} finally {
result.close();
}
}
----
Note that the close()
method (a newer form of legacy computeStatusIfUnknown()
) automatically computes
the result based on subresults (assuming success if there's no indication of a failure). In theory we could put it inside
the `try` block (because `recordFatalError` effectively closes the result as well), but using `finally` is perhaps more
explicit. It may be also more future-proof if we would decide to add some extra functionality right into close()
method itself.- Author:
- lazyman, Radovan Semancik
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
Constructor Summary
ConstructorDescriptionOperationResult
(String operation) OperationResult
(String operation, OperationResultStatus status, LocalizableMessage userFriendlyMessage) OperationResult
(String operation, OperationResultStatus status, String message) OperationResult
(String operation, Map<String, Collection<String>> params, OperationResultStatus status, long token, String messageCode, String message, LocalizableMessage userFriendlyMessage, Throwable cause, List<OperationResult> subresults) OperationResult
(String operation, Map<String, Collection<String>> params, Map<String, Collection<String>> context, Map<String, Collection<String>> returns, OperationResultStatus status, long token, String messageCode, String message, LocalizableMessage userFriendlyMessage, Throwable cause, List<OperationResult> subresults) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(Visitor<OperationResult> visitor) addArbitraryObjectAsContext
(String name, Object value) addArbitraryObjectAsParam
(String paramName, Object paramValue) void
addArbitraryObjectAsReturn
(String name, Object value) addArbitraryObjectCollectionAsContext
(String paramName, Collection<?> paramValue) addArbitraryObjectCollectionAsParam
(String name, Collection<?> value) void
addArbitraryObjectCollectionAsReturn
(String paramName, Collection<?> paramValue) addContext
(String name, boolean value) addContext
(String name, int value) addContext
(String name, long value) addContext
(String name, ObjectDelta<?> value) addContext
(String name, PolyString value) addContext
(String name, PrismObject<? extends ObjectType> value) addContext
(String name, ObjectQuery value) addContext
(String name, ObjectType value) addContext
(String name, Class<?> value) addContext
(String name, String value) addContext
(String name, String... values) addContext
(String name, QName value) addParam
(String name, ObjectDelta<?> value) addParam
(String name, PolyString value) addParam
(String name, PrismObject<? extends ObjectType> value) addParam
(String name, ObjectQuery value) addParam
(String name, ObjectType value) addQualifier
(String value) void
addReturn
(String name, ObjectDelta<?> value) void
addReturn
(String name, PolyString value) void
addReturn
(String name, PrismObject<? extends ObjectType> value) void
addReturn
(String name, ObjectQuery value) void
addReturn
(String name, ObjectType value) void
void
void
void
void
void
void
void
addReturnComment
(String comment) void
addSubresult
(OperationResult subresult) void
void
appendDetail
(String detailLine) static void
applyOperationResultHandlingStrategy
(@NotNull List<OperationResultHandlingStrategyType> configuredStrategies) build()
boolean
void
Checks if the recorder was correctly flushed.void
cleanup()
AscleanupResult(Throwable)
but uses the recorded exception for diagnostics.void
Deprecated.void
Deprecated.void
void
void
void
clone()
void
close()
void
Computes operation result status based on subtask status.void
computeStatus
(boolean skipFinish) void
computeStatus
(String errorMessage) Computes operation result status based on subtask status and sets an error message if the status is FATAL_ERROR.void
computeStatus
(String errorMessage, String warnMessage) void
Used when the result contains several composite sub-result that are of equivalent meaning.void
void
AscreateOperationResultType()
but does not export minor success entries.AscreateOperationResultType()
but exports only the root result.static OperationResultBuilder
createMinorSubresult
(String operation) static OperationResult
@NotNull OperationResultType
@NotNull OperationResultType
createOperationResultType
(Function<LocalizableMessage, String> resolveKeys) createSubresult
(String operation) static OperationResult
createSubResultOrNewResult
(OperationResult parentResult, String operation) debugDump
(int indent) void
dump
(boolean withStack) void
dumpBasicInfo
(StringBuilder sb, String prefix, int indent) boolean
@Nullable String
This method partially duplicates functionality of computeStatus.@Nullable String
A convenience method.findSubresult
(String operation) findSubresults
(String operation) Finds given operation among subresults of the current op.@NotNull List<OperationResult>
findSubresultsDeeply
(@NotNull String operation) Finds given operation in a subtree rooted by the current op.findSubResultStrictly
(String operation) @Nullable String
A convenience method.Reference to an asynchronous operation that can be used to retrieve the status of the running operation.getCause()
@NotNull Map<String,
Collection<String>> @Nullable ParamsType
int
getCount()
getEnd()
<T> T
getFirstTrace
(Class<T> traceClass) int
Contains message code based on module error catalog.Contains operation name.@NotNull Map<String,
Collection<String>> Method returnsMap
with operation parameters.@Nullable ParamsType
getParamSingle
(String name) @NotNull Map<String,
Collection<String>> @Nullable ParamsType
getReturnSingle
(String name) getStart()
Contains operation status as defined inOperationResultStatus
@NotNull List<OperationResult>
Method returns list of operation subresultsOperationResult
.long
getToken()
@NotNull TracingLevelType
getTracingLevel
(Class<? extends TraceType> traceClass) int
hashCode()
boolean
Returns true if result status is UNKNOWN or any of the subresult status is unknown (recursive).void
boolean
Returns true if the result is acceptable for further processing.boolean
isClosed()
boolean
isEmpty()
boolean
isError()
boolean
boolean
boolean
static boolean
boolean
isMinor()
boolean
boolean
boolean
boolean
Returns true if the result is success.boolean
boolean
boolean
static boolean
boolean
isTraced()
boolean
isTracing
(Class<? extends TraceType> traceClass, TracingLevelType threshold) boolean
isTracingAny
(Class<? extends TraceType> traceClass) boolean
isTracingDetailed
(Class<? extends TraceType> traceClass) boolean
isTracingNormal
(Class<? extends TraceType> traceClass) boolean
boolean
static OperationResult
keepRootOnly
(OperationResult result) void
Marks the current exception (that is expected to be throws outside the context of the current operation) as already processed - so no further actions (besides closing the result) are necessary.void
void
If the operation is an error then it will switch the status to HANDLED_ERROR.void
Set all error status in this result and all subresults as handled.void
operationKind
(OperationKindType value) preserve()
void
void
recomputeStatus
(String errorMessage) void
recomputeStatus
(String errorMessage, String warningMessage) void
record
(CommonException exception) Records result from a common exception type.void
void
recordException
(@NotNull Throwable cause) Convenience version ofrecordException(String, Throwable)
(with no custom message).void
recordException
(String message, @NotNull Throwable cause) A more sophisticated replacement forrecordFatalError(String, Throwable)
.void
recordExceptionNotFinish
(@NotNull Throwable cause) Convenience version ofrecordExceptionNotFinish(String, Throwable)
(with no custom message).void
recordExceptionNotFinish
(String message, @NotNull Throwable cause) AsrecordException(String, Throwable)
but does not mark operation as finished.void
recordFatalError
(String message) void
recordFatalError
(String message, Throwable cause) void
recordFatalError
(Throwable cause) void
recordHandledError
(String message) void
recordHandledError
(String message, Throwable cause) void
recordHandledError
(Throwable cause) void
void
void
recordNotApplicable
(String message) void
void
recordPartialError
(String message) void
recordPartialError
(String message, Throwable cause) void
recordPartialError
(Throwable cause) void
recordStatus
(OperationResultStatus status) void
recordStatus
(OperationResultStatus status, String message) void
recordStatus
(OperationResultStatus status, String message, Throwable cause) void
recordStatus
(OperationResultStatus status, Throwable cause) void
void
void
void
recordWarning
(String message) void
recordWarning
(String message, Throwable cause) void
recordWarning
(Throwable cause) void
recordWarningNotFinish
(String message, Throwable cause) static String
referenceToCaseOid
(String ref) static String
referenceToTaskOid
(String ref) void
boolean
void
setAsynchronousOperationReference
(String asynchronousOperationReference) void
void
setCallerReason
(String callerReason) void
setCaseOid
(String oid) void
setCount
(int count) void
setCpuMicroseconds
(Long cpuMicroseconds) void
void
setExtractedDictionary
(TraceDictionaryType extractedDictionary) void
setFatalError
(String message, Throwable cause) void
setFatalError
(Throwable cause) void
setHiddenRecordsCount
(int hiddenRecordsCount) void
void
setInProgress
(String message) void
setInvocationId
(Long invocationId) void
setMessage
(String message) void
setMicroseconds
(Long microseconds) setMinor()
void
void
void
setNotApplicable
(String message) void
setPartialError
(String message) void
setPropagateHandledErrorAsSuccess
(boolean propagateHandledErrorAsSuccess) void
void
setStatus
(OperationResultStatus status) Sets the status _without_ recording operation end.void
void
setSummarizeErrors
(boolean summarizeErrors) void
setSummarizePartialErrors
(boolean summarizePartialErrors) void
setSummarizeSuccesses
(boolean summarizeSuccesses) static void
setThreadLocalHandlingStrategy
(@Nullable String strategyName) void
void
setUserFriendlyMessage
(LocalizableMessage userFriendlyMessage) void
Show the content of the object intended for diagnostics.void
void
summarize
(boolean alsoSubresults) void
This is used in situations where handled error is actually the success.toString()
tracingProfile
(CompiledTracingProfile profile) void
"Un-marks" the exception as being recorded.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDumpLazily, debugDumpLazily
Methods inherited from interface com.evolveum.midpoint.util.ShortDumpable
shortDump, shortDumpLazily
-
Field Details
-
CONTEXT_IMPLEMENTATION_CLASS
- See Also:
-
CONTEXT_PROGRESS
- See Also:
-
CONTEXT_OID
- See Also:
-
CONTEXT_OBJECT
- See Also:
-
CONTEXT_ITEM
- See Also:
-
CONTEXT_REASON
- See Also:
-
PARAM_OID
- See Also:
-
PARAM_NAME
- See Also:
-
PARAM_TYPE
- See Also:
-
PARAM_OPTIONS
- See Also:
-
PARAM_RESOURCE
- See Also:
-
PARAM_TASK
- See Also:
-
PARAM_OBJECT
- See Also:
-
PARAM_QUERY
- See Also:
-
PARAM_PROJECTION
- See Also:
-
PARAM_LANGUAGE
- See Also:
-
PARAM_POLICY_RULE
- See Also:
-
PARAM_POLICY_RULE_ID
- See Also:
-
RETURN_COUNT
- See Also:
-
RETURN_COMMENT
- See Also:
-
DEFAULT
- See Also:
-
-
Constructor Details
-
OperationResult
-
OperationResult
public OperationResult(String operation, OperationResultStatus status, LocalizableMessage userFriendlyMessage) -
OperationResult
-
OperationResult
public OperationResult(String operation, Map<String, Collection<String>> params, OperationResultStatus status, long token, String messageCode, String message, LocalizableMessage userFriendlyMessage, Throwable cause, List<OperationResult> subresults) -
OperationResult
public OperationResult(String operation, Map<String, Collection<String>> params, Map<String, Collection<String>> context, Map<String, Collection<String>> returns, OperationResultStatus status, long token, String messageCode, String message, LocalizableMessage userFriendlyMessage, Throwable cause, List<OperationResult> subresults)
-
-
Method Details
-
keepRootOnly
-
keepRootOnly
-
subresult
-
createFor
-
build
- Specified by:
build
in interfaceOperationResultBuilder
-
createSubresult
-
createMinorSubresult
-
recordEnd
public void recordEnd() -
checkLogRecorderFlushed
public void checkLogRecorderFlushed()Checks if the recorder was correctly flushed. Used before writing the trace file. -
getAsynchronousOperationReference
Reference to an asynchronous operation that can be used to retrieve the status of the running operation. This may be a task identifier, identifier of a ticket in ITSM system or anything else. The exact format of this reference depends on the operation which is being executed. Looks only in the current result. SeefindAsynchronousOperationReference()
for the recursive version. -
setAsynchronousOperationReference
-
clearAsynchronousOperationReferencesDeeply
@VisibleForTesting public void clearAsynchronousOperationReferencesDeeply() -
findAsynchronousOperationReference
This method partially duplicates functionality of computeStatus. However, computeStatus currently does not propagate taskOid from tasks switched to background, because switchToBackground sets its result to SUCCESS (not IN_PROGRESS) because of some historical reasons. So, until this is fixed somehow, this is a bit of hack to fetch asynchronous operation reference even in such cases. -
findTaskOid
A convenience method. (Assumes we have only a single asynchronous operation reference in the tree.) -
findCaseOid
A convenience method. (Assumes we have only a single asynchronous operation reference in the tree.) -
isTaskOid
-
referenceToTaskOid
-
referenceToCaseOid
-
getOperation
Contains operation name. Operation name must be defined asString
constant in module interface with description and possible parameters. It can be used for further processing. It will be used as key for translation in admin-gui.- Returns:
- always return non null, non empty string
-
getCount
public int getCount() -
setCount
public void setCount(int count) -
incrementCount
public void incrementCount() -
getHiddenRecordsCount
public int getHiddenRecordsCount() -
setHiddenRecordsCount
public void setHiddenRecordsCount(int hiddenRecordsCount) -
representsHiddenRecords
public boolean representsHiddenRecords() -
isSummarizeErrors
public boolean isSummarizeErrors() -
setSummarizeErrors
public void setSummarizeErrors(boolean summarizeErrors) -
isSummarizePartialErrors
public boolean isSummarizePartialErrors() -
setSummarizePartialErrors
public void setSummarizePartialErrors(boolean summarizePartialErrors) -
isSummarizeSuccesses
public boolean isSummarizeSuccesses() -
setSummarizeSuccesses
public void setSummarizeSuccesses(boolean summarizeSuccesses) -
isEmpty
public boolean isEmpty() -
getSubresults
Method returns list of operation subresultsOperationResult
. -
getLastSubresult
- Returns:
- last subresult, or null if there are no subresults.
-
removeLastSubresult
public void removeLastSubresult() -
getLastSubresultStatus
- Returns:
- last subresult status, or null if there are no subresults.
-
addSubresult
-
findSubresult
-
findSubresultsDeeply
@NotNull public @NotNull List<OperationResult> findSubresultsDeeply(@NotNull @NotNull String operation) Finds given operation in a subtree rooted by the current op. result. Includes this one! -
findSubresults
Finds given operation among subresults of the current op. result. -
getStatus
Contains operation status as defined inOperationResultStatus
- Returns:
- never returns null
-
getStatusBean
-
setStatus
Sets the status _without_ recording operation end. -
isSuccess
public boolean isSuccess()Returns true if the result is success.This returns true if the result is absolute success. Presence of partial failures or warnings fail this test.
- Returns:
- true if the result is success.
-
isWarning
public boolean isWarning() -
isAcceptable
public boolean isAcceptable()Returns true if the result is acceptable for further processing.In other words: if there were no fatal errors. Warnings and partial errors are acceptable. Yet, this test also fails if the operation state is not known.
- Returns:
- true if the result is acceptable for further processing.
-
isUnknown
public boolean isUnknown() -
isInProgress
public boolean isInProgress() -
isError
public boolean isError() -
isFatalError
public boolean isFatalError() -
isPartialError
public boolean isPartialError() -
isHandledError
public boolean isHandledError() -
isNotApplicable
public boolean isNotApplicable() -
muteErrorsRecursively
public void muteErrorsRecursively()Set all error status in this result and all subresults as handled. -
computeStatus
Computes operation result status based on subtask status and sets an error message if the status is FATAL_ERROR.- Parameters:
errorMessage
- error message
-
computeStatus
-
computeStatus
public void computeStatus()Computes operation result status based on subtask status. -
computeStatus
public void computeStatus(boolean skipFinish) -
computeStatusComposite
public void computeStatusComposite()Used when the result contains several composite sub-result that are of equivalent meaning. If all of them fail the result will be fatal error as well. If only some of them fail the result will be partial error. Handled error is considered a success. -
addTrace
-
tracingProfile
- Specified by:
tracingProfile
in interfaceOperationResultBuilder
-
getFirstTrace
-
addReturnComment
-
isTracingNormal
-
isTracingAny
-
isTracingDetailed
-
isTracing
-
getTracingLevel
-
clearTracingProfile
public void clearTracingProfile() -
accept
- Specified by:
accept
in interfaceVisitable<OperationResult>
-
getResultStream
-
findSubResultStrictly
-
switchHandledErrorToSuccess
This is used in situations where handled error is actually the success. For example, when writing an operation execution record to an object which we expect to be deleted, we consider such an operation to be a success. We do not want to bother user or administrator with the information that there was something that went wrong - when, in fact, it was really expected. -
computePreview
-
getComputeStatus
-
close
public void close() -
isClosed
public boolean isClosed() -
computeStatusIfUnknown
public void computeStatusIfUnknown() -
computeStatusIfUnknownComposite
public void computeStatusIfUnknownComposite() -
recomputeStatus
public void recomputeStatus() -
recomputeStatus
-
recomputeStatus
-
recordSuccessIfUnknown
public void recordSuccessIfUnknown() -
recordNotApplicableIfUnknown
public void recordNotApplicableIfUnknown() -
recordNotApplicable
public void recordNotApplicable() -
recordNotApplicable
-
setNotApplicable
public void setNotApplicable() -
setNotApplicable
-
isMinor
public boolean isMinor() -
getParams
Method returnsMap
with operation parameters. Parameters keys are described in module interface for every operation. -
getParamsBean
-
getParam
-
getParamSingle
-
addQualifier
- Specified by:
addQualifier
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addParam
- Specified by:
addParam
in interfaceOperationResultBuilder
-
addArbitraryObjectAsParam
- Specified by:
addArbitraryObjectAsParam
in interfaceOperationResultBuilder
-
addArbitraryObjectCollectionAsParam
- Specified by:
addArbitraryObjectCollectionAsParam
in interfaceOperationResultBuilder
-
getContext
-
getContextBean
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addContext
- Specified by:
addContext
in interfaceOperationResultBuilder
-
addArbitraryObjectAsContext
- Specified by:
addArbitraryObjectAsContext
in interfaceOperationResultBuilder
-
addArbitraryObjectCollectionAsContext
public OperationResult addArbitraryObjectCollectionAsContext(String paramName, Collection<?> paramValue) - Specified by:
addArbitraryObjectCollectionAsContext
in interfaceOperationResultBuilder
-
getReturns
-
getReturnsBean
-
getReturn
-
getReturnSingle
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addReturn
-
addArbitraryObjectAsReturn
-
addArbitraryObjectCollectionAsReturn
-
getToken
public long getToken()- Returns:
- Contains random long number, for better searching in logs.
-
getMessageCode
Contains message code based on module error catalog.- Returns:
- Can return null.
-
getMessage
- Returns:
- Method returns operation result message. Message is required. It will be key for translation in admin-gui.
-
setMessage
-
getUserFriendlyMessage
-
setUserFriendlyMessage
-
getCause
- Returns:
- Method returns operation result exception. Not required, can be null.
-
recordSuccess
public void recordSuccess() -
setSuccess
public void setSuccess() -
recordInProgress
public void recordInProgress() -
setInProgress
public void setInProgress() -
setInProgress
-
setUnknown
public void setUnknown() -
recordFatalError
-
recordException
A more sophisticated replacement forrecordFatalError(String, Throwable)
. . Takes care not to overwrite the exception if it was already processed. . Marks the exception as processed. . Sets the appropriate result status. See the class javadoc. -
recordException
Convenience version ofrecordException(String, Throwable)
(with no custom message). -
recordExceptionNotFinish
AsrecordException(String, Throwable)
but does not mark operation as finished. -
recordExceptionNotFinish
Convenience version ofrecordExceptionNotFinish(String, Throwable)
(with no custom message). -
markExceptionRecorded
Marks the current exception (that is expected to be throws outside the context of the current operation) as already processed - so no further actions (besides closing the result) are necessary. See also the class javadoc.- See Also:
-
unmarkExceptionRecorded
public void unmarkExceptionRecorded()"Un-marks" the exception as being recorded. To be used when the code decides e.g. that the exception will not be thrown out of the context of the current operation. -
setFatalError
-
setFatalError
-
muteError
public void muteError()If the operation is an error then it will switch the status to HANDLED_ERROR. This is used if the error is expected and properly handled. -
muteAllSubresultErrors
public void muteAllSubresultErrors() -
muteLastSubresultError
public void muteLastSubresultError() -
clearLastSubresultError
public void clearLastSubresultError() -
deleteLastSubresultIfError
public void deleteLastSubresultIfError() -
recordPartialError
-
recordWarning
-
recordStatus
-
recordFatalError
-
recordPartialError
-
recordWarning
-
recordWarningNotFinish
-
recordHandledError
-
recordHandledError
-
recordHandledError
-
recordStatus
-
setPropagateHandledErrorAsSuccess
public void setPropagateHandledErrorAsSuccess(boolean propagateHandledErrorAsSuccess) -
recordFatalError
-
recordPartialError
-
setPartialError
-
recordWarning
-
record
Records result from a common exception type. This automatically determines status and also sets appropriate message.- Parameters:
exception
- common exception
-
recordStatus
-
recordStatus
-
hasUnknownStatus
public boolean hasUnknownStatus()Returns true if result status is UNKNOWN or any of the subresult status is unknown (recursive).May come handy in tests to check if all the operations fill out the status as they should.
-
appendDetail
-
getDetail
-
createOperationResult
@Contract("null -> null; !null -> !null") public static OperationResult createOperationResult(OperationResultType bean) -
createBeanReduced
AscreateOperationResultType()
but does not export minor success entries. This is needed to reduce the size of e.g.ShadowType
objects with fetchResult that includes full traced clockwork processing. -
createBeanRootOnly
AscreateOperationResultType()
but exports only the root result. -
createOperationResultType
-
createOperationResultType
@NotNull public @NotNull OperationResultType createOperationResultType(Function<LocalizableMessage, String> resolveKeys) -
summarize
public void summarize() -
summarize
public void summarize(boolean alsoSubresults) -
cleanupResultDeeply
public void cleanupResultDeeply() -
cleanup
public void cleanup()AscleanupResult(Throwable)
but uses the recorded exception for diagnostics. It is more convenient than that method, as it can be used in the `finally` block - assuming that the exception was recorded in the `catch` block or earlier. -
cleanupResult
Deprecated.Removes all the successful minor results. Also checks if the result is roughly consistent and complete. (e.g. does not have unknown operation status, etc.) -
cleanupResult
Deprecated.Removes all the successful minor results. Also checks if the result is roughly consistent and complete. (e.g. does not have unknown operation status, etc.)The argument "e" is for easier use of the cleanup in the exceptions handlers. The original exception is passed to the IAE that this method produces for easier debugging.
-
canBeCleanedUp
public boolean canBeCleanedUp() -
isLesserThan
public static boolean isLesserThan(OperationResultImportanceType x, @NotNull @NotNull OperationResultImportanceType y) - Returns:
- true if x < y
-
debugDump
- Specified by:
debugDump
in interfaceDebugDumpable
-
dump
-
dumpBasicInfo
-
shortDump
Description copied from interface:ShortDumpable
Show the content of the object intended for diagnostics. This method is supposed to append a compact, human-readable output in a single line. Unlike toString() method, there is no requirement to identify the actual class or type of the object. It is assumed that the class/type will be obvious from the context in which the output is used.- Specified by:
shortDump
in interfaceShortDumpable
- Parameters:
sb
- StringBuilder to which to a compact one-line content of the object intended for diagnostics by system administrator should be appended.
-
toString
-
setBackgroundTaskOid
-
setCaseOid
-
operationKind
- Specified by:
operationKind
in interfaceOperationResultBuilder
-
getOperationKind
-
preserve
- Specified by:
preserve
in interfaceOperationResultBuilder
-
isPreserve
public boolean isPreserve() -
setMinor
- Specified by:
setMinor
in interfaceOperationResultBuilder
-
getImportance
-
setImportance
- Specified by:
setImportance
in interfaceOperationResultBuilder
-
recordThrowableIfNeeded
-
createSubResultOrNewResult
public static OperationResult createSubResultOrNewResult(OperationResult parentResult, String operation) -
clone
-
clone
-
applyOperationResultHandlingStrategy
public static void applyOperationResultHandlingStrategy(@NotNull @NotNull List<OperationResultHandlingStrategyType> configuredStrategies) -
setThreadLocalHandlingStrategy
-
equals
-
hashCode
public int hashCode() -
getStart
-
setStart
-
getEnd
-
setEnd
-
getMicroseconds
-
setMicroseconds
-
getCpuMicroseconds
-
setCpuMicroseconds
-
getInvocationId
-
setInvocationId
-
isTraced
public boolean isTraced() -
getTracingProfile
-
getTraces
-
getMonitoredOperations
-
setMonitoredOperations
-
getQualifiers
-
getCallerReason
-
setCallerReason
-
getLogSegments
-
getExtractedDictionary
-
setExtractedDictionary
-