MetadataImportHandler implements IPlatformImportHandler { InputStream StripDswFromStream( InputStream inputStream ) throws Exception { InputStream inputStream2 = null; String xmi = null; XmiParser xmiParser = new XmiParser(); try { byte[] is = IOUtils.toByteArray( inputStream ); xmi = new String( is, "UTF-8" ); Domain domain = xmiParser.parseXmi( new java.io.ByteArrayInputStream( is ) ); boolean changed = false; Iterator<LogicalModel> iterator = domain.getLogicalModels().iterator(); while ( iterator.hasNext() ) { LogicalModel logicalModel = iterator.next(); Object property = logicalModel.getProperty( DSW_SOURCE_PROPERTY ); if ( property != null ) { if ( logicalModel.getProperty( LogicalModel.PROPERTY_OLAP_DIMS ) != null ) { iterator.remove(); } else { logicalModel.removeChildProperty( DSW_SOURCE_PROPERTY ); logicalModel.removeChildProperty( AGILE_BI_VERSION_PROPERTY ); logicalModel.removeChildProperty( WIZARD_GENERATED_PROPERTY ); } changed = true; } } if ( changed ) { xmi = xmiParser.generateXmi( domain ); } inputStream2 = new java.io.ByteArrayInputStream( xmi.getBytes( "UTF-8" ) ); } catch ( Exception e ) { throw new PlatformImportException( e.getMessage(), PlatformImportException.PUBLISH_TO_SERVER_FAILED, e ); } return inputStream2; } MetadataImportHandler( List<IMimeType> mimeTypes,
                                final IPentahoMetadataDomainRepositoryImporter metadataImporter ); @Override void importFile( IPlatformImportBundle file ); @Override List<IMimeType> getMimeTypes();  }
@Test public void testBiserver13711() throws Exception { String xmi = null; FileInputStream in = new FileInputStream( new File( TestResourceLocation.TEST_RESOURCES + "/ImportTest/13711.xmi" ) ); byte[] is = IOUtils.toByteArray( in ); xmi = new String( is, "UTF-8" ); Assert.assertTrue( xmi.contains( "AGILE_BI_GENERATED_SCHEMA" ) ); Assert.assertTrue( xmi.contains( "AGILE_BI_VERSION" ) ); Assert.assertTrue( xmi.contains( "WIZARD_GENERATED_SCHEMA" ) ); in = new FileInputStream( new File( TestResourceLocation.TEST_RESOURCES + "/ImportTest/13711.xmi" ) ); InputStream processedStream = metadataHandler.StripDswFromStream( in ); is = IOUtils.toByteArray( processedStream ); xmi = new String( is, "UTF-8" ); Assert.assertFalse( xmi.contains( "AGILE_BI_GENERATED_SCHEMA" ) ); Assert.assertFalse( xmi.contains( "AGILE_BI_VERSION" ) ); Assert.assertFalse( xmi.contains( "WIZARD_GENERATED_SCHEMA" ) ); }