Program: 73599
Project: 73599
Buggy source:
/** 
 * Save the model to the database, together with the references changes  to its parent models. 
 * @param isNew Whether this is a new model. 
 * @param id The id of this model. 
 * @param parentsMaintainOldVersion The list of parents names that do not want to reflect the changes to the submodel they have.  
 * @param newVersionName The new name of this saving model, to have those parent models maintaining the old reference.
 * @throws Exception Thrown if errors occur during the saving. 
 */
private void _commitSave(boolean isNew,String id,ArrayList<String> parentsMaintainOldVersion,String newVersionName) throws Exception {
  String newName=_attributesListPanel.getModelName();
  _modelToSave.setName(newName);
  _updateDisplayedModel();
  if (isNew || id == null) {
    if (_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR) != null) {
      _modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR).setContainer(null);
      try {
        MoMLChangeRequest change=new MoMLChangeRequest(this,null,_modelToSave.exportMoML());
        change.setUndoable(true);
        _modelToSave.requestChange(change);
      }
 catch (      Exception e) {
        _resetValues();
        throw e;
      }
    }
  }
  if (_xmlModel == null) {
    _xmlModel=new XMLDBModel(_modelToSave.getName());
  }
  _xmlModel.setModelName(_modelToSave.getName());
  _xmlModel.setModel(_modelToSave.exportMoML());
  _xmlModel.setIsNew(isNew);
  _xmlModel.setModelId(id);
  XMLDBModelWithReferenceChanges xmlDBModelWithReferenceChanges=new XMLDBModelWithReferenceChanges(_xmlModel,parentsMaintainOldVersion,newVersionName);
  try {
    String modelId=_saveModelManager.saveWithParents(xmlDBModelWithReferenceChanges);
    if (modelId != null) {
      JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
      if (_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR) == null) {
        StringConstantParameter dbModelParam=new StringConstantParameter(_modelToSave,XMLDBModel.DB_MODEL_ID_ATTR);
        dbModelParam.setExpression(modelId);
        dbModelParam.setContainer(_modelToSave);
      }
 else       if (!((StringParameter)_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR)).getExpression().equals(modelId)) {
        ((StringParameter)_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR)).setExpression(modelId);
      }
      try {
        MoMLChangeRequest change=new MoMLChangeRequest(this,null,_modelToSave.exportMoML());
        change.setUndoable(true);
        _modelToSave.requestChange(change);
        _source.setTitle(_xmlModel.getModelName());
        try {
          _source.updateDBModelHistory(_xmlModel.getModelName(),false);
        }
 catch (        IOException e) {
        }
      }
 catch (      Exception e) {
        throw e;
      }
      ArrayList<String> openedParents=null;
      if (_parentValidateFrame != null) {
        openedParents=new ArrayList<String>();
        for (        String openedParentModelName : _parentValidateFrame._getOpenedParents()) {
          openedParents.add(openedParentModelName);
        }
      }
      _source.setModified(false);
      if (_parentValidateFrame != null) {
        _parentValidateFrame.dispose();
      }
      dispose();
      if (openedParents != null) {
        for (        String openedParentModelName : openedParents) {
          PtolemyEffigy parentModelEffigy=(PtolemyEffigy)_source.getConfiguration().getDirectory().getEffigy(openedParentModelName);
          parentModelEffigy.closeTableaux();
          parentModelEffigy.setContainer(null);
          PtolemyEffigy updatedParentModelEffigy=LoadManager.loadModel(openedParentModelName,_source.getConfiguration());
          if (updatedParentModelEffigy != null) {
            updatedParentModelEffigy.showTableaux();
          }
        }
      }
      _source.getConfiguration().getDirectory().getEffigy(_xmlModel.getModelName()).showTableaux();
    }
 else {
      JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    }
  }
 catch (  DBConnectionException exception) {
    _resetValues();
    throw exception;
  }
catch (  DBExecutionException exception) {
    _resetValues();
    throw exception;
  }
catch (  IllegalArgumentException exception) {
    _resetValues();
    throw exception;
  }
catch (  ModelAlreadyExistException exception) {
    _resetValues();
    JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    _rollbackModel();
  }
}

Fixed version (ground truth):
/** 
 * Save the model to the database, together with the references changes  to its parent models. 
 * @param isNew Whether this is a new model. 
 * @param id The id of this model. 
 * @param parentsMaintainOldVersion The list of parents names that do not want to reflect the changes to the submodel they have.  
 * @param newVersionName The new name of this saving model, to have those parent models maintaining the old reference.
 * @throws Exception Thrown if errors occur during the saving. 
 */
private void _commitSave(boolean isNew,String id,ArrayList<String> parentsMaintainOldVersion,String newVersionName) throws Exception {
  String newName=_attributesListPanel.getModelName();
  _modelToSave.setName(newName);
  _updateDisplayedModel();
  if (isNew || id == null) {
    if (_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR) != null) {
      _modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR).setContainer(null);
      try {
        MoMLChangeRequest change=new MoMLChangeRequest(this,null,_modelToSave.exportMoML());
        change.setUndoable(true);
        _modelToSave.requestChange(change);
      }
 catch (      Exception e) {
        _resetValues();
        throw e;
      }
    }
  }
  if (_xmlModel == null) {
    _xmlModel=new XMLDBModel(_modelToSave.getName());
  }
  _xmlModel.setModelName(_modelToSave.getName());
  _xmlModel.setModel(_modelToSave.exportMoML());
  _xmlModel.setIsNew(isNew);
  _xmlModel.setModelId(id);
  XMLDBModelWithReferenceChanges xmlDBModelWithReferenceChanges=new XMLDBModelWithReferenceChanges(_xmlModel,parentsMaintainOldVersion,newVersionName);
  try {
    String modelId=_saveModelManager.saveWithParents(xmlDBModelWithReferenceChanges);
    if (modelId != null) {
      JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
      if (_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR) == null) {
        StringConstantParameter dbModelParam=new StringConstantParameter(_modelToSave,XMLDBModel.DB_MODEL_ID_ATTR);
        dbModelParam.setExpression(modelId);
        dbModelParam.setContainer(_modelToSave);
      }
 else       if (!((StringParameter)_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR)).getExpression().equals(modelId)) {
        ((StringParameter)_modelToSave.getAttribute(XMLDBModel.DB_MODEL_ID_ATTR)).setExpression(modelId);
      }
      try {
        MoMLChangeRequest change=new MoMLChangeRequest(this,null,_modelToSave.exportMoML());
        change.setUndoable(true);
        _modelToSave.requestChange(change);
        _source.setTitle(_xmlModel.getModelName());
        try {
          _source.updateDBModelHistory(_xmlModel.getModelName(),false);
        }
 catch (        IOException e) {
        }
      }
 catch (      Exception e) {
        throw e;
      }
      ArrayList<String> openedParents=null;
      if (_parentValidateFrame != null) {
        openedParents=new ArrayList<String>();
        for (        String openedParentModelName : _parentValidateFrame._getOpenedParents()) {
          openedParents.add(openedParentModelName);
        }
      }
      _source.setModified(false);
      if (_parentValidateFrame != null) {
        _parentValidateFrame.dispose();
      }
      dispose();
      if (openedParents != null) {
        for (        String openedParentModelName : openedParents) {
          PtolemyEffigy parentModelEffigy=(PtolemyEffigy)_source.getConfiguration().getDirectory().getEffigy(openedParentModelName);
          parentModelEffigy.closeTableaux();
          parentModelEffigy.setContainer(null);
          PtolemyEffigy updatedParentModelEffigy=LoadManager.loadModel(openedParentModelName,_source.getConfiguration());
          if (updatedParentModelEffigy != null) {
            updatedParentModelEffigy.showTableaux();
          }
        }
      }
      if (_source.getConfiguration().getDirectory().getEffigy(_xmlModel.getModelName()) != null) {
        _source.getConfiguration().getDirectory().getEffigy(_xmlModel.getModelName()).showTableaux();
      }
    }
 else {
      JOptionPane.showMessageDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.INFORMATION_MESSAGE,null);
    }
  }
 catch (  DBConnectionException exception) {
    _resetValues();
    throw exception;
  }
catch (  DBExecutionException exception) {
    _resetValues();
    throw exception;
  }
catch (  IllegalArgumentException exception) {
    _resetValues();
    throw exception;
  }
catch (  ModelAlreadyExistException exception) {
    _resetValues();
    JOptionPane.showMessageDialog(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    _rollbackModel();
  }
}