use of org.pentaho.platform.web.http.api.resources.Setting in project pentaho-platform by pentaho.
the class FileServiceTest method testDoGetCanAccessList.
@Test
public void testDoGetCanAccessList() {
String permissions = RepositoryFilePermission.READ.ordinal() + "|" + RepositoryFilePermission.WRITE.ordinal() + "|" + RepositoryFilePermission.DELETE.ordinal();
doReturn(true).when(fileService.repository).hasAccess(anyString(), any(EnumSet.class));
List<Setting> settings = fileService.doGetCanAccessList("pathId", permissions);
assertTrue(settings.size() > 0);
}
use of org.pentaho.platform.web.http.api.resources.Setting in project pentaho-platform by pentaho.
the class FileServiceTest method testDoGetPathsAccessList.
@Test
public void testDoGetPathsAccessList() {
List<String> paths = new ArrayList<String>();
paths.add("path1");
paths.add("path2");
paths.add("path3");
doReturn(true).when(fileService.repository).hasAccess(anyString(), any(EnumSet.class));
List<Setting> settings = fileService.doGetPathsAccessList(new StringListWrapper(paths));
assertTrue(settings.size() > 0);
doReturn(false).when(fileService.repository).hasAccess(anyString(), any(EnumSet.class));
settings = fileService.doGetPathsAccessList(new StringListWrapper(paths));
assertEquals(0, settings.size());
}
use of org.pentaho.platform.web.http.api.resources.Setting in project pentaho-platform by pentaho.
the class FileService method doGetCanAccessList.
public List<Setting> doGetCanAccessList(String pathId, String permissions) {
StringTokenizer tokenizer = new StringTokenizer(permissions, "|");
ArrayList<Setting> permMap = new ArrayList<Setting>();
while (tokenizer.hasMoreTokens()) {
Integer perm = Integer.valueOf(tokenizer.nextToken());
EnumSet<RepositoryFilePermission> permission = EnumSet.of(RepositoryFilePermission.values()[perm]);
permMap.add(new Setting(perm.toString(), new Boolean(getRepository().hasAccess(idToPath(pathId), permission)).toString()));
}
return permMap;
}
use of org.pentaho.platform.web.http.api.resources.Setting in project pentaho-platform by pentaho.
the class FileService method doGetPathsAccessList.
public List<Setting> doGetPathsAccessList(StringListWrapper pathsWrapper) {
List<Setting> pathsPermissonsSettings = new ArrayList<Setting>();
String permissions = RepositoryFilePermission.READ.ordinal() + "|" + RepositoryFilePermission.WRITE.ordinal() + "|" + RepositoryFilePermission.DELETE.ordinal() + "|" + RepositoryFilePermission.ACL_MANAGEMENT.ordinal() + "|" + RepositoryFilePermission.ALL.ordinal();
List<String> paths = pathsWrapper.getStrings();
for (String path : paths) {
List<Setting> permList = doGetCanAccessList(path, permissions);
for (Setting perm : permList) {
if (Boolean.parseBoolean(perm.getValue())) {
Setting setting = new Setting();
setting.setName(path);
setting.setValue(perm.getName());
pathsPermissonsSettings.add(setting);
}
}
}
return pathsPermissonsSettings;
}
Aggregations