Pages

Tuesday, October 27, 2015

RIDC sample : GenericRIDC Class to run every idc service

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 

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( "...........");

}

}




 }

Monday, October 12, 2015

How to create wifi hotspot in fedora 21 ?


In this example , wifi hotspot from fedoa21 is connecting to Android Phone



1. Create HotSpot network

Settings → Network → Select wifi → Use As Hotspot





2. It will create Hotspot file under   /etc/NetworkManager/system-connections






3. Usually this sufficient to access from your phone .


Select SID:
Provide the password :



4. Sometime phone can connect to SID , but stuck at “Authenticating “ or “Getting IP adress

in that case , Follow below steps to debug the issue

5. Verify the Hotsport file created in /etc/NetworkManager/system-connections


[root@sterinlap system-connections]# more Hotspot
[connection]
id=Hotspot
uuid=e6a7f45e-2bf3-4e92-8ba3-90e759sds32f2bc
type=wifi
autoconnect=false

[wifi]
ssid=sterinlap
mode=ap
mac-address=AC:7B:A1:3C:E2:3B
security=802-11-wireless-security
hidden=true

[wifi-security]
key-mgmt=wpa-psk
proto=rsn;
pairwise=ccmp;
group=ccmp;
psk=PASSWORD

[ipv4]
method=shared

[ipv6]
method=auto

Key is mode should ap

6. Get the Lan Card details :
ifconfig whill show the deails

Here my wirless card is wlp2s0:

7.Disable the firewall
systemctl stop firewalld.service

8.Start the hotspot from commadline :
nmcli con up Hotspot ifname wlp2s0


[root@sterinlap system-connections]# nmcli con up Hotspot ifname wlp2s0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/19)


9. Connect from mobile

10.Some times , you have to set proxy in phone to access internet .




  1. Connect to WIFI network (e.g. 'sterinlap')
  2. Settings->WIFI
  3. Long tap on connected network's name (e.g. on 'sterinlap')
  4. Modify network config-> Show advanced options
  5. Set proxy settings

11. Next time , while accessing the hotspot, you have to simply follow steps 1,2 Phone will be automatically connects it






Tuesday, October 6, 2015

Static IP is not coming up in Vmware after restoring from backup



Network is not working in VM ware . After the reboot guest OS is up but not able to access in network




Steps to Debug

1. Get the mac address from Virtual Box console , by clicking on settings and Network

2. Make sure that “Brigded” is selected

3. In Guest OS try these  steps

4. Verify the mac address by running

ifconfig and grep hardware

ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:5A:29:A5
inet addr:IP Bcast:IP Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:718 errors:0 dropped:0 overruns:0 frame:0
TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:57933 (56.5 KiB) TX bytes:3516 (3.4 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:32 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1882 (1.8 KiB) TX bytes:1882 (1.8 KiB)

Here mac address is 00:0C:29:5A:29:A5

ifconfig | grep Hwaddr
eth0 Link encap:Ethernet HWaddr 00:0C:29:5A:29:A5


it should match with step 1

if mac  address is not matching then follow step 10 .



5. Search in  dmesg for  etho

[root@OS ~]# dmesg|grep eth0
e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:5a:29:a5
e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

it should match mac from step 1

6.Try with disabling Ipv6

to disable Ipv6 edit : /etc/sysctl.conf and add net.ipv6.conf.all.disable_ipv6 = 1



7. Set NM_CONTROLLED=no in /etc/sysconfig/networking-script/if-eth0

8. Copy /etc/sysconfig/networking-script/if-eth0 to
             /etc/sysconfig/networking/devices/ifcfg-eth0

9.After restarting , issue resolved



Step 10 :
If mac address is not matching with VM IP and  ifconfig | grep Hwaddr

Change using below steps
 

  
# ifconfig eth0 down
# ifconfig eth0 hw ether 00:0C:29:5A:29:A5 
# ifconfig eth0 up
# ifconfig eth0 |grep 
 
Details : http://www.aboutlinux.info/2005/09/how-to-change-mac-address-of-your.html 







Thursday, October 1, 2015

Hello world ucm Custom component

Hello world ucm Custom component :




Purpose :

it is simple component which explains
1.How to create new service
2.How to create new template
3.How to link java class with service
4.How to pass values from class to template

Detailed steps

1. Start ComponentWizard and Add New component “HelloWorld”












































2. After providing the component name , Add the service

3.Add → Service →


4. Provide the service name and other details




















































Name: HELLO_WORLD
Servic Class : Service
Template : ( which will updated after creating the template)
Actions : ( which will updated after creating java class )


5 . Add → Static Table (HTML format )

6. Second page , Merget to column name : ServiceHandlers




7 . Edit resource :
File Name : helloworld_resource.htm Location : Intradoc/custom/HelloWorld/resource
from <td>ServiceHandler</td><td>MyServiceHandler </td><td>MysearchOrder</td>
<td>Service</td><td>Helloworld.MyJavaClass</td><td>MysearchOrder</td>
Line : 16


























8. On the file system , new folder will be created under <>/custom folder
Go to <>/ucm/cs/custom/Helloworld



9. Create folders as
classes/<PackageName>/<Classes>
here
classes/Helloworld/

10. Copy the complied java class . ( Java is menstion at the bottom of the page )

MyJavaClass is the class name
public class MyJavaClass extends ServiceHandler
myJavaMethod is the method name

11. Add the template

Name : helloworld_display
Clas : User
Form Type : Home page
File Name : helloworld_display.htm














































12. Edit helloworld_display.htm using editor : Entire file will at the bottom of the page





<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<$defaultPageTitle="Helloworld"$>
<$include std_html_head_declarations$>
</head>

<$include body_def$>

<$include std_page_begin$>

<$include std_header$>

Helloworld!!


<$include std_page_end$>

</body>
</html>


<$include are required to display the template in normal UCM page .


13 .Go to Build → Build settings → Advanced
Custom Class path : $COMPONENT_DIR/classes ( From drop down) – “ok”
Add → Component Class ( use defailt option) - “ok”



14 . Edit the service as step 4 add the template

15 . Edit the service as step 4 add the java method



































































16. Build → Build

17 . Add DisableAuthorizationTokenCheck=true in config.cfg (to disable to idcToken )


18. Restart the UCM


Verify the component

1. Access IdcService=HELLO_WORLD
it will show























2.In system audit info page add Trace section as “Helloworld”



























3. Verify the server output , after accessing the idc service

>Helloworld/6   10.02 16:48:38.652      IdcServer-52    Paramater1 Passed from service  is null

4. Access like IdcService=HELLO_WORLD&Paramater1=RED
>Helloworld/6   10.02 16:49:46.614      IdcServer-55    Paramater1 Passed from service  is RED



Follow below url to add link : http://wccandlinux.blogspot.in/2015/09/how-to-create-ucm-wcc-custom-component.html



MyJavaClass.java

package Helloworld;

import java.util.*;
import java.io.*;
import intradoc.common.*;
import intradoc.data.*;
import intradoc.server.*;
import intradoc.shared.*;


public class MyJavaClass extends ServiceHandler
{
   
    /**
     * This code will create a html page based on the data in the databinder,
     * and email it to the list of addresses specified by the user.
     */
    public void myJavaMethod() throws DataException, ServiceException
    {
                 String Paramater1;



                       
                    Paramater1 = m_binder.getLocal("Paramater1");

                    traceVerbose( "Paramater1 Passed from service  is " + Paramater1) ;

                 
                       // Accessing standard Java classes
                     String osdetails  = System.getProperty("os.name")+System.getProperty("os.arch")+System.getProperty("os.version") ;
                        // Sending to LocalData to display
                            
                      
                             m_binder.putLocal("osdetails",osdetails);



                 
       
   
    }
   
   



private static void trace(final String message)

              {          // Setting trace section
                           Report.trace("Helloworld", message, null);
              }       


 private static void traceVerbose(final String message)

                  {
               
                if (Report.m_verbose)
                         {
                        trace(message);
                         }
                   }


}