Program: 106014
Project: 106014
Buggy source:
private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd){
  Long id=cmd.getId();
  String name=cmd.getTemplateName();
  String displayText=cmd.getDisplayText();
  String format=cmd.getFormat();
  Long guestOSId=cmd.getOsTypeId();
  Boolean passwordEnabled=cmd.isPasswordEnabled();
  Boolean isDynamicallyScalable=cmd.isDynamicallyScalable();
  Boolean isRoutingTemplate=cmd.isRoutingType();
  Boolean bootable=cmd.isBootable();
  Integer sortKey=cmd.getSortKey();
  Account account=CallContext.current().getCallingAccount();
  VMTemplateVO template=_tmpltDao.findById(id);
  if (template == null || template.getRemoved() != null) {
    InvalidParameterValueException ex=new InvalidParameterValueException("String_Node_Str");
    ex.addProxyObject(String.valueOf(id),"String_Node_Str");
    throw ex;
  }
  if (id == Long.valueOf(1)) {
    InvalidParameterValueException ex=new InvalidParameterValueException("String_Node_Str");
    ex.addProxyObject(String.valueOf(id),"String_Node_Str");
    throw ex;
  }
  _accountMgr.checkAccess(account,AccessType.ModifyEntry,true,template);
  if (cmd.isRoutingType() != null) {
    if (!_accountService.isRootAdmin(account.getType())) {
      throw new PermissionDeniedException("String_Node_Str");
    }
  }
  boolean updateNeeded=!(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null && bootable == null && sortKey == null && isDynamicallyScalable == null && isRoutingTemplate == null);
  if (!updateNeeded) {
    return template;
  }
  template=_tmpltDao.createForUpdate(id);
  if (name != null) {
    template.setName(name);
  }
  if (displayText != null) {
    template.setDisplayText(displayText);
  }
  if (sortKey != null) {
    template.setSortKey(sortKey);
  }
  ImageFormat imageFormat=null;
  if (format != null) {
    try {
      imageFormat=ImageFormat.valueOf(format.toUpperCase());
    }
 catch (    IllegalArgumentException e) {
      throw new InvalidParameterValueException("String_Node_Str" + format + "String_Node_Str"+ EnumUtils.listValues(ImageFormat.values()));
    }
    template.setFormat(imageFormat);
  }
  if (guestOSId != null) {
    GuestOSVO guestOS=_guestOSDao.findById(guestOSId);
    if (guestOS == null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
 else {
      template.setGuestOSId(guestOSId);
    }
  }
  if (passwordEnabled != null) {
    template.setEnablePassword(passwordEnabled);
  }
  if (bootable != null) {
    template.setBootable(bootable);
  }
  if (isDynamicallyScalable != null) {
    template.setDynamicallyScalable(isDynamicallyScalable);
  }
  if (isRoutingTemplate != null) {
    if (isRoutingTemplate) {
      template.setTemplateType(TemplateType.ROUTING);
    }
 else {
      template.setTemplateType(TemplateType.USER);
    }
  }
  _tmpltDao.update(id,template);
  return _tmpltDao.findById(id);
}

Fixed version (ground truth):
private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd){
  Long id=cmd.getId();
  String name=cmd.getTemplateName();
  String displayText=cmd.getDisplayText();
  String format=cmd.getFormat();
  Long guestOSId=cmd.getOsTypeId();
  Boolean passwordEnabled=cmd.isPasswordEnabled();
  Boolean isDynamicallyScalable=cmd.isDynamicallyScalable();
  Boolean isRoutingTemplate=cmd.isRoutingType();
  Boolean bootable=cmd.isBootable();
  Integer sortKey=cmd.getSortKey();
  Account account=CallContext.current().getCallingAccount();
  VMTemplateVO template=_tmpltDao.findById(id);
  if (template == null || template.getRemoved() != null) {
    InvalidParameterValueException ex=new InvalidParameterValueException("String_Node_Str");
    ex.addProxyObject(String.valueOf(id),"String_Node_Str");
    throw ex;
  }
  if (Long.valueOf(1).equals(id)) {
    InvalidParameterValueException ex=new InvalidParameterValueException("String_Node_Str");
    ex.addProxyObject(String.valueOf(id),"String_Node_Str");
    throw ex;
  }
  _accountMgr.checkAccess(account,AccessType.ModifyEntry,true,template);
  if (cmd.isRoutingType() != null) {
    if (!_accountService.isRootAdmin(account.getType())) {
      throw new PermissionDeniedException("String_Node_Str");
    }
  }
  boolean updateNeeded=!(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null && bootable == null && sortKey == null && isDynamicallyScalable == null && isRoutingTemplate == null);
  if (!updateNeeded) {
    return template;
  }
  template=_tmpltDao.createForUpdate(id);
  if (name != null) {
    template.setName(name);
  }
  if (displayText != null) {
    template.setDisplayText(displayText);
  }
  if (sortKey != null) {
    template.setSortKey(sortKey);
  }
  ImageFormat imageFormat=null;
  if (format != null) {
    try {
      imageFormat=ImageFormat.valueOf(format.toUpperCase());
    }
 catch (    IllegalArgumentException e) {
      throw new InvalidParameterValueException("String_Node_Str" + format + "String_Node_Str"+ EnumUtils.listValues(ImageFormat.values()));
    }
    template.setFormat(imageFormat);
  }
  if (guestOSId != null) {
    GuestOSVO guestOS=_guestOSDao.findById(guestOSId);
    if (guestOS == null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
 else {
      template.setGuestOSId(guestOSId);
    }
  }
  if (passwordEnabled != null) {
    template.setEnablePassword(passwordEnabled);
  }
  if (bootable != null) {
    template.setBootable(bootable);
  }
  if (isDynamicallyScalable != null) {
    template.setDynamicallyScalable(isDynamicallyScalable);
  }
  if (isRoutingTemplate != null) {
    if (isRoutingTemplate) {
      template.setTemplateType(TemplateType.ROUTING);
    }
 else {
      template.setTemplateType(TemplateType.USER);
    }
  }
  _tmpltDao.update(id,template);
  return _tmpltDao.findById(id);
}