Tuesday, 18 November 2014

View Content (Attachment) in FileNet Document (Content Engine API)

//View Content (Attachment) in FileNet Document (Content Engine API)


        ceConnection = //Get Connection
        domain = //Get Domain
        objectStore = //Get Object Store
       
        InputStream inputStream=null;
        try
        {
        FileInputStream is=null;
       
        System.out.println("inside fetchdoc Filenet----------------------------");
        ArrayList[] ars=new ArrayList[2];
        SearchScope search=new SearchScope(objectStore);
       
        String sql1= "Select * from [DocClass_Test] where ([DocumentTitle]= '"+DocTitle+"')";
        SearchSQL searchSQL=new SearchSQL(sql1);
        DocumentSet documents=(DocumentSet)search.fetchObjects(searchSQL, Integer.getInteger("50"), null, Boolean.valueOf(true));
        Document doc;
        Iterator it=documents.iterator();
       
        System.out.println("calling FileInputStream");
        while(it.hasNext())
        {
            doc=(Document)it.next();
            ContentElementList contents = doc.get_ContentElements();
              ContentTransfer ct;
              Iterator itContent = contents.iterator();
              while(itContent.hasNext()) {
                  ct = (ContentTransfer)itContent.next();
              inputStream = ct.accessContentStream();
              int bufferLength = 64*1024; // buffer size (64KB)
                byte[] buffer = new byte[bufferLength];
                int read=0;
              
                DataOutputStream out = new DataOutputStream(response.getOutputStream());
                System.out.println("calling while-- check");
                while((read=inputStream.read(buffer))!=-1)
                {
                    out.write(buffer,0,read);                 
                }
               
                out.close();
   
        }     
        }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

1 comment:

  1. response cannot be resolved error in the below line
    DataOutputStream out = new DataOutputStream(response.getOutputStream());

    What is the resolve for this?

    ReplyDelete