Skip to content

Commit f4f69cf

Browse files
author
TanyaEf
committed
Resolving conflicts with develop
2 parents 0ecfba9 + 1024447 commit f4f69cf

File tree

56 files changed

+746
-512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+746
-512
lines changed

README.md

Lines changed: 107 additions & 19 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).
@@ -107,7 +109,7 @@ Table of Contents
107109
12. [Thumbnail Search Service](#thumbnail-search-service).
108110
13. [Query executor service](#queryexecutor-service).
109111
14. [REST Server Information](#rest-server-information).
110-
15. [Internalization](#internalization).
112+
15. [Bundles service](#bundles-service).
111113
16. [Exception handling](#exception-handling).
112114
17. [Asynchronous API](#asynchronous-api).
113115
18. [Getting serialized content from response](#getting-serialized-content-from-response).
@@ -151,6 +153,12 @@ TrustManager[] trustManagers = new TrustManager[1];
151153
trustManagers[0] = x509TrustManager;
152154
configuration.setTrustManagers(trustManagers);
153155
```
156+
####X-HTTP-Method override
157+
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`:
158+
```java
159+
session.getStorage().getConfiguration().setRestrictedHttpMethods(true);
160+
```
161+
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.
154162
####Client instantiation:
155163
Here everything is easy, you need just to pass `configuration` to `JasperserverRestClient` constructor.
156164
```java
@@ -165,16 +173,20 @@ Session session = client.authenticate("jasperadmin", "jasperadmin");
165173
//authentication with multitenancy enabled
166174
Session session = client.authenticate("jasperadmin|organization_1", "jasperadmin");
167175
```
168-
`JasperserverRestClient` supports three authentication types: REST, SPRING and BASIC.
169-
`REST` type of authentication means that your credentials are sent through `/rest/login`, and in the `SPRING` mode – through `/j_security_check directly/`. Using these types you obtain JSESSIONID cookie of authenticated session after sending credentials.
176+
`JasperserverRestClient` supports two authentication types: SPRING and BASIC.
177+
`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.
170178
In the `BASIC` mode `JasperserverRestClient` uses basic authentication (sends encrypted credentials with each request).
171-
Client uses `REST` authentication by default but you can change the mode using follow code:
179+
Client uses `SPRING` authentication by default but you can specify authentication type in RestClientConfiguration instance:
172180
```java
173181
config.setAuthenticationType(AuthenticationType.SPRING);
174182
```
175-
Or specify authentication type in RestClientConfiguration instance (for details, read section [Configuration](https://github.com/Jaspersoft/jrs-rest-java-client/blob/master/README.md#configuration).
176-
Please notice, the basic authentication is not stateless and it is valid till method logout() is called or the application is restarted.
177-
183+
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)).
184+
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 authentication (for details, read section [Configuration](https://github.com/Jaspersoft/jrs-rest-java-client/blob/master/README.md#report-services)).
185+
###Anonymous session
186+
For some Jasperserver services authentication is not required (for example, settings service and server info service), so you can use anonymous session:
187+
```java
188+
AnonymousSession session = client.getAnonymousSession();
189+
```
178190
####Invalidating session
179191
Not to store session on server you can invalidate it with `logout()` method.
180192
```java
@@ -202,6 +214,30 @@ OperationResult<InputStream> result = client
202214
.run();
203215
InputStream report = result.getEntity();
204216
```
217+
You can set format of report as String as well(name of format is case insensitive):
218+
```java
219+
OperationResult<InputStream> result = client
220+
.authenticate("jasperadmin", "jasperadmin")
221+
.reportingService()
222+
.report("/reports/samples/Cascading_multi_select_report")
223+
.prepareForRun("HTML", 1)
224+
.parameter("Cascading_name_single_select", "A & U Stalker Telecommunications, Inc")
225+
.run();
226+
```
227+
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):
228+
```java
229+
OperationResult<InputStream> result = client
230+
.authenticate("superuser", "superuser")
231+
.reportingService()
232+
.report("/reports/samples/Cascading_multi_select_report")
233+
.prepareForRun(ReportOutputFormat.PDF, 1)
234+
.parameter("Cascading_state_multi_select", "CA")
235+
.parameter("Cascading_state_multi_select", "OR", "WA")
236+
.parameter("Cascading_name_single_select", "Adams-Steen Transportation Holdings")
237+
.parameter("Country_multi_select", "USA")
238+
.run();
239+
```
240+
Please notice, if you pass zero as number of page, you will get all pages of report.
205241
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.
206242

207243
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:
@@ -211,7 +247,7 @@ ReportExecutionRequest request = new ReportExecutionRequest();
211247
request.setReportUnitUri("/reports/samples/StandardChartsReport");
212248
request
213249
.setAsync(true) //this means that report will be run on server asynchronously
214-
.setOutputFormat("html"); //report can be requested in different formats e.g. html, pdf, etc.
250+
.setOutputFormat(ReportOutputFormat.HTML); //report can be requested in different formats e.g. html, pdf, etc.
215251

216252
OperationResult<ReportExecutionDescriptor> operationResult =
217253
session //pay attention to this, all requests are in the same session!!!
@@ -221,6 +257,14 @@ OperationResult<ReportExecutionDescriptor> operationResult =
221257
reportExecutionDescriptor = operationResult.getEntity();
222258
```
223259
In the above code we've created `ReportExecutionRequest` instance and sent it to JR server through the `newReportExecutionRequest` method. As a response we've got `OperationResult` instance which contains HTTP response wrapper and instance of `ReportExecutionDescriptor` which we can get with `operationResult.getEntity()`.
260+
Also you can set output format as String:
261+
```java
262+
ReportExecutionRequest request = new ReportExecutionRequest();
263+
request.setReportUnitUri("/reports/samples/StandardChartsReport");
264+
request
265+
.setAsync(true)
266+
.setOutputFormat("html");
267+
```
224268
####Requesting report execution status:
225269
After you've got `ReportExecutionDescriptor` you can request for the report execution status:
226270
```java
@@ -279,7 +323,7 @@ for(AttachmentDescriptor attDescriptor : htmlExportDescriptor.getAttachments()){
279323
After running a report and downloading its content in a given format, you can request the same report in other formats. As with exporting report formats through the user interface, the report does not run again because the export process is independent of the report.
280324
```java
281325
ExportExecutionOptions exportExecutionOptions = new ExportExecutionOptions()
282-
.setOutputFormat("pdf")
326+
.setOutputFormat(ReportOutputFormat.PDF)
283327
.setPages("3");
284328

285329
OperationResult<ExportExecutionDescriptor> operationResult =
@@ -402,7 +446,8 @@ To create an organization, put all information in an organization descriptor, an
402446
```java
403447
Organization organization = new Organization();
404448
organization.setAlias("myOrg1");
405-
449+
```
450+
``java
406451
OperationResult<Organization> result = session
407452
.organizationsService()
408453
.organizations()
@@ -842,18 +887,25 @@ Settings Service
842887

843888
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.
844889

845-
####Getting settings
846-
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.
847-
890+
####Getting server specific settings
891+
To get settings, use the `getEntity()` method and specify the group of settings in the `group()` method and class of entity as shown below. The method `getEntity()` returns instance of specified class:
848892
```java
849893
final Map settings = session
850894
.settingsService()
851895
.settings()
852-
.group(group)
896+
.group(group, Map.class)
853897
.getEntity();
854898

855899
```
856-
Supported groups are:
900+
Please notice, you can get settings of user’s time zones in this way as List only:
901+
```java
902+
final List settings = session
903+
.settingsService()
904+
.settings()
905+
.group("userTimeZones", List.class)
906+
.getEntity();
907+
```
908+
Supported groups of settings are:
857909

858910
1. “request”. Settings related to current AJAX request configuration. Returned settings are: maxInactiveInterval, contextPath;
859911

@@ -877,6 +929,42 @@ Supported groups are:
877929

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

932+
There is another way to get settings using specified methods for groups of settings that return specific object of settings:
933+
```java
934+
Final RequestSettings settings = session
935+
.settingsService()
936+
.settings()
937+
.ofRequestGroup()
938+
.getEntity();
939+
```
940+
Pleace notice, you should use List interface to get user’s time zones setting in this way:
941+
```java
942+
final List<UserTimeZone> settings = session
943+
.settingsService()
944+
.settings()
945+
.ofUserTimeZonesGroup()
946+
.getEntity();
947+
```
948+
Or you can get List of specified DTO for user’s time zones using GenericType class:
949+
```java
950+
final List<UserTimeZone> settings = session
951+
.settingsService()
952+
.settings()
953+
.group("userTimeZones", new GenericType<List<UserTimeZone>>() {})
954+
.getEntity();
955+
```
956+
Supported specified methods are:
957+
```java
958+
OperationResult<RequestSettings> ofRequestGroup();
959+
OperationResult<DataSourcePatternsSettings> ofDataSourcePatternsGroup();
960+
OperationResult<List<UserTimeZone>> ofUserTimeZonesGroup();
961+
OperationResult<AwsSettings> ofAwsGroup();
962+
OperationResult<DecimalFormatSymbolsSettings> ofDecimalFormatSymbolsGroup();
963+
OperationResult<DashboardSettings> ofDashboardGroup();
964+
OperationResult<GlobalConfigurationSettings> ofGlobalConfigurationGroup();
965+
OperationResult<DateTimeSettings> ofDateTimeGroup();
966+
OperationResult<InputControlsSettings> ofInputControlsGroup();
967+
```
880968

881969
Repository Services
882970
=====================
@@ -1484,13 +1572,13 @@ OperationResult<String> result = client
14841572

14851573
String edition = result.getEntity();
14861574
```
1487-
###Internalization
1575+
###Bundles service
14881576
Use bundles service to get bundles of internalization properties for particular or default user’s locale as JSON. To get all bundles for particular locale(foe example, "de") use the code below:
14891577
```java
14901578
final JSONObject bundles = session
14911579
.bundlesService()
14921580
.forLocale("de")
1493-
.bundles()
1581+
.allBundles()
14941582
.getEntity();
14951583
```
14961584
If you pass `null` in `.forLocale()` method, you will get bundles for your default locale.
@@ -1499,7 +1587,7 @@ To get bundle by name you should specified locale in `.forLocale()` method and n
14991587
final JSONObject bundle = session
15001588
.bundlesService()
15011589
.forLocale("en_US")
1502-
.bundles("jasperserver_messages")
1590+
.bundle("jasperserver_messages")
15031591
.getEntity();
15041592
```
15051593
###Exception handling

Vagrantfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved.
3+
# http://www.jaspersoft.com.
4+
#
5+
# Unless you have purchased a commercial license agreement from Jaspersoft,
6+
# the following license terms apply:
7+
#
8+
# This program is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU Affero General Public License as
10+
# published by the Free Software Foundation, either version 3 of the
11+
# License, or (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU Affero General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU Affero General Public License
19+
# along with this program.&nbsp; If not, see <http://www.gnu.org/licenses/>.
20+
#
21+
22+
Vagrant.configure(2) do |config|
23+
24+
config.vm.box = "JasperSoft/JasperServer6.1.0"
25+
config.vm.box_check_update = false
26+
config.ssh.pty = true
27+
28+
config.vm.network "forwarded_port", guest: 8080, host: 8090
29+
config.vm.network "forwarded_port", guest: 5432, host: 5430
30+
31+
config.vm.provision "shell", inline: "su vagrant -l -c '/bin/sh /home/vagrant/jasperreports-server-cp-6.1.0/ctlscript.sh start'"
32+
33+
end

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@
169169
<artifactId>maven-compiler-plugin</artifactId>
170170
<version>3.1</version>
171171
<configuration>
172-
<source>1.7</source>
173-
<target>1.7</target>
172+
<source>1.6</source>
173+
<target>1.6</target>
174174
</configuration>
175175
</plugin>
176176
<plugin>

src/integration-test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/ServerAttributesServiceIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.attributes;
22

3-
import com.jaspersoft.jasperserver.jaxrs.client.core.JRSVersion;
3+
import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion;
44
import com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient;
5-
import com.jaspersoft.jasperserver.jaxrs.client.core.MimeType;
5+
import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType;
66
import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration;
77
import com.jaspersoft.jasperserver.jaxrs.client.core.Session;
88
import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.NullEntityOperationResult;

src/integration-test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersServiceIT.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users;
22

33
import com.jaspersoft.jasperserver.dto.authority.ClientUser;
4-
import com.jaspersoft.jasperserver.jaxrs.client.core.*;
4+
import com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient;
5+
import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration;
6+
import com.jaspersoft.jasperserver.jaxrs.client.core.Session;
7+
import com.jaspersoft.jasperserver.jaxrs.client.core.enums.AuthenticationType;
8+
import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion;
9+
import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType;
10+
import java.util.List;
511
import org.testng.Assert;
612
import org.testng.annotations.AfterMethod;
713
import org.testng.annotations.BeforeMethod;
814
import org.testng.annotations.Test;
915

10-
import java.util.List;
11-
1216
/**
1317
* @author Alexander Krasnyanskiy
1418
*/
@@ -26,15 +30,17 @@ public void before() {
2630
config.setJrsVersion(JRSVersion.v6_0_1);
2731
config.setIsJerseyRequestLogged(true);
2832
// config.setIsJSonEntitieLogged(true);
29-
config.setAuthenticationType(AuthenticationType.REST);
3033
client = new JasperserverRestClient(config);
34+
3135
session = client.authenticate("superuser", "superuser");
3236
}
3337

3438
@Test
3539
public void shouldReturnAllUsers() {
3640

41+
3742
//When
43+
3844
List<ClientUser> users = session
3945
.usersService()
4046
.allUsers()
@@ -58,6 +64,7 @@ public void should_return_list_users_by_role() {
5864
.getUserList();
5965

6066
//Then
67+
6168
Assert.assertTrue(users.size() > 3);
6269
}
6370

src/integration-test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/bundles/BundlesServiceIT.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.bundles;
22

33
import com.jaspersoft.jasperserver.jaxrs.client.core.*;
4+
import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion;
5+
import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType;
46
import org.codehaus.jettison.json.JSONObject;
57
import org.testng.annotations.BeforeMethod;
68
import org.testng.annotations.Test;
@@ -34,7 +36,7 @@ public void should_return_all_bundles_for_default_locale() {
3436
final JSONObject bundles = session
3537
.bundlesService()
3638
.forLocale(null)
37-
.bundles()
39+
.allBundles()
3840
.getEntity();
3941

4042
// Then
@@ -49,7 +51,7 @@ public void should_return_all_bundles_for_specified_locale() {
4951
final JSONObject bundles = session
5052
.bundlesService()
5153
.forLocale("de")
52-
.bundles()
54+
.allBundles()
5355
.getEntity();
5456

5557
// Then
@@ -64,7 +66,7 @@ public void should_return__bundle_by_name_for_specified_locale() {
6466
final JSONObject bundle = session
6567
.bundlesService()
6668
.forLocale("de")
67-
.bundles("jasperserver_messages")
69+
.bundle("jasperserver_messages")
6870
.getEntity();
6971

7072
// Then
@@ -79,7 +81,7 @@ public void should_return__bundle_by_name_for_default_locale() {
7981
final JSONObject bundle = session
8082
.bundlesService()
8183
.forLocale(null)
82-
.bundles("jasperserver_messages")
84+
.bundle("jasperserver_messages")
8385
.getEntity();
8486

8587
// Then

0 commit comments

Comments
 (0)