Oracle Business Intelligence Publisher Online Help Release 10.1.3.4 Part Number E12602-01 | Contents | Previous | Next |
This chapter covers the following topics:
BI Publisher enables you to set up an HTTP notification that will execute after report generation as an after report trigger. This enables you to integrate BI Publisher with other Oracle and third-party applications such as a BPEL process, Content Management applications, or other workflow applications.
Note that immediately upon the generation of the report in BI Publisher, the notification will execute. There is currently no ability to call back or introduce a listener or process between the report generation and the HTTP notification to your servlet.
The following tasks are required to complete the setup of an after report trigger for your report:
Create your servlet or third-party application, as described in this chapter.
Register your servlet URL as an HTTP delivery server in the BI Publisher Admin page. See Set Up an HTTP Server.
Create a schedule for the report, choosing HTTP Notification. See Scheduling a Report.
When the report generation has completed BI Publisher will call the HTTP notification as a postprocess and submit the URL (that you registered as an HTTP server) with the following additional parameters:
jobid
report_url
status
Values for status are "S" for success and "F" for failure.
Your remote application can then access these parameters using BI Publisher's APIs and Web services to access the job details, including report output and XML data as shown in the following code sample:
String id= request.getParameter("jobid");
String report_url = request.getParameter("report_url");
String status = request.getParameter("status");
try
{
Scheduler sch =new SchedulerImpl();
JobHistoryInfo[] jobs= sch.getJobHistoryInfo(id);
for (int i = 0; i<jobs.length; i++){
JobHistoryInfo outinfo = jobs[i];
FileOutputStream fos = new FileOutputStream(targetDir+id+".pdf");
byte[] buf = new byte[256];
int read = 0;
InputStream in = outinfo.getDocumentOutput();
while ((read =in.read(buf)) > 0) {
fos.write(buf, 0, read);
}
in.close();
fos.close();
}
} catch (Exception e) {
Logger.log(e);
}
Following is a sample HTTP servlet that is called as an HTTP Notification. In this example, the servlet is deployed on the same server as the BI Publisher application. If your servlet is deployed on a remote server, use the BI Publisher Web service APIs to access the report details. For more information about the BI Publisher Web service APIs, see Using the BI Publisher Web Services, Oracle Business Intelligence Publisher Administrator's and Developer's Guide.
In this sample, the servlet uses the information provided by the HTTP request as input to the BI Publisher Web services to retrieve the report output. This could then be used to insert in an approval workflow.
ackage oracle.xdo.service.scheduling;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.xdo.common.log.Logger;
import oracle.xdo.server.JobHistoryInfo;
import oracle.xdo.server.Scheduler;
import oracle.xdo.server.impl.SchedulerImpl;
public class HttpNotificationTest extends HttpServlet
{
public String targetDir = "c://oc4j1013/j2ee/home/applications/xmlpserver/xmlpserver/output/";
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
doPost(request, response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
String id= request.getParameter("jobid");
String report_url = request.getParameter("report_url");
String status = request.getParameter("status");
try
{
Scheduler sch =new SchedulerImpl();
JobHistoryInfo[] jobs= sch.getJobHistoryInfo(id);
for (int i = 0; i<jobs.length; i++){
JobHistoryInfo outinfo = jobs[i];
FileOutputStream fos = new FileOutputStream(targetDir+id+"."+getFileExtension(outinfo.getDocumentDataContentType()));
byte[] buf = new byte[256];
int read = 0;
InputStream in = outinfo.getDocumentOutput();
while ((read =in.read(buf)) > 0) {
fos.write(buf, 0, read);
}
in.close();
fos.close();
}
} catch (Exception e) {
Logger.log(e);
}
}
public static String getFileExtension(String contentType)
{
String ext="pdf";
if (contentType == "application/pdf")
ext="pdf" ;
else if (contentType == "text/html; charset=UTF-8")
ext="html";
return ext;
}
Copyright © 2005, 2008, Oracle and/or its affiliates. All rights reserved.