Pages

Monday, December 21, 2015

RIDC sample : How to Create Native file URL from checkin response

RIDC sample : How to Create Native file  URL from  checkin response


Customer having requirment to get the Native URL after checkin the file . Usually it takes one more service call required to get the Native File URL . Using this method we can save the next DOC_INFO service call and create the link or URL from the same response of checking

1. Place required lib files under lib folder
commons-codec-1.2.jar
commons-httpclient-3.1.jar
commons-logging-1.0.4.jar
oracle.ucm.ridc-11.1.1.jar


2.Create classpath file :

LIB=`pwd`/lib

CLASSPATH=$CLASSPATH:$LIB/oracle.ucm.ridc-11.1.1.jar:$LIB/commons-codec-1.2.jar:$LIB/commons-httpclient-3.1.jar:$LIB/commons-logging-1.0.4.jar:.
export CLASSPATH


3. source classpath

. ./classpath

4. Complie RIDCCheckinAndNativeURL.java file ( check the bottom of page )


javac RIDCCheckinAndNativeURL.java

5. Create connection.properties : this contains connection details like IP,username & password

url=http://IP:16200/cs/idcplg
#url=idc://IP:IDCPORT
user=weblogic
password=welcome1
primaryFile=/tmp/sterin

Make sure that file will be created in path mention in the config.properties file

8. Run java class:

java RIDCCheckinAndNativeURL

Example of Output


java RIDCCheckinAndNativeURL

java RIDCCheckinAndNativeURL
@Properties LocalData
UserDateFormat=iso8601
IdcService=CHECKIN_UNIVERSAL
UserTimeZone=UTC
dDocTitle=Test RIDC Checkin
dDocType=Document
dDocAccount=
dSecurityGroup=Public
@end
ContentID is STJACOBPC1IDCO1245601
dID is 1245601
GET_FILE_URL http://IP:PORT/cs/idcplg?IdcService=GET_FILE&dID=1245601&dDocName=CO1245601&AllowInterrupt=1


I edited the IP and PORT from the output


If there is issue with check in , then exception will be automatically caught

Code :


import java.io.*;
import oracle.stellent.ridc.*;
import oracle.stellent.ridc.model.*;
import oracle.stellent.ridc.protocol.*;
import oracle.stellent.ridc.protocol.intradoc.*;
import oracle.stellent.ridc.common.log.*;
import oracle.stellent.ridc.model.serialize.*;
import oracle.stellent.ridc.protocol.http.*;
import java.util.*;

/*
* @author Sterin Jacob -
*
* This is a class used to test the basic functionality
* of submitting a checkin to Content Server using RIDC.
*/

public class RIDCCheckinAndNativeURL {

/**
* @param args
*/
public static void main(String[] args) {
// Create a new IdcClientManager
IdcClientManager manager = new IdcClientManager ();
Properties prop = new Properties();
InputStream input = null;

try{

input = new FileInputStream("config.properties");
// load a properties file
prop.load(input);


// Create a new IdcClient Connection using idc protocol (i.e. socket connection to Content Server)
IdcClient idcClient = manager.createClient (prop.getProperty("url"));

IdcContext userContext = new IdcContext (prop.getProperty("user"),prop.getProperty("password"));

// 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 ());
// Create a new binder for submitting a search
DataBinder dataBinder = idcClient.createBinder();
// Databinder for checkin request
dataBinder.putLocal("IdcService", "CHECKIN_UNIVERSAL");
dataBinder.putLocal("dDocTitle", "Test RIDC Checkin");
dataBinder.putLocal("dDocType", "Document");
dataBinder.putLocal("dDocAccount", "");
dataBinder.putLocal("dSecurityGroup", "Public");
dataBinder.addFile("primaryFile", new File( prop.getProperty("primaryFile") ));
// Write the data binder for the request to stdout
serializer.serializeBinder (System.out, dataBinder);
// Send the request to Content Server
ServiceResponse response = idcClient.sendRequest(userContext,dataBinder);
// Get the data binder for the response from Content Server
DataBinder responseData = response.getResponseAsBinder();
// Write the response data binder to stdout
//serializer.serializeBinder (System.out, responseData);


System.out.println("ContentID is " + responseData.getLocal("dDocName"));
System.out.println("dID is " + responseData.getLocal("dID"));
String GET_FILE_URL;

GET_FILE_URL=prop.getProperty("url")+"?IdcService=GET_FILE&dID="+responseData.getLocal("dID")+"&dDocName="+responseData.getLocal("dDocName")+"&AllowInterrupt=1";

System.out.println("GET_FILE_URL "+ GET_FILE_URL);
} catch (IdcClientException ice){
ice.printStackTrace();
} catch (IOException ioe){
ioe.printStackTrace();
}
}

}


No comments:

Post a Comment