Showing posts with label Cloud. Show all posts
Showing posts with label Cloud. Show all posts

Wednesday, May 30, 2018

Oracle Bot Cloud (IBCS): Custom UI

Problem Description: In this blog I would be going over various options to build a web UI for IBCS chat bot.

By default IBCS provides two sdks to build web UI for Chatbot. We can download those sdks from
http://www.oracle.com/technetwork/topics/cloud/downloads/mobile-suite-3636471.html under heading Bots Client SDK


We can follow link https://docs.oracle.com/en/cloud/paas/mobile-suite/use-chatbot/bot-channels.html#GUID-A0A40E26-54BA-4EDD-A4C5-95D498D6CF61 to find out how to use these SDKs.


Widget is very cool and rich but still at times you want to build your own custom UI instead of widget. To do that you can follow
https://docs.oracle.com/en/cloud/paas/mobile-suite/use-chatbot/bot-channels.html#GUID-78F6DD7E-5085-476B-AD03-1318D9107D39

In this blog I am trying to enhance that code to handle postback requests. Also this blog will help me in my next blog to achieve voice based conversation.

1. Add below code in html
HTML:
 <div id="no-display" style="display:none;"></div>
       <p>User ID: <span id="user-id"></span></p>
       <ul id="conversation"></ul>
    <input type="text" id="text-input" placeholder="text">

<script src="js/app.js"></script>


2. Add app.js inside js directory. It can have following code
!function(e,t,n,r){
    function s(){try{var e;if((e="string"==typeof this.response?JSON.parse(this.response):this.response).url){var n=t.getElementsByTagName("script")[0],r=t.createElement("script");r.async=!0,r.src=e.url,n.parentNode.insertBefore(r,n)}}catch(e){}}var o,p,a,i=[],c=[];e[n]={init:function(){o=arguments;var e={then:function(t){return c.push({type:"t",next:t}),e},catch:function(t){return c.push({type:"c",next:t}),e}};return e},on:function(){i.push(arguments)},render:function(){p=arguments},destroy:function(){a=arguments}},e.__onWebMessengerHostReady__=function(t){if(delete e.__onWebMessengerHostReady__,e[n]=t,o)for(var r=t.init.apply(t,o),s=0;s<c.length;s++){var u=c[s];r="t"===u.type?r.then(u.next):r.catch(u.next)}p&&t.render.apply(t,p),a&&t.destroy.apply(t,a);for(s=0;s<i.length;s++)t.on.apply(t,i[s])};var u=new XMLHttpRequest;u.addEventListener("load",s),u.open("GET",r+"/loader.json",!0),u.responseType="json",u.send()
}(window,document,"Bots", "<Your-Bot-sdk-url>");

var appId = '<Your app id>';

Bots.init({
        appId: appId, embedded: true
    }).then(function (res){
        console.log("init complete");

    });

Bots.render(document.getElementById('no-display'));


var inputElement = document.getElementById('text-input');
  inputElement.onkeyup = function(e) {
  if (e.key === 'Enter') {
    var totalMsg = Bots.getConversation().messages.length;
    if(Bots.getConversation().messages[totalMsg-1] && Bots.getConversation().messages[totalMsg-1].actions){
        
        var actions = Bots.getConversation().messages[totalMsg-1].actions.filter(function(action){
            return action.text === inputElement.value; //Improve it by performing case insensitive matching
        })
        if(actions){
            Bots.triggerPostback(actions[0]._id).then(function() {
                        inputElement.value = '';
                    });
        }
        
    }
    else{
       Bots.sendMessage(inputElement.value).then(function() {
                inputElement.value = '';
            }); 
    }
        
    }
   
  }


function displayUserMessage(message) {
    console.log(message);
            var conversationElement = document.getElementById('conversation');
            var messageElement = document.createElement('li');
            messageElement.innerText = message.name + ' says "' + message.text + '"';
            conversationElement.appendChild(messageElement);
        }

        function createButtonElement(action) {
            var btnElement = document.createElement('button');
            var btnTitle = document.createTextNode(action.text);
            btnElement.appendChild(btnTitle);
            btnElement.onclick = function(e){Bots.triggerPostback(action._id);};
            return btnElement;
        }

    function displayServerMessage(message) {
         console.log(message);
            var conversationElement = document.getElementById('conversation');
            var messageElement = document.createElement('li');
            var text = 'Server says "' + message.text + '"';
            messageElement.innerText = text;

            if(message.actions && message.actions.length > 0){
                var wrapperElement = document.createElement('div');
                for(var i = 0; i < message.actions.length; i++){
                    var action = message.actions[i];
                    var btnElement = createButtonElement(action);
                    wrapperElement.appendChild(btnElement);
                }
                messageElement.appendChild(wrapperElement);
                isPostBackRequired = true;
                lastPostBackServerMsg = message;
            }
            conversationElement.appendChild(messageElement);


        }
  // display new messages
  Bots.on('message:sent', displayUserMessage);

  Bots.on('message:received', displayServerMessage);



NOTE:
1. Bot-sdk-url is url of your sdk directory. If you copy bot-sdk inside js directory as bot-client-sdk-js and server is running on port 8000, your bot-sdk-url would be http://localhost:8000/js/bots-client-sdk-js
2. app-id mentioned in above code is given on channels page of IBCS (once you register a web channel)

3. Input element in which user types message is enhanced to handle postBack message of user.
4. displayUserMessage function adds user typed message in list
5. displayServerMessage function adds server message in list. It also create appropriate buttons if server wants user to select one value.

UI is very crude but it gives you complete control to decorate it.

Now we have a very basic UI ready. My idea is to enhance it further and add voice feature to it in my Next blog.

Thats all in this blog.

Wednesday, May 16, 2018

Oracle Bot Cloud (IBCS): Switching Intents while in conversation (Nested Intent)

Problem Description: If we see IBCS flow generally tries to find user intent first. Once it identifies and intent, it tries to complete intent based on flow defined. There are all reasons that end user may want to switch his intent before completing first intent. For example, I am ordering pizza but while system asks me for pizza type, I decide to verify their payment options and I changed my intent. Something like below

Me: I would like to order a pizza
       
                   Bot: Which type of pizza would you like to have?

Me: Hold on, What are your payment options
     
               
In ideal conversation bot should provide me details of payment. Once payment options information is provided, it can ask me if I want to continue with Pizza order.

But in general we use either System.Text or System.List component when we want to take user input. This is the time when user can change his mind (or intent).

It looks like
askPizzaType:
    component: "System.List"
    properties:
      options: "${pizzaType.type.enumValues}"
      prompt: "Which type of pizza would you like to have?"
      variable: "pizzaType"
    transitions: {}

with this state, bot will provide a list of pizza types (say small, medium or large). Now even if user changes his mind and asks about payment options, bot will ask pizza type again and again. Very annoying.

In this blog we want to make it a bit realistic and introduce intelligence of user intent switching.

Lets say we have following initial bot configuration

1. Intents: OrderPizza, ProvideInfo
2. Entity: PizzaType (Associated with OrderPizza Intent)

3. Dialog-Flow:

Its able to complete payment option enquiry and pizza order but if user tries to switch from OrderPizza intent to ProvideInfo, bot keeps on asking about pizza type as shown below


Now lets improve it to handle intent switching.
a. To stop bot asking for pizzaType repeatedly, we can introduce maxPrompts=1 with askPizzaType (System.List) component.

b. We can add cancel action with askPizzaType (System.List) component to perform a transition, if bot can't find pizzaType even after max number of attempts ( NOTE: here we have already set max attempt as 1, so user can only provide one input. If that is not small/medium/large, cancel transition will take place)
askPizzaType:
    component: "System.List"
    properties:
      options: "${pizzaType.type.enumValues}"
      prompt: "Which type of pizza would you like to have?"
      variable: "pizzaType" 
      maxPrompts: 1
    transitions: 
      actions:
        cancel: "verifyIntentWhileOrderPizzaInProgress"    

c. verifyIntentWhileOrderPizzaInProgress can set uncompletedIntent in a variable and then perform an nlp intent-matching on user input. If its unresolved in NLP matching assume that user is trying to answer pizzaType question but some typo etc happened so lets take him back to askPizzaType.

verifyIntentWhileOrderPizzaInProgress:
    component: "System.SetVariable"
    properties:
      variable: "uncompletedIntent"
      value: "OrderPizza"
    transitions: {}        
  verifyIntent:
    component: "System.Intent"
    properties:
      variable: "iResult2"
      confidenceThreshold: 0.4
    transitions:
      actions:
        OrderPizza: "orderPizza"
        ProvideInfo: "provideInfo"
        unresolvedIntent: "askPizzaType"

d. Lets improve provideInfo state as well to handle uncompleted intent (OrderPizza). After providing information of payment option, verify if there is any uncompleted intent. If yes suggest to continue with that intent else done
provideInfo:
    component: "System.Output"
    properties:
      text: "We support credit card, debit card and cash on delivery. "
      keepTurn: true
    transitions: 
       next: "isAnyIncompleteIntent"

e. Lets introduce few states to gracefully end conversation or ask for any pending intent completion.
  isAnyIncompleteIntent:
    component: "System.ConditionEquals"
    properties:
      variable: "uncompletedIntent"
      value: "OrderPizza"
    transitions:
      actions:
        equal: "askToStartPizzaOrderAgain"
        notequal: "done"  
  askToStartPizzaOrderAgain:
    component: "System.Output"
    properties:
      text: "Lets continue with Pizza ordering."
      keepTurn: true
    transitions: 
       next: "orderPizza"   
  done:
    component: "System.Output"
    properties:
      text: "Is there any other way I can help you?"
    transitions:
      actions:
       return: "done"

Complete flow looks like below

Effectively by above improvements in flow we are trying to enable user to switch intent while in between conversation.
After above change flow looks like this.
Thats all

Monday, July 31, 2017

JCS-SX: Deploy your first application

Problem description: If you create a minimum ADF application and try deploy it directly on JCS-SX instance your deployment may fail with below error

2017-07-31 19:02:13 CDT: weblogic.application.ModuleException: weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1531)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:488)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:59)
at


Solution:
You need to create weblogic.xml file inside WEB-INF and make following entry in it

<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd"
      xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
   

    <library-ref>
        <library-name>adf.oracle.domain.webapp</library-name>
    </library-ref>
    <library-ref>
        <library-name>jstl</library-name>
        <specification-version>1.2</specification-version>
    </library-ref>
    <library-ref>
        <library-name>jsf</library-name>
        <specification-version>1.2</specification-version>
        <exact-match>true</exact-match>
    </library-ref>


</weblogic-web-app>


Once done you can deploy your application.


Thats all.

Sunday, April 16, 2017

JCS/JCS-SX: Creating application server connection

Problem Description: I see most of the time people face issues while creating connection with JCS server using Jdev. Its pretty straight forward but we provide wrong details most of the time.

Solution

1. Use Resources pane and select New Connection > Application Server

2. If this JCS account then you can enable your weblogic ports 7001/7002 to public and make normal weblogic application server connection in Resource tab.


3. If its JCS-SX then you may want to use Oracle Cloud type of application-server connection. On first tab provide any name to your connection and select connection-type = Oracle Cloud


4. Next tab provide username/password. NOTE: These are cloud service user not weblogic user. In normal weblogic connection we provide weblogic user and its password but here it should be cloud user and password. If you don't have cloud user details ask cloud admin (who owns identity domain of cloud).



5. Next tab is where you need to select cloud service details [Datacenter, Identity-domain, Service Name]. This is the tab where I see mistakes most of the time. We should be knowing how to get these information. For that login to your cloud my services dashboard.

Datacenter, you always know as that is first thing you select when you want to login to your cloud account. Most of the time for me its us2.

Find identity domain on dashboard



   Select your JCS-SX instance and launch Service Detail page. 
   Get Service-Name as shown below from Service Detail page


   You can also get service name from Java console. Select Java Console from service detail page
   Service Name is mentioned at top of page


Now mention these details on your Jdev connection


Navigate to Test tab and perform a test



Thats all.

Tuesday, January 3, 2017

Oracle Cloud: Using Cloud Berry to connect with Cloud Storage

Problem Description: In this blog I just want to show how can we use cloud berry to connect with Oracle Cloud Storage.

Solution
1. Get Oracle Cloud storage: To use Oracle Cloud storage you must have cloud storage account. You can get it from https://cloud.oracle.com/en_US/storage


2. Get details from Cloud environment: Once you have Oracle Cloud login you will have username/password and identity domain. Using this you can see you dashboard. From Dashboard you can launch cloud storage home page.



2. Install Cloud Berry: You can download and install Cloud Berry from http://www.cloudberrylab.com/explorer/openstack.aspx

3.Run Cloud Berry and Navigate to File > New Oracle Cloud Account


     Before filling details in above shown form keep your REST endpoint handy. Its shown in Step-2

  • Display Name: It could be anything, which helps you to recognize cloud environment.
  • User Name: This is important. Most of the time mistake we make is we directly provide username. It actually has two parts. First part is last part of REST endpoint url [Storage-<IdentityDomain>]. Second part is your oracle cloud username. Now join both of them using colon (:)
  • Password: Your oracle cloud password.
  • Authentication Service: This is another important part. You can provide two values here. 
    • Take REST endpoint url and remove /v1/Storage-<IdentityDomain> and replace it with /auth/V1.0 as shown in above diagram.
    • Another way is if you have us2 datacenter you can use https://us2.storage.oraclecloud.com/auth/v1.0

4. Thats all, Now you can start managing cloud using Cloud Berry
         

Friday, January 29, 2016

RIDC: Checkin your file to Oracle HCM Cloud

In this blog I will talking about my findings of using Oracle HCM Cloud as storage. You can actually checkin/checkout your files here. There are various reasons you may want to store your files there. Few could be
1. FBL
2. HDL
3. You Paas Application needs to store some file (Although I will prefer storage cloud but then you might need a separate license. Why not to use UCM of Oracle HCM Cloud itself).

Before coming to actual implementation, I would like to clear few things.

1. If saas url is https://hcm-abc.oracleoutsourcing.com/homePage/faces/AtkHomePageWelcome, What will be content-server url
Ans: https://fs-abc.oracleoutsourcing.com/cs/idcplg (Same SaaS username/password will work)


2. As we are going to use RIDC apis we need to understand supported protocols:

Intradoc (with SSL also): This is a direct connection between client and server. Server must be configured to accept request from selected clients. You must be setting IntradocServerPort and SocketHostAddressSecurityFilter in WCC_domain/ucm/cs/config/config.cfg file or (Web UI hos:port/cs/idplg >> Administration >> Admin Server >> General Configuration




As this connection is done over trusted network, it does not need any password authentication. Only provide username and do transaction.

IdcContext userContext = new IdcContext("HCM_ADMIN"); //No need of password.
Intradoc communication can also be done over SSL. You should do below line of coding for that.
// create the manager
IdcClientManager manager = new IdcClientManager();
// build a client that will communicate using the intradoc protocol
IdcClient idcClient = manager.createClient("idc://localhost:4444");
// set the SSL socket options
IntradocClientConfig config = (IntradocClientConfig) idcClient.getConfig();
config.setKeystoreFile("ketstore/client_keystore");  //location of keystore file
config.setKeystorePassword ("password");      // keystore password
config.setKeystoreAlias("SecureClient");  //keystore alias
config.setKeystoreAliasPassword("password");  //password for keystore alias

In case of SaaS, intradoc may not be useful as we can’t configure SocketHostAddressSecurityFilter property of UCM server.

http/https: RIDC communicates with the web server for Oracle Content Server using the Apache HttpClient package. Unlike Intradoc, this protocol requires authentication credentials for each request. It does not require any configuration on server side.
If you want to use http/https, you need to use url as 
// create the manager
IdcClientManager manager = new IdcClientManager();

IdcClient idcClient = manager.createClient("https://host.oracleoutsourcing.com/_dav/cs/idcplg");
//NOTE: we have used _dav in url. Otherwise you will receive //oracle.stellent.ridc.protocol.http.HttpProtocolException: Http status: //HTTP/1.1 302 Moved Temporarily //ERROR

//If you are using https, you need to set truststores as 
System.setProperty("javax.net.ssl.trustStore", "D:/jks/Cert_DER.jks");
System.setProperty("javax.net.ssl.trustStorePassword","mypassword");

//For usercontext you should set AuthScheme as Basic
IdcContext userContext = new IdcContext("username", "password");             
userContext.setAuthScheme(IdcContext.HttpAuthScheme.BasicAuth);

JAX-WS: The JAX-WS protocol is supported only in Oracle WebCenter Content 11g with Oracle Content Server running in Oracle WebLogic Server. To provide JAX-WS support, several additional JAR files are required.


NOW COMING TO THE MAIN PART: Steps to import a file on Oracle HCM Cloud (UCM) server

1. No special configuration is needed on server side
2. Get url to make connection. It should be https://host.oracleoutsourcing.com/_dav/cs/idcplg
Replace host with your environment and don’t forget _dav
3. Get username/password who has access to UCM. You can use your SaaS username/password to login to https://host.oracleoutsourcing.com/cs
If you are able to login successfully then check if you can upload/download documents etc. If you can do it through UI, you should be able to do it programmatically.
4. Create keystore and install certificate. (THIS STEP IS IMPORTANT and ERROR PRON)
  • Launch https://host.oracleoutsourcing.com/cs in IE
  • Install certificate in browser 
    Lock-Icon-in-url >> View Certificate >> Install Certificate
            

  • Export certificate from browser Tools >> Internet Options >> Content >> Certificate >> Other People >> Select Certificate >> Export

  • Import downloaded certificate in a keystore
  • If you do not have a keystore already and you want to create new keystore altogether.  
    NOTE: In case of weblogic web program you may want to get existing keystore and then add new certificate instead of creating new keystore. 
    keytool -import -file D:\jks\Cert_DER.cer -alias orakey -keypass mypassword -keystore D:\jks\Cert_DER.jks -storepass mypassword
    This command will cerate a keystore (jks file) with a key (named orakey). Password for key and keystore is same as ‘mypassword’. Certificate is imported in this keystore. 

    If you already have keystore and you want to import certificate in it 
    keytool -importcert -file D:\jks\Cert_DER.cer –keystore D:\oldjks\Cert_DER.jks -alias orakey -storepass <whatever-is-keystore-password>

    If you want to list keystore data you can 
    keytool -list -v -keystore D:\jks\Cert_DER.jks -storepass mypassword

Following above keystore steps your keystore should be ready with appropriate certificate.

Now we need to write a java code with RIDC apis and configure it to use jks file we just created. 
NOTE: If you are using weblogic server then you should configure weblogic keystore instead of referring jks from code.

5. Java Code: Let say you have placed your jks as D:/jks/Cert_DER.jks and file that you want to import at D:/file/test.txt

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
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.TransferFile;
import oracle.stellent.ridc.protocol.ServiceResponse;

public class RIDCUtil {
      public static void main(String[] arg) throws Exception {
             try {
                            IdcClientManager m_clientManager = new IdcClientManager();
                            IdcClient idcClient = m_clientManager.createClient("https://host.oracleoutsourcing.com/_dav/cs/idcplg");
                            IdcContext userContext = new IdcContext("username", "pwd");
 userContext.setAuthScheme(IdcContext.HttpAuthScheme.BasicAuth);
 System.setProperty("javax.net.ssl.trustStore", "D:/jks/Cert_DER.jks");
           System.setProperty("javax.net.ssl.trustStorePassword","mypassword");
 checkin(idcClient, userContext, "D:/file/test.txt", // Replace with fully qualified path to source file
          "Document", // content type
          "Test Document to check RIDC", // doc title
           userContext.getUser(), // author
           "FAFusionImportExport", // security group
           "hcm$/dataloader$/import$", // account
           "TEST_DOC_FOR_RIDC") // dDocName - this is the ContentId
                        ;
        } catch (IdcClientException e) {
                e.printStackTrace();
            }
    }

/** * Method description * *
     * @param idcClient *
     * @param userContext *
     * @param sourceFileFQP fully qualified path to source content *
     * @param contentType content type *
     * @param dDocTitle doc title *
     * @param dDocAuthor author *
     * @param dSecurityGroup security group *
     * @param dDocAccount account *
     * @param dDocName dDocName * *
     * @throws IdcClientException */
    public static void checkin(IdcClient idcClient, IdcContext userContext,
                               String sourceFileFQP, String contentType,
                               String dDocTitle, String dDocAuthor,
                               String dSecurityGroup, String dDocAccount,
                               String dDocName) throws IdcClientException {
                                   
        InputStream is = null;
        try {
            String fileName = sourceFileFQP.substring(sourceFileFQP.lastIndexOf('/') + 1);
            is = new FileInputStream(sourceFileFQP);
            long fileLength = new File(sourceFileFQP).length();
            TransferFile primaryFile = new TransferFile();
            primaryFile.setInputStream(is);
            primaryFile.setContentType(contentType);
            primaryFile.setFileName(fileName);
            primaryFile.setContentLength(fileLength); // note!!! when using HTTP protocol (not intradoc/jaxws) - one must explicitly // set the Content Length when supplying an InputStream to the transfer file // e.g.
            primaryFile.setContentLength(fileLength); // otherwise, a 0-byte file results on the server
            DataBinder request = idcClient.createBinder();
            request.putLocal("IdcService", "CHECKIN_UNIVERSAL");
            request.addFile("primaryFile", primaryFile);
            request.putLocal("dDocTitle", dDocTitle);
            request.putLocal("dDocAuthor", dDocAuthor);
            request.putLocal("dDocType", contentType);
            request.putLocal("dSecurityGroup", dSecurityGroup);
            // if server is setup to use accounts - an account MUST be specified
            // // even if it is the empty string; supplying null results in Content server
            // // attempting to apply an account named "null" to the content!
            request.putLocal("dDocAccount", dDocAccount == null ? "" : dDocAccount);
            if (dDocName != null && dDocName.trim().length() > 0) {
                request.putLocal("dDocName", dDocName);
            }
            // execute the request
            ServiceResponse response = idcClient.sendRequest(userContext, request); // throws IdcClientException
            // get the binder - get a binder closes the response automatically
            DataBinder responseBinder = response.getResponseAsBinder(); // throws IdcClientException
        } catch (IOException e) {
            e.printStackTrace(System.out);
        } finally {
            if (is != null) {
                try { is.close();
            } catch (IOException ignore) {
                    }
                }
            }
        }
    }

If you are making your RIDC call using a web program deployed on weblogic server, you should not set javax.net.ssl.trustStore  and javax.net.ssl.trustStorePassword property in java code but you should configure jks file in weblogic.



6. Above code can be improved in many way. You may want to checkin file in a particular folder, you may want to see if file already present, You may want to handle exception gracefully, you may want to take all hardcoded strings (ucm-url, ucm-username/password, keystore-location/password, content-type, security-group, account etc.) to a property file. Here it is just a POC.


7.  To run java program from command prompt, generate a jar file containing RIDCUtil (say MyIntegrationJar.jar). Place all required jars in one directory and run below command from that directory.

C:\jdk1.6.0_31_64\bin\java -classpath .\MyIntegrationJar.jar;.\oracle.ucm.ridc-11.1.1.jar;.\commons-httpclient-3.1.jar;.\commons-logging-1.0.4.jar;.\commons-codec-1.2.jar RIDCUtil

8. You can verify document in UCM by login into UCM https://host.oracleoutsourcing.com/cs and searching the document 



Below are the various issue that you may face while implementing it. Most of them are actually certificate related


Issues Solutions
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:183)
at java.security.cert.PKIXParameters.(PKIXParameters.java:103)
at java.security.cert.PKIXBuilderParameters.(PKIXBuilderParameters.java:87)
at sun.security.validator.PKIXValidator.(PKIXValidator.java:55)
jks file cannot be located. Check if you have given correct path for jks file.NOTE: On windows you should use / instead of \\.
Caused by: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:179)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:212)

Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at java.security.Provider$Service.newInstance(Provider.java:1245)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:220)

Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:771)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
at java.security.KeyStore.load(KeyStore.java:1185)

Caused by: java.security.UnrecoverableKeyException: Password verification failed
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:769)
... 30 more
keystore or key password is wrong. I generally keep keystore and key password same and provide that.
oracle.stellent.ridc.protocol.http.HttpProtocolException: Http status: HTTP/1.1 302 Moved Temporarily
at oracle.stellent.ridc.protocol.http.IdcHttpProtocol.writeRequest(IdcHttpProtocol.java:407)
at oracle.stellent.ridc.IdcClient.sendRequest(IdcClient.java:179)
Use _dav in url. By default cs/idcplg url is for web access and it redirects user to login page. If you add _dav in url, then you can pass username/password with request and they will be used to login.
oracle.stellent.ridc.protocol.ProtocolException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at oracle.stellent.ridc.protocol.http.IdcHttpProtocol.sendRequest(IdcHttpProtocol.java:661)
at oracle.stellent.ridc.protocol.http.IdcHttpProtocol.sendRequest(IdcHttpProtocol.java:623)
at oracle.stellent.ridc.protocol.http.auth.BasicAuthHandler.sendAuthenticatedRequest(BasicAuthHandler.java:91)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1731)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1206)
…..
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:323)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:217)
at sun.security.validator.Validator.validate(Validator.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1185)
... 31 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:318)
... 37 more
It means, Java has located keystore but using that keystore its not able to make handshake. There could be multiple reasons for that
  1. If you are using standalone java program, you might not have added below java code System.setProperty("javax.net.ssl.trustStore", "D:/jks/Cert_DER.jks"); System.setProperty("javax.net.ssl.trustStorePassword","mypassword");
  2. If you are using web program on weblogic, You might not have configured your jks as keystore.
  3. Your path of jks is wrong
  4. For windows also you should use / to define path. You might have used \\ or \
  5. Your jks file does not have certificate that is needed to communicate with server. Verify it using keytool –list command
  6. Your jks file has expired certificate. Verify it using keytool –list (Valid From and Valit To). If expired, download new cer, import it in keystore and mention new keystore in code.
oracle.stellent.ridc.protocol.ServiceException: Content item 'TEST_DOC_FOR_RIDC' was not successfully checked in. The content item is not currently checked out.
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:142)
at oracle.stellent.ridc.protocol.ServiceResponse.getResponseAsBinder(ServiceResponse.java:108)
It means content is already present in server and it must be checkedout before check in. Ideally you should search content first using GET_SEARCH_RESULTS service and dIsCheckedOut metadata. If content is not checked out you should check-out first and then check-in.
org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'UCM WebDAV Server'@host.oracleoutsourcing.com:443
These are just warnings but its because you missed to set authentication scheme userContext.setAuthScheme(IdcContext.HttpAuthScheme.BasicAuth);