Skip to content

Commit 756cdaa

Browse files
Pushing 9.0.0 changes
Pushing 9.0.0 changes
1 parent ce3f488 commit 756cdaa

25 files changed

+3099
-3
lines changed

pom.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
<groupId>com.jaspersoft</groupId>
99
<artifactId>jrs-rest-java-client</artifactId>
10-
<version>8.2.0</version>
10+
<version>9.0.0</version>
1111
<name>REST client for JasperReports server</name>
1212
<url>http://github.com/Jaspersoft/jrs-rest-java-client</url>
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<jasperserver-dto.version>8.2.0</jasperserver-dto.version>
16+
<jasperserver-dto.version>9.0.0</jasperserver-dto.version>
1717
<powermock.version>2.0.9</powermock.version>
1818
<jersey.version>2.39</jersey.version>
1919
<jackson.version>2.13.5</jackson.version>
@@ -26,6 +26,11 @@
2626
</scm>
2727

2828
<repositories>
29+
<repository>
30+
<id>mvn-central</id>
31+
<name>Maven Central</name>
32+
<url>https://repo.maven.apache.org/maven2</url>
33+
</repository>
2934
<repository>
3035
<id>jaspersoft-clients-snapshots</id>
3136
<name>Jaspersoft clients snapshots</name>
@@ -36,6 +41,11 @@
3641
<name>jaspersoft-releases</name>
3742
<url>https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-releases</url>
3843
</repository>
44+
<repository>
45+
<id>branch-central</id>
46+
<name>jaspersoft-releases</name>
47+
<url>https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-snapshots</url>
48+
</repository>
3949
</repositories>
4050

4151
<dependencies>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting;
22+
23+
import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor;
24+
import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.ValidationException;
25+
import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler;
26+
import com.jaspersoft.jasperserver.jaxrs.client.dto.common.ValidationError;
27+
import com.jaspersoft.jasperserver.jaxrs.client.dto.common.ValidationErrorsListWrapper;
28+
29+
import javax.ws.rs.core.Response;
30+
import java.util.ArrayList;
31+
import java.util.List;
32+
33+
public class AlertValidationErrorHandler extends DefaultErrorHandler {
34+
35+
@Override
36+
protected void handleBodyError(Response response) {
37+
List<ErrorDescriptor> errorDescriptors;
38+
if (response.getHeaderString("Content-Type").contains("xml") || response.getHeaderString("Content-Type").contains("alert+json")) {
39+
ValidationErrorsListWrapper validationErrors = readBody(response, ValidationErrorsListWrapper.class);
40+
if (validationErrors == null) {
41+
super.handleBodyError(response);
42+
return;
43+
}
44+
errorDescriptors = toErrorDescriptorList(validationErrors);
45+
throw new ValidationException(generateErrorMessage(errorDescriptors), errorDescriptors);
46+
}
47+
super.handleBodyError(response);
48+
}
49+
50+
protected List<ErrorDescriptor> toErrorDescriptorList(ValidationErrorsListWrapper validationErrors) {
51+
List<ErrorDescriptor> errorDescriptors = new ArrayList<ErrorDescriptor>();
52+
List<ValidationError> errors = validationErrors.getErrors();
53+
for (ValidationError error : errors) {
54+
ErrorDescriptor errorDescriptor = new ErrorDescriptor();
55+
errorDescriptor.setMessage(error.toString() + " (field: " + error.getField() + ")");
56+
errorDescriptor.setErrorCode(error.getErrorCode());
57+
errorDescriptor.addParameters(error.getErrorArguments());
58+
errorDescriptors.add(errorDescriptor);
59+
}
60+
return errorDescriptors;
61+
}
62+
63+
private String generateErrorMessage(List<ErrorDescriptor> errorDescriptors) {
64+
StringBuilder sb = new StringBuilder();
65+
if (errorDescriptors != null) {
66+
for (ErrorDescriptor errorDescriptor : errorDescriptors) {
67+
String message = errorDescriptor.getMessage();
68+
sb.append("\n\t\t").append(message != null ? message : errorDescriptor.getErrorCode());
69+
}
70+
}
71+
return sb.toString();
72+
}
73+
}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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+
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting;
23+
24+
public enum AlertsParameter {
25+
26+
/**
27+
* URI of thumbnail inFolder schedule. Report
28+
* options URI can also be used
29+
* here
30+
*/
31+
SEARCH_RESOURCE_URI("resourceURI"),
32+
33+
/**
34+
* Name|Organization of the user,
35+
* who scheduled the job
36+
*/
37+
SEARCH_OWNER("owner"),
38+
39+
/**
40+
* Label of the jobs inFolder find.
41+
*/
42+
SEARCH_LABEL("label"),
43+
44+
/**
45+
* This argument defines the current state of a job.
46+
* The parameter accepts multiple values:
47+
* NORMAL
48+
* EXECUTING
49+
* PAUSED
50+
* COMPLETE
51+
* ERROR
52+
*/
53+
SEARCH_STATE("state"),
54+
55+
/**
56+
* Reserved, not implemented
57+
*/
58+
SEARCH_PREVIOUS_FIRE_TIME("previousFireTime"),
59+
60+
/**
61+
* Reserved, not implemented
62+
*/
63+
SEARCH_NEXT_FIRE_TIME("nextFireTime"),
64+
65+
/**
66+
* Pagination, start index
67+
*/
68+
SEARCH_START_INDEX("startIndex"),
69+
70+
/**
71+
* Pagination, results count in a
72+
* page
73+
*/
74+
SEARCH_NUMBER_OF_ROWS("numberOfRows"),
75+
76+
/**
77+
* Field name inFolder sort by.
78+
* Supported values:
79+
* NONE
80+
* SORTBY_JOBID
81+
* SORTBY_JOBNAME
82+
* SORTBY_REPORTURI
83+
* SORTBY_REPORTNAME
84+
* SORTBY_REPORTFOLDER
85+
* SORTBY_OWNER
86+
* SORTBY_STATUS
87+
* SORTBY_LASTRUN
88+
* SORTBY_NEXTRUN
89+
* SORTBY_RESOURCELABEL
90+
*/
91+
SEARCH_SORT_TYPE("sortType"),
92+
93+
/**
94+
* Sorting direction. Supported values:
95+
* true - ascending;
96+
* false - descending
97+
*/
98+
SEARCH_IS_ASCENDING("isAscending"),
99+
100+
/**
101+
* This argument defines the job id; jobID should be integer/long
102+
*/
103+
SEARCH_JOB_ID("jobID"),
104+
105+
/**
106+
* This argument defines the start of a range of time that matches if the job was previously triggered during this time.
107+
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
108+
*/
109+
SEARCH_PREVIOUS_FIRE_TIME_FROM("previousFireTimeFrom"),
110+
111+
/**
112+
* This argument defines the end of a range of time that matches if the job was previously triggered during this time.
113+
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
114+
*/
115+
SEARCH_PREVIOUS_FIRE_TIME_TO("previousFireTimeTo"),
116+
117+
/**
118+
* This argument defines the start of a range of time that matches if the job that is currently running was triggered during this time.
119+
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
120+
*/
121+
SEARCH_NEST_FIRE_TIME_FROM("nextFireTimeFrom"),
122+
123+
/**
124+
* This argument defines the end of a range of time that matches if the job that is currently running was triggered during this time.
125+
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
126+
*/
127+
SEARCH_NEST_FIRE_TIME_TO("nextFireTimeTo"),
128+
129+
/**
130+
* This argument defines the job label.
131+
*/
132+
SEARCH_JOB_LABEL("jobLabel"),
133+
134+
/**
135+
* This argument defines the Resource label.
136+
*/
137+
SEARCH_JOB_RESOURCE_LABEL("resourceLabel"),
138+
139+
/**
140+
* This argument defines the job description.
141+
*/
142+
SEARCH_JOB_DESCRIPTION("description"),
143+
144+
/**
145+
* Can be used multiple times inFolder createInFolder a list of jobIDs inFolder update
146+
*/
147+
JOB_ID("id"),
148+
149+
/**
150+
* When true, the trigger is replaced from the content being sent and the trigger
151+
* type is ignored. When false or omitted, the trigger is updated automatically
152+
* by the scheduler.
153+
*/
154+
UPDATE_REPLACE_TRIGGER_IGNORE_TYPE("replaceTriggerIgnoreType"),
155+
/**
156+
* Pagination. Start index for requested pate.
157+
*/
158+
OFFSET("offset"),
159+
160+
/**
161+
* Pagination. Resources count per page
162+
*/
163+
LIMIT("limit")
164+
;
165+
166+
private String name;
167+
168+
private AlertsParameter(String name) {
169+
this.name = name;
170+
}
171+
172+
173+
public String getName() {
174+
return name;
175+
}
176+
177+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting;
23+
24+
import com.jaspersoft.jasperserver.dto.alerting.ClientAlertCalendar;
25+
import com.jaspersoft.jasperserver.dto.alerting.ClientReportAlert;
26+
import com.jaspersoft.jasperserver.dto.alerting.wrappers.ClientCalendarNameListWrapper;
27+
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter;
28+
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting.calendar.SingleCalendarOperationsAdapter;
29+
import com.jaspersoft.jasperserver.jaxrs.client.core.*;
30+
import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult;
31+
32+
import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest;
33+
34+
public class AlertsService extends AbstractAdapter {
35+
36+
public static final String SERVICE_URI = "alerts";
37+
public static final String CALENDARS = "calendars";
38+
39+
public AlertsService(SessionStorage sessionStorage) {
40+
super(sessionStorage);
41+
}
42+
43+
public BatchAlertsOperationsAdapter alerts() {
44+
return new BatchAlertsOperationsAdapter(sessionStorage);
45+
}
46+
47+
public BatchAlertsOperationsAdapter alerts(Long... ids) {
48+
return new BatchAlertsOperationsAdapter(sessionStorage, ids);
49+
}
50+
51+
public SingleAlertOperationsAdapter alert(long id) {
52+
return new SingleAlertOperationsAdapter(sessionStorage, String.valueOf(id));
53+
}
54+
55+
public SingleAlertOperationsAdapter alert(ClientReportAlert reportAlert) {
56+
return new SingleAlertOperationsAdapter(sessionStorage, reportAlert);
57+
}
58+
59+
public OperationResult<ClientCalendarNameListWrapper> allCalendars() {
60+
return calendar((ClientAlertCalendar.Type) null);
61+
}
62+
63+
public <R> RequestExecution asyncCalendar(final Callback<OperationResult<ClientCalendarNameListWrapper>, R> callback) {
64+
return asyncCalendar(null, callback);
65+
}
66+
67+
public OperationResult<ClientCalendarNameListWrapper> calendar(ClientAlertCalendar.Type type) {
68+
JerseyRequest<ClientCalendarNameListWrapper> request = buildRequest(sessionStorage, ClientCalendarNameListWrapper.class, new String[]{SERVICE_URI, CALENDARS});
69+
if (type != null) {
70+
request.addParam("calendarType", type.name().toLowerCase());
71+
}
72+
return request.get();
73+
}
74+
75+
public <R> RequestExecution asyncCalendar(final ClientAlertCalendar.Type type, final Callback<OperationResult<ClientCalendarNameListWrapper>, R> callback) {
76+
final JerseyRequest<ClientCalendarNameListWrapper> request = buildRequest(sessionStorage, ClientCalendarNameListWrapper.class, new String[]{SERVICE_URI, CALENDARS});
77+
if (type != null) {
78+
request.addParam("calendarType", type.name().toLowerCase());
79+
}
80+
RequestExecution task = new RequestExecution(new Runnable() {
81+
@Override
82+
public void run() {
83+
callback.execute(request.get());
84+
}
85+
});
86+
ThreadPoolUtil.runAsynchronously(task);
87+
return task;
88+
}
89+
90+
public SingleCalendarOperationsAdapter calendar(String calendarName) {
91+
if ("".equals(calendarName) || "/".equals(calendarName)) {
92+
throw new IllegalArgumentException("'calendarName' mustn't be an empty string");
93+
}
94+
return new SingleCalendarOperationsAdapter(sessionStorage, calendarName);
95+
}
96+
97+
}

0 commit comments

Comments
 (0)