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);
}
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);
}
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;
}
Aggregations