Jump to content
We've recently updated our Privacy Statement, available here ×

External Access to Repository


codyjasperForge

Recommended Posts

Hello again,

 

I have another question.

 

With the new version (2.1), what are some possibilities of accessing the repository directories externally?

 

How would you gain access to the repository from outside of the JasperServer application itself?

 

Any ideas are appreciated.

 

Thanks again.

Post edited by: codyjasperForge, at: 2007/11/14 17:22

Link to comment
Share on other sites

  • Replies 17
  • Created
  • Last Reply

Top Posters In This Topic

I'm new to Jasper, but I think it provides WebDAV folders which means you can access the repository from anything -- even M$ Office.

 

Take a look at the JasperServer plug-in that comes with iReport. When you create a new connection to a JasperServer repository, it shows a URL in there by default -- I think that's how you access the repository.

Link to comment
Share on other sites

gabrielinux wrote:

I'm new to Jasper, but I think it provides WebDAV folders which means you can access the repository from anything -- even M$ Office.

 

It's not exactly WebDAV, it's a custom SOAP web service. The service is described in the JasperServer web services guide.

 

Regards,

Lucian

Link to comment
Share on other sites

New scenario:

 

I am scheduling jobs using the new web services...

 

However, for some unexplained reason, a method being called by the 'ReportSchedulerFacade' is now returning 'null' when earlier it was returning actual results. I have only made minor changes to my code, yet I can't seem to find out what would be causing this.

 

The method(s) is/are:

 

.getReportJobs(String reportURI);

and

.getAllJobs();

 

The only changes that I have made were to my custom code, so what are some possibilities?

 

Thanks in advance.

:pinch:

Link to comment
Share on other sites

codyjasperForge wrote:

How is it that you are able to bypass the Security to the repository?

I understand that it uses BASIC authentication, however, I have supplied the necessary parameters to my connection object, and I still get re-directed to the login page.

 

Is this about JasperServer web services? If so, how exactly are you getting redirected to the login page? Web services are usually called from application code, and not from a browser.

 

What "connection" object are you using and how are you supplying authentication parameters?

 

Regards,

Lucian

Link to comment
Share on other sites

Ok,

 

I am scheduling jobs via the newly added web service(s). Once the jobs complete, the output files are stored in the JasperServer repository under the '/ContentFiles/' directory.

 

The client of my web application is polling the status of the job, when it is 'COMPLETE' then I wish to direct them to the output file. (under /ContentFiles)

 

Up to now, everything is functional, with the exception that when I try to direct them to the repository, the login page is what I get.

 

I have a utility class in my web application that creates a java.net.HttpURLConnection object with the BASIC authentication header.

 

The username and password are gathered from the WSClient's getUserName & getPassword methods. I encode the username and password using sun.misc.BASE64Encoder().

 

I am able to access the output files from within my utility class and I can create an InputStream and read in the content of the output file. (e.g. reportOutput.html)

 

What I wish to do is simply direct the client to that output file, whether it be a .pdf, .html, or the other formats.

 

I have read through the JasperForge forums, and everyone is stating that the login page can be bypassed, yet I can't see to find out how...

 

Do you have any suggestions?

 

:)

Link to comment
Share on other sites

Another idea that I had was to use the web service api from my utility class to do a 'get' on the output file.

 

The problem with this solution is that I do not see a way to display the output file by getting it as a 'ResourceDescriptor' object.

 

I need a direct link into the repository that bypasses the security model. All of our users will have the necessary credentials to login to JasperServer.

 

Is this possible?

 

Thank you once again Lucianc.

Link to comment
Share on other sites

codyjasperForge wrote:

Another idea that I had was to use the web service api from my utility class to do a 'get' on the output file.

The problem with this solution is that I do not see a way to display the output file by getting it as a 'ResourceDescriptor' object.

 

Take a look at the java-webapp-sample application (in particular to ContentResourceDataServlet.java).

 

I need a direct link into the repository that bypasses the security model. All of our users will have the necessary credentials to login to JasperServer.

Is this possible?

 

I'm not sure about this, I'll have to research it.

 

Regards,

Lucian

Link to comment
Share on other sites

I have implemented the necessary changes to my code.

 

But I am unable to display html formatted reports. All I see on the forwarded page is byte code. I have set the response content-Type and encoding values to those of the ContentResourceDataServlet. What else needs to be done?

 

What would cause this to happen?

 

The .pdf format works fine. As does the others, so I know the problem lies in the html formatting...

 

Ideas?

Post edited by: codyjasperForge, at: 2007/11/20 18:56

Link to comment
Share on other sites

Thanks for the reply...

 

Could you post the code that writes HTML and the resulting output?

 

Here are the two functions I am using...

 

 

 

Code:
public void retrieveReport(HttpServletRequest req, HttpServletResponse response){
java.io.File tmp = (File) req.getSession().getServletContext().getAttribute("javax.servlet.context.tempdir"«»);
File tmpFile = null;
try {
tmpFile = File.createTempFile("contentResource", ".data", tmp);
WSClient client = (WSClient) req.getSession().getAttribute("client"«»);
ResourceDescriptor outputFile = new ResourceDescriptor();
outputFile.setUriString("/ContentFiles/" + req.getParameter("reportName"«»)+ "." + req.getParameter("format"«»));
outputFile.setName(req.getParameter("reportName"«»));
outputFile.setWsType("UNKNOW"«»);
ResourceDescriptor result = client.get(outputFile, tmpFile);
String contentType = result.getResourcePropertyValue(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE);
if (contentType.equals("html"«»)) {
response.setContentType("text/html; charset=UTF-8"«»);//charset=UTF-8 charset=ISO-8859-1 pageEncoding=ISO-8859-1
} else if (contentType.equals("pdf"«»)) {
response.setContentType("application/pdf"«»);
response.setHeader("Content-Disposition", "inline; filename="" + result.getName() + """«»);
} else if (contentType.equals("xls"«»)) {
response.setContentType("application/xls"«»);
response.setHeader("Content-Disposition", "inline; filename="" + result.getName() + """«»);
} else if (contentType.equals("rtf"«»)) {
response.setContentType("application/rtf"«»);
response.setHeader("Content-Disposition", "inline; filename="" + result.getName() + """«»);
} else if (contentType.equals("csv"«»)) {
response.setContentType("text/csv"«»);
response.setHeader("Content-Disposition", "inline; filename="" + result.getName() + """«»);
}
response.setContentLength((int)tmpFile.length());

writeFileContent(response, tmpFile);
}catch(Exception e){
e.printStackTrace();
}finally{
tmpFile.delete();
}
}

public void writeFileContent(HttpServletResponse response, File file){
try{
javax.servlet.ServletOutputStream out = response.getOutputStream();
java.io.FileInputStream fileIn = new java.io.FileInputStream(file);
try {
byte[] buf = new byte[bUFFER_SIZE];
int read;
while((read = fileIn.read(buf)) > 0) {
out.write(buf, 0, read);
}
} finally {
fileIn.close();
}
out.flush();
out.close();
}catch(java.io.IOException ioe){
ioe.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}

}

}

 

Here is what the output looks like for html files...

 

Code:
[code]GIF89a               b    w        wi                w     *!   w             t          B      w x                dB     w               b                               $                   d      w w         w    C  l                       w  h         b       4                   w                                     w  P x     w    x        t x       X     O |                         x                 d b     w            ~n     N  |                          + b            O  |   +    N  |                O  | j           x b XK     ?  ON||  [  b  N            ×®   NN ||lW o N    (   N     ,  O |   x   w  P       Nw |  x Üº O   T    0         N  |   wn    F w !      ,         H   *È° Ã‡  H  Å‹3j È‘†C I  É“(?  1 K 0cVLI  Íš+eRt@ O 7   4 Ï£H1 ]z  M :yN )u*Õž^R y jW ~ 8 Ì²gÅ’ k $T R Æ•Û“n] Y % qoÛ¾    "  s & W Ö— #GÞ‹ 2e 1O  leË„c qq䪦S? vÜ“  Î® n < g !8 hƨW   .kÙž3 ~ ye Nm   [ aÒŒ+nݪ     [   < y gM  r`  U ?_ v 3q   y # Ö–[   I   | yuxrI  l! y }Va  QÄžH<@ a Yt q q Õ„ m "H ]    aH! H  Ã¡ d  `y1>G  0 7 J7    

 

Its virtually the same as the code in the ContentResourceDataServlet.

 

Thanks for you help...

Link to comment
Share on other sites

Once again thank you for your suggestions.

 

A thread in another forum states that the source of the .gif image that is included is causing this to appear.

 

After testing this theory, I set the Content-Type to "image/gif" and the result was the JasperReport logo.

 

Do you have any other suggestions for directing the user to the actual output file location? (in the repository)

 

Would it possible to manually prompt the user for their credentials before they are redirected to the JasperServer login page?

Post edited by: codyjasperForge, at: 2007/11/26 14:53

Link to comment
Share on other sites

I should change my screen name to "GuyWith2ManyQuestions" :lol:

 

================================================

 

I have yet another question, this time it is NOT concerning the web services API...

 

Is it possible to have JasperServer running in a cluster?

 

If so, what are JasperServers capabilities as far as fail-over and session-replication?

 

Where might I find more information on this topic? (specifically)

 

Thanks Lucianc, you've been a great help.

Link to comment
Share on other sites

  • 1 year later...

Hello,

 

I am also want to the same way as you have done . Can I get the code please... I am using Adobe Air with Jasperserver reports.. I get the jasperserver ui page in that Adobe air properly. But as soon as I click on pdf, csv, excel it gives me a blank page with no errors.. so it's not helping me. So I am looking for different options now. I already have generated url like :http://hq1svrdev001/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/DierTracts/Contracts&ContractID=512&ContractID=512 and now this should go ahead and run the report which will be saved in the repository. Once completed then it should go to that repository and get that file in whatever user wants ie. pdf,csv,or excel. And what you have mentioned is doing the same, so can you please provide more help in that. Please contact me at vsoneta@yahoo.com and one more small request is there any way you can share the code.

 

My thing is : I have the url to the report generated. Now I want to run that url, will create the report and get that report and save it on user's local machine or direcyly access that file whether it's pdf, csv or excel and then open those files direcly from the available softwares.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...