Pages

Wednesday, February 17, 2016

How to search old revisions of the contents in UCM or WCC server?

How to search old revisions of the contents in UCM or WCC server? 

OR 

How to search for dID in WCC instead of dDocName ?

By default GET_SEARCH_RESULT search only the active revision of the content

 .

Like Revision 1 of content having Comment as '123'
Revision 2 of content having Comment as '456'

GET_SEARCH_RESULT with xComments=456 will show the content . But xComment=123 wont show any content .

This is working as expected from UCM side .

Work around : IdcService GET_DATARESULTSET can be used here . But this service wont have any dynamic Html page is associated with it . So you need some customization to use it

Append &IsSoap=1 will show the DataResultSet in xml format .

Paramete to pass:

IdcService=GET_DATARESULTSET
dataSource=Documents
whereClause=(xComments='123')
resultName=DOCUMENTS
IsSoap=1 (or Is Java=1 , IsJson=1)


RIDC code for this

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

java class



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 SearchfordID {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
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.putLocal("IdcService", "GET_DATARESULTSET");
dataBinder.putLocal("dataSource", "Documents");
dataBinder.putLocal("whereClause", "xComments='123'");
dataBinder.putLocal("resultName", "DOCUMENTS");

ServiceResponse response = idcClient.sendRequest(userContext,dataBinder);

DataBinder responseData = response.getResponseAsBinder();
DataResultSet resultSet = responseData.getResultSet("DOCUMENTS");



for (DataObject dataObject : resultSet.getRows ())

{
System.out.println("dID "+ dataObject.get("dID")+" dDocName "+dataObject.get("dDocName") + " Revision " +dataObject.get("dRevLabel") );


}



} catch (IdcClientException ice){
ice.printStackTrace();
} catch (IOException ioe){
ioe.printStackTrace();
}
}

}

Example of Output


java SearchfordID

dID 1335 dDocName SOURCEFF001325 Revision 1
dID 802 dDocName SOURCEFF000802 Revision 1
dID 1337 dDocName SOURCEFF001325 Revision 3


Monday, February 15, 2016

Java : How to iterate through array with out using any loop ?
     
     OR

 How to get sum of members of array with out using any loop



Purpose : This java class to show to iterate array with out using any loop like ( for ,while etc)




public class SumArrayWithoutLoop



{



public static void main (String args[])


 {


int  a [] = {3,5,6,7,8,9,10};


System.out.println("Sum is "+ sumfunction(a,0,-1));

 }


 public static  int  sumfunction ( int arr[ ],int sum,int index)

 {
           

      if (  index  > arr.length-2  )

         {
              
         
          return sum;

         }

    else 
         {   index++;
            sum  = sum + arr[index];
             System.out.println("Index  "+index +" Sum "+sum);
            sum=sumfunction(arr,sum,index);

          }

return sum;

 }






Output :

java SumArrayWithoutLoop

Index  0 Sum 3
Index  1 Sum 8
Index  2 Sum 14
Index  3 Sum 21
Index  4 Sum 29
Index  5 Sum 38
Index  6 Sum 48
Sum is 48


Tuesday, February 2, 2016

How to create High Availability Port with idc protocol ?

How to create High Availability Port with  idc protocol ?




Purpose : Using balance software , HA port is created with idc protocol . So this will help to load balance idc port in clustered domain .



Steps :
1.Install balance
2.run balance command


Detailed Steps :

1. Download balance from : https://www.inlab.de/balance.html




2. Make and Install it

cd balance-3.56
[root@LB balance-3.56]# make

gcc -O2 -Wall -Wstrict-prototypes -Wuninitialized -I. -c balance.c
balance.c: In function ‘stream’:
balance.c:910: warning: pointer targets in passing argument 1 of ‘hash_fold’ differ in signedness
./balance.h:133: note: expected ‘char *’ but argument is of type ‘unsigned char *’
balance.c: In function ‘main’:
balance.c:1813: warning: pointer targets in passing argument 1 of ‘hash_fold’ differ in signedness
./balance.h:133: note: expected ‘char *’ but argument is of type ‘unsigned char *’
gcc -O2 -Wall -Wstrict-prototypes -Wuninitialized -I. -c butils.c
gcc -O2 -Wall -Wstrict-prototypes -Wuninitialized -I. -o balance balance.o butils.o

[root@LB balance-3.56]# make install


install -o root -g root -m 755 balance \
/usr/sbin/balance
install -o root -g root -m 755 balance.1 \
/usr/sbin/../man/man1
install: cannot create regular file `/usr/sbin/../man/man1': No such file or directory


3.Verify by running balance commad

[root@myserver ~]balance
_ _
| |__ __ _| | __ _ _ __ ___ ___
| '_ \ / _` | |/ _` | '_ \ / __/ _ \
| |_) | (_| | | (_| | | | | (_| __/
|_.__/ \__,_|_|\__,_|_| |_|\___\___|
this is balance 3.56
Copyright (c) 2000-2009,2010
by Inlab Software GmbH, Gruenwald, Germany.
All rights reserved.



4.Run the balance command with idc server

Example : balance -b ::ffff:<LB> -B <LBHOSTNAME> <LBPORT> <IP1:POR1> <IP2:PORT2>

[root@myserver ~]# netstat -anp | grep 4444

[root@LB ]# balance -b ::ffff:10.111.11.111 -B LBHOST 4444 10.111.11.121:4453 10.111.11.122:4997
[root@LB ]# netstat -anp | grep 4444
tcp 0 0 ::ffff:10.111.11.111:4444 :::* LISTEN 23705/balance


6. Verify it

Here for testing purpose I am connecting two different WCC servers , which is having different autoprefix and running CHECKIN_UNIVERSAL . Make sure that admin server should be up and running while connecting via idc protocol

url= 10.111.11.111:4444
[sterin@sterinlap test]$ java TestRIDCCheckin
dDocName is SOURCEFF001052
[sterin@sterinlap test]$ java TestRIDCCheckin
dDocName is STJACOBPC1IDCO001205

So It will connect in round robin fashion . If one server is down, then automatically connect to other one