Search in sources :

Example 1 with PentahoMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository in project pentaho-platform by pentaho.

the class SolutionFolderIT method testNoLocaleFileDiscovery.

/**
 * Tests MetadataDomainRepository.getLocalePropertyFilenames() where one xmi resource and no property file exists in
 * the metadata folder.
 */
@Test
public void testNoLocaleFileDiscovery() {
    PentahoMetadataDomainRepository domainRepository;
    IUnifiedRepository repository = new FileSystemBackedUnifiedRepository();
    repository = new FileSystemBackedUnifiedRepository(BI_DEVELOPERS_FULL_PATH);
    domainRepository = new PentahoMetadataDomainRepository(repository);
    File metadataXmiFile = null;
    try {
        metadataXmiFile = localeTestUtil.createFile(BI_DEVELOPERS_FULL_PATH, XMI_FILENAME_EXTENSION);
        Map<String, InputStream> localizationFiles = domainRepository.getDomainFilesData("metadata");
        assertEquals(0, localizationFiles.size());
    } catch (IOException ioe) {
        fail(ioe.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (metadataXmiFile != null) {
            metadataXmiFile.delete();
        }
    }
}
Also used : InputStream(java.io.InputStream) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) IOException(java.io.IOException) File(java.io.File) DomainStorageException(org.pentaho.metadata.repository.DomainStorageException) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) IOException(java.io.IOException) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Test(org.junit.Test)

Example 2 with PentahoMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository in project data-access by pentaho.

the class MetadataServiceTest method testSetMetadataDatasourceAclNoAcl.

@Test
public void testSetMetadataDatasourceAclNoAcl() throws Exception {
    String domainId = DOMAIN_ID;
    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, null);
    verify(metadataService.aclAwarePentahoMetadataDomainRepositoryImporter).setAclFor(eq(domainId), (RepositoryFileAcl) isNull());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) StringInputStream(org.apache.tools.ant.filters.StringInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with PentahoMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository 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)));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) StringInputStream(org.apache.tools.ant.filters.StringInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) RepositoryFileAclDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAclAdapter(org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter) Test(org.junit.Test)

Example 4 with PentahoMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository in project data-access by pentaho.

the class SerializeMultiTableServiceIT method createMetadataDomainRepository.

public PentahoMetadataDomainRepository createMetadataDomainRepository() throws Exception {
    IUnifiedRepository repository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
    booter.defineInstance(IUnifiedRepository.class, repository);
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null));
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/mondrian", true, true, null));
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/savetest", true, true, null));
    PentahoMetadataDomainRepository pentahoMetadataDomainRepository = new PentahoMetadataDomainRepository(repository);
    return pentahoMetadataDomainRepository;
}
Also used : RepositoryUtils(org.pentaho.platform.repository2.unified.RepositoryUtils) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)

Example 5 with PentahoMetadataDomainRepository

use of org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository in project data-access by pentaho.

the class SerializeServiceIT method createMetadataDomainRepository.

public PentahoMetadataDomainRepository createMetadataDomainRepository() throws Exception {
    IUnifiedRepository repository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
    booter.defineInstance(IUnifiedRepository.class, repository);
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/metadata", true, true, null));
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/etc/mondrian", true, true, null));
    Assert.assertNotNull(new RepositoryUtils(repository).getFolder("/savetest", true, true, null));
    PentahoMetadataDomainRepository pentahoMetadataDomainRepository = new PentahoMetadataDomainRepository(repository);
    return pentahoMetadataDomainRepository;
}
Also used : RepositoryUtils(org.pentaho.platform.repository2.unified.RepositoryUtils) PentahoMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)

Aggregations

PentahoMetadataDomainRepository (org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepository)11 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)7 FileInputStream (java.io.FileInputStream)5 InputStream (java.io.InputStream)5 Test (org.junit.Test)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 StringInputStream (org.apache.tools.ant.filters.StringInputStream)4 Matchers.anyString (org.mockito.Matchers.anyString)4 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)4 Facet (org.codehaus.enunciate.Facet)3 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)3 RepositoryUtils (org.pentaho.platform.repository2.unified.RepositoryUtils)3 RepositoryFileAclDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclDto)3 RepositoryFileAclAdapter (org.pentaho.platform.repository2.unified.webservices.RepositoryFileAclAdapter)2 File (java.io.File)1 IOException (java.io.IOException)1 StringTokenizer (java.util.StringTokenizer)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DomainStorageException (org.pentaho.metadata.repository.DomainStorageException)1