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
Here is example of `configuration.properties` file:
139
144
```java
140
-
url=http://localhost:4444/jasperserver-pro
141
-
connectionTimeout=100
145
+
// required content
146
+
url=http://localhost:8080/jasperserver-pro
147
+
// optional content
148
+
connectionTimeout=20
142
149
readTimeout=20
143
150
jasperserverVersion=v6_0_0
144
-
authenticationType=REST
151
+
authenticationType=SPRING
145
152
logHttp=true
146
-
logHttpEntity=false
153
+
logHttpEntity=true
147
154
restrictedHttpMethods=false
148
155
handleErrors=true
149
156
contentMimeType=JSON
150
157
acceptMimeType=JSON
151
158
```
152
159
File must contain at least URL which is entry point to your server's REST services and it is needed to URL corresponds to this pattern `{protocol}://{host}:{port}/{contextPath}`.
160
+
Please notice, configuration settings may be changed after loading manually in java code.
153
161
####Creation of manual configuration
154
162
To configure `JasperserverRestClient` manually, use the constructor of `RestClientConfiguration` and properties:
To avoid situation, when your proxies or web services do not support arbitrary HTTP methods or newer HTTP methods, you can use “restricted mode”. In this mode `JaperserverRestClient` sends requests through POST method and set the `X-HTTP-Method-Override` header with value of intended HTTP method. To use this mode you should set flag `RestrictedHttpMethods`:
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
191
+
####Switching authentication type
192
+
`JasperserverRestClient` supports two authentication types:SPRING and BASIC.
193
+
`SPRING` type of authentication means that your credentials are sent as a form to `/j_security_check directly/` uri. Using these types you obtain JSESSIONID cookie of authenticated session after sending credentials.
194
+
In the `BASIC` mode `JasperserverRestClient` uses basic authentication (sends encrypted credentials with each request).
195
+
Client uses `SPRING` authentication by default but you can specify authentication type in RestClientConfiguration instance:
Please notice, the basic authentication is not stateless and it is valid till method logout() is called or the application is restarted and you can not use this authentication type for Report Service, because all operations must be executed in the same session (for details, read section [Report services](https://github.com/Jaspersoft/jrs-rest-java-client/blob/master/README.md#report-services)).
206
+
####Exception handling
181
207
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.
208
+
1. handling of errors directly. This mode is allowed by default.
183
209
2. getting operation result in any case with null entity and handling error after calling `getEntity()` method:
184
210
```java
185
211
OperationResult<InputStream> result = session
@@ -193,18 +219,50 @@ To apply the second strategy set `handleErrors` property of `RestCleintConfigura
193
219
```java
194
220
configuration.setHandleErrors(false);
195
221
```
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
-
222
+
or specify this property in configuration file:
223
+
```java
224
+
handleErrors=true
225
+
```
198
226
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
227
200
228
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
229
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)`.
230
+
1. Existed handlers:
231
+
*`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.
232
+
2. You can create your own handler by implementing `com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.ErrorHandler`.
233
+
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)`.
234
+
235
+
####Logging
236
+
It is possible to log outgoing requests and incoming responses using `logHttp` property of `RestCleintConfiguration`:
237
+
```java
238
+
config.setLogHttp(true);
239
+
```
240
+
Also, you are able to log entities using `logHttpEntity` option:
241
+
```java
242
+
config.setLogHttpEntity(true).
243
+
```
244
+
In configuration file:
245
+
```java
246
+
logHttp=true
247
+
logHttpEntity=true
248
+
249
+
####Switching between JSON and XML
250
+
You can configure a client to make request either with JSON or XML content.
`JasperserverRestClient` supports two authentication types: SPRING and BASIC.
221
-
`SPRING` type of authentication means that your credentials are sent as a form to `/j_security_check directly/` uri. Using these types you obtain JSESSIONID cookie of authenticated session after sending credentials.
222
-
In the `BASIC` mode `JasperserverRestClient` uses basic authentication (sends encrypted credentials with each request).
223
-
Client uses `SPRING` authentication by default but you can specify authentication type in RestClientConfiguration instance:
Or set authentication type in configuration file (for details, read section [Configuration](https://github.com/Jaspersoft/jrs-rest-java-client/blob/master/README.md#configuration)).
228
-
Please notice, the basic authentication is not stateless and it is valid till method logout() is called or the application is restarted and you can not use this authentication type for Report Service, because all operations must be executed in the same session (for details, read section [Report services](https://github.com/Jaspersoft/jrs-rest-java-client/blob/master/README.md#report-services)).
229
278
###Anonymous session
230
279
For some Jasperserver services authentication is not required (for example, settings service, bundles service or server info service), so you can use anonymous session:
231
280
```java
@@ -1778,35 +1827,6 @@ OperationResult<UsersListWrapper> result = ...
1778
1827
result.getSerializedContent();
1779
1828
```
1780
1829
1781
-
###Switching between JSON and XML
1782
-
You can configure a client to make request either with JSON or XML content.
1783
-
```java
1784
-
RestClientConfiguration configuration = new RestClientConfiguration("http://localhost:4444/jasperserver");
It is possible to log outgoing requests and incoming responses using `logHttp` property of `RestCleintConfiguration`:
1802
-
```java
1803
-
config.setLogHttp(true);
1804
-
```
1805
-
Also, you are able to log entities using `logHttpEntity` option:
1806
-
```java
1807
-
config.setLogHttpEntity(true).
1808
-
```
1809
-
1810
1830
###Possible issues
1811
1831
1. <strong>Deploying jrs-rest-client within web app to any Appplication Server, e.g. JBoss, Glassfish, WebSphere etc.</strong>
1812
1832
jrs-rest-client uses the implementation of JAX-RS API of version 2.0 and if your application server does not support this version you will get an error. To solve this problem you need to add to your application a deployment configuration specific for your AS where you need to exclude modules with old JAX-RS API version. Example of such descriptor for JBoss AS you can find below:
0 commit comments