Skip to content

Commit e482d07

Browse files
author
TanyaEf
committed
Merge branch 'readmeUpdate' into 411error
2 parents b528864 + e745f4e commit e482d07

File tree

1 file changed

+76
-6
lines changed

1 file changed

+76
-6
lines changed

README.md

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ Table of Contents
1010
* [Loading configuration from file](#loading-configuration-from-file).
1111
* [Creation of manual configuration](#creation-of-manual-configuration).
1212
* [HTTPS configuration](#https-configuration).
13+
* [X-HTTP-Method override](#x-http-method-override).
1314
* [Client instantiation](#client-instantiation).
1415
3. [Authentication](#authentication).
16+
* [Anonymous session](#anonymous-session).
1517
* [Invalidating session](#invalidating-session).
1618
4. [Report services](#report-services).
1719
* [Running a report](#running-a-report).
@@ -58,7 +60,7 @@ Table of Contents
5860
* [Setting Role Membership](#setting-role-membership).
5961
* [Deleting a Role](#deleting-a-role).
6062
5. [The Settings Service](#settings-service).
61-
* [Getting server specific settings](#getting-settings).
63+
* [Getting server specific settings](#getting-server-specific-settings).
6264
7. [Repository Services](#repository-services).
6365
1. [Resources Service](#resources-service).
6466
* [Searching the Repository](#searching-the-repository).
@@ -149,6 +151,12 @@ TrustManager[] trustManagers = new TrustManager[1];
149151
trustManagers[0] = x509TrustManager;
150152
configuration.setTrustManagers(trustManagers);
151153
```
154+
####X-HTTP-Method override
155+
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`:
156+
```java
157+
session.getStorage().getConfiguration().setRestrictedHttpMethods(true);
158+
```
159+
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.
152160
####Client instantiation:
153161
Here everything is easy, you need just to pass `configuration` to `JasperserverRestClient` constructor.
154162
```java
@@ -163,6 +171,11 @@ Session session = client.authenticate("jasperadmin", "jasperadmin");
163171
//authentication with multitenancy enabled
164172
Session session = client.authenticate("jasperadmin|organization_1", "jasperadmin");
165173
```
174+
###Anonymous session
175+
For some Jasperserver services authentication is not required (for example, settings service and server info service), so you can use anonymous session:
176+
```java
177+
AnonymousSession session = client.getAnonymousSession();
178+
```
166179
####Invalidating session
167180
Not to store session on server you can invalidate it with `logout()` method.
168181
```java
@@ -190,6 +203,19 @@ OperationResult<InputStream> result = client
190203
.run();
191204
InputStream report = result.getEntity();
192205
```
206+
Also you can use this method to run report with several values for the same parameter. In this case new values of the parameter are added to the previous ones (new values do not replace previous values of the parameter):
207+
```java
208+
OperationResult<InputStream> result = client
209+
.authenticate("superuser", "superuser")
210+
.reportingService()
211+
.report("/reports/samples/Cascading_multi_select_report")
212+
.prepareForRun(ReportOutputFormat.PDF, 1)
213+
.parameter("Cascading_state_multi_select", "CA")
214+
.parameter("Cascading_state_multi_select", "OR", "WA")
215+
.parameter("Cascading_name_single_select", "Adams-Steen Transportation Holdings")
216+
.parameter("Country_multi_select", "USA")
217+
.run();
218+
```
193219
In this mode you don't need to work in one session. In the above code we specified report URI, format in which we want to get a report and some report parameters. As we a result we got `InputStream` instance. In synchronous mode as a response you get a report itself while in asynchronous you get just a descriptor with report ID which you can use to download report afer it will be ready.
194220

195221
In order to run a report in asynchronous mode, you need firstly build `ReportExecutionRequest` instance and specify all the parameters needed to launch a report. The response from the server is the `ReportExecutionDescriptor` instance which contains the request ID needed to track the execution until completion and others report parameters. Here's the code to run a report:
@@ -390,7 +416,8 @@ To create an organization, put all information in an organization descriptor, an
390416
```java
391417
Organization organization = new Organization();
392418
organization.setAlias("myOrg1");
393-
419+
```
420+
``java
394421
OperationResult<Organization> result = session
395422
.organizationsService()
396423
.organizations()
@@ -830,17 +857,24 @@ Settings Service
830857

831858
It provides method that allow you to get server specific settings, required by UI to work with the server in sync. There can be formats and patterns, modes for some modules etc.
832859

833-
####Getting settings
834-
To get settings, use the `getEntity()` method and specify the group of settings in the `group()` method. The method `getEntity()` returns map of settings where the keys in the map are names of the settings and values can be any objects.
835-
860+
####Getting server specific settings
861+
To get settings, use the getEntity() method and specify the group of settings in the group() method and class of entity. The method getEntity() returns instance of specified class:
836862
```java
837863
final Map settings = session
838864
.settingsService()
839865
.settings()
840-
.group(group)
866+
.group(group, Map.class)
841867
.getEntity();
842868

843869
```
870+
Please notice, you can get settings of user’s time zones in this way as List only:
871+
```java
872+
final List settings = session
873+
.settingsService()
874+
.settings()
875+
.group("userTimeZones", List.class)
876+
.getEntity();
877+
```
844878
Supported groups are:
845879

846880
1. “request”. Settings related to current AJAX request configuration. Returned settings are: maxInactiveInterval, contextPath;
@@ -865,6 +899,42 @@ Supported groups are:
865899

866900
11. “adhocview”. Different configuration dictionary values and lists for ad hoc. Configuration of settings depends on configuration of Jaspersoft server.
867901

902+
There is another way to get settings using specified methods for groups of settings that return specific object of settings:
903+
```java
904+
Final RequestSettings settings = session
905+
.settingsService()
906+
.settings()
907+
.ofRequestGroup()
908+
.getEntity();
909+
```
910+
Pleace notice, you should use List interface to get user’s time zones setting in this way:
911+
```java
912+
final List<UserTimeZone> settings = session
913+
.settingsService()
914+
.settings()
915+
.ofUserTimeZonesGroup()
916+
.getEntity();
917+
```
918+
Or you can get List of specified DTO for user’s time zones using GenericType class:
919+
```java
920+
final List<UserTimeZone> settings = session
921+
.settingsService()
922+
.settings()
923+
.group("userTimeZones", new GenericType<List<UserTimeZone>>() {})
924+
.getEntity();
925+
```
926+
Supported specified methods are:
927+
```java
928+
OperationResult<RequestSettings> ofRequestGroup();
929+
OperationResult<DataSourcePatternsSettings> ofDataSourcePatternsGroup();
930+
OperationResult<List<UserTimeZone>> ofUserTimeZonesGroup();
931+
OperationResult<AwsSettings> ofAwsGroup();
932+
OperationResult<DecimalFormatSymbolsSettings> ofDecimalFormatSymbolsGroup();
933+
OperationResult<DashboardSettings> ofDashboardGroup();
934+
OperationResult<GlobalConfigurationSettings> ofGlobalConfigurationGroup();
935+
OperationResult<DateTimeSettings> ofDateTimeGroup();
936+
OperationResult<InputControlsSettings> ofInputControlsGroup();
937+
```
868938

869939
Repository Services
870940
=====================

0 commit comments

Comments
 (0)