2016-07-03 14 views

Antwort

3

Ja, es ist möglich. So mache ich es in JasperReports Server v6.2.1 mit dem jrs-rest-java-client v6.2.3:

// build configuration object 
RestClientConfiguration configuration = new RestClientConfiguration("http://localhost:8080/jasperserver"); 
configuration.setContentMimeType(MimeType.JSON); 
configuration.setAcceptMimeType(MimeType.JSON); 
configuration.setAuthenticationType(AuthenticationType.SPRING); 
configuration.setLogHttp(true); 
configuration.setLogHttpEntity(true); 

// build client and authenticate 
JasperserverRestClient client = new JasperserverRestClient(configuration); 
Session session = client.authenticate("jasperadmin", "jasperadmin"); 

String reportUnitUri = "/path/to/reportUnit"; 

// first get the version of the reportUnit to prevent update conflicts from optimistic locking 
OperationResult<ClientReportUnit> reportUnitOperationResult = session.resourcesService().resource(reportUnitUri).get(ClientReportUnit.class); 
Integer reportUnitVersion = reportUnitOperationResult.getEntity().getVersion(); 

// build patchDescriptor with the dataSource field 
PatchDescriptor patchDescriptor = new PatchDescriptor(); 
patchDescriptor.setVersion(reportUnitVersion); 
patchDescriptor.field("dataSource", "/path/to/repository/dataSource"); 

// apply the patchDescriptor 
session.resourcesService().resource(reportUnitUri).patchResource(ClientReportUnit.class, patchDescriptor);