use of org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService in project pentaho-platform by pentaho.
the class MondrianImportHandlerTest method testImportFile_applyAclSettings.
@Test
public void testImportFile_applyAclSettings() throws Exception {
RepositoryFileAcl acl = mock(RepositoryFileAcl.class);
when(bundle.getProperty(eq(MondrianImportHandler.DOMAIN_ID))).thenReturn(MondrianImportHandler.DOMAIN_ID);
when(bundle.isApplyAclSettings()).thenReturn(true);
when(bundle.getAcl()).thenReturn(acl);
IAclAwareMondrianCatalogService aclImporter = mock(IAclAwareMondrianCatalogService.class);
MondrianImportHandler handler = new MondrianImportHandler(mimeTypes, aclImporter);
handler.importFile(bundle);
ArgumentCaptor<RepositoryFileAcl> captor = ArgumentCaptor.forClass(RepositoryFileAcl.class);
verify(aclImporter).addCatalog(any(InputStream.class), any(MondrianCatalog.class), anyBoolean(), captor.capture(), any(IPentahoSession.class));
assertEquals(acl, captor.getValue());
}
use of org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService in project pentaho-platform by pentaho.
the class MondrianImportHandler method importFile.
/**
* **************************************** Main entry point from the Spring Interface
*
* @param IPlatformImportBundle
* @throws IOException
* @throws DomainStorageException
* @throws DomainAlreadyExistsException
* @throws DomainIdNullException
* @throws PlatformImportException
* @throws SAXException
* @throws ParserConfigurationException
*/
public void importFile(IPlatformImportBundle bundle) throws PlatformImportException, DomainIdNullException, DomainAlreadyExistsException, DomainStorageException, IOException {
boolean overwriteInRepossitory = bundle.overwriteInRepository();
boolean xmla = "false".equalsIgnoreCase(findParameterPropertyValue(bundle, ENABLE_XMLA)) ? false : true;
final String domainId = (String) bundle.getProperty(DOMAIN_ID);
if (domainId == null) {
throw new PlatformImportException("Bundle missing required domain-id property");
}
try {
InputStream is = bundle.getInputStream();
MondrianCatalog catalog = this.createCatalogObject(domainId, xmla, bundle);
IPentahoSession session = PentahoSessionHolder.getSession();
if (mondrianRepositoryImporter instanceof IAclAwareMondrianCatalogService) {
RepositoryFileAcl acl = bundle.isApplyAclSettings() ? bundle.getAcl() : null;
IAclAwareMondrianCatalogService aware = (IAclAwareMondrianCatalogService) mondrianRepositoryImporter;
aware.addCatalog(is, catalog, overwriteInRepossitory, acl, session);
} else {
mondrianRepositoryImporter.addCatalog(is, catalog, overwriteInRepossitory, session);
}
} catch (MondrianCatalogServiceException mse) {
int statusCode = convertExceptionToStatus(mse);
throw new PlatformImportException(mse.getMessage(), statusCode);
} catch (Exception e) {
throw new PlatformImportException(e.getMessage(), PlatformImportException.PUBLISH_GENERAL_ERROR);
}
}
use of org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService in project pentaho-platform by pentaho.
the class MondrianImportHandlerTest method testImportFile_DoNotApplyAclSettings.
@Test
public void testImportFile_DoNotApplyAclSettings() throws Exception {
when(bundle.getProperty(eq(MondrianImportHandler.DOMAIN_ID))).thenReturn(MondrianImportHandler.DOMAIN_ID);
when(bundle.isApplyAclSettings()).thenReturn(false);
IAclAwareMondrianCatalogService aclImporter = mock(IAclAwareMondrianCatalogService.class);
MondrianImportHandler handler = new MondrianImportHandler(mimeTypes, aclImporter);
handler.importFile(bundle);
ArgumentCaptor<RepositoryFileAcl> captor = ArgumentCaptor.forClass(RepositoryFileAcl.class);
verify(aclImporter).addCatalog(any(InputStream.class), any(MondrianCatalog.class), anyBoolean(), captor.capture(), any(IPentahoSession.class));
assertNull(captor.getValue());
}
Aggregations