Program: 105334
Project: 105334
Buggy source:
public UploadEntity createUploadEntity(String uuid,String metadata,long contentLength){
  TemplateOrVolumePostUploadCommand cmd=getTemplateOrVolumePostUploadCmd(metadata);
  UploadEntity uploadEntity=null;
  if (cmd == null) {
    String errorMessage="String_Node_Str";
    updateStateMapWithError(uuid,errorMessage);
    throw new InvalidParameterValueException(errorMessage);
  }
 else {
    uuid=cmd.getEntityUUID();
    if (isOneTimePostUrlUsed(cmd)) {
      uploadEntity=uploadEntityStateMap.get(uuid);
      StringBuilder errorMessage=new StringBuilder("String_Node_Str");
      if (uploadEntity != null) {
        errorMessage.append("String_Node_Str").append(uploadEntity.getUploadState()).append("String_Node_Str");
      }
      throw new InvalidParameterValueException(errorMessage.toString());
    }
    int maxSizeInGB=Integer.valueOf(cmd.getMaxUploadSize());
    int contentLengthInGB=getSizeInGB(contentLength);
    if (contentLengthInGB > maxSizeInGB) {
      String errorMessage="String_Node_Str" + contentLengthInGB + "String_Node_Str"+ maxSizeInGB+ "String_Node_Str";
      updateStateMapWithError(uuid,errorMessage);
      throw new InvalidParameterValueException(errorMessage);
    }
    checkSecondaryStorageResourceLimit(cmd,contentLengthInGB);
    try {
      String absolutePath=cmd.getAbsolutePath();
      uploadEntity=new UploadEntity(uuid,cmd.getEntityId(),UploadEntity.Status.IN_PROGRESS,cmd.getName(),absolutePath);
      uploadEntity.setMetaDataPopulated(true);
      uploadEntity.setResourceType(UploadEntity.ResourceType.valueOf(cmd.getType()));
      uploadEntity.setFormat(Storage.ImageFormat.valueOf(cmd.getImageFormat()));
      uploadEntity.setTemplatePath(absolutePath);
      String dataStoreUrl=cmd.getDataTo();
      String installPathPrefix=this.getRootDir(dataStoreUrl) + File.separator + absolutePath;
      uploadEntity.setInstallPathPrefix(installPathPrefix);
      uploadEntity.setHvm(cmd.getRequiresHvm());
      uploadEntity.setChksum(cmd.getChecksum());
      uploadEntity.setMaxSizeInGB(maxSizeInGB);
      uploadEntity.setDescription(cmd.getDescription());
      uploadEntity.setContentLength(contentLength);
      if (!_storage.exists(installPathPrefix)) {
        _storage.mkdir(installPathPrefix);
      }
      uploadEntityStateMap.put(uuid,uploadEntity);
    }
 catch (    Exception e) {
      s_logger.error("String_Node_Str",e);
      updateStateMapWithError(uuid,e.getMessage());
    }
  }
  return uploadEntity;
}

Fixed version (ground truth):
public UploadEntity createUploadEntity(String uuid,String metadata,long contentLength){
  TemplateOrVolumePostUploadCommand cmd=getTemplateOrVolumePostUploadCmd(metadata);
  UploadEntity uploadEntity=null;
  if (cmd == null) {
    String errorMessage="String_Node_Str";
    updateStateMapWithError(uuid,errorMessage);
    throw new InvalidParameterValueException(errorMessage);
  }
 else {
    uuid=cmd.getEntityUUID();
    if (isOneTimePostUrlUsed(cmd)) {
      uploadEntity=uploadEntityStateMap.get(uuid);
      StringBuilder errorMessage=new StringBuilder("String_Node_Str");
      if (uploadEntity != null) {
        errorMessage.append("String_Node_Str").append(uploadEntity.getUploadState()).append("String_Node_Str");
      }
      throw new InvalidParameterValueException(errorMessage.toString());
    }
    int maxSizeInGB=Integer.parseInt(cmd.getMaxUploadSize());
    int contentLengthInGB=getSizeInGB(contentLength);
    if (contentLengthInGB > maxSizeInGB) {
      String errorMessage="String_Node_Str" + contentLengthInGB + "String_Node_Str"+ maxSizeInGB+ "String_Node_Str";
      updateStateMapWithError(uuid,errorMessage);
      throw new InvalidParameterValueException(errorMessage);
    }
    checkSecondaryStorageResourceLimit(cmd,contentLengthInGB);
    try {
      String absolutePath=cmd.getAbsolutePath();
      uploadEntity=new UploadEntity(uuid,cmd.getEntityId(),UploadEntity.Status.IN_PROGRESS,cmd.getName(),absolutePath);
      uploadEntity.setMetaDataPopulated(true);
      uploadEntity.setResourceType(UploadEntity.ResourceType.valueOf(cmd.getType()));
      uploadEntity.setFormat(Storage.ImageFormat.valueOf(cmd.getImageFormat()));
      uploadEntity.setTemplatePath(absolutePath);
      String dataStoreUrl=cmd.getDataTo();
      String installPathPrefix=this.getRootDir(dataStoreUrl) + File.separator + absolutePath;
      uploadEntity.setInstallPathPrefix(installPathPrefix);
      uploadEntity.setHvm(cmd.getRequiresHvm());
      uploadEntity.setChksum(cmd.getChecksum());
      uploadEntity.setMaxSizeInGB(maxSizeInGB);
      uploadEntity.setDescription(cmd.getDescription());
      uploadEntity.setContentLength(contentLength);
      if (!_storage.exists(installPathPrefix)) {
        _storage.mkdir(installPathPrefix);
      }
      uploadEntityStateMap.put(uuid,uploadEntity);
    }
 catch (    Exception e) {
      s_logger.error("String_Node_Str",e);
      updateStateMapWithError(uuid,e.getMessage());
    }
  }
  return uploadEntity;
}