Sitemap

Sunday, April 5, 2015

RIDC: Download files in ZIP format

    public static void main(String[] args) throws IOException {
        IdcClientManager manager = new IdcClientManager();
        try {
            IdcClient idcClient = manager.createClient("idc://localhost:4444");
            IdcContext userContext = new IdcContext("weblogic");

            DataBinder dataBinder = idcClient.createBinder();
            dataBinder.putLocal("IdcService", "GET_ZIP_BUNDLE");
            dataBinder.putLocal("pkg:dDocName1", "HY000227");
            dataBinder.putLocal("pkg:dDocName0", "HY000001");
//            dataBinder.putLocal("pkg:Rendition1", "Primary");
//            dataBinder.putLocal("pkg:Rendition0", "Web");
            dataBinder.putLocal("bundleKeys", "pkg:dDocName,pkg:Rendition");
            ServiceResponse response = idcClient.sendRequest(userContext, dataBinder);
            InputStream is = response.getResponseStream();
            FileOutputStream fos = new FileOutputStream("bundle.zip");
            int read = 0;
            byte[] bytes = new byte[1024];
            while ((read = is.read(bytes)) != -1) {
                fos.write(bytes, 0, read);
            }
        } catch (IdcClientException ice) {
            ice.printStackTrace();
        }
    }


No comments:

Post a Comment