ExecuteReportContentHandler { StagingMode getStagingMode( final Map<String, Object> inputs, final MasterReport report ) { final Object o = inputs.get( "report-staging-mode" ); if ( o != null ) { try { return StagingMode.valueOf( String.valueOf( o ) ); } catch ( IllegalArgumentException ie ) { logger.trace( "Staging mode was specified but invalid" ); } } StagingMode mode = (StagingMode) report.getAttribute( AttributeNames.Pentaho.NAMESPACE, AttributeNames.Pentaho.STAGING_MODE ); if ( mode == null ) { logger.trace( "Looking at default settings for mode" ); String defaultStagingMode = PentahoSystem.getSystemSetting( "report-staging-mode", null ); if ( defaultStagingMode == null ) { defaultStagingMode = DEFAULT.toString(); logger.trace( "Nothing in settings/staging-mode - defaulting to MEMORY" ); } else { logger.trace( "Read " + defaultStagingMode + " from settings/report-staging-mode" ); } try { mode = StagingMode.valueOf( defaultStagingMode.toUpperCase() ); logger.trace( "Staging mode set from default - " + mode ); } catch ( IllegalArgumentException badStringInSettings ) { mode = DEFAULT; } } return mode; } ExecuteReportContentHandler( final ReportContentGenerator contentGenerator ); void createReportContent( final OutputStream outputStream, final Serializable fileId, final String path,
      final boolean forceDefaultOutputTarget ); void createReportContent( final OutputStream outputStream, final Serializable fileId, final String path,
                                   final boolean forceDefaultOutputTarget,
                                   final SimpleReportingComponent reportComponent,
                                   final AuditWrapper audit ); static final String FORCED_BUFFERED_WRITING; }
@Test public void testGetStagingModeFromInputs() { final ExecuteReportContentHandler handler = new ExecuteReportContentHandler( contentGenerator ); StagingMode mode = (StagingMode) inputs.get( "report-staging-mode" ); assertEquals( StagingMode.THRU, mode ); mode = handler.getStagingMode( inputs, report ); assertEquals( StagingMode.THRU, mode ); inputs.put( "report-staging-mode", StagingMode.MEMORY ); mode = handler.getStagingMode( inputs, report ); assertEquals( StagingMode.MEMORY, mode ); }
@Test public void testGetStagingHandlerFromReport() { final ExecuteReportContentHandler handler = new ExecuteReportContentHandler( contentGenerator ); inputs.remove( "report-staging-mode" ); when( report.getAttribute( eq( AttributeNames.Pentaho.NAMESPACE ), eq( AttributeNames.Pentaho.STAGING_MODE ) ) ).thenReturn( StagingMode.TMPFILE ); StagingMode mode = handler.getStagingMode( inputs, report ); assertEquals( StagingMode.TMPFILE, mode ); }
@Test public void testGetStagingModeDefault() { final ExecuteReportContentHandler handler = new ExecuteReportContentHandler( contentGenerator ); inputs.remove( "report-staging-mode" ); StagingMode mode = handler.getStagingMode( inputs, report ); assertEquals( StagingMode.THRU, mode ); }