MondrianImportHandler implements IPlatformImportHandler { protected MondrianCatalog createCatalogObject( String catName, boolean xmlaEnabled, IPlatformImportBundle bundle ) throws ParserConfigurationException, SAXException, IOException, PlatformImportException { final Map<String, String> parameters = findParameters( bundle ); final String dsName = findParameterPropertyValue( bundle, DATA_SOURCE ); final String provider; if ( parameters.containsKey( PROVIDER ) ) { provider = findParameterPropertyValue( bundle, PROVIDER ); } else { provider = DEFAULT_PROVIDER; } StringBuilder sb = new StringBuilder(); if ( dsName != null ) { sb.append( "DataSource=\"" ) .append( StringEscapeUtils.escapeXml( dsName.replaceAll( "&quot;", "\"" ) ) ) .append( "\";" ); } if ( !parameters.containsKey( "EnableXmla" ) ) { sb.append( "EnableXmla=" ) .append( xmlaEnabled ) .append( ";" ); } sb.append( "Provider=\"" ) .append( StringEscapeUtils.escapeXml( provider.replaceAll( "&quot;", "\"" ) ) ) .append( "\"" ); for ( Entry<String, String> parameter : parameters.entrySet() ) { if ( !parameter.getKey().equals( DATA_SOURCE ) && !parameter.getKey().equals( PROVIDER ) ) { String parseSafeValue = StringEscapeUtils.escapeXml( parameter.getValue().replaceAll( "&quot;", "\"" ) ); sb.append( ";" ); sb.append( parameter.getKey() ); sb.append( "=\"" ); sb.append( parseSafeValue ); sb.append( "\"" ); } } MondrianCatalog catalog = new MondrianCatalog( catName, sb.toString(), provider + ":" + RepositoryFile.SEPARATOR + catName, null, null ); return catalog; } MondrianImportHandler( List<IMimeType> mimeTypes, final IMondrianCatalogService mondrianImporter ); void importFile( IPlatformImportBundle bundle ); @Override List<IMimeType> getMimeTypes();  }
@Test public void testCreateCatalogObject_SpecificSymbolsInBundle() throws Exception { IPlatformImportBundle customBundle = mock( IPlatformImportBundle.class ); parameters = MondrianImportHandler.PROVIDER + "=provider;" + MondrianImportHandler.DATA_SOURCE + "=\"DS &quot;Test's&quot; & <Fun>\";" + "DynamicSchemaProcessor=\"DSP's & &quot;Other&quot; <stuff>\""; String expectedValue = new StringBuilder() .append( "DataSource=\"DS &quot;Test&apos;s&quot; &amp; &lt;Fun&gt;\";" ) .append( "EnableXmla=true;" ) .append( "Provider=\"provider\";" ) .append( "DynamicSchemaProcessor=\"DSP&apos;s &amp; &quot;Other&quot; &lt;stuff&gt;\"" ) .toString(); when( customBundle.getProperty( eq( MondrianImportHandler.ENABLE_XMLA ) ) ).thenReturn( "true" ); when( customBundle.getProperty( eq( MondrianImportHandler.DATA_SOURCE ) ) ).thenReturn( "DS &quot;Test's&quot; & <Fun>" ); when( customBundle.getProperty( eq( MondrianImportHandler.PARAMETERS ) ) ).thenReturn( parameters ); MondrianImportHandler mondrianImportHandler = new MondrianImportHandler( mimeTypes, mondrianImporter ); MondrianCatalog catalog = mondrianImportHandler.createCatalogObject( "catalog", true, customBundle ); assertEquals( catalog.getDataSourceInfo(), expectedValue ); }