// Store OLEDate equivalents of now and lastbuild for performance
nowDate = new OLEDate(now.getTime());
OLEDate lastBuildDate = new OLEDate(lastBuild.getTime());
Server server = null;
try {
// Set up two view snapshots, one at lastbuild time, one now
View view = StarTeamFinder.openView(userName + ":" + password + "@" + url);
server = view.getServer();
View snapshotAtNow = new View(view, ViewConfiguration.createFromTime(nowDate));
View snapshotAtLastBuild =
new View(view, ViewConfiguration.createFromTime(lastBuildDate));
Map nowFiles = new HashMap();
Map lastBuildFiles = new HashMap();
Folder nowRoot = StarTeamFinder.findFolder(snapshotAtNow.getRootFolder(), folder);
PropertyNames stPropertyNames = server.getPropertyNames();
// properties to fetch immediately and cache
final String[] propertiesToCache =
new String[] {
stPropertyNames.FILE_CONTENT_REVISION,
stPropertyNames.MODIFIED_TIME,
stPropertyNames.FILE_FILE_TIME_AT_CHECKIN,
stPropertyNames.COMMENT,
stPropertyNames.MODIFIED_USER_ID,
stPropertyNames.FILE_NAME };
if (preloadFileInformation) {
// cache information for now
nowRoot.populateNow(server.getTypeNames().FILE, propertiesToCache, -1);
}
// Visit all files in the snapshots and add to Maps
addFolderModsToList(nowFiles, nowRoot);
try {
Folder lastBuildRoot =
StarTeamFinder.findFolder(snapshotAtLastBuild.getRootFolder(), folder);
if (preloadFileInformation) {
// cache information for last build
lastBuildRoot.populateNow(server.getTypeNames().FILE, propertiesToCache, -1);
}
addFolderModsToList(lastBuildFiles, lastBuildRoot);
} catch (ServerException se) {
LOG.error("Server Exception occurred visiting last build view: ", se);
}
compareFileLists(nowFiles, lastBuildFiles);
// Discard cached items so memory is not eaten up
snapshotAtNow.getRootFolder().discardItems(server.getTypeNames().FILE, -1);
try {
snapshotAtLastBuild.getRootFolder().discardItems(server.getTypeNames().FILE, -1);
} catch (ServerException se) {
LOG.error("Server Exception occurred discarding last build file cache: ", se);
}
LOG.info(modifications.size() + " modifications in " + folder);
return modifications;
} catch (Exception e) {
LOG.error("Problem looking up modifications in StarTeam.", e);
modifications.clear();
return modifications;
} finally {
if (server != null) {
server.disconnect();
}
}
}