use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceTest method testGetDefaultLocation_Scenario_ProvidedFolderIsVisible.
@Test
public void testGetDefaultLocation_Scenario_ProvidedFolderIsVisible() throws Exception {
RepositoryFileDto visibleDto = new RepositoryFileDto();
visibleDto.setFolder(true);
visibleDto.setHidden(false);
visibleDto.setId(RandomStringUtils.randomNumeric(20));
visibleDto.setName("joe");
visibleDto.setPath("/home/joe");
RepositoryFileDto homeFolderDto = new RepositoryFileDto();
homeFolderDto.setFolder(true);
homeFolderDto.setHidden(false);
homeFolderDto.setId(RandomStringUtils.randomNumeric(20));
homeFolderDto.setName("home");
homeFolderDto.setPath("/home");
DefaultUnifiedRepositoryWebService repoWs = mock(DefaultUnifiedRepositoryWebService.class);
doReturn(repoWs).when(fileService).getRepoWs();
doReturn(visibleDto).when(repoWs).getFile("/home/joe");
doReturn(homeFolderDto).when(repoWs).getFile("/home");
assertEquals("/home/joe", fileService.doGetDefaultLocation(":home:joe"));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileServiceTest method testGetDefaultLocation_Scenario_DefaultFolderIsVisible.
@Test
public void testGetDefaultLocation_Scenario_DefaultFolderIsVisible() throws Exception {
RepositoryFileDto hiddenDto = new RepositoryFileDto();
hiddenDto.setFolder(true);
hiddenDto.setHidden(true);
hiddenDto.setId(RandomStringUtils.randomNumeric(20));
hiddenDto.setName("suzy");
hiddenDto.setPath("/home/suzy");
RepositoryFileDto defaultDto = new RepositoryFileDto();
defaultDto.setFolder(true);
defaultDto.setHidden(false);
defaultDto.setId(RandomStringUtils.randomNumeric(20));
defaultDto.setName("default");
defaultDto.setPath("/default-folder");
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(defaultDto).when(repoWs).getFile("/default-folder");
assertEquals("/default-folder", fileService.doGetDefaultLocation(":home:suzy"));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doCreateDirFor.
boolean doCreateDirFor(String pathWithSlashes) {
// $NON-NLS-1$//$NON-NLS-2$
String[] folders = pathWithSlashes.split("[" + FileUtils.PATH_SEPARATOR + "]");
RepositoryFileDto parentDir = getRepoWs().getFile(FileUtils.PATH_SEPARATOR);
boolean dirCreated = false;
for (String folder : folders) {
String currentFolderPath = (parentDir.getPath() + FileUtils.PATH_SEPARATOR + folder).substring(1);
if (!currentFolderPath.startsWith(FileUtils.PATH_SEPARATOR)) {
currentFolderPath = FileUtils.PATH_SEPARATOR + currentFolderPath;
}
RepositoryFileDto currentFolder = getRepoWs().getFile(currentFolderPath);
if (currentFolder == null) {
currentFolder = new RepositoryFileDto();
currentFolder.setFolder(true);
currentFolder.setName(decode(folder));
currentFolder.setPath(parentDir.getPath() + FileUtils.PATH_SEPARATOR + folder);
currentFolder = getRepoWs().createFolder(parentDir.getId(), currentFolder, currentFolderPath);
dirCreated = true;
}
parentDir = currentFolder;
}
return dirCreated;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doGetLocaleProperties.
/**
* Retrieve the list of locale properties for a given locale
*
* @param pathId (colon separated path for the repository file)
* @param locale
* @return
*/
public List<StringKeyStringValueDto> doGetLocaleProperties(String pathId, String locale) {
RepositoryFileDto file = getRepoWs().getFile(idToPath(pathId));
List<StringKeyStringValueDto> keyValueList = new ArrayList<StringKeyStringValueDto>();
if (file != null) {
PropertiesWrapper propertiesWrapper = getRepoWs().getLocalePropertiesForFileById(file.getId(), locale);
if (propertiesWrapper != null) {
Properties properties = propertiesWrapper.getProperties();
if (properties != null && !properties.isEmpty()) {
for (String key : properties.stringPropertyNames()) {
keyValueList.add(getStringKeyStringValueDto(key, properties.getProperty(key)));
}
}
}
}
return keyValueList;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method getRepositoryRequest.
protected RepositoryRequest getRepositoryRequest(RepositoryFileDto repositoryFileDto, Boolean showHidden, String filter, Boolean includeAcls) {
RepositoryRequest repositoryRequest = new RepositoryRequest(repositoryFileDto.getId(), showHidden, 0, filter);
repositoryRequest.setIncludeAcls(includeAcls);
return repositoryRequest;
}
Aggregations