Program: 155352
Project: 155352
Buggy source:
@SuppressWarnings("String_Node_Str") public String savePost(Map<String,ArrayList<String>> parameters){
  IWContext iwc=CoreUtil.getIWContext();
  if (!iwc.isLoggedOn()) {
    String errorMsg=this.getResourceBundle().getLocalizedString("String_Node_Str","String_Node_Str");
    return errorMsg;
  }
  String errorMsg=this.getResourceBundle().getLocalizedString("String_Node_Str","String_Node_Str");
  User currentUser=iwc.getCurrentUser();
  UserApplicationEngine userApplicationEngine=this.getUserApplicationEngine();
  UserDataBean userInfo=userApplicationEngine.getUserInfo(currentUser);
  int creatorId=userInfo.getUserId();
  ArrayList<String> userReceiversIds=parameters.get(PostBusiness.ParameterNames.RECEIVERS_PARAMETER_NAME);
  int usersReceiversAmmount=0;
  Collection<Integer> usersReceivers=null;
  boolean areUserReceivers=!ListUtil.isEmpty(userReceiversIds);
  if (areUserReceivers) {
    usersReceiversAmmount=userReceiversIds.size();
    usersReceivers=new ArrayList<Integer>(usersReceiversAmmount);
    for (    String receiver : userReceiversIds) {
      usersReceivers.add(Integer.valueOf(receiver));
    }
  }
  ArrayList<String> groupsReceiversIds=parameters.get(PostBusiness.ParameterNames.GROUP_RECEIVERS_PARAMETER_NAME);
  Collection<Integer> groupsReceivers=new ArrayList<Integer>();
  ;
  if (!ListUtil.isEmpty(groupsReceiversIds)) {
    for (    String receiver : groupsReceiversIds) {
      groupsReceivers.add(Integer.valueOf(receiver));
    }
  }
  if (areUserReceivers) {
    String msgType=parameters.get(PostBusiness.ParameterNames.MESSAGE_TYPE).get(0);
    if (msgType.equals(PostBusiness.ParameterNames.PUBLIC_MESSAGE)) {
      for (      Integer userId : usersReceivers) {
        Collection<Group> userGroups=null;
        try {
          userGroups=this.getUserBusiness().getUserGroups(userId);
        }
 catch (        RemoteException e) {
          this.getLogger().log(Level.WARNING,"String_Node_Str",e);
          return errorMsg;
        }
        if (!ListUtil.isEmpty(userGroups)) {
          for (          Group group : userGroups) {
            groupsReceivers.add(Integer.valueOf(group.getId()));
          }
        }
        groupsReceivers.add(userId);
      }
    }
  }
  ArrayList<String> postToAllUserGroups=parameters.get(PostBusiness.ParameterNames.POST_TO_ALL_USER_GROUPS);
  if (!ListUtil.isEmpty(postToAllUserGroups)) {
    Collection<Group> userGroups=null;
    try {
      userGroups=this.getUserBusiness().getUserGroups(currentUser);
    }
 catch (    RemoteException e) {
      this.getLogger().log(Level.WARNING,"String_Node_Str",e);
      return errorMsg;
    }
    if (!ListUtil.isEmpty(userGroups)) {
      for (      Group group : userGroups) {
        groupsReceivers.add(Integer.valueOf(group.getId()));
      }
    }
  }
  if ((usersReceivers == null) && (ListUtil.isEmpty(groupsReceivers))) {
    return iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
  }
  PostItemBean post=new PostItemBean();
  String body=CoreConstants.EMPTY;
  if (parameters.containsKey(PostBusiness.ParameterNames.BODY_PARAMETER_NAME)) {
    body=parameters.get(PostBusiness.ParameterNames.BODY_PARAMETER_NAME).get(0);
    post.setBody(body);
  }
  if (StringUtil.isEmpty(body)) {
    return iwrb.getLocalizedString("String_Node_Str","String_Node_Str") + CoreConstants.COLON + iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
  }
  if (parameters.containsKey(PostBusiness.ParameterNames.POST_TITLE_PARAMETER)) {
    String parameter=parameters.get(PostBusiness.ParameterNames.POST_TITLE_PARAMETER).get(0);
    post.setHeadline(parameter);
  }
  post.setCreatedByUserId(creatorId);
  String name=userInfo.getName();
  post.setAuthor(name);
  ArrayList<String> attachments=parameters.get(PostBusiness.ParameterNames.POST_ATTACHMENTS_PARAMETER_NAME);
  if (!ListUtil.isEmpty(attachments)) {
    post.setAttachment(attachments);
  }
  String resourcePath=post.getResourcePath();
  StringBuilder errors=null;
  boolean postupdated=false;
  boolean privateSaved=true;
  if (!ListUtil.isEmpty(usersReceivers)) {
    privateSaved=postDao.updatePost(resourcePath,usersReceivers,creatorId);
    if (privateSaved) {
      postupdated=true;
      sendMails(userInfo.getEmail(),usersReceivers,body,post.getAttachments());
      ArrayList<Integer> accessUsers=new ArrayList<Integer>(usersReceivers.size() + 1);
      accessUsers.add(creatorId);
      setAccessRights(resourcePath,iwc,accessUsers);
    }
 else {
      errors=new StringBuilder("String_Node_Str").append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str")).append("String_Node_Str").append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str"));
    }
  }
  boolean groupSaved=true;
  if (!ListUtil.isEmpty(groupsReceivers)) {
    groupSaved=postDao.updatePost(resourcePath,groupsReceivers,PostEntity.PUBLIC,creatorId);
    if (groupSaved) {
      setAccessRights(resourcePath,iwc,groupsReceivers);
      postupdated=true;
    }
 else {
      if (errors == null) {
        errors=new StringBuilder("String_Node_Str").append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str")).append(CoreConstants.COLON);
      }
      errors.append(CoreConstants.NEWLINE).append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str"));
    }
  }
  if (postupdated) {
    post.store();
    String successMsg=iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
    String returnMsg=errors == null ? successMsg : successMsg + errors.toString();
    ScriptCaller scriptCaller=new ScriptCaller(WebContextFactory.get(),PostContentViewer.POST_LOAD_SCRIPT,true);
    scriptCaller.run();
    return returnMsg;
  }
 else {
    return errorMsg;
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public String savePost(Map<String,List<String>> parameters){
  IWResourceBundle iwrb=getResourceBundle(getBundle(SocialConstants.IW_BUNDLE_IDENTIFIER));
  IWContext iwc=CoreUtil.getIWContext();
  if (!iwc.isLoggedOn()) {
    String errorMsg=iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
    return errorMsg;
  }
  String errorMsg=iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
  User currentUser=iwc.getCurrentUser();
  UserApplicationEngine userApplicationEngine=this.getUserApplicationEngine();
  UserDataBean userInfo=userApplicationEngine.getUserInfo(currentUser);
  int creatorId=userInfo.getUserId();
  List<String> userReceiversIds=parameters.get(PostBusiness.ParameterNames.RECEIVERS_PARAMETER_NAME);
  int usersReceiversAmmount=0;
  Collection<Integer> usersReceivers=null;
  boolean areUserReceivers=!ListUtil.isEmpty(userReceiversIds);
  if (areUserReceivers) {
    usersReceiversAmmount=userReceiversIds.size();
    usersReceivers=new ArrayList<Integer>(usersReceiversAmmount);
    for (    String receiver : userReceiversIds) {
      usersReceivers.add(Integer.valueOf(receiver));
    }
  }
  List<String> groupsReceiversIds=parameters.get(PostBusiness.ParameterNames.GROUP_RECEIVERS_PARAMETER_NAME);
  Collection<Integer> groupsReceivers=new ArrayList<Integer>();
  if (!ListUtil.isEmpty(groupsReceiversIds)) {
    for (    String receiver : groupsReceiversIds) {
      groupsReceivers.add(Integer.valueOf(receiver));
    }
  }
  if (areUserReceivers) {
    String msgType=parameters.get(PostBusiness.ParameterNames.MESSAGE_TYPE).get(0);
    if (msgType.equals(PostBusiness.ParameterNames.PUBLIC_MESSAGE)) {
      for (      Integer userId : usersReceivers) {
        Collection<Group> userGroups=null;
        try {
          userGroups=this.getUserBusiness().getUserGroups(userId);
        }
 catch (        RemoteException e) {
          this.getLogger().log(Level.WARNING,"String_Node_Str",e);
          return errorMsg;
        }
        if (!ListUtil.isEmpty(userGroups)) {
          for (          Group group : userGroups) {
            groupsReceivers.add(Integer.valueOf(group.getId()));
          }
        }
        groupsReceivers.add(userId);
      }
    }
  }
  List<String> postToAllUserGroups=parameters.get(PostBusiness.ParameterNames.POST_TO_ALL_USER_GROUPS);
  if (!ListUtil.isEmpty(postToAllUserGroups)) {
    Collection<Group> userGroups=null;
    try {
      userGroups=this.getUserBusiness().getUserGroups(currentUser);
    }
 catch (    RemoteException e) {
      this.getLogger().log(Level.WARNING,"String_Node_Str",e);
      return errorMsg;
    }
    if (!ListUtil.isEmpty(userGroups)) {
      for (      Group group : userGroups) {
        groupsReceivers.add(Integer.valueOf(group.getId()));
      }
    }
  }
  if ((usersReceivers == null) && (ListUtil.isEmpty(groupsReceivers))) {
    return iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
  }
  PostItemBean post=new PostItemBean();
  String body=CoreConstants.EMPTY;
  if (parameters.containsKey(PostBusiness.ParameterNames.BODY_PARAMETER_NAME)) {
    body=parameters.get(PostBusiness.ParameterNames.BODY_PARAMETER_NAME).get(0);
    post.setBody(body);
  }
  if (StringUtil.isEmpty(body)) {
    return iwrb.getLocalizedString("String_Node_Str","String_Node_Str") + CoreConstants.COLON + iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
  }
  if (parameters.containsKey(PostBusiness.ParameterNames.POST_TITLE_PARAMETER)) {
    String parameter=parameters.get(PostBusiness.ParameterNames.POST_TITLE_PARAMETER).get(0);
    post.setHeadline(parameter);
  }
  post.setCreatedByUserId(creatorId);
  String name=userInfo.getName();
  post.setAuthor(name);
  List<String> attachments=parameters.get(PostBusiness.ParameterNames.POST_ATTACHMENTS_PARAMETER_NAME);
  if (!ListUtil.isEmpty(attachments)) {
    post.setAttachment(attachments);
  }
  String resourcePath=post.getResourcePath();
  StringBuilder errors=null;
  boolean postupdated=false;
  boolean privateSaved=true;
  if (!ListUtil.isEmpty(usersReceivers)) {
    privateSaved=postDao.updatePost(resourcePath,usersReceivers,creatorId);
    if (privateSaved) {
      postupdated=true;
      String title=post.getHeadline();
      if (StringUtil.isEmpty(title))       title=getResourceBundle(getBundle(SocialConstants.IW_BUNDLE_IDENTIFIER)).getLocalizedString("String_Node_Str","String_Node_Str") + iwc.getDomain().getName();
      sendMails(userInfo.getEmail(),usersReceivers,title,body,post.getAttachments());
      List<Integer> accessUsers=new ArrayList<Integer>(usersReceivers.size() + 1);
      accessUsers.add(creatorId);
      setAccessRights(resourcePath,iwc,accessUsers);
    }
 else {
      errors=new StringBuilder("String_Node_Str").append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str")).append("String_Node_Str").append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str"));
    }
  }
  boolean groupSaved=true;
  if (!ListUtil.isEmpty(groupsReceivers)) {
    groupSaved=postDao.updatePost(resourcePath,groupsReceivers,PostEntity.PUBLIC,creatorId);
    if (groupSaved) {
      setAccessRights(resourcePath,iwc,groupsReceivers);
      postupdated=true;
    }
 else {
      if (errors == null) {
        errors=new StringBuilder("String_Node_Str").append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str")).append(CoreConstants.COLON);
      }
      errors.append(CoreConstants.NEWLINE).append(iwrb.getLocalizedString("String_Node_Str","String_Node_Str"));
    }
  }
  if (postupdated) {
    post.store();
    String successMsg=iwrb.getLocalizedString("String_Node_Str","String_Node_Str");
    String returnMsg=errors == null ? successMsg : successMsg + errors.toString();
    ScriptCaller scriptCaller=new ScriptCaller(WebContextFactory.get(),PostContentViewer.POST_LOAD_SCRIPT,true);
    scriptCaller.run();
    return returnMsg;
  }
 else {
    return errorMsg;
  }
}