Skip to content

Commit

Permalink
Pushing 9.0.0 changes
Browse files Browse the repository at this point in the history
Pushing 9.0.0 changes
  • Loading branch information
hguntupa-tibco committed Jan 25, 2024
1 parent ce3f488 commit 756cdaa
Show file tree
Hide file tree
Showing 25 changed files with 3,099 additions and 3 deletions.
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

<groupId>com.jaspersoft</groupId>
<artifactId>jrs-rest-java-client</artifactId>
<version>8.2.0</version>
<version>9.0.0</version>
<name>REST client for JasperReports server</name>
<url>http://github.com/Jaspersoft/jrs-rest-java-client</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jasperserver-dto.version>8.2.0</jasperserver-dto.version>
<jasperserver-dto.version>9.0.0</jasperserver-dto.version>
<powermock.version>2.0.9</powermock.version>
<jersey.version>2.39</jersey.version>
<jackson.version>2.13.5</jackson.version>
Expand All @@ -26,6 +26,11 @@
</scm>

<repositories>
<repository>
<id>mvn-central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>jaspersoft-clients-snapshots</id>
<name>Jaspersoft clients snapshots</name>
Expand All @@ -36,6 +41,11 @@
<name>jaspersoft-releases</name>
<url>https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-releases</url>
</repository>
<repository>
<id>branch-central</id>
<name>jaspersoft-releases</name>
<url>https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-snapshots</url>
</repository>
</repositories>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved.
* http://www.jaspersoft.com.
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.&nbsp; If not, see <http://www.gnu.org/licenses/>.
*/
package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting;

import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor;
import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.ValidationException;
import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler;
import com.jaspersoft.jasperserver.jaxrs.client.dto.common.ValidationError;
import com.jaspersoft.jasperserver.jaxrs.client.dto.common.ValidationErrorsListWrapper;

import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;

public class AlertValidationErrorHandler extends DefaultErrorHandler {

@Override
protected void handleBodyError(Response response) {
List<ErrorDescriptor> errorDescriptors;
if (response.getHeaderString("Content-Type").contains("xml") || response.getHeaderString("Content-Type").contains("alert+json")) {
ValidationErrorsListWrapper validationErrors = readBody(response, ValidationErrorsListWrapper.class);
if (validationErrors == null) {
super.handleBodyError(response);
return;
}
errorDescriptors = toErrorDescriptorList(validationErrors);
throw new ValidationException(generateErrorMessage(errorDescriptors), errorDescriptors);
}
super.handleBodyError(response);
}

protected List<ErrorDescriptor> toErrorDescriptorList(ValidationErrorsListWrapper validationErrors) {
List<ErrorDescriptor> errorDescriptors = new ArrayList<ErrorDescriptor>();
List<ValidationError> errors = validationErrors.getErrors();
for (ValidationError error : errors) {
ErrorDescriptor errorDescriptor = new ErrorDescriptor();
errorDescriptor.setMessage(error.toString() + " (field: " + error.getField() + ")");
errorDescriptor.setErrorCode(error.getErrorCode());
errorDescriptor.addParameters(error.getErrorArguments());
errorDescriptors.add(errorDescriptor);
}
return errorDescriptors;
}

private String generateErrorMessage(List<ErrorDescriptor> errorDescriptors) {
StringBuilder sb = new StringBuilder();
if (errorDescriptors != null) {
for (ErrorDescriptor errorDescriptor : errorDescriptors) {
String message = errorDescriptor.getMessage();
sb.append("\n\t\t").append(message != null ? message : errorDescriptor.getErrorCode());
}
}
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/*
* Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved.
* http://www.jaspersoft.com.
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.&nbsp; If not, see <http://www.gnu.org/licenses/>.
*/

package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting;

public enum AlertsParameter {

/**
* URI of thumbnail inFolder schedule. Report
* options URI can also be used
* here
*/
SEARCH_RESOURCE_URI("resourceURI"),

/**
* Name|Organization of the user,
* who scheduled the job
*/
SEARCH_OWNER("owner"),

/**
* Label of the jobs inFolder find.
*/
SEARCH_LABEL("label"),

/**
* This argument defines the current state of a job.
* The parameter accepts multiple values:
* NORMAL
* EXECUTING
* PAUSED
* COMPLETE
* ERROR
*/
SEARCH_STATE("state"),

/**
* Reserved, not implemented
*/
SEARCH_PREVIOUS_FIRE_TIME("previousFireTime"),

/**
* Reserved, not implemented
*/
SEARCH_NEXT_FIRE_TIME("nextFireTime"),

/**
* Pagination, start index
*/
SEARCH_START_INDEX("startIndex"),

/**
* Pagination, results count in a
* page
*/
SEARCH_NUMBER_OF_ROWS("numberOfRows"),

/**
* Field name inFolder sort by.
* Supported values:
* NONE
* SORTBY_JOBID
* SORTBY_JOBNAME
* SORTBY_REPORTURI
* SORTBY_REPORTNAME
* SORTBY_REPORTFOLDER
* SORTBY_OWNER
* SORTBY_STATUS
* SORTBY_LASTRUN
* SORTBY_NEXTRUN
* SORTBY_RESOURCELABEL
*/
SEARCH_SORT_TYPE("sortType"),

/**
* Sorting direction. Supported values:
* true - ascending;
* false - descending
*/
SEARCH_IS_ASCENDING("isAscending"),

/**
* This argument defines the job id; jobID should be integer/long
*/
SEARCH_JOB_ID("jobID"),

/**
* This argument defines the start of a range of time that matches if the job was previously triggered during this time.
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
*/
SEARCH_PREVIOUS_FIRE_TIME_FROM("previousFireTimeFrom"),

/**
* This argument defines the end of a range of time that matches if the job was previously triggered during this time.
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
*/
SEARCH_PREVIOUS_FIRE_TIME_TO("previousFireTimeTo"),

/**
* This argument defines the start of a range of time that matches if the job that is currently running was triggered during this time.
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
*/
SEARCH_NEST_FIRE_TIME_FROM("nextFireTimeFrom"),

/**
* This argument defines the end of a range of time that matches if the job that is currently running was triggered during this time.
* Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
*/
SEARCH_NEST_FIRE_TIME_TO("nextFireTimeTo"),

/**
* This argument defines the job label.
*/
SEARCH_JOB_LABEL("jobLabel"),

/**
* This argument defines the Resource label.
*/
SEARCH_JOB_RESOURCE_LABEL("resourceLabel"),

/**
* This argument defines the job description.
*/
SEARCH_JOB_DESCRIPTION("description"),

/**
* Can be used multiple times inFolder createInFolder a list of jobIDs inFolder update
*/
JOB_ID("id"),

/**
* When true, the trigger is replaced from the content being sent and the trigger
* type is ignored. When false or omitted, the trigger is updated automatically
* by the scheduler.
*/
UPDATE_REPLACE_TRIGGER_IGNORE_TYPE("replaceTriggerIgnoreType"),
/**
* Pagination. Start index for requested pate.
*/
OFFSET("offset"),

/**
* Pagination. Resources count per page
*/
LIMIT("limit")
;

private String name;

private AlertsParameter(String name) {
this.name = name;
}


public String getName() {
return name;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved.
* http://www.jaspersoft.com.
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.&nbsp; If not, see <http://www.gnu.org/licenses/>.
*/

package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting;

import com.jaspersoft.jasperserver.dto.alerting.ClientAlertCalendar;
import com.jaspersoft.jasperserver.dto.alerting.ClientReportAlert;
import com.jaspersoft.jasperserver.dto.alerting.wrappers.ClientCalendarNameListWrapper;
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter;
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.alerting.calendar.SingleCalendarOperationsAdapter;
import com.jaspersoft.jasperserver.jaxrs.client.core.*;
import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult;

import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest;

public class AlertsService extends AbstractAdapter {

public static final String SERVICE_URI = "alerts";
public static final String CALENDARS = "calendars";

public AlertsService(SessionStorage sessionStorage) {
super(sessionStorage);
}

public BatchAlertsOperationsAdapter alerts() {
return new BatchAlertsOperationsAdapter(sessionStorage);
}

public BatchAlertsOperationsAdapter alerts(Long... ids) {
return new BatchAlertsOperationsAdapter(sessionStorage, ids);
}

public SingleAlertOperationsAdapter alert(long id) {
return new SingleAlertOperationsAdapter(sessionStorage, String.valueOf(id));
}

public SingleAlertOperationsAdapter alert(ClientReportAlert reportAlert) {
return new SingleAlertOperationsAdapter(sessionStorage, reportAlert);
}

public OperationResult<ClientCalendarNameListWrapper> allCalendars() {
return calendar((ClientAlertCalendar.Type) null);
}

public <R> RequestExecution asyncCalendar(final Callback<OperationResult<ClientCalendarNameListWrapper>, R> callback) {
return asyncCalendar(null, callback);
}

public OperationResult<ClientCalendarNameListWrapper> calendar(ClientAlertCalendar.Type type) {
JerseyRequest<ClientCalendarNameListWrapper> request = buildRequest(sessionStorage, ClientCalendarNameListWrapper.class, new String[]{SERVICE_URI, CALENDARS});
if (type != null) {
request.addParam("calendarType", type.name().toLowerCase());
}
return request.get();
}

public <R> RequestExecution asyncCalendar(final ClientAlertCalendar.Type type, final Callback<OperationResult<ClientCalendarNameListWrapper>, R> callback) {
final JerseyRequest<ClientCalendarNameListWrapper> request = buildRequest(sessionStorage, ClientCalendarNameListWrapper.class, new String[]{SERVICE_URI, CALENDARS});
if (type != null) {
request.addParam("calendarType", type.name().toLowerCase());
}
RequestExecution task = new RequestExecution(new Runnable() {
@Override
public void run() {
callback.execute(request.get());
}
});
ThreadPoolUtil.runAsynchronously(task);
return task;
}

public SingleCalendarOperationsAdapter calendar(String calendarName) {
if ("".equals(calendarName) || "/".equals(calendarName)) {
throw new IllegalArgumentException("'calendarName' mustn't be an empty string");
}
return new SingleCalendarOperationsAdapter(sessionStorage, calendarName);
}

}
Loading

0 comments on commit 756cdaa

Please sign in to comment.