Search in sources :

Example 1 with IAclAwareMondrianCatalogService

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

Example 2 with IAclAwareMondrianCatalogService

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);
    }
}
Also used : MondrianCatalog(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog) MondrianCatalogServiceException(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogServiceException) IAclAwareMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService) InputStream(java.io.InputStream) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) DomainAlreadyExistsException(org.pentaho.metadata.repository.DomainAlreadyExistsException) DomainStorageException(org.pentaho.metadata.repository.DomainStorageException) IOException(java.io.IOException) DomainIdNullException(org.pentaho.metadata.repository.DomainIdNullException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) MondrianCatalogServiceException(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogServiceException) SAXException(org.xml.sax.SAXException)

Example 3 with IAclAwareMondrianCatalogService

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

Aggregations

InputStream (java.io.InputStream)3 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)3 IAclAwareMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService)3 MondrianCatalog (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog)3 Test (org.junit.Test)2 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 DomainAlreadyExistsException (org.pentaho.metadata.repository.DomainAlreadyExistsException)1 DomainIdNullException (org.pentaho.metadata.repository.DomainIdNullException)1 DomainStorageException (org.pentaho.metadata.repository.DomainStorageException)1 MondrianCatalogServiceException (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogServiceException)1 SAXException (org.xml.sax.SAXException)1