Sending and Receiving Streams Using RIDC Objects in JSP and JSPX Pages

Using Remote Intradoc Client RIDC 9-7

9.6.1 Closing Resources

The following examples show how to use the options for closing resources. To close resources through getResponseAsBinder: execute the request ServiceResponse response = idcClient.sendRequest userContext, binder; get a binder closes the response automatically response.getResponseAsBinder ; To close resources by closing the stream: execute the request ServiceResponse response = idcClient.sendRequest userContext, binder; get the result stream and read it InputStream stream = response.getResponseStream ; int read = 0; while read = stream.read = -1 { } close the stream stream.close ; To close resources by calling the close method on the ServiceResponse object: execute the request ServiceResponse response = idcClient.sendRequest userContext, binder; close the response which closes the stream directly response.close ;

9.6.2 Handling Connection Pooling

The IdcClientConfiggetConnectionPool property determines how RIDC will handle the pooling of connections. There are two options, pool and simple. ■ Pool is the default, and it means to use an internal pool that allows a configurable number of active connections at a time configurable via the IdcClientConfiggetConnectionSize property, with the default active size set to 20. ■ Simple does not enforce a connection maximum and rather lets every connection proceed without blocking. You can register a different pool implementation through the IdcClientManagergetConnectionPoolManagerregisterPool method, which maps a name to an implementation of the ConnectionPool interface. Then you can use the name in the IdcClientConfig object to select that pool for a particular client.

9.7 Sending and Receiving Streams

Streams are sent to Oracle Content Server through the TransferStream interface. This interface wraps the actual stream with metadata about the stream length, name, and so on. 9-8 Oracle Fusion Middleware Developers Guide for Oracle Universal Content Management This example code performs a check-in to Oracle Content Server: create request DataBinder binder = idcClient.createBinder; binder.putLocal IdcService, CHECKIN_UNIVERSAL; get the binder binder.putLocal dDocTitle, Test File; binder.putLocal dDocName, test-checkin-6; binder.putLocal dDocType, ADACCT; binder.putLocal dSecurityGroup, Public; add a file binder.addFile primaryFile, new TransferFile test.doc; check in the file idcClient.sendRequest userContext, binder; You can receive a stream from Oracle Content Server through the ServiceResponse object; the response is not converted into a DataBinder object unless you specifically request it. If you just want the raw HDA data, you can get that directly, along with converting the response to a String or DataBinder object: create request DataBinder binder = idcClient.createBinder ; execute the service ServiceResponse response = idcClient.sendRequest userContext, binder; get the response stream InputStream stream = response.getResponseStream ; get the response as a string String responseString = response.getResponseAsString ; parse into data binder DataBinder dataBinder = response.getResponseAsBinder ;

9.8 Using RIDC Objects in JSP and JSPX Pages

The RIDC objects all follow the standard Java Collection paradigms, which makes them extremely easy to consume from a JSP or JSPX page. Assume the ServerResponse object used in the previous example was available in the HttpServletRequest object in an attribute called idcResponse. This example JSPX code will iterate over the response and create a small table of data: table tr thTitleth thAuthorth thRelease Dateth tr c:forEach var=row items={idcResponse.dataBinder.SearchResults.rows} tr td{row.dDocTitle}td td{row.dDocAuthor}td td{row.dInDate}td tr c:forEach table Using Remote Intradoc Client RIDC 9-9

9.9 Reusing Binders for Multiple Requests