use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.
the class FileService method doGetFileAcl.
/**
* Retrieves the acls of the selected repository file
*
* @param pathId (colon separated path for the repository file)
* @return <code> RepositoryFileAclDto </code>
*/
public RepositoryFileAclDto doGetFileAcl(String pathId) {
RepositoryFileDto file = getRepoWs().getFile(FileUtils.idToPath(pathId));
RepositoryFileAclDto fileAcl = getRepoWs().getAcl(file.getId());
if (fileAcl.isEntriesInheriting()) {
List<RepositoryFileAclAceDto> aces = getRepoWs().getEffectiveAcesWithForceFlag(file.getId(), fileAcl.isEntriesInheriting());
fileAcl.setAces(aces, fileAcl.isEntriesInheriting());
}
addAdminRole(fileAcl);
return fileAcl;
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.
the class FileServiceTest method testSetFileAcls.
@Test
public void testSetFileAcls() throws Exception {
RepositoryFileDto file = mock(RepositoryFileDto.class);
doReturn("file.txt").when(file).getName();
when(fileService.defaultUnifiedRepositoryWebService.getFile(anyString())).thenReturn(file);
String pathId = "/usr/folder/file.txt";
RepositoryFileAclDto acl = mock(RepositoryFileAclDto.class);
fileService.setFileAcls(pathId, acl);
verify(acl, times(1)).setId(anyString());
verify(file, times(1)).getId();
verify(fileService.defaultUnifiedRepositoryWebService, times(1)).updateAcl(acl);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class AnalysisServiceTest method testGetAnalysisDatasourceAclNoAcl.
@Test
public void testGetAnalysisDatasourceAclNoAcl() throws Exception {
allAccess();
final String catalogName = "catalogName";
final MondrianCatalog mondrianCatalog = mock(MondrianCatalog.class);
when(catalogService.getCatalog(eq(catalogName), any(IPentahoSession.class))).thenReturn(mondrianCatalog);
when(catalogService.getAclFor(catalogName)).thenReturn(null);
final RepositoryFileAclDto aclDto = analysisService.getAnalysisDatasourceAcl(catalogName);
assertNull(aclDto);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class DataSourceWizardServiceTest method testPublishDswFromTemp.
@Test
public void testPublishDswFromTemp() throws Exception {
InputStream metadataFile = getClass().getClassLoader().getResourceAsStream(TEST_XMI_FILE_PATH);
boolean overwrite = true;
boolean checkConnection = false;
XmiParser mockXmiParser = mock(XmiParser.class);
Domain mockDomain = mock(Domain.class);
InputStream mockInputStream = mock(InputStream.class);
IPlatformImportBundle mockMetadataBundle = mock(IPlatformImportBundle.class);
IPlatformImportBundle mockMondrianBundle = mock(IPlatformImportBundle.class);
IPlatformImporter mockIPlatformImporter = mock(IPlatformImporter.class);
IPentahoSession mockIPentahoSession = mock(IPentahoSession.class);
final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
aclDto.setOwner("owner");
aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
doReturn(true).when(dataSourceWizardService).hasManageAccessCheck();
doReturn(true).when(dataSourceWizardService).endsWith(anyString(), anyString());
doReturn(mockXmiParser).when(dataSourceWizardService).createXmiParser();
doReturn(mockDomain).when(mockXmiParser).parseXmi(metadataFile);
doReturn(mockInputStream).when(dataSourceWizardService).toInputStreamWrapper(mockDomain, mockXmiParser);
doReturn(mockMetadataBundle).when(dataSourceWizardService).createMetadataDswBundle(mockDomain, mockInputStream, overwrite, aclDto);
doReturn(mockMondrianBundle).when(dataSourceWizardService).createMondrianDswBundle(mockDomain, aclDto);
doReturn(mockIPlatformImporter).when(dataSourceWizardService).getIPlatformImporter();
doReturn(mockIPentahoSession).when(dataSourceWizardService).getSession();
doReturn(metadataFile).when(dataSourceWizardService).createInputStreamFromFile(anyString());
MetadataTempFilesListDto fileList = new MetadataTempFilesListDto();
fileList.setXmiFileName(XMI_TEMP_FILE_NAME);
String list = "{\"xmiFileName\":\"" + XMI_TEMP_FILE_NAME + "\"}";
String response = dataSourceWizardService.publishDswFromTemp(DOMAIN_ID, fileList, overwrite, checkConnection, aclDto);
assertEquals(DOMAIN_ID + DataSourceWizardService.METADATA_EXT, response);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class DataSourceWizardServiceTest method testGetDSWAclNoAcl.
@Test
public void testGetDSWAclNoAcl() throws Exception {
String domainId = "domainId";
doReturn(true).when(dataSourceWizardService).canManageACL();
when(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter.getAclFor(domainId)).thenReturn(null);
doReturn(new HashMap<String, InputStream>()).when(dataSourceWizardService).doGetDSWFilesAsDownload(domainId);
final RepositoryFileAclDto aclDto = dataSourceWizardService.getDSWAcl(domainId);
verify(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter).getAclFor(eq(domainId));
assertNull(aclDto);
}
Aggregations