use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class RepositoryFileTreeAdapter method marshal.
@Override
public RepositoryFileTreeDto marshal(final RepositoryFileTree v) {
RepositoryFileTreeDto treeDto = new RepositoryFileTreeDto();
RepositoryFileDto file = RepositoryFileAdapter.toFileDto(v, membersSet, exclude, includeAcls);
if (file != null) {
treeDto.setFile(RepositoryFileAdapter.toFileDto(v, membersSet, exclude, includeAcls));
List<RepositoryFileTreeDto> children = null;
if (v.getChildren() != null) {
children = new ArrayList<RepositoryFileTreeDto>();
for (RepositoryFileTree child : v.getChildren()) {
RepositoryFileTreeDto childTreeDto = marshal(child);
if (childTreeDto != null) {
children.add(childTreeDto);
}
}
}
treeDto.setChildren(children);
return treeDto;
} else {
return null;
}
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class UnifiedRepositoryToWebServiceAdapter method getDataForReadInBatch.
@Override
@SuppressWarnings("unchecked")
public <T extends IRepositoryFileData> java.util.List<T> getDataForReadInBatch(final List<RepositoryFile> files, final Class<T> dataClass) {
List<RepositoryFileDto> fileDtos = new ArrayList<RepositoryFileDto>(files.size());
for (RepositoryFile file : files) {
fileDtos.add(repositoryFileAdapter.marshal(file));
}
if (dataClass.equals(NodeRepositoryFileData.class)) {
List<NodeRepositoryFileDataDto> nodeData = repoWebService.getDataAsNodeForReadInBatch(fileDtos);
List<T> data = new ArrayList<T>(nodeData.size());
for (NodeRepositoryFileDataDto node : nodeData) {
data.add((T) nodeRepositoryFileDataAdapter.unmarshal(node));
}
return data;
} else if (dataClass.equals(SimpleRepositoryFileData.class)) {
List<SimpleRepositoryFileDataDto> nodeData = repoWebService.getDataAsBinaryForReadInBatch(fileDtos);
List<T> data = new ArrayList<T>(nodeData.size());
for (SimpleRepositoryFileDataDto node : nodeData) {
data.add((T) SimpleRepositoryFileDataDto.convert(node));
}
return data;
} else {
throw new IllegalArgumentException();
}
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class RepositoryFileUtils method convertFromRepositoryFileTree.
public static RepositoryFileTreeDto convertFromRepositoryFileTree(RepositoryFileTree tree) {
RepositoryFileTreeDto fileTreeDto = new RepositoryFileTreeDto();
List<RepositoryFileTreeDto> fileList = new ArrayList<RepositoryFileTreeDto>();
RepositoryFileDto file = convertFromRepositoryFile(tree.getFile());
fileTreeDto.setFile(file);
for (RepositoryFileTree treeItem : tree.getChildren()) {
fileList.add(convertFromRepositoryFileTree(treeItem));
}
fileTreeDto.setChildren(fileList);
return fileTreeDto;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testDoGetGeneratedContentForSchedule.
@Test
public void testDoGetGeneratedContentForSchedule() throws Exception {
String lineageId = "test.prpt";
FileService mockFileService = mock(FileService.class);
doReturn(mockFileService).when(schedulerService).getFileService();
SessionResource mockSessionResource = mock(SessionResource.class);
doReturn(mockSessionResource).when(schedulerService).getSessionResource();
String currentUserDir = "currentUserDir";
doReturn(currentUserDir).when(mockSessionResource).doGetCurrentUserDir();
List<RepositoryFileDto> mockList = mock(List.class);
doReturn(mockList).when(mockFileService).searchGeneratedContent(currentUserDir, lineageId, QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID);
List<RepositoryFileDto> list = schedulerService.doGetGeneratedContentForSchedule(lineageId);
assertEquals(mockList, list);
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceTest method testGetDefaultLocation_Scenario_DefaultFolderIsNotAccessible.
@Test
public void testGetDefaultLocation_Scenario_DefaultFolderIsNotAccessible() throws Exception {
RepositoryFileDto hiddenDto = new RepositoryFileDto();
hiddenDto.setFolder(true);
hiddenDto.setHidden(true);
hiddenDto.setId(RandomStringUtils.randomNumeric(20));
hiddenDto.setName("suzy");
hiddenDto.setPath("/home/suzy");
DefaultUnifiedRepositoryWebService repoWs = mock(DefaultUnifiedRepositoryWebService.class);
doReturn(repoWs).when(fileService).getRepoWs();
doReturn(hiddenDto).when(repoWs).getFile("/home/suzy");
when(PentahoSystem.get(ISystemConfig.class).getProperty(eq(PentahoSystem.DEFAULT_FOLDER_WHEN_HOME_FOLDER_IS_HIDDEN_PROPERTY))).thenReturn("/default-folder");
doReturn(null).when(repoWs).getFile("/default-folder");
assertEquals(ClientRepositoryPaths.getRootFolderPath(), fileService.doGetDefaultLocation(":home:suzy"));
}
Aggregations