Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve resource from jasperserver repository using server java api

I'm trying to retrieve resource from Jasperserver repository using its java API, according to jasper report server ultimate guide, I should get an instance of the ExecutionContext interface:

ExecutionContext context = JasperServerUtil.getExecutionContext();

then, get an instance of the RepositoryService interface:

RepositoryService repositoryService = ...; //how??

Now I can get the file using the following code:

FileResourceData fileResourceData = repositoryService.getContentResourceData(context, "/examples/report.pdf");

my question is how can I get the RepositoryService instance?

like image 559
Muhamad Serawan Avatar asked Dec 14 '25 09:12

Muhamad Serawan


1 Answers

ApplicationContext ctx = StaticApplicationContext.getApplicationContext();
String repositoryServiceName = "repositoryService";
RepositoryService repositoryService = (RepositoryService) ctx.getBean(repositoryServiceName);
ExecutionContext context = JasperServerUtil.getExecutionContext();
Resource resource = repositoryService.getResource(context, fileURI);
like image 107
Muhamad Serawan Avatar answered Dec 15 '25 22:12

Muhamad Serawan