Friday, July 26, 2013

Oracle SOA File Adapter - Spaces in pay load

Recently we got a new integration for reading a file.  We don't know the source of the file, so we started developing with default values, for the File Adapter in JDeveloper.
The given file is a comma-separated with Double quotes as shown below.





However when configuring the JDEV, when the default CHARACTER SET US-ASCII is given to this file, it started inserting spaces between each character inside an element.




Initially we ignored this and developed out component.  But during run time, we were getting the pay load with spaces and are not able to figure out what the real issue is.

Basically this is a file format issue and by Just changing the Character Set to UTF-16 in the File Adapter XSD, this got fixed.

Sunday, July 21, 2013

Java - Interesting..

SimpleDateFormat is not ThreadSafe.  

http://www.codefutures.com/weblog/andygrove/2007/10/simpledateformat-and-thread-safety.html

Also,
SimpleDateFormat stores intermediate results in instance fields. So if one instance is used by two threads they can mess each other's results.
Looking at the source code reveals that there is a Calendar instance field, which is used by operations on DateFormat / SimpleDateFormat
For example parse(..) calls calendar.clear() initially and then calendar.add(..). If another thread invokes parse(..) before the completion of the first invocation, it will clear the calendar, but the other invocation will expect it to be populated with intermediate results of the calculation.
One way to reuse date formats without trading thread-safety is to put them in a ThreadLocal - some libraries do that. That's if you need to use the same format multiple times within one thread. But in case you are using a servlet container (that has a thread pool), remember to clean the thread-local after you finish.
To be honest, I don't understand why they need the instance field, but that's the way it is. You can also use joda-time DateTimeFormat which is threadsafe.
=================================================================================

HASHMAP - MULTITHREAD RACE CONDITION EXPLANATION



Tuesday, June 4, 2013

AIX commands

SFTP to a system:

sftp soauser@optaixdbexe01qa
sftp> put /utl/eaistaging/ebs/outbound/o2c/Oracle_EXE_I552_Orders/Orders53/MAULDIN_51.txt .
sftp> ls /home/soauser
sftp> exit

sftp username@hostname
put localpath remotePath

===================================
Find File System Disk space

df -k /
df -k /home/sdoddi

=====

Find Command:

find . -name '*.DAT'

this will find all the files ending with .DAT starting from  the current directory (the DOT (.) indicates the current directory)

If you don't want to do this recursively and search only the current folder,

find . -xdev -name '*.DAT'

For finding from root,

find / -name '*.DAT'

For finding from a specific directory,
find /utl/mdm/logs -name '*.DAT'

For size
find . -size +2  (1 block is 512 kb.. )

for files which got changed in the last 2 days,

find . -mtime -2

find . -name '*.DAT' -mmin -120

files which are not access for last 7 days and which end with .DAT

find . -name '*.DAT' -atime +7

Wednesday, April 24, 2013

Passing two variables to Xquery Transformation

Using Xquery Transformation wizard in OEPE we can create a Xquery transformation with multiple input source variable types.  But sometimes when we want to add an extra parameter to the source to an existing Xquery transformation do the below:
suppose we have an existing xquery transformation as below: (Removed the mappings to be clear)

 ========================================================================

declare function xf:sample($orcl2FoodlinVendorOutputCollection1 as element(ns0:Orcl2FoodlinVendorOutputCollection))
    as element(ns1:VendorList) {
       
};
                             
declare variable $orcl2FoodlinVendorOutputCollection1 as element(ns0:Orcl2FoodlinVendorOutputCollection) external;


xf:sample($orcl2FoodlinVendorOutputCollection1)

 ========================================================================
And I would like to add another variable, "runId" which is a string as an input to the above Xquery Transformation:

declare function xf:sample($orcl2FoodlinVendorOutputCollection1 as element(ns0:Orcl2FoodlinVendorOutputCollection),$runId as xs:string)
    as element(ns1:VendorList) {
       
};

declare variable $orcl2FoodlinVendorOutputCollection1 as element(ns0:Orcl2FoodlinVendorOutputCollection) external;
declare variable $runId as xs:string external;

xf:sample($orcl2FoodlinVendorOutputCollection1, $runId)


========================================================================
The variable "runId" should be declared and assigned prior to this xquery transformation in the proxy service message flow (or in the split join flow)

Monday, April 22, 2013

Setting space as constant in Xquery Transformation

Add below to the prolog and set the space to the xml tag.

declare xmlspace preserve;



Thursday, April 4, 2013

JAXB JAXBElement XJC @XmlRootElement




C:\orderXSDs>xjc -d  C:\src -p com.cswg.soa.ebs.otc.outbound.exe.orders.dcinfo F
ileTypeByDCInfo_table.xsd


FileTypeByDCInfo_table.xsd is located under orderXSDs directory.  The generated clases will be under C:\src directory

if you are getting the exception,
java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast
look @
http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html

http://stackoverflow.com/questions/707084/class-cast-exception-when-trying-to-unmarshall-xml