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)
File List via CSSDK Web Service
johneweb
What method of the CSSDK web service can I call to get a listing of all the files in a workarea/VPath/directory?
I've tried getFilesByVPaths and getFilesInArea from the File Service. However, the output seems to only provide information on the workarea/VPath/directory folder. I can't seem to see where any data is returned on the contents of that folder.
Thanks,
John
Find more posts tagged with
Comments
RoseRuby
Hi John
Did you find the csdemo example provided by the Teamsite.
There is an example of listing the files under the directory.
I don't remember reading anywhere the recursive built in function (API) which would return directories with their files.
Please let me know, if I am wrong .
Thank you
Rose
autopagesize.rptdesign
nickcolorado
Hi,
I'm trying to figure out how to do this as well. I cannot locate the code or methods to list all files in a directory in a workarea. For example, I want to list all files in /default/main/WWW/WORKAREA/websuer/digitalAssets/. I see the code for listing all files at the root of the workarea, but not in a subdirectory of the workarea. Can anyone help?
Thanks
Nick
nickcolorado
Answered my own question. Hope this answer helps someone else...
CSFile TmpPathFile = client.getFile(new CSVPath( "/default/main/WWW/WORKAREA/spna3/docroot/DynamoDocRoot/digitalAssets" ));
CSFile[] TmpFiles= (CSFile[])TmpPathFile.getChildren();
for( int y=0; y<TmpFiles.length; y++)
{
System.out.println(TmpFiles.getName());
}
Bjorn
Here's an example to get an iterator over objects when you want control of the type (and some other things):
CSDir dir = (CSDir)client.getFile(dirVPath);
CSSortKey[] sortKey = {new CSSortKey(CSSortKey.NAME,true),new CSSortKey(CSSortKey.MODDATE,true)}
CSIterator it = dir.getFiles(
CSFileKindMask.SIMPLEFILE,
sortKey,
CSFileKindMask.ALLNONHOLES,
".*",
0,
-1
);
(For what it's worth, I also like to write a utility class reusing this code in methods such as CSIterator MyUtil.getCSSimpleFiles(CSDir dir). This reuse keeps things clean.)
This may seem overkill, but the getChildren method is from the CSNode interface and returns CSNode objects. I guess it's not a big deal, especially if you only need the name of the object, but if you're going to take a certain action on each object returned, you can't assume that the objects returned from getChildren will have the methods/props you need (because it might NOT be a file at all). For example, if your code wants a CSSimpleFile object, but the object returned is a CSHole, you'll obviously run into problems. You can of course type check when you get to that point, but I think it's easier to get only the types I want. Just my 2 cents.