How to determine if IVersionable is a file or a directory?
![]()
Jazzers,
with a handle in IVersionable, what is a fast way to determine in java code whether this IVersionable is a directory or a file? Underlying reason: for a change set I want to determine whether it contains actual file changes or "just" added / removed directories. Best, Arne |
3 answers
![]()
Ralph Schoon (62.7k●3●36●43)
| answered Jul 23 '14, 11:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
This is what i used in https://rsjazz.wordpress.com/2013/10/15/extracting-an-archive-into-jazz-scm-using-the-plain-java-client-libraries/ another source to look at would be http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html
/** * Find a folder in an existing parent folder. * * @param folderName * @param parentFolder * @return * @throws TeamRepositoryException */ private IFolder getFolder(String folderName, IFolderHandle parentFolder) throws TeamRepositoryException { IVersionable foundItem = getVersionable(folderName, parentFolder); if (null != foundItem) { if (foundItem instanceof IFolder) { return (IFolder) foundItem; } } return null; } /** * Tries to find a IFileItem node in a given IFolder. Returns the IFileItem * found or null if none was found. * * @param file * @param parentFolder * @return * @throws TeamRepositoryException */ private IFileItem getFile(File file, IFolderHandle parentFolder) throws TeamRepositoryException { IVersionable foundItem = getVersionable(file.getName(), parentFolder); if (null != foundItem) { if (foundItem instanceof IFileItem) { return (IFileItem) foundItem; } } return null; } |