Implement DeliveryRequest Interface Implement DeliveryRequestHandler Interface

Using the Delivery Manager Java APIs 8-37 } } flushes and closes the output stream to submit the request. public void submitRequest throws DeliveryException { try { flush and close mOut.flush; mOut.close; set request status mRequest.setStatusDeliveryStatusDefinitions.STATUS_SUCCESSFUL; mIsOpen = false; } catch IOException e { closeRequest; throw new DeliveryExceptione; } } checks the delivery status. public void updateRequestStatus throws DeliveryException { check if the file is successfully delivered String filename = String mRequest.getPropertyFileDeliveryRequest.FILE_DESTINATION; File f = new Filefilename; set request status if f.exists mRequest.setStatusDeliveryStatusDefinitions.STATUS_SUCCESSFUL; else mRequest.setStatusDeliveryStatusDefinitions.STATUS_FAILED_IO_ERROR; } returns the request status. public boolean isRequestOpen { return mIsOpen; } closes the request, frees all resources. public void closeRequest { mIsOpen = false; try { if mOut = null 8-38 Developers Guide for Oracle Business Intelligence Publisher { mOut.flush; mOut.close; } } catch IOException e { } finally { mOut = null; } } }

8.20.4 Implement DeliveryRequestFactory Interface

Implement the DeliveryRequestFactory interface to register your custom delivery channel to the delivery system. A sample implementation of oracle.apps.xdo.delivery.DeliveryRequestFactory is as follows: Example 8–38 Sample Code for Implementing the DeliveryRequestFactory Interface package oracle.apps.xdo.delivery.file; import oracle.apps.xdo.delivery.DeliveryRequest; import oracle.apps.xdo.delivery.DeliveryRequestFactory; import oracle.apps.xdo.delivery.DeliveryRequestHandler; public class FileDeliveryRequestFactory implements DeliveryRequestFactory { default constructor. public FileDeliveryRequestFactory { } returns delivery request. public DeliveryRequest createRequest { return new FileDeliveryRequest; } returns delivery request handler. public DeliveryRequestHandler createRequestHandler { return new FileDeliveryRequestHandler; } returns this public DeliveryRequestFactory getFactory Using the Delivery Manager Java APIs 8-39 { return this; } }

8.20.5 Register your custom DeliveryRequestFactory to DeliveryManager

The final step is to register your custom delivery channel to the delivery system. You can register your delivery channel in two ways: ■ Static method Use this method to register your delivery channel to the whole delivery system by specifying it in the configuration file. See Section 8.21, Configuration File Support. ■ Dynamic method Register the delivery channel to the Java VM instance by calling the Register API programmatically. Sample code to register the file delivery channel using the dynamic method and call the file delivery channel is as follows: Example 8–39 Sample Code for Registering and Calling File Delivery Channel Using the Dynamic Method package oracle.apps.xdo.delivery.file; import oracle.apps.xdo.delivery.DeliveryManager; import oracle.apps.xdo.delivery.DeliveryRequest; public class FileDeliverySample { public static void mainString[] args throws Exception { register the file delivery channel DeliveryManager.addRequestFactoryfile, oracle.apps.xdo.delivery.file.FileDeliveryRequestFactory; create delivery manager instance DeliveryManager dm = new DeliveryManager; create a delivery request DeliveryRequest req = dm.createRequestfile; set the destination req.addProperty FileDeliveryRequest.FILE_DESTINATION, d:TemptestDocument_delivered.pdf; set the document to deliver req.setDocumentD:TemptestDocument.pdf; submit the request req.submit; close the request req.close; } } 8-40 Developers Guide for Oracle Business Intelligence Publisher

8.21 Configuration File Support

The delivery systems supports a configuration file to set default servers, default properties, and custom delivery channels. The location of the configuration file is {XDO_TOP}resourcexdodelivery.cfg where {XDO_TOP} is a Java system property that points to the physical directory. This system property can be set in two ways: ■ Pass -DXDO_TOP=pathtoxdotop to the Java startup parameter ■ Use a Java API in your code, such as java.lang.System.getProperties.putXDO_TOP, pathtoxdotop The system property must be defined before constructing a DeliveryManager object. Following is a sample configuration file: Example 8–40 Sample Configuration File ?xml version=1.0 encoding=UTF-8? config xmlns=http:xmlns.oracle.comoxpdeliveryconfig - ======================================================== - - servers section - - List your pre-defined servers here. - - ======================================================== - servers server name=myprinter1 type=ipp_printer default=true uriipp:myprinter1.oracle.com:631printersmyprinter1uri server server name=myprinter2 type=ipp_printer hostmyprinter2.oracle.comhost port631port uriipp:myprinter2.oracle.com:631printersmyprinter2uri authTypebasicauthType usernamexdousername passwordxdopassword server server name=myfax1 type=ipp_fax default=true hostmyfax1.oracle.comhost port631port uriipp:myfax1.oracle.com:631printersmyfax1uri server server name=mysmtp1 type=smtp_email default=true hostmyprinter1.oracle.comhost port25port server server name=mysmtp2 type=smtp_email hostmysmtp12.oracle.comhost port25port usernamexdousername passwordxdopassword