Pages

Showing posts with label RIDC. Show all posts
Showing posts with label RIDC. Show all posts

Create the IdcContext based on an application resource connection

In the previous post I showed how to use get_file with the RIDC protocol. You create an IdcClient & IdcContext and use this to set up the connection. However, it is also possible to use the application resource connection for this.

First set up the connection in JDeveloper:

This will result in an entry in the connections.xml in your META-INF:

      
      
         
            username
         
         
         
            
         
         
            idc://servername:portnumber
         
      
   
 
Now you can create an AdfConnectionFacade based on the name of this connection.
Then you create the IdcClient & IdcContext based on the AdfConnectionFacade:
      //Use the defined WebCenterContent connection
      AdfConnectionFacade acf = new AdfConnectionFacade("WebCenterContent");
      IdcClient idcClient = acf.getIdcClient();
      //Create an idcContext based on the Credentials.
      IdcContext idcContext = new IdcContext(acf.getUserCredentials("user"));
The parameter “user” in getUserCredentials refers to the user you see in the connections.xml. 

Get a Document out of WebCenter Content by ID

The use case was to show PDFs in the browser that come out of WebCenter Content.
I achieved this by using the RIDC library.

The information you need, you can find in the WebCenter Content Admin Server.
Login and go to the General Configuration. Look up the IntradocServerPort number that is configured there, so you know the portnumber for the call.

It only takes a few lines of code to get the InputStream from the document:
      IdcClientManager manager = new IdcClientManager();
      IdcClient idcClient = manager.createClient("idc://servername:portnumber");
      IdcContext idcContext = new IdcContext("username", "password");

      DataBinder requestBinder = idcClient.createBinder();
      requestBinder.putLocal("IdcService", "GET_FILE");
      requestBinder.putLocal("dID", "id");

If you want you can get some extra info from the response:
    response.getHeader("Content-Length");
    response.getHeader("Content-type");
    response.getHeader("Content-Disposition");

And that’s probably all you need.