How to determine if IVersionable is a file or a directory?
3 answers
I think you have to resolve it and then check the versionable for type of IFolder.
if its NOT an IFolder then it must be a file.
if its NOT an IFolder then it must be a file.
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; }
Thanks, everybody.
Actually I found IFolderHandle and now trying this:
Will update this if this is *not* working and post alternative.
Actually I found IFolderHandle and now trying this:
boolean result = ChangeSetFilter.IS_NOT_FILTERED; List <IChange> changeList = changeSet.changes();
if (changeList.isEmpty()) {
result = ChangeSetFilter.IS_FILTERED;
return result;
}
for (IChange change : changeList) {
if(! (change.item() instanceof IFolderHandle)) {
result = ChangeSetFilter.IS_FILTERED;
return result;
}
}
(hopefully) sneakily getting around having to resolve all change set handles.
Will update this if this is *not* working and post alternative.