Program: 125583
Project: 125583
Buggy source:
static void revertPropertiesForContextMode(DatabaseConnection conn,ContextType contextType){
  if (conn == null || contextType == null) {
    return;
  }
  String server=ContextParameterUtils.getOriginalValue(contextType,conn.getServerName());
  String username=ContextParameterUtils.getOriginalValue(contextType,conn.getUsername());
  String password=ContextParameterUtils.getOriginalValue(contextType,conn.getRawPassword());
  String port=ContextParameterUtils.getOriginalValue(contextType,conn.getPort());
  String sidOrDatabase=ContextParameterUtils.getOriginalValue(contextType,conn.getSID());
  String datasource=ContextParameterUtils.getOriginalValue(contextType,conn.getDatasourceName());
  String filePath=ContextParameterUtils.getOriginalValue(contextType,conn.getFileFieldName());
  String schemaOracle=ContextParameterUtils.getOriginalValue(contextType,conn.getUiSchema());
  String dbRootPath=ContextParameterUtils.getOriginalValue(contextType,conn.getDBRootPath());
  String additionParam=ContextParameterUtils.getOriginalValue(contextType,conn.getAdditionalParams());
  String jdbcUrl=ContextParameterUtils.getOriginalValue(contextType,conn.getURL());
  String driverJar=ContextParameterUtils.getOriginalValue(contextType,conn.getDriverJarPath());
  String className=ContextParameterUtils.getOriginalValue(contextType,conn.getDriverClass());
  String mappingFile=ContextParameterUtils.getOriginalValue(contextType,conn.getDbmsId());
  filePath=TalendQuoteUtils.removeQuotes(filePath);
  dbRootPath=TalendQuoteUtils.removeQuotes(dbRootPath);
  conn.setAdditionalParams(additionParam);
  conn.setDatasourceName(datasource);
  conn.setDBRootPath(dbRootPath);
  conn.setFileFieldName(filePath);
  conn.setRawPassword(password);
  conn.setPort(port);
  conn.setUiSchema(schemaOracle);
  conn.setServerName(server);
  if (conn.getDataPackage() != null) {
    for (    orgomg.cwm.objectmodel.core.Package dataPackage : conn.getDataPackage()) {
      if (dataPackage instanceof ModelElement) {
        ModelElement element=dataPackage;
        if (conn.getSID() != null && conn.getSID().equals(element.getName())) {
          element.setName(sidOrDatabase);
        }
      }
    }
  }
  conn.setSID(sidOrDatabase);
  conn.setUsername(username);
  conn.setURL(jdbcUrl);
  conn.setDriverJarPath(driverJar);
  conn.setDriverClass(className);
  conn.setDbmsId(mappingFile);
  revertConnSubElement(conn,contextType);
  if (EDatabaseTypeName.HIVE.equals(EDatabaseTypeName.getTypeFromDbType(conn.getDatabaseType()))) {
    String hadoopUserName=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USERNAME);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USERNAME,ContextParameterUtils.getOriginalValue(contextType,hadoopUserName));
    String jobTracker=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL,ContextParameterUtils.getOriginalValue(contextType,jobTracker));
    String nameNode=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL,ContextParameterUtils.getOriginalValue(contextType,nameNode));
    String hivePrincipal=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA,ContextParameterUtils.getOriginalValue(contextType,hivePrincipal));
    String hiveMetadata=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL,ContextParameterUtils.getOriginalValue(contextType,hiveMetadata));
    String driverPath=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH,ContextParameterUtils.getOriginalValue(contextType,driverPath));
    String driverClass=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS,ContextParameterUtils.getOriginalValue(contextType,driverClass));
    String hiveUserName=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME,ContextParameterUtils.getOriginalValue(contextType,hiveUserName));
    String hivePassword=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD,ContextParameterUtils.getOriginalValue(contextType,hivePassword));
    String ktPrincipal=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,ktPrincipal));
    String keytab=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,ContextParameterUtils.getOriginalValue(contextType,keytab));
    String addtionalJDBCParameters=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS,ContextParameterUtils.getOriginalValue(contextType,addtionalJDBCParameters));
    String sslTrustStorePath=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH,ContextParameterUtils.getOriginalValue(contextType,sslTrustStorePath));
    String sslTrustStorePassword=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD,conn.getValue(ContextParameterUtils.getOriginalValue(contextType,sslTrustStorePassword),true));
  }
  if (EDatabaseTypeName.HBASE.equals(EDatabaseTypeName.getTypeFromDbType(conn.getDatabaseType()))) {
    String hbaseMasterPrin=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,hbaseMasterPrin));
    String hbaseRegionPrin=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,hbaseRegionPrin));
    String hbaseKeyTabPrin=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,hbaseKeyTabPrin));
    String hbaseKeyTab=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,ContextParameterUtils.getOriginalValue(contextType,hbaseKeyTab));
  }
  String hadoopPropertiesJson=transformContextModeToOriginal(getHiveOrHbaseHadoopProperties(conn),contextType);
  setAdditionalHadoopProperties(conn,hadoopPropertiesJson);
  String hivePropertiesJson=transformContextModeToOriginal(getHiveJdbcProperties(conn),contextType);
  setAdditionalHiveJdbcProperties(conn,hivePropertiesJson);
}

Fixed version (ground truth):
static void revertPropertiesForContextMode(DatabaseConnection conn,ContextType contextType){
  if (conn == null || contextType == null) {
    return;
  }
  String server=ContextParameterUtils.getOriginalValue(contextType,conn.getServerName());
  String username=ContextParameterUtils.getOriginalValue(contextType,conn.getUsername());
  String password=ContextParameterUtils.getOriginalValue(contextType,conn.getRawPassword());
  String port=ContextParameterUtils.getOriginalValue(contextType,conn.getPort());
  String sidOrDatabase=ContextParameterUtils.getOriginalValue(contextType,conn.getSID());
  String datasource=ContextParameterUtils.getOriginalValue(contextType,conn.getDatasourceName());
  String filePath=ContextParameterUtils.getOriginalValue(contextType,conn.getFileFieldName());
  String schemaOracle=ContextParameterUtils.getOriginalValue(contextType,conn.getUiSchema());
  String dbRootPath=ContextParameterUtils.getOriginalValue(contextType,conn.getDBRootPath());
  String additionParam=ContextParameterUtils.getOriginalValue(contextType,conn.getAdditionalParams());
  String jdbcUrl=ContextParameterUtils.getOriginalValue(contextType,conn.getURL());
  String driverJar=ContextParameterUtils.getOriginalValue(contextType,conn.getDriverJarPath());
  String className=ContextParameterUtils.getOriginalValue(contextType,conn.getDriverClass());
  String mappingFile=ContextParameterUtils.getOriginalValue(contextType,conn.getDbmsId());
  filePath=TalendQuoteUtils.removeQuotes(filePath);
  dbRootPath=TalendQuoteUtils.removeQuotes(dbRootPath);
  conn.setAdditionalParams(additionParam);
  conn.setDatasourceName(datasource);
  conn.setDBRootPath(dbRootPath);
  conn.setFileFieldName(filePath);
  conn.setRawPassword(password);
  conn.setPort(port);
  conn.setUiSchema(schemaOracle);
  conn.setServerName(server);
  if (conn.getDataPackage() != null) {
    for (    orgomg.cwm.objectmodel.core.Package dataPackage : conn.getDataPackage()) {
      if (dataPackage instanceof ModelElement) {
        ModelElement element=dataPackage;
        if (conn.getSID() != null && conn.getSID().equals(element.getName())) {
          element.setName(sidOrDatabase);
        }
      }
    }
  }
  conn.setSID(sidOrDatabase);
  conn.setUsername(username);
  conn.setURL(jdbcUrl);
  conn.setDriverJarPath(driverJar);
  conn.setDriverClass(className);
  conn.setDbmsId(mappingFile);
  revertConnSubElement(conn,contextType);
  if (EDatabaseTypeName.HIVE.equals(EDatabaseTypeName.getTypeFromDbType(conn.getDatabaseType()))) {
    String hadoopUserName=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USERNAME);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USERNAME,ContextParameterUtils.getOriginalValue(contextType,hadoopUserName));
    String jobTracker=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL,ContextParameterUtils.getOriginalValue(contextType,jobTracker));
    String nameNode=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL,ContextParameterUtils.getOriginalValue(contextType,nameNode));
    String hivePrincipal=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA,ContextParameterUtils.getOriginalValue(contextType,hivePrincipal));
    String hiveMetadata=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL,ContextParameterUtils.getOriginalValue(contextType,hiveMetadata));
    String driverPath=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH,ContextParameterUtils.getOriginalValue(contextType,driverPath));
    String driverClass=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS,ContextParameterUtils.getOriginalValue(contextType,driverClass));
    String hiveUserName=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME,ContextParameterUtils.getOriginalValue(contextType,hiveUserName));
    String hivePassword=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD);
    conn.getParameters().put(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD,ContextParameterUtils.getOriginalValue(contextType,hivePassword));
    String ktPrincipal=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,ktPrincipal));
    String keytab=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,ContextParameterUtils.getOriginalValue(contextType,keytab));
    String addtionalJDBCParameters=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS,ContextParameterUtils.getOriginalValue(contextType,addtionalJDBCParameters));
    String sslTrustStorePath=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH,ContextParameterUtils.getOriginalValue(contextType,sslTrustStorePath));
    String sslTrustStorePassword=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD,conn.getValue(ContextParameterUtils.getOriginalValue(contextType,sslTrustStorePassword),true));
    String maprticket_Username=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME,ContextParameterUtils.getOriginalValue(contextType,maprticket_Username));
    String maprticket_Password=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD,ContextParameterUtils.getOriginalValue(contextType,maprticket_Password));
    String maprticket_Cluster=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER,ContextParameterUtils.getOriginalValue(contextType,maprticket_Cluster));
    String maprticket_Duration=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION,ContextParameterUtils.getOriginalValue(contextType,maprticket_Duration));
  }
  if (EDatabaseTypeName.HBASE.equals(EDatabaseTypeName.getTypeFromDbType(conn.getDatabaseType()))) {
    String hbaseMasterPrin=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,hbaseMasterPrin));
    String hbaseRegionPrin=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,hbaseRegionPrin));
    String hbaseKeyTabPrin=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,ContextParameterUtils.getOriginalValue(contextType,hbaseKeyTabPrin));
    String hbaseKeyTab=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,ContextParameterUtils.getOriginalValue(contextType,hbaseKeyTab));
    String maprticket_Username=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME,ContextParameterUtils.getOriginalValue(contextType,maprticket_Username));
    String maprticket_Password=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD,ContextParameterUtils.getOriginalValue(contextType,maprticket_Password));
    String maprticket_Cluster=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER,ContextParameterUtils.getOriginalValue(contextType,maprticket_Cluster));
    String maprticket_Duration=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION,ContextParameterUtils.getOriginalValue(contextType,maprticket_Duration));
  }
  String hadoopPropertiesJson=transformContextModeToOriginal(getHiveOrHbaseHadoopProperties(conn),contextType);
  setAdditionalHadoopProperties(conn,hadoopPropertiesJson);
  String hivePropertiesJson=transformContextModeToOriginal(getHiveJdbcProperties(conn),contextType);
  setAdditionalHiveJdbcProperties(conn,hivePropertiesJson);
}