Forum Stats

  • 3,757,039 Users
  • 2,251,189 Discussions
  • 7,869,698 Comments

Discussions

Unable to Download the Resource from Content Server 12c using RIDC

3717022
3717022 Member Posts: 40
edited Feb 11, 2019 9:55AM in WebCenter Content

Hi Experts,

I am using RIDC to donwload resource from content server of wcc 12c, Using the idc service of GET_FILE to download the file i.e text file but when i run the code it runs without any error but the download doesn't start. Below is the code i am following :

<note: some of the import file are not used here please ignore that>

import java.io.BufferedReader;

import java.io.ByteArrayOutputStream;

import java.io.DataInputStream;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import javax.servlet.*;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.*;

import java.util.List;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.util.Stack;

import oracle.stellent.ridc.IdcClient;

import oracle.stellent.ridc.IdcClientException;

import oracle.stellent.ridc.IdcClientManager;

import oracle.stellent.ridc.IdcContext;

import oracle.stellent.ridc.model.DataBinder;

import oracle.stellent.ridc.model.serialize.HdaBinderSerializer;

import oracle.stellent.ridc.protocol.ServiceResponse;

@WebServlet(name = "TestRIDCDownload", urlPatterns = { "/TestRIDCDownload" })   

public class TestRIDCDownload extends HttpServlet {

  

    private static final long serialVersionUID = 1L;

    private static final String CONTENT_TYPE = "text/html; charset=windows-1252; application/pdf; xml";

        File path = new File("D:\\RIDC");   // here i am using the path to store the content

            public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

                  IdcClientManager manager = new IdcClientManager ();

                System.out.println("inside main class");

                try

                {

                    System.out.println("inside idcclient");

                     // Create a new IdcClient Connection using idc protocol (i.e. socket connection to Content Server)

                     IdcClient idcClient = manager.createClient ("idc://hostname:port");

                     // Create new context using the 'sysadmin' user

                     IdcContext userContext = new IdcContext ("sysadmin");

                     // Create an HdaBinderSerializer; this is not necessary, but it allows us to serialize the request and response data binders

                     HdaBinderSerializer serializer = new HdaBinderSerializer ("UTF-8", idcClient.getDataFactory ());

               

                     // Databinder for checkin request

                     DataBinder dataBinder = idcClient.createBinder();

                   System.out.println("inside dataBinder and above GET_FILE");

                    dataBinder.putLocal("IdcService", "GET_FILE");

                    //dID is important ----------------

                  

                    dataBinder.putLocal("dID","4803" );

                   dataBinder.putLocal("dDocName","WCC215.GENX.COM004803");

               

                   //  dataBinder.putLocal("dDocName", "MYDOCNAME");

                   // dataBinder.putLocal("allowInterrupt", "1");

                    serializer.serializeBinder (System.out, dataBinder);

                    // Send the request to Content Server

               

                    // Create an output stream to output the file received

                                    // Send the request to Content Server

                       ServiceResponse response1 =

                       idcClient.sendRequest(userContext, dataBinder);

                       // Create an input stream from the response

                       InputStream fis = response1.getResponseStream();

                 FileOutputStream fos = new FileOutputStream(path);

                 

                       // Read the data in 1KB chunks and write it to the file

                       byte[] readData = new byte[1024];

                       int i = fis.read(readData);

                       while (i != -1) {

                         fos.write(readData, 0, i);

                           System.out.println("reading the data ");

                         i = fis.read(readData);

                       }

                   

                       // Close the socket connection

                       response1.close();

                       // Don't leave the streams open

                       fos.close();

                       fis.close();

                }                                     

                    catch (IdcClientException ice)

                 {

                   ice.printStackTrace();

                 }

                  catch (IOException ioe)

                  {

                 ioe.printStackTrace();

              

            }

}

Kindly analyse my code and let me know the problem here why i am not able to download the file.

Answers