use of org.pentaho.di.core.LastUsedFile in project pentaho-kettle by pentaho.
the class Spoon method recentRepoFileExists.
/**
* Returns true if the {@link LastUsedFile} at the given {@code index} within the {@link
* PropsUI#getLastUsedRepoFiles()} collection exists within the given {@code repo} {@link Repository},
* and false otherwise.
*
* @param repo the {@link Repository} containing the file
* @param indexStr the String index of the file within the last used repo file collection
* @return true if the {@link LastUsedFile} at the given {@code index} within the {@link
* PropsUI#getLastUsedRepoFiles()} collection exists within the given {@code repo} {@link Repository},
* and false otherwise
* @throws KettleException
*/
public boolean recentRepoFileExists(String repo, String indexStr) {
final LastUsedFile lastUsedFile = getLastUsedRepoFile(repo, indexStr);
// this should never happen when used on a repo file, but we check just to be safe
if (lastUsedFile == null) {
return false;
}
// again, should never happen, since the file being selected is a valid repo file in this repo
if (!lastUsedFile.isSourceRepository() || !rep.getName().equalsIgnoreCase(lastUsedFile.getRepositoryName())) {
return false;
}
try {
final RepositoryDirectoryInterface rdi = rep.findDirectory(lastUsedFile.getDirectory());
if (rdi == null) {
return false;
}
final RepositoryObjectType fileType = lastUsedFile.isJob() ? RepositoryObjectType.JOB : RepositoryObjectType.TRANSFORMATION;
return rep.exists(lastUsedFile.getFilename(), rdi, fileType);
} catch (final KettleException ke) {
// log
return false;
}
}
Aggregations