You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you do not use the "restricted mode", POST or GET methods and server returns the response with 411 error code, `JaperserverRestClient` resend this request through POST method with the X-HTTP-Method-Override header automatically.
179
+
180
+
###Exception handling
181
+
You can choose strategy of errors that are specified by status code of server response:
182
+
1. handling of errors directly. This is allied by default.
183
+
2. getting operation result in any case with null entity and handling error after calling `getEntity()` method:
184
+
```java
185
+
OperationResult<InputStream> result = session
186
+
.thumbnailsService()
187
+
.thumbnail()
188
+
.report("/")
189
+
.get(); // response status is 406, but exception won't be thrown
190
+
result.getEntity(); // the error will be handled and an exception will be thrown
191
+
```
192
+
To apply the second strategy set `handleErrors` property of `RestCleintConfiguration` to `false`:
193
+
```java
194
+
configuration.setHandleErrors(false);
195
+
```
196
+
or specify this property in configuration file (for details, read section [Configuration](https://github.com/Jaspersoft/jrs-rest-java-client/blob/master/README.md#configuration)).
197
+
198
+
You can customize exception handling for each endpoint. To do this you need to pass `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.ErrorHandler` implementation to `JerseyRequestBuilder.buildRequest()` factory method.
199
+
200
+
JRS REST client exception handling system is based on `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.ErrorHandler` interface. Its `void handleError(Response response)` method is responsible for all error handling logic. You can use existed handlers, define your own handlers or extend existed handlers.
201
+
202
+
1. Existed handlers:
203
+
*`com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultExceptionHandler` - this implementation is suitable for most of the JRS errors, but sometimes you can meet some not standart errors and here such implementations as `com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobValidationErrorHandler`, `com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.RunReportErrorHandler`, etc. take responsibility.
204
+
2. You can create your own handler by implementing `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.ErrorHandler`.
205
+
3. You can extend `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultExceptionHandler` or any other handler and override its methods `void handleBodyError(Response response)` and/or `void handleStatusCodeError(Response response, String overridingMessage)`.
182
206
####Client instantiation:
183
207
Here everything is easy, you need just to pass `configuration` to `JasperserverRestClient` constructor.
184
208
```java
@@ -1727,32 +1751,6 @@ final Map<String, String> bundle = session
1727
1751
.bundle("jasperserver_messages")
1728
1752
.getEntity();
1729
1753
```
1730
-
###Exception handling
1731
-
You can choose strategy of errors that are specified by status code of server response:
1732
-
1. handling of errors directly. This is allied by default.
1733
-
2. getting operation result in any case with null entity and handling error after calling `getEntity()` method:
1734
-
```java
1735
-
OperationResult<InputStream> result = session
1736
-
.thumbnailsService()
1737
-
.thumbnail()
1738
-
.report("/")
1739
-
.get(); // response status is 406, but exception won't be thrown
1740
-
result.getEntity(); // the error will be handled and an exception will be thrown
1741
-
```
1742
-
To apply the second strategy set `handleErrors` property of `RestCleintConfiguration` to `false`:
1743
-
```java
1744
-
configuration.setHandleErrors(false);
1745
-
```
1746
-
or specify this property in configuration file (for details, read section [Configuration](https://github.com/Jaspersoft/jrs-rest-java-client/blob/master/README.md#configuration)).
1747
-
1748
-
You can customize exception handling for each endpoint. Todothis you need to pass `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.ErrorHandler` implementation to `JerseyRequestBuilder.buildRequest()` factory method.
1749
-
1750
-
JRSREST client exception handling system is based on `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.ErrorHandler` interface. Its `void handleError(Response response)` method is responsible for all error handling logic. You can use existed handlers, define your own handlers or extend existed handlers.
1751
-
1752
-
1.Existed handlers:
1753
-
* `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultExceptionHandler` -this implementation is suitable for most of the JRS errors, but sometimes you can meet some not standart errors and here such implementations as `com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobValidationErrorHandler`, `com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.RunReportErrorHandler`, etc. take responsibility.
1754
-
2.You can create your own handler by implementing `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.ErrorHandler`.
1755
-
3.You can extend `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultExceptionHandler` or any other handler and override its methods `void handleBodyError(Response response)` and/or `void handleStatusCodeError(Response response, String overridingMessage)`.
1756
1754
1757
1755
###Asynchronous API
1758
1756
Each operation which requests server has its asynchronous brother which has same name with `async` prefix, e. g. `get() -> asyncGet()`. Each of these operations take a `com.jaspersoft.jasperserver.jaxrs.client.core.Callback` implementation with `execute()` method implemented. `execute()` takes an `OperationResult` instance as a parameter. The `execute` method is called when the response from server came.
0 commit comments