Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Writing into DCR using CSSDK
Jeya
Hi All,
Working with TeamSite 7.2.1.0.0. I am working on a requirement where i have to update thousands of DCRs with the data retrieved from an external DB in a click event.We are using CSSDK. Below is the approach i can think of.
1. Retrieve the data, dump in a collection
2. Get the DCR, conver it to a DOM object, update it with DB data.
3.Convert the DOM to byte array
4.Write back using CSSimpleFile.write() which takes byte[] as a param.
I would like to know if there is any better way to do this. Does CSSimplFile have any other method which I could use? I see a getOutputStream.
"java.io.OutputStream getOutputStream(boolean threadSafe)
Gets the output stream to write to the SimpleFile "
Any idea how to use this?
Find more posts tagged with
Comments
Rick Poulin
CSSimpleFile.getOutputStream() is the method I'd recommend. I can attest to the fact that it works. Note that in a previous version (7.1 I think it was), there was some oddity with finding non-visible whitespace characters in front of the XML declaration when reading DCRs with CSSimpleFile.getInputStream(), so be aware that you may need to clean up the String a bit before feeding it to a DOM parser.
That whole "in a click event" piece would make me very nervous in terms of file locks and concurrent changes though. I suggest executing this process in a separate workarea and/or creating editions of the content and/or doing something smart with file locks, before running such a potentially destructive process. Just a thought.
Jeya
Thank you Rick. . If the file is locked for editing no updates should be done and a log file captures the file name. (won't IsLocked suffice?? havent explored yet..)
One more question on DOM objects. . Each DB row data goes as a repeating container item set in the DCR. Before adding a new repeating container i have to check whether that row is already added. Herecomes DOM object comparison.. (I cant compare the whole file as there is an option for the user to add additional items in DCR..) have to compare each node..
1. Compare as basic string junks or
2.Compare as xml nodes(XPaths).
Has anyone done this before... Any thoughts on which would be faster?