REST Expanders 1.15.0
CommandExtension linking
In previous versions of the main expanders, the commands were injected into the logic bean as a feature. Since we do not nest features, this made it impossible to implement commands from another expander bundle, such as the rest-expanders. This feature was integrated into the bean expander, allowing other bundles to now implement commands.
To solve this original issue, the rest-expanders injected some code into the custom anchors of the commands in the logic bean. This was never intended to be a permanent solution, but a temporary workaround to address this issue. Version 1.15.0
of the rest-expanders has a minimum dependency of version 4.12.0
of the main expanders, to be able to transition to actual feature injection for this purpose. As the previous code has now ended up in the harvest files of every project, the workaround has been inverted to remove the workaround code that was injected.
An example of the old injected code:
// anchor:custom-command-createEntity:start
// Default implementation generated by the REST expanders
commandResult = executeCreateEntityCommand(commandParameter);
// anchor:custom-command-createEntity:end
The code will be removed automatically if the endpoint still exists in the model and no code (other than whitespace) has been added in between the start anchor and the injected code.
The previous execute methods were added to avoid the code from being altered easily and make the transition more difficult. These have now been removed and the code they contained is now injected as part of the feature.
An example of the new injected feature code, which was previously in the execute method:
// @anchor:command-createEntity:start
commandResult = new CreateEntityCommandExtension().execute(commandParameter);
if (commandResult == null || commandResult.isError()) {
sessionContext.setRollbackOnly();
}
// @anchor:command-createEntity:end
Exposing diagnostics
We are no longer exposing values in Diagnostic
object directly through error payloads in the REST API. The reasoning behind this is that we do not want to expose diagnostic information directly to the end-user. As an alternative, all exceptions that are handled by the REST API that contain diagnostics now have their diagnostics output into the logs along with the information that was already logged previously. Given that this pertains to 5xx errors, these are technical errors that should not occur in production and will likely be handled by a developer. Any issues with input of data should already have been handled by the validation system. These errors which return diagnostics are only thrown when something unexpected has occurred. The diagnostics have more value to a developer rather than the end-user and are more easily accessed through the application logs.
A transient option jaxrs.transient.exposeDiagnostics.enable
has been supplied to revert the behavior of the expanders for backwards compatibility. But keep in mind that this option will be removed in the future and has only been supplied for short-term compatibility if needed, allowing for planning to upgrade the codebase. The option will once again expose the diagnostics through the API, but they will also appear in the application logs.
The transient option jaxrs.transient.exposeDiagnostics.enable
was removed in rest-expanders
version 2.9.0
.
The following expanders have been affected:
CreateFailedExceptionHandlerExpander
- File:
CreateFailedExceptionHandler.java
- Changes:
- Import removed:
net.democritus.sys.Diagnostic
- Objects returned by
exception.getDiagnostics()
no longer added toerrorModel
inmapException(exception)
method
- Import removed:
- File:
DeleteFailedExceptionHandlerExpander
- File:
DeleteFailedExceptionHandler.java
- Changes:
- Import removed:
net.democritus.sys.Diagnostic
- Objects returned by
exception.getDiagnostics()
no longer added toerrorModel
inmapException(exception)
method
- Import removed:
- File:
ModificationFailedExceptionHandlerExpander
- File:
ModificationFailedExceptionHandler.java
- Changes:
- Import removed:
net.democritus.sys.Diagnostic
- Objects returned by
exception.getDiagnostics()
no longer added toerrorModel
inmapException(exception)
method
- Import removed:
- File:
SearchResultExceptionHandlerExpander
- File:
SearchResultExceptionHandler.java
- Changes:
- Import removed:
net.democritus.sys.Diagnostic
- Objects returned by
exception.getDiagnostics()
no longer added toerrorModel
inmapException(exception)
method
- Import removed:
- File:
ServerErrorModelExpander
- File:
ServerErrorInfoModel.java
- Changes:
- Import removed:
java.util.ArrayList
- Import removed:
java.util.List
- Field removed:
List<String> diagnostics
- Method removed:
List<String> getDiagnostics()
- Method removed:
void setDiagnostics(List<String>)
- Method removed:
void addDiagnostic(String)
- Import removed:
- File:
Miscellaneous
- The
ValidationException
class was moved from the shared layer to the control layer. It was never intended to be used outside the control layer.