Skip to content

Commit 8bde095

Browse files
author
TanyaEf
committed
Resolved conflicts in JasperserverRestClientTest
2 parents 1bd722b + 08f30c1 commit 8bde095

File tree

22 files changed

+239
-326
lines changed

22 files changed

+239
-326
lines changed

README.md

Lines changed: 77 additions & 7 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,18 +857,25 @@ 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 as shown below. 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
```
844-
Supported groups are:
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+
```
878+
Supported groups of settings are:
845879

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

@@ -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
=====================

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
@@ -153,8 +153,8 @@
153153
<artifactId>maven-compiler-plugin</artifactId>
154154
<version>3.1</version>
155155
<configuration>
156-
<source>1.7</source>
157-
<target>1.7</target>
156+
<source>1.6</source>
157+
<target>1.6</target>
158158
</configuration>
159159
</plugin>
160160
<plugin>

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ public class UsersServiceIT {
2020

2121
@BeforeMethod
2222
public void before() {
23-
config = new RestClientConfiguration("http://localhost:4444/jasperserver-pro");
24-
config.setAcceptMimeType(MimeType.JSON);
25-
config.setContentMimeType(MimeType.JSON);
26-
config.setJrsVersion(JRSVersion.v6_0_1);
27-
client = new JasperserverRestClient(config);
23+
24+
RestClientConfiguration cfg = new RestClientConfiguration("http://localhost:4444/jasperserver-pro");
25+
JasperserverRestClient client = new JasperserverRestClient(cfg);
26+
2827
session = client.authenticate("superuser", "superuser");
2928
}
3029

3130
@Test
3231
public void shouldReturnAllUsers() {
3332

33+
3434
//When
35+
3536
List<ClientUser> users = session
3637
.usersService()
3738
.allUsers()
@@ -55,6 +56,7 @@ public void should_return_list_users_by_role() {
5556
.getUserList();
5657

5758
//Then
59+
5860
Assert.assertTrue(users.size() > 3);
5961
}
6062

src/integration-test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourcesServiceIT.java

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

3-
import com.jaspersoft.jasperserver.dto.resources.ClientFolder;
4-
import com.jaspersoft.jasperserver.dto.resources.ClientResource;
5-
import com.jaspersoft.jasperserver.jaxrs.client.core.*;
6-
import junit.framework.Assert;
3+
import com.jaspersoft.jasperserver.jaxrs.client.core.JRSVersion;
4+
import com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient;
5+
import com.jaspersoft.jasperserver.jaxrs.client.core.MimeType;
6+
import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration;
7+
import com.jaspersoft.jasperserver.jaxrs.client.core.Session;
8+
import java.io.ByteArrayInputStream;
9+
import java.util.concurrent.TimeUnit;
10+
import javax.ws.rs.core.Response;
11+
import org.testng.Assert;
712
import org.testng.annotations.AfterMethod;
813
import org.testng.annotations.BeforeMethod;
914
import org.testng.annotations.Test;
1015

11-
import javax.ws.rs.core.Response;
12-
import java.io.ByteArrayInputStream;
13-
import java.util.concurrent.TimeUnit;
14-
1516
/**
1617
* @author Alexander Krasnyanskiy
1718
*/

src/integration-test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/settings/SettingsServiceIT.java

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

3-
import com.jaspersoft.jasperserver.jaxrs.client.core.*;
4-
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.*;
3+
import com.jaspersoft.jasperserver.jaxrs.client.core.AnonymousSession;
4+
import com.jaspersoft.jasperserver.jaxrs.client.core.JRSVersion;
5+
import com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient;
6+
import com.jaspersoft.jasperserver.jaxrs.client.core.MimeType;
7+
import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration;
8+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.AwsSettings;
9+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.DashboardSettings;
10+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.DataSourcePatternsSettings;
11+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.DateTimeSettings;
12+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.DecimalFormatSymbolsSettings;
13+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.GlobalConfigurationSettings;
14+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.InputControlsSettings;
15+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.RequestSettings;
16+
import com.jaspersoft.jasperserver.jaxrs.client.dto.settings.UserTimeZone;
17+
import java.util.List;
18+
import java.util.Map;
19+
import javax.ws.rs.core.GenericType;
520
import org.testng.annotations.AfterMethod;
621
import org.testng.annotations.BeforeMethod;
722
import org.testng.annotations.Test;
823

9-
import javax.ws.rs.core.GenericType;
10-
import java.util.List;
11-
import java.util.Map;
12-
1324
import static junit.framework.Assert.assertFalse;
1425
import static junit.framework.Assert.assertNotNull;
1526
import static junit.framework.Assert.assertSame;

src/integration-test/resoursec/daracouese_resp.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/integration-test/resoursec/global_settings_resp.json

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)