use of org.pentaho.platform.api.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.api.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);
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class DataSourceWizardServiceTest method testSetMetadataDatasourceAcl.
@Test
public void testSetMetadataDatasourceAcl() throws Exception {
String domainId = DOMAIN_ID;
String domainIdWithoutExt = "domainId";
final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
aclDto.setOwner("owner");
aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
doReturn(true).when(dataSourceWizardService).canManageACL();
doReturn(new HashMap<String, InputStream>()).when(dataSourceWizardService).doGetDSWFilesAsDownload(domainId);
dataSourceWizardService.setDSWAcl(domainId, aclDto);
final RepositoryFileAcl acl = new RepositoryFileAclAdapter().unmarshal(aclDto);
verify(dataSourceWizardService.aclAwarePentahoMetadataDomainRepositoryImporter).setAclFor(eq(domainId), eq(acl));
verify(dataSourceWizardService.aclAwareMondrianCatalogService).setAclFor(eq(domainIdWithoutExt), eq(acl));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class MetadataServiceTest method testSetMetadataDatasourceAcl.
@Test
public void testSetMetadataDatasourceAcl() throws Exception {
String domainId = DOMAIN_ID;
final RepositoryFileAclDto aclDto = new RepositoryFileAclDto();
aclDto.setOwner("owner");
aclDto.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
doReturn(true).when(metadataService).canManageACL();
final Map<String, InputStream> domainFilesData = mock(Map.class);
when(domainFilesData.isEmpty()).thenReturn(false);
when(((PentahoMetadataDomainRepository) metadataService.metadataDomainRepository).getDomainFilesData(domainId)).thenReturn(domainFilesData);
metadataService.setMetadataAcl(domainId, aclDto);
verify(metadataService.aclAwarePentahoMetadataDomainRepositoryImporter).setAclFor(eq(domainId), eq(new RepositoryFileAclAdapter().unmarshal(aclDto)));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project data-access by pentaho.
the class AnalysisService method setAnalysisDatasourceAcl.
public void setAnalysisDatasourceAcl(String analysisId, RepositoryFileAclDto aclDto) throws PentahoAccessControlException, FileNotFoundException {
checkAnalysisExists(analysisId);
final RepositoryFileAcl acl = aclDto == null ? null : repositoryFileAclAdapter.unmarshal(aclDto);
if (aclAwareMondrianCatalogService != null) {
aclAwareMondrianCatalogService.setAclFor(analysisId, acl);
}
flushDataSources();
}
Aggregations