private 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"); // $NON-NLS-1$
      // Unable to use the plugin settings.xml because the
      // classloader for the ReportContentGenerator isn't the plugin classloader
      // IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
      // String defaultStagingMode = resLoader.getPluginSetting(ReportContentGenerator.class,
      // "settings/report-staging-mode"); //$NON-NLS-1$
      //
      // So - get default setting from the pentaho.xml instead
      String defaultStagingMode =
          PentahoSystem.getSystemSetting("report-staging-mode", null); // $NON-NLS-1$
      if (defaultStagingMode == null) {
        // workaround for a bug in getPluginSetting that ignores the default passed in
        defaultStagingMode = DEFAULT.toString(); // $NON-NLS-1$
        logger.trace("Nothing in settings/staging-mode - defaulting to MEMORY"); // $NON-NLS-1$
      } else {
        logger.trace(
            "Read "
                + defaultStagingMode
                + " from settings/report-staging-mode"); //$NON-NLS-1$//$NON-NLS-2$
      }
      try {
        mode = StagingMode.valueOf(defaultStagingMode.toUpperCase());
        logger.trace("Staging mode set from default - " + mode); // $NON-NLS-1$
      } catch (IllegalArgumentException badStringInSettings) {
        mode = DEFAULT; // default state - handling staging in memory by default.
      }
    }
    return mode;
  }