Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(java): Add more newlines to improve readability of snippets #1020

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions java/event-handlers/indicating-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ If no such error status is set when creating the ServiceException, it defaults t
// default error status
throw new ServiceException("An internal server error occurred", originalException);
// specifying an error status
throw new ServiceException(ErrorStatuses.CONFLICT, "Not enough stock available")
throw new ServiceException(ErrorStatuses.CONFLICT, "Not enough stock available");
// specifying an error status and the original exception
throw new ServiceException(ErrorStatuses.BAD_REQUEST, "No book title specified", originalException);
```
Expand Down Expand Up @@ -189,7 +189,8 @@ service CatalogService {
createdBy,
modifiedBy
} actions {
action addReview(reviewer : Reviewer, rating : Integer, title : String, text : String) returns Reviews;
action addReview(reviewer : Reviewer, rating : Integer,
title : String, text : String) returns Reviews;
};
}
```
Expand Down Expand Up @@ -353,7 +354,9 @@ public class SimpleExceptionHandler implements EventHandler {
@After
public void overrideMissingAuthMessage(ErrorResponseEventContext context) {
if (context.getException().getErrorStatus().equals(CdsErrorStatuses.EVENT_FORBIDDEN)) {
context.getResult().getMessages().set(0, Message.create(Severity.ERROR, "You cannot execute this action"));
context.getResult().getMessages().set(0,
Message.create(Message.Severity.ERROR,
"You cannot execute this action"));
}
}
}
Expand Down Expand Up @@ -389,4 +392,4 @@ public class ExceptionServiceErrorMessagesHandler implements EventHandler {

::: tip
If you replace the message with a new one, make sure that you copy the code and target of the original. Otherwise, SAP Fiori clients may not be able to display them properly. Use method `Message.create(Severity severity, String text, Message message)` to create a new message and copy all additional attributes from the existing one.
:::
:::
8 changes: 5 additions & 3 deletions java/event-handlers/request-contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ The `RequestContextRunner` API offers convenience methods that allow an easy tra
| Method | Description |
|----------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| systemUserProvider() | Switches to a technical user targeting the provider account. |
| systemUser() | Switches to a technical user and preserves the tenant from the current `UserInfo` (for example down grade of a named user Request Context). |
| systemUser() | Switches to a technical user and preserves the tenant from the current `UserInfo` (for example downgrade of a named user Request Context). |
| systemUser(tenant) | Switches to a technical user targeting a given subscriber account. |
| anonymousUser() | Switches to an anonymous user. |
| privilegedUser() | Elevates the current `UserInfo` to by-pass all authorization checks. |
Expand Down Expand Up @@ -181,7 +181,8 @@ The application is using a job scheduler that needs to regularly perform tasks o

```java
runtime.requestContext().systemUser(tenant).run(reqContext -> {
return persistenceService.run(Select.from(Books_.class)).listOf(Books.class);
return persistenceService.run(Select.from(Books_.class))
.listOf(Books.class);
});
```
## Modifying Request Contexts { #modifying-requestcontext}
Expand All @@ -193,7 +194,8 @@ List<Books> readBooksNotLocalized(EventContext context) {
return context.getCdsRuntime().requestContext()
.modifyParameters(param -> param.setLocale(null))
.run(newContext -> {
return persistenceService.run(Select.from(Books_.class)).listOf(Books.class);
return persistenceService.run(Select.from(Books_.class))
.listOf(Books.class);
});
}
```
Expand Down
Loading