Java Code Examples for org.pentaho.reporting.engine.classic.core.ClassicEngineBoot#computeVersionId()

The following examples show how to use org.pentaho.reporting.engine.classic.core.ClassicEngineBoot#computeVersionId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedKettleDataFactoryMetaData.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Create a new metadata object for the embedded datafactory.
 *
 * @param name        the unique identifier, currently the relative path and file name from the /datasources dir to
 *                    end
 * @param displayName the display name. Could be the file name as well, or something totally different. Probably needs
 *                    to be internationalized in the production code.
 */
public EmbeddedKettleDataFactoryMetaData( final String name, final String displayName, byte[] embedded ) {
  super( name, "org.pentaho.reporting.engine.classic.extensions.datasources.kettle.KettleDataFactoryBundle",
    "",
    false, // expert
    false, // preferred
    false, // hidden
    false, // deprecated,
    true,  // editable
    false, // free-form
    false, // metadata-source
    MaturityLevel.Production, // experimental
    new KettleDataFactoryCore(),
    ClassicEngineBoot.computeVersionId( 4, 0, 0 ) );

  this.displayName = displayName;
  this.embedded = embedded;
}
 
Example 2
Source File: ContentRootElementHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Done parsing.
 *
 * @throws SAXException
 *           if there is a parsing error.
 */
protected void doneParsing() throws SAXException {
  // Now, after all the user-defined and global files have been parsed, finally override whatever had been
  // defined in these files with the contents from the bundle. This will merge all the settings from the bundle
  // with the global definitions but grants the local settings higer preference
  parseLocalFiles();

  final Object definedCompatLevel = report.getCompatibilityLevel();
  if ( definedCompatLevel instanceof Integer == false ) {
    final Object specRaw = getRootHandler().getHelperObject( PRPT_SPEC_VERSION );
    final Integer x = ClassicEngineBoot.computeVersionId( 999, 999, 999 );
    if ( specRaw instanceof Integer && x.equals( specRaw ) == false ) {
      report.setCompatibilityLevel( (Integer) specRaw );
    } else {
      report.setCompatibilityLevel( x );
    }
  }
}
 
Example 3
Source File: ProcessState.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Configuration wrapForCompatibility( final ProcessingContext processingContext ) {
  final int compatibilityLevel = processingContext.getCompatibilityLevel();
  if ( compatibilityLevel < 0 ) {
    return processingContext.getConfiguration();
  }

  if ( compatibilityLevel < ClassicEngineBoot.computeVersionId( 3, 999, 999 ) ) {
    // enable strict compatibility mode for reports older than 4.0.
    final HierarchicalConfiguration config = new HierarchicalConfiguration( processingContext.getConfiguration() );
    config
      .setConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.WrapProgressMarkerInSection", "true" );
    config.setConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.StrictCompatibility", "true" );
    return config;
  }

  // this is a trunk or 4.0 or newer report.
  return processingContext.getConfiguration();
}
 
Example 4
Source File: DebugReportRunner.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static Configuration wrapForCompatibility( final MasterReport processingContext ) {
  final Integer compatibilityLevel = processingContext.getCompatibilityLevel();
  if ( compatibilityLevel == null || compatibilityLevel < 0 ) {
    return processingContext.getConfiguration();
  }

  if ( compatibilityLevel < ClassicEngineBoot.computeVersionId( 3, 999, 999 ) ) {
    // enable strict compatibility mode for reports older than 4.0.
    final HierarchicalConfiguration config = new HierarchicalConfiguration( processingContext.getConfiguration() );
    config.setConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.WrapProgressMarkerInSection", "true" );
    config.setConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.StrictCompatibility", "true" );
    return config;
  }

  // this is a trunk or 4.0 or newer report.
  return processingContext.getConfiguration();
}
 
Example 5
Source File: PasswordEncryptionService.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String decrypt( final RootXmlReadHandler root, final String encryptedPassword ) {
  if ( StringUtils.isEmpty( encryptedPassword ) ) {
    // empty string vs. null may have significance.
    return encryptedPassword;
  }

  final Object helperObject = root.getHelperObject( ContentRootElementHandler.PRPT_SPEC_VERSION );
  final boolean legacyFix;
  if ( helperObject instanceof Integer ) {
    final Integer version = (Integer) helperObject;
    if ( version == -1 ) {
      logger.warn( "Decrypting password skipped, as we are dealing with an older version. " );
      return encryptedPassword;
    }

    legacyFix = ( version.intValue() < ClassicEngineBoot.computeVersionId( 5, 0, 0 ) );
  } else {
    legacyFix = false;
  }

  final int separatorPos = encryptedPassword.indexOf( ':' );
  if ( separatorPos == -1 ) {
    // assume legacy mode
    logger.warn( "Decrypting password skipped, as the password-text has no service indicator. " );
    return encryptedPassword;
  }

  final String serviceName = encryptedPassword.substring( 0, separatorPos );
  final String payload = encryptedPassword.substring( separatorPos + 1 );
  final PasswordEncryptionServiceProvider provider = services.get( serviceName );

  if ( legacyFix && ObscurificatePasswordEncryptionServiceProvider.SERVICE_TAG.equals( serviceName ) ) {
    return new Obscurificate48PasswordEncryptionServiceProvider().decrypt( payload );
  }
  if ( provider != null ) {
    return provider.decrypt( payload );
  }
  logger.debug( "Decrypting password skipped, as the service indicator is not recognized. " );
  return encryptedPassword;
}
 
Example 6
Source File: BundleMetaFileWriter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeVersionMarker( final WriteableDocumentMetaData writeableMetaData, final MasterReport masterReport ) {
  final int releaseMajor = ParserUtil.parseInt( ClassicEngineInfo.getInstance().getReleaseMajor(), -1 );
  final int releaseMinor = ParserUtil.parseInt( ClassicEngineInfo.getInstance().getReleaseMinor(), -1 );
  final int releasePatch = ParserUtil.parseInt( ClassicEngineInfo.getInstance().getReleaseMilestone(), -1 );
  int versionId = ClassicEngineBoot.computeVersionId( releaseMajor, releaseMinor, releasePatch );
  if ( versionId > 0 && ClassicEngineBoot.VERSION_TRUNK != versionId ) {
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.major",
        releaseMajor );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.minor",
        releaseMinor );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.patch",
        releasePatch );
  } else {
    final Configuration configuration = masterReport.getConfiguration();
    if ( "true"
        .equals( configuration
            .getConfigProperty( "org.pentaho.reporting.engine.classic.core.designtime.PreserveOriginalCompatibilitySettingInTrunk" ) ) ) {
      final Integer reportCompatibility = masterReport.getCompatibilityLevel();
      if ( reportCompatibility != null && reportCompatibility > 0 ) {
        final int patch = reportCompatibility % 1000;
        final int minor = ( reportCompatibility / 1000 ) % 1000;
        final int major = ( reportCompatibility / 1000000 );
        writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.major", major );
        writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.minor", minor );
        writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.patch", patch );
        return;
      }
    }
    // trunk is just the strongest player in town
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.major", 999 );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.minor", 999 );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.patch", 999 );
  }
}
 
Example 7
Source File: LayoutCompatibility_5_0_Converter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public int getTargetVersion() {
  return ClassicEngineBoot.computeVersionId( 5, 0, 0 );
}
 
Example 8
Source File: LayoutCompatibility_3_9_Converter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public int getTargetVersion() {
  return ClassicEngineBoot.computeVersionId( 3, 9, 0 );
}
 
Example 9
Source File: MondrianDataSource_50_CompatibilityConverter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public int getTargetVersion() {
  return ClassicEngineBoot.computeVersionId( 5, 0, 0 );
}