Wednesday, October 31, 2012

SecureStorageRuntimeInterface api for XI message mapping


In my one of the support project, I have found one udf in message mapping,

they are using SecureStorageRuntimeInterface

After analyzing this code, i have identified, this is used to store the required parameters( when we execute message mapping , by required parameters, it stores internally and uses these values at run time). No need to send these values again at run time.



In our migration project, we disabled this logic, used Message mapping parameterized 


Sample code: for this UDF


public String SecureStorageObjectHandler(String ObjectID, String ObjectValue, String Action, Container container) throws StreamTransformationException{
Object o;
String myObjectRet = "Init";
AbstractTrace trace = container.getTrace();
try {
javax.naming.Context ctx = new javax.naming.InitialContext();
o = (Object) ctx.lookup("tc~sec~securestorage~service");
SecureStorageRuntimeInterface secStore = (SecureStorageRuntimeInterface) o;
//Continue with implementation
RemoteSecureStorageClientContextInterface myContext = secStore.getSecureStorageClientContext();
trace.addInfo("Check Action");
if (Action.equals("SET")) {
trace.addInfo("Store Object");
//Store an object
myContext.storeObject(ObjectValue, ObjectID); 
myObjectRet = ObjectValue +"/"+ ObjectID;
trace.addInfo(ObjectValue +"/"+ ObjectID);
}
else {
myObjectRet = "Retreive Object";
//Retrieve an object
String myObject = (String) myContext.retrieveObject(ObjectID);
myObjectRet = myObject; 
trace.addInfo(myObjectRet);
}
} catch (RemoteException e1) {
// TODO Auto-generated catch block
throw  new RuntimeException( "RemoteException " + e1.getMessage());

} catch (ObjectStorageException e1) {
// TODO Auto-generated catch block
throw  new RuntimeException( "ObjectStorageException " + e1.getMessage());

} catch (ObjectRetrievalException e1) {
// TODO Auto-generated catch block
throw  new RuntimeException( "ObjectRetrievalException " + e1.getMessage());

} catch (NamingException e1) {
// TODO Auto-generated catch block
throw  new RuntimeException( "NamingException " + e1.getMessage());

}

return myObjectRet;

}