PentahoPlatformExporter extends ZipExportProcessor { protected void exportMetastore() throws IOException { log.debug( "export the metastore" ); try { Path tempDirectory = Files.createTempDirectory( METASTORE ); IMetaStore xmlMetaStore = new XmlMetaStore( tempDirectory.toString() ); MetaStoreUtil.copy( getRepoMetaStore(), xmlMetaStore ); File zippedMetastore = Files.createTempFile( METASTORE, EXPORT_TEMP_FILENAME_EXT ).toFile(); ZipOutputStream zipOutputStream = new ZipOutputStream( new FileOutputStream( zippedMetastore ) ); zipFolder( tempDirectory.toFile(), zipOutputStream, tempDirectory.toString() ); zipOutputStream.close(); FileInputStream zis = new FileInputStream( zippedMetastore ); String zipFileLocation = METASTORE + METASTORE_BACKUP_EXT; ZipEntry metastoreZipFileZipEntry = new ZipEntry( zipFileLocation ); zos.putNextEntry( metastoreZipFileZipEntry ); try { IOUtils.copy( zis, zos ); } catch ( IOException e ) { throw e; } finally { zis.close(); zos.closeEntry(); } ExportManifestMetaStore exportManifestMetaStore = new ExportManifestMetaStore( zipFileLocation, getRepoMetaStore().getName(), getRepoMetaStore().getDescription() ); getExportManifest().setMetaStore( exportManifestMetaStore ); zippedMetastore.deleteOnExit(); tempDirectory.toFile().deleteOnExit(); } catch ( Exception e ) { log.error( Messages.getInstance().getString( "PentahoPlatformExporter.ERROR.ExportingMetaStore" ) ); log.debug( Messages.getInstance().getString( "PentahoPlatformExporter.ERROR.ExportingMetaStore" ), e ); } } PentahoPlatformExporter( IUnifiedRepository repository ); File performExport(); @Override File performExport( RepositoryFile exportRepositoryFile ); IScheduler getScheduler(); void setScheduler( IScheduler scheduler ); IMetadataDomainRepository getMetadataDomainRepository(); void setMetadataDomainRepository( IMetadataDomainRepository metadataDomainRepository ); IDatasourceMgmtService getDatasourceMgmtService(); void setDatasourceMgmtService( IDatasourceMgmtService datasourceMgmtService ); MondrianCatalogRepositoryHelper getMondrianCatalogRepositoryHelper(); void setMondrianCatalogRepositoryHelper(
    MondrianCatalogRepositoryHelper mondrianCatalogRepositoryHelper ); IMondrianCatalogService getMondrianCatalogService(); void setMondrianCatalogService(
    IMondrianCatalogService mondrianCatalogService ); IUserSettingService getUserSettingService(); void setUserSettingService( IUserSettingService userSettingService ); static final String ROOT; static final String DATA_SOURCES_PATH_IN_ZIP; static final String METADATA_PATH_IN_ZIP; static final String ANALYSIS_PATH_IN_ZIP; static final String CONNECTIONS_PATH_IN_ZIP; static final String METASTORE; static final String METASTORE_BACKUP_EXT; }
@Test public void testExportMetaStore() throws Exception { exporterSpy.zos = mock( ZipOutputStream.class ); IMetaStore metastore = mock( IMetaStore.class ); exporterSpy.setRepoMetaStore( metastore ); ExportManifest manifest = mock( ExportManifest.class ); exporterSpy.setExportManifest( manifest ); exporterSpy.exportMetastore(); verify( exporterSpy.zos ).putNextEntry( any( ZipEntry.class ) ); verify( manifest ).setMetaStore( any( ExportManifestMetaStore.class ) ); }