Program: 76450
Project: 76450
Buggy source:
/** 
 * Inserts a level view to the given position. The position index is a 0-based integer.
 * @param levelHandle the cube level handle to insert
 * @param index the target position, 0-based integer
 * @return the level view handle that is generated and inserted to thisdimension view, null if OLAP level handle is used by another level view or insert operation fails
 * @throws SemanticException
 */
public LevelViewHandle insertLevel(LevelHandle levelHandle,int index) throws SemanticException {
  ExtendedItemHandle extendedItemHandle=CrosstabExtendedItemFactory.createLevelView(moduleHandle,levelHandle);
  if (extendedItemHandle == null)   return null;
  if (levelHandle != null) {
    if (!levelHandle.getContainer().getContainer().getQualifiedName().equals(getCubeDimensionName())) {
      logger.log(Level.WARNING,"String_Node_Str");
      return null;
    }
    if (getLevel(levelHandle.getQualifiedName()) != null) {
      logger.log(Level.SEVERE,MessageConstants.CROSSTAB_EXCEPTION_DUPLICATE_LEVEL,levelHandle.getQualifiedName());
      throw new CrosstabException(handle.getElement(),new String[]{levelHandle.getQualifiedName(),handle.getElement().getIdentifier()},MessageConstants.CROSSTAB_EXCEPTION_DUPLICATE_LEVEL);
    }
  }
  CommandStack stack=getCommandStack();
  stack.startTrans(null);
  LevelViewHandle levelView=null;
  try {
    getLevelsProperty().add(extendedItemHandle,index);
    if (levelHandle != null) {
      levelView=(LevelViewHandle)CrosstabUtil.getReportItem(extendedItemHandle,LEVEL_VIEW_EXTENSION_NAME);
      CrosstabReportItemHandle crosstab=getCrosstab();
      if (levelView != null && crosstab != null) {
        CrosstabUtil.adjustForLevelView(crosstab,levelView,getCubeDimensionName(),levelHandle.getQualifiedName(),getAxisType(),true);
      }
    }
  }
 catch (  SemanticException e) {
    stack.rollback();
    throw e;
  }
  stack.commit();
  return levelView;
}

Fixed version (ground truth):
/** 
 * Inserts a level view to the given position. The position index is a 0-based integer.
 * @param levelHandle the cube level handle to insert
 * @param index the target position, 0-based integer
 * @return the level view handle that is generated and inserted to thisdimension view, null if OLAP level handle is used by another level view or insert operation fails
 * @throws SemanticException
 */
public LevelViewHandle insertLevel(LevelHandle levelHandle,int index) throws SemanticException {
  ExtendedItemHandle extendedItemHandle=CrosstabExtendedItemFactory.createLevelView(moduleHandle,levelHandle);
  if (extendedItemHandle == null)   return null;
  if (levelHandle != null) {
    if (!levelHandle.getContainer().getContainer().getQualifiedName().equals(getCubeDimensionName())) {
      logger.log(Level.WARNING,"String_Node_Str");
      return null;
    }
    if (getLevel(levelHandle.getQualifiedName()) != null) {
      logger.log(Level.SEVERE,MessageConstants.CROSSTAB_EXCEPTION_DUPLICATE_LEVEL,levelHandle.getQualifiedName());
      throw new CrosstabException(handle.getElement(),new String[]{levelHandle.getQualifiedName(),handle.getElement().getIdentifier()},MessageConstants.CROSSTAB_EXCEPTION_DUPLICATE_LEVEL);
    }
  }
  CommandStack stack=getCommandStack();
  stack.startTrans(null);
  LevelViewHandle levelView=null;
  try {
    getLevelsProperty().add(extendedItemHandle,index);
    if (levelHandle != null) {
      levelView=(LevelViewHandle)CrosstabUtil.getReportItem(extendedItemHandle,LEVEL_VIEW_EXTENSION_NAME);
      CrosstabReportItemHandle crosstab=getCrosstab();
      if (levelView != null && crosstab != null) {
        CrosstabModelUtil.adjustForLevelView(this,levelView,true);
      }
    }
  }
 catch (  SemanticException e) {
    stack.rollback();
    throw e;
  }
  stack.commit();
  return levelView;
}