Search in sources :

Example 11 with MondrianCatalogRepositoryHelper

use of org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper in project pentaho-platform by pentaho.

the class MondrianCatalogHelperIT method testRemoveCatalog.

@Test
public void testRemoveCatalog() throws Exception {
    File file1 = new File(TestResourceLocation.TEST_RESOURCES + "/solution/test/charts/steelwheels.mondrian.xml");
    String mondrianSchema1 = IOUtils.toString(new FileInputStream(file1));
    final String mondrianFolderPath = ClientRepositoryPaths.getEtcFolderPath() + RepositoryFile.SEPARATOR + "mondrian";
    UnifiedRepositoryTestUtils.stubGetFolder(repo, mondrianFolderPath);
    UnifiedRepositoryTestUtils.stubGetChildren(repo, mondrianFolderPath, "SteelWheels/");
    final String steelWheelsFolderPath = mondrianFolderPath + RepositoryFile.SEPARATOR + "SteelWheels";
    final String steelWheelsMetadataPath = steelWheelsFolderPath + RepositoryFile.SEPARATOR + "metadata";
    final String steelWheelsSchemaPath = steelWheelsFolderPath + RepositoryFile.SEPARATOR + "schema.xml";
    UnifiedRepositoryTestUtils.stubGetFile(repo, steelWheelsMetadataPath);
    UnifiedRepositoryTestUtils.stubGetData(repo, steelWheelsMetadataPath, "catalog", UnifiedRepositoryTestUtils.pathPropertyPair("/catalog/definition", "mondrian:/SteelWheels"), UnifiedRepositoryTestUtils.pathPropertyPair("/catalog/datasourceInfo", "Provider=mondrian;DataSource=SteelWheels;"));
    UnifiedRepositoryTestUtils.stubGetFile(repo, steelWheelsSchemaPath);
    UnifiedRepositoryTestUtils.stubGetData(repo, steelWheelsSchemaPath, mondrianSchema1);
    UnifiedRepositoryTestUtils.stubGetFolder(repo, steelWheelsFolderPath);
    IPentahoSession session = new StandaloneSession("admin");
    helper = spy(helper);
    IAclNodeHelper aclHelper = mock(IAclNodeHelper.class);
    when(aclHelper.canAccess(any(RepositoryFile.class), any(EnumSet.class))).thenReturn(true);
    doReturn(aclHelper).when(helper).getAclHelper();
    MondrianCatalogRepositoryHelper repositoryHelper = mock(MondrianCatalogRepositoryHelper.class);
    doReturn(repositoryHelper).when(helper).getMondrianCatalogRepositoryHelper();
    helper.removeCatalog("mondrian:/SteelWheels", session);
    verify(repo).deleteFile(eq(UnifiedRepositoryTestUtils.makeIdObject(steelWheelsFolderPath)), eq(true), anyString());
    // cache should be cleared for this schema only
    verify(olapService, times(1)).getConnection(CATALOG_NAME, session);
    verify(mondrianCacheControl, times(1)).flushSchema(this.mondrianSchema);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) IAclNodeHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper) EnumSet(java.util.EnumSet) MondrianCatalogRepositoryHelper(org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 12 with MondrianCatalogRepositoryHelper

use of org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper in project pentaho-platform by pentaho.

the class MondrianCatalogHelperIT method removeCatalog_WhenProhibited.

@Test(expected = MondrianCatalogServiceException.class)
public void removeCatalog_WhenProhibited() throws Exception {
    IPentahoSession session = mock(IPentahoSession.class);
    helper = spy(helper);
    doReturn(createTestCatalog()).when(helper).getCatalog(eq(CATALOG_NAME), eq(session));
    doNothing().when(helper).reInit(eq(session));
    MondrianCatalogRepositoryHelper repositoryHelper = mock(MondrianCatalogRepositoryHelper.class);
    doReturn(repositoryHelper).when(helper).getMondrianCatalogRepositoryHelper();
    IAclNodeHelper aclHelper = mock(IAclNodeHelper.class);
    when(aclHelper.canAccess(any(RepositoryFile.class), any(EnumSet.class))).thenReturn(false);
    doReturn(aclHelper).when(helper).getAclHelper();
    helper.removeCatalog(CATALOG_NAME, session);
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) IAclNodeHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper) EnumSet(java.util.EnumSet) MondrianCatalogRepositoryHelper(org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) Test(org.junit.Test)

Example 13 with MondrianCatalogRepositoryHelper

use of org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper in project data-access by pentaho.

the class AnalysisService method doGetAnalysisFilesAsDownload.

public Map<String, InputStream> doGetAnalysisFilesAsDownload(String analysisId) throws PentahoAccessControlException {
    if (!canManageACL()) {
        throw new PentahoAccessControlException();
    }
    MondrianCatalogRepositoryHelper helper = createNewMondrianCatalogRepositoryHelper();
    Map<String, InputStream> fileData = helper.getModrianSchemaFiles(analysisId);
    super.parseMondrianSchemaName(analysisId, fileData);
    return fileData;
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MondrianCatalogRepositoryHelper(org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException)

Aggregations

MondrianCatalogRepositoryHelper (org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper)13 Test (org.junit.Test)6 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 IAclNodeHelper (org.pentaho.platform.api.repository2.unified.IAclNodeHelper)4 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)4 EnumSet (java.util.EnumSet)3 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 ZipInputStream (java.util.zip.ZipInputStream)2 MondrianException (mondrian.olap.MondrianException)2 FileSystemException (org.apache.commons.vfs2.FileSystemException)2 Matchers.anyString (org.mockito.Matchers.anyString)2 OlapException (org.olap4j.OlapException)2 ModelerWorkspace (org.pentaho.agilebi.modeler.ModelerWorkspace)2 LogicalModel (org.pentaho.metadata.model.LogicalModel)2 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)2