use of org.pentaho.platform.repository2.unified.fileio.RepositoryFileInputStream in project pentaho-platform by pentaho.
the class FileServiceTest method testDoGetFileOrDirException.
@Test
public void testDoGetFileOrDirException() throws Exception {
RepositoryFile file = mock(RepositoryFile.class);
doReturn("file.txt").when(file).getName();
RepositoryFileInputStream mockInputStream = mock(RepositoryFileInputStream.class);
doReturn(1).when(fileService).copy(any(java.io.InputStream.class), any(java.io.OutputStream.class));
doReturn(mockInputStream).when(fileService).getRepositoryFileInputStream(any(RepositoryFile.class));
String pathId = "/usr/folder/file.txt";
try {
fileService.doGetFileOrDir(pathId);
// This line should never be reached
fail();
} catch (FileNotFoundException fileNotFound) {
// Expected exception
}
}
use of org.pentaho.platform.repository2.unified.fileio.RepositoryFileInputStream in project pentaho-platform by pentaho.
the class PentahoMetadataDomainRepository method getDomainFilesData.
/*
* retrieves the data streams for the metadata referenced by domainId. This could be a single .xmi file or an .xmi
* file and multiple .properties files.
*/
public Map<String, InputStream> getDomainFilesData(final String domainId) {
Set<RepositoryFile> metadataFiles;
lock.readLock().lock();
try {
metadataFiles = metadataMapping.getFiles(domainId);
} finally {
lock.readLock().unlock();
}
Map<String, InputStream> values = new HashMap<String, InputStream>(metadataFiles.size());
for (RepositoryFile repoFile : metadataFiles) {
RepositoryFileInputStream is;
try {
is = new RepositoryFileInputStream(repoFile);
} catch (Exception e) {
// This pretty much ensures an exception will be thrown later and passed to the client
return null;
}
String fileName = repoFile.getName().endsWith(".properties") ? repoFile.getName() : domainId + (domainId.endsWith(".xmi") ? "" : ".xmi");
values.put(fileName, is);
}
return values;
}
Aggregations