3

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?

Muhamad Serawan
  • 445
  • 5
  • 16

1 Answers1

4
ApplicationContext ctx = StaticApplicationContext.getApplicationContext();
String repositoryServiceName = "repositoryService";
RepositoryService repositoryService = (RepositoryService) ctx.getBean(repositoryServiceName);
ExecutionContext context = JasperServerUtil.getExecutionContext();
Resource resource = repositoryService.getResource(context, fileURI);
Muhamad Serawan
  • 445
  • 5
  • 16
  • 1
    Here I wrote how to get a subreport resource for manipulation in a scriptlet with your approach: http://stackoverflow.com/a/37961222/1915920 Thx a lot for this! – Andreas Covidiot Jun 22 '16 at 07:28