Checkin UCM

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import java.io.

BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.List;
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.DataObject;
import oracle.stellent.ridc.model.TransferFile;
import oracle.stellent.ridc.protocol.ServiceResponse;

public class Checkin_UCM {


// private IdcClient client;
// private IdcContext connectionContext;
public static void main(String[] args) throws IdcClientException,
IOException {
SearchUCM upload = new SearchUCM();
IdcClientManager manager = new IdcClientManager();
// build a client that will communicate using the intradoc protocol
IdcClient idcClient = manager.createClient("idc://172.19.8.143:4444");
// create an identity
IdcContext userContext = new IdcContext("weblogic_ucm");
ServiceResponse myServiceResponse = null;
FileInputStream fis = new FileInputStream(new File("D://input_for_checko
ut.csv"));
//PrintStream out = new PrintStream(new FileOutputStream("D://input_for_
checkout.csv"));
DataInputStream in = new DataInputStream(fis);
// BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
String csvFile = "D://input_for_checkout.csv";
BufferedReader br = null;
String line = "";
String cvsSplitBy = ",";
FileInputStream fileStream=null;
br = new BufferedReader(new FileReader(csvFile));
while ((strLine = br.readLine()) != null) {
try {
String[] content = strLine.split(cvsSplitBy);
// FileInputStream fileStream = null;
String fileName = content[0];
fileStream = new FileInputStream(fileName);
long fileLength = new File(fileName).length();
DataBinder myRequestDataBinder = idcClient.createBinder();
myRequestDataBinder.putLocal("IdcService",
"CHECKIN_UNIVERSAL");
myRequestDataBinder.putLocal("dDocName", content[1]);
myRequestDataBinder.addFile("primaryFile",new TransferFile(fileS
tream,fileName,fileLength,"text/html"));
myServiceResponse =
idcClient.sendRequest(userContext, myRequestDataBinder);
InputStream myInputStream =
myServiceResponse.getResponseStream();
String myResponseString =
myServiceResponse.getResponseAsString();
System.out.println("File Checked-in Successfully: " + "Content_I
D="+ content[0] +"File name="+content[1] +"Other Details="+ myResponseString);
DataBinder myResponseDataBinder =
myServiceResponse.getResponseAsBinder();
System.out.println("File uploaded successfully");
} catch (IdcClientException idcce) {
System.out.println("IDC Client Exception occurred. Unable to upl
oad file. Message: " +
idcce.getMessage() + ", Stack trace: ");
idcce.printStackTrace();
} catch (IOException ioe) {
System.out.println("IO Exception occurred. Unable to upload file
. Message: " +
ioe.getMessage() + ", Stack trace: ");
ioe.printStackTrace();
} catch (Exception e) {
System.out.println("Exception occurred. Unable to upload file. M
essage: " +
e.getMessage() + ", Stack trace: ");
e.printStackTrace();
} finally {
if (myServiceResponse != null) {
myServiceResponse.close();
}
if (fileStream != null) {
try {
fileStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}

You might also like