Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
How to get the top level branch
Bill Klish
TeamSite 6.1 SP1 Linux
I am trying to get ther top level branch path (i.e. /default/main) using the CS SDK methods. I can't seem to find the function that just returns main. I would rather not hard code that value.
This is what I have
vpath = /default/main/Ajuba/Wireless
Code snippet that i had to use:
CSVPath topLevelBranch = new CSVPath(vpath.getStore().toString() + "/main");
getStore() only returns /default. Is there a way to get main without writing me own string manipulation of the branch path?
Find more posts tagged with
Comments
Bjorn
Considering Interwoven forces you to use "main" (if I'm not mistaken), I don't think it's as big of a deal to hardcode append "/main" to create that vpath.
That said, I despise hardcoding for the obvious reasons. So I'd take one of two approaches:
1 - Use the CSBranch[] getBranches method of CSStore, with a grain of salt.
Like:
CSStore store = client.getStore(vpath,true);
CSBranch[] main = store.getBranches();
Problem:
"Returns the top-level branches in this store.
Currently
, this should return only one branch - the main branch of the store. This method does not return sub-branches within the top-level branches."
2 - Code a bit more abstractly (and ridiculously convolutedly) to avoid the pure hardcoding of main (while still resorting to using string manipulation on the path)
Like:
String str = vpath.toString();
String mainPath = str.substring(0,str.indexOf("/",str.indexOf(vpath.getStoreName())+vpath.getStoreName().length()+1));
(This assumes you'll always have a vpath that's deeper than just the store, but that's a pretty safe bet.)