Search in sources :

Example 6 with RepositoryFileAclDto

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;
}
Also used : RepositoryFileDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto) RepositoryFileAclAceDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAceDto) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto)

Example 7 with RepositoryFileAclDto

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);
}
Also used : RepositoryFileDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 8 with RepositoryFileAclDto

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);
}
Also used : MondrianCatalog(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) Test(org.junit.Test)

Example 9 with RepositoryFileAclDto

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);
}
Also used : IPlatformImportBundle(org.pentaho.platform.api.repository2.unified.IPlatformImportBundle) MetadataTempFilesListDto(org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListDto) InputStream(java.io.InputStream) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) XmiParser(org.pentaho.metadata.util.XmiParser) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) IPlatformImporter(org.pentaho.platform.plugin.services.importer.IPlatformImporter) Matchers.anyString(org.mockito.Matchers.anyString) Domain(org.pentaho.metadata.model.Domain) Test(org.junit.Test)

Example 10 with RepositoryFileAclDto

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);
}
Also used : InputStream(java.io.InputStream) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

RepositoryFileAclDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto)31 Test (org.junit.Test)28 Matchers.anyString (org.mockito.Matchers.anyString)16 InputStream (java.io.InputStream)12 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)9 FileInputStream (java.io.FileInputStream)8 RepositoryFileAclAdapter (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter)8 RepositoryFileDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto)8 RepositoryFileAclAceDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAceDto)7 FileNotFoundException (java.io.FileNotFoundException)6 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 GeneralSecurityException (java.security.GeneralSecurityException)5 ArrayList (java.util.ArrayList)5 StringInputStream (org.apache.tools.ant.filters.StringInputStream)5 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 WebResource (com.sun.jersey.api.client.WebResource)4 FormDataBodyPart (com.sun.jersey.multipart.FormDataBodyPart)4 JerseyTest (com.sun.jersey.test.framework.JerseyTest)4 Response (javax.ws.rs.core.Response)4