RIDC sample : GenericRIDC Class
Purpose : To Run every service
in UCM by changing parameter .
Other than checkin or any upload service , we can use this class to pass parameters and display required output
Other than checkin or any upload service , we can use this class to pass parameters and display required output
To Display output of
one ResultSet
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
GenericRIDCCallAndDisplay.java file ( check the bottom of page )
javac GenericRIDCCallAndDisplay.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
6.Create
service.properties : this contains idc service details :
for search of
Content Type having Application
IdcService=GET_SEARCH_RESULTS
QueryText=dDocType
<contains> `Application`
SearchQueryFormat=Universal
ResultCount=20
7. Create
output.properties : this contains details of ResultSet and Fields to
display
Case 1 : Display all
the fields in the result set
ResultSet=SearchResults
#if DisplayAll set to "yes"
,then it will display all the columns of Resultset, else , it wil
display
DisplayAll=yes
Case 2 : Disaplt
Specific Fields in the ResultSet
ResultSet=SearchResults
#if DisplayAll set to "yes"
,then it will display all the columns of Resultset, else , it wil
display
DisplayAll=no
#####
dDocName=yes
dDocTitle=yes
dDocAuthor=yes
8. Run java class:
java
GenericRIDCCallAndDisplay
Example of Output of
Case 2 :
[sterin@sterinlap
GenericRIDC]$ java GenericRIDCCallAndDisplay
@Properties LocalData
UserDateFormat=iso8601
IdcService=GET_SEARCH_RESULTS
SearchQueryFormat=Universal
UserTimeZone=UTC
query=Read
QueryText=dDocType
<contains> `Application`
ResultCount=20
contexts=ExternalRoles.dExtRoleName
@end
SearchResults is found
--------
Going to Results
dDocName is SS_TEXTAREA_FORM
dDocAuthor is sysadmin
dDocTitle is
SS_TEXTAREA_FORM
...........
dDocName is
SS_CUSTOM_QUERY_FORM
dDocAuthor is sysadmin
dDocTitle is
SS_CUSTOM_QUERY_FORM
Example of Output of
Case1 :
[sterin@sterinlap
GenericRIDC]$ java GenericRIDCCallAndDisplay
@Properties LocalData
UserDateFormat=iso8601
IdcService=GET_SEARCH_RESULTS
SearchQueryFormat=Universal
UserTimeZone=UTC
query=Read
QueryText=dDocType
<contains> `Application`
ResultCount=20
contexts=ExternalRoles.dExtRoleName
@end
SearchResults is found
--------
Going to Results
dDocName SS_TEXTAREA_FORM
dDocTitle
SS_TEXTAREA_FORM
dDocType Application
dSecurityGroup Public
dInDate 2015-08-07
10:13:29Z
xLibraryGUID
xHidden FALSE
…........................................
Another fields ( it will display all the metadata in the
system))).......................................................
…........................................
Another Contents
.......................................................
RIDC java file
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 java.util.Properties;
/*
* @author Sterin- Oracle Inc
*
* This is a class used to test the basic functionality
* of submitting a search to Content Server using RIDC.
* The response is then used to retrieve metadata about
* the content items.
*/
public class GenericRIDCCallAndDisplay {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
IdcClientManager manager = new IdcClientManager ();
Properties propConnection = new Properties();
Properties propService = new Properties();
Properties propOutput = new Properties();
InputStream input = null;
try{
input = new FileInputStream("connection.properties");
// load a properties file
propConnection.load(input);
input = new FileInputStream("service.properties");
propService.load(input);
input = new FileInputStream("output.properties");
propOutput.load(input);
// Create a new IdcClient Connection using
idc protocol (i.e. socket connection to Content Server)
IdcClient idcClient = manager.createClient
(propConnection.getProperty("url"));
IdcContext userContext = new IdcContext
(propConnection.getProperty("user"),propConnection.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();
for (String key :
propService.stringPropertyNames()) {
dataBinder.putLocal(key,propService.getProperty(key));
}
// 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);
// Retrieve the SearchResults ResultSet from the response
DataResultSet resultSet =
responseData.getResultSet(propOutput.getProperty("ResultSet"));
if (resultSet != null)
{
System.out.println(propOutput.getProperty("ResultSet") + "
is found");
System.out.println("--------\n" + "Going
to Results \n");
}
else
{
System.out.println(propOutput.getProperty("ResultSet") + "
is not valid Resultset .. exiting ");
}
// Iterate over the ResultSet, retrieve properties from
the content items
// int columsize = resultSet.getFields().size();
if (
propOutput.getProperty("DisplayAll").equalsIgnoreCase("yes"))
{
DisplayAll(resultSet);
}
else
{
for (DataObject
dataObject : resultSet.getRows ()) {
for
(String key : propOutput.stringPropertyNames()) {
String value = propOutput.getProperty(key);
if
(!key.equals("ResultSet") &&
!key.equals("DisplayAll") &&
value.equalsIgnoreCase("yes") )
{
System.out.println(key + " is " + dataObject.get(key) );
}
}
System.out.println( "...........");
}
}
} catch (IdcClientException ice){
ice.printStackTrace();
} catch (IOException ioe){
ioe.printStackTrace();
}
}
public static void DisplayAll (DataResultSet resultSet)
{
int columsize = resultSet.getFields().size();
for (DataObject dataObject : resultSet.getRows ()) {
for ( int
j=0;j< columsize ; j++)
{
// System.out.println( resultSet.getField(j).getName());
String key = resultSet.getField(j).getName();
String value = dataObject.get(key);
System.out.println( key + " " + value);
}
System.out.println( "...........");
}
}
}