Skip to content

Commit 37691a7

Browse files
authored
Provide exception API documentation (#1061)
To follow the reactive and functional style of the new service API, exceptions must not be thrown but provided wrapped as Mono or Flux.
1 parent 4d9e9b3 commit 37691a7

File tree

1 file changed

+69
-25
lines changed

1 file changed

+69
-25
lines changed

project-management/src/main/java/life/qbic/projectmanagement/application/api/AsyncProjectService.java

+69-25
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,22 @@ public interface AsyncProjectService {
4343
* <p>
4444
* The implementing class must also ensure to only return responses with classes implementing the
4545
* {@link ProjectUpdateResponseBody} interface.
46+
* <p>
47+
* <b>Exceptions</b>
48+
* <p>
49+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
50+
* the throw section below.
4651
*
4752
* @param request the request to update a project
4853
* @return a {@link Mono<ProjectUpdateResponse>} object publishing an
49-
* {@link ProjectUpdateResponse} on success.
54+
* {@link ProjectUpdateResponse} on success. Exceptions are provided as
55+
* {@link Mono#error(Throwable)}.
5056
* @throws UnknownRequestException if an unknown request has been used in the service call
5157
* @throws RequestFailedException if the request was not successfully executed
5258
* @throws AccessDeniedException if the user has insufficient rights
5359
* @since 1.9.0
5460
*/
55-
Mono<ProjectUpdateResponse> update(
56-
ProjectUpdateRequest request)
57-
throws UnknownRequestException, RequestFailedException, AccessDeniedException;
61+
Mono<ProjectUpdateResponse> update(ProjectUpdateRequest request);
5862

5963

6064
/**
@@ -68,27 +72,38 @@ Mono<ProjectUpdateResponse> update(
6872
* <p>
6973
* The implementing class must also ensure to only return responses with classes implementing the
7074
* {@link ProjectUpdateResponseBody} interface.
75+
* <p>
76+
* <b>Exceptions</b>
77+
* <p>
78+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
79+
* the throw section below.
7180
*
7281
* @param request the request to update a project
7382
* @return a {@link Mono<ProjectUpdateResponse>} object publishing an
74-
* {@link ProjectUpdateResponse} on success.
83+
* {@link ProjectUpdateResponse} on success. Exceptions are provided as
84+
* {@link Mono#error(Throwable)}.
7585
* @throws UnknownRequestException if an unknown request has been used in the service call
7686
* @throws RequestFailedException if the request was not successfully executed
7787
* @throws AccessDeniedException if the user has insufficient rights
7888
* @since 1.9.0
7989
*/
80-
Mono<ExperimentUpdateResponse> update(ExperimentUpdateRequest request)
81-
throws RequestFailedException, AccessDeniedException;
90+
Mono<ExperimentUpdateResponse> update(ExperimentUpdateRequest request);
8291

8392
/**
8493
* Submits a project creation request and returns a {@link Mono< ProjectCreationResponse >}
8594
* immediately.
8695
* <p>
8796
* This implementation must be non-blocking.
97+
* <p>
98+
* <b>Exceptions</b>
99+
* <p>
100+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
101+
* the throw section below.
88102
*
89103
* @param request the request with information required for project creation.
90104
* @return {@link Mono<ProjectCreationResponse>} object publishing an
91-
* {@link ProjectCreationResponse} on success.
105+
* {@link ProjectCreationResponse} on success. Exceptions are provided as
106+
* {@link Mono#error(Throwable)}.
92107
* @throws UnknownRequestException if an unknown request has been used in the service call
93108
* @throws RequestFailedException if the request was not successfully executed
94109
* @throws AccessDeniedException if the user has insufficient rights
@@ -100,34 +115,54 @@ Mono<ProjectCreationResponse> create(ProjectCreationRequest request)
100115

101116
/**
102117
* Requests {@link SamplePreview} for a given experiment.
118+
* <p>
119+
* <b>Exceptions</b>
120+
* <p>
121+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
122+
* the throw section below.
103123
*
104124
* @param projectId the project ID for the project to get the samples for
105125
* @param experimentId the experiment ID for which the sample preview shall be retrieved
106-
* @return a reactive stream of {@link SamplePreview} objects of the experiment
126+
* @return a reactive stream of {@link SamplePreview} objects of the experiment. Exceptions are
127+
* provided as {@link Mono#error(Throwable)}.
107128
* @throws RequestFailedException if the request could not be executed
108129
* @since 1.10.0
109130
*/
110-
Flux<SamplePreview> getSamplePreviews(String projectId, String experimentId) throws RequestFailedException;
131+
Flux<SamplePreview> getSamplePreviews(String projectId, String experimentId)
132+
throws RequestFailedException;
111133

112134
/**
113135
* Requests {@link SamplePreview} for a given experiment with pagination support.
136+
* <p>
137+
* <b>Exceptions</b>
138+
* <p>
139+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
140+
* the throw section below.
114141
*
115142
* @param projectId the project ID for the project to get the samples for
116143
* @param experimentId the experiment ID for which the sample preview shall be retrieved
117144
* @param offset the offset from 0 of all available previews the returned previews should
118145
* start
119146
* @param limit the maximum number of previews that should be returned
120-
* @return a reactive stream of {@link SamplePreview} objects in the experiment
147+
* @return a reactive stream of {@link SamplePreview} objects in the experiment. Exceptions are
148+
* provided as {@link Mono#error(Throwable)}.
121149
* @since 1.10.0
122150
*/
123-
Flux<SamplePreview> getSamplePreviews(String projectId, String experimentId, int offset, int limit);
151+
Flux<SamplePreview> getSamplePreviews(String projectId, String experimentId, int offset,
152+
int limit);
124153

125154
/**
126155
* Requests all {@link Sample} for a given experiment.
156+
* <p>
157+
* <b>Exceptions</b>
158+
* <p>
159+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
160+
* the throw section below.
127161
*
128162
* @param projectId the project ID for the project to get the samples for
129163
* @param experimentId the experiment ID for which the samples shall be retrieved
130-
* @return a reactive stream of {@link Sample} objects
164+
* @return a reactive stream of {@link Sample} objects. Exceptions are provided as
165+
* {@link Mono#error(Throwable)}.
131166
* @throws RequestFailedException in case the request cannot be executed
132167
* @since 1.10.0
133168
*/
@@ -136,20 +171,33 @@ Mono<ProjectCreationResponse> create(ProjectCreationRequest request)
136171
/**
137172
* Requests all {@link Sample} for a given batch
138173
*
174+
* <p>
175+
* <b>Exceptions</b>
176+
* <p>
177+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
178+
* the throw section below.
179+
*
139180
* @param projectId the project ID for the project to get the samples for
140181
* @param batchId the batch ID the samples shall be retrieved for
141-
* @return a reactive stream of {@link Sample} objects for the given batch
182+
* @return a reactive stream of {@link Sample} objects for the given batch. Exceptions are
183+
* provided as {@link Mono#error(Throwable)}.
142184
* @throws RequestFailedException in case the request cannot be executed
143185
* @since 1.10.0
144186
*/
145187
Flux<Sample> getSamplesForBatch(String projectId, String batchId) throws RequestFailedException;
146188

147189
/**
148190
* Find the sample ID for a given sample code
191+
* <p>
192+
* <b>Exceptions</b>
193+
* <p>
194+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
195+
* the throw section below.
149196
*
150197
* @param projectId the project ID for the project to get the samples for
151198
* @param sampleCode the sample code (e.g. Q2TEST001AE) for the project
152-
* @return a reactive container of {@link SampleIdCodeEntry} for the sample code
199+
* @return a reactive container of {@link SampleIdCodeEntry} for the sample code. Exceptions are
200+
* provided as {@link Mono#error(Throwable)}.
153201
* @throws RequestFailedException in case the request cannot be executed
154202
* @since 1.10.0
155203
*/
@@ -278,10 +326,8 @@ record ExperimentalVariable(String name, Set<String> levels, @Nullable String un
278326
* @param experimentalVariables the list of experimental variables
279327
* @since 1.9.0
280328
*/
281-
record ExperimentalVariables(
282-
List<ExperimentalVariable> experimentalVariables) implements
283-
ExperimentUpdateRequestBody,
284-
ExperimentUpdateResponseBody {
329+
record ExperimentalVariables(List<ExperimentalVariable> experimentalVariables) implements
330+
ExperimentUpdateRequestBody, ExperimentUpdateResponseBody {
285331

286332
public ExperimentalVariables {
287333
experimentalVariables = List.copyOf(experimentalVariables);
@@ -326,8 +372,7 @@ record ExperimentalGroup(@Nullable Long groupId, String name, int sampleSize,
326372
* @since 1.9.0
327373
*/
328374
record ExperimentalGroups(List<ExperimentalGroup> experimentalGroups) implements
329-
ExperimentUpdateRequestBody,
330-
ExperimentUpdateResponseBody {
375+
ExperimentUpdateRequestBody, ExperimentUpdateResponseBody {
331376

332377
public ExperimentalGroups {
333378
experimentalGroups = List.copyOf(experimentalGroups);
@@ -384,8 +429,8 @@ record ConfoundingVariables(List<ConfoundingVariableInformation> confoundingVari
384429
* @since 1.9.0
385430
*/
386431
record ExperimentUpdateRequest(String projectId, String experimentId,
387-
ExperimentUpdateRequestBody body,
388-
String requestId) implements CacheableRequest {
432+
ExperimentUpdateRequestBody body, String requestId) implements
433+
CacheableRequest {
389434

390435
/**
391436
* A service request to update an experiment
@@ -487,8 +532,7 @@ record ProjectCreationResponse(String projectId) {
487532
* @since 1.9.0
488533
*/
489534
record ProjectUpdateRequest(String projectId, ProjectUpdateRequestBody requestBody,
490-
String id) implements
491-
CacheableRequest {
535+
String id) implements CacheableRequest {
492536

493537
public ProjectUpdateRequest(String projectId, ProjectUpdateRequestBody requestBody) {
494538
this(projectId, requestBody, UUID.randomUUID().toString());

0 commit comments

Comments
 (0)