public String getGroupDetails() {
   GroupDAO grp = new GroupDAOImpl();
   System.out.println("group_id     " + group_id);
   setGroupDetail(null);
   HttpSession session = ServletActionContext.getRequest().getSession(false);
   User u = (User) session.getAttribute("user");
   if (!(group_id == null)) {
     setGroupDetail(grp.getGroupDetails(group_id, Integer.parseInt(u.getUserId())));
     System.out.println("group id" + groupDetail.getGroup_id());
     System.out.println("group name" + groupDetail.getGroup_name());
   }
   NewsFeedAction n = new NewsFeedAction();
   setGrpList(grp.getAllGroups(Integer.parseInt(u.getUserId())));
   setFeedList(n.getGroupNewsFeed(group_id));
   int i = 0;
   while (i < grpList.size()) {
     System.out.println(grpList.get(i).getGroup_id());
     i++;
   }
   i = 0;
   System.out.println("post..................");
   while (i < feedList.size()) {
     System.out.println(feedList.get(i).getPostId());
     i++;
   }
   HttpServletRequest request = ServletActionContext.getRequest();
   request.setAttribute("groupDetail", groupDetail);
   request.setAttribute("grpList", grpList);
   request.setAttribute("groupDetail", groupDetail);
   return "success";
 }
  public String uploadImage() {

    System.out.println("1111" + albumId);
    HttpSession session = ServletActionContext.getRequest().getSession(false);
    User user = (User) session.getAttribute("user");
    System.out.println("UserPostAction Photo===>" + picFileName);
    System.out.println("UserPostAction Photo===>" + picContentType);
    System.out.println("UserPostAction Photo===>" + pic);
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date dateobj = new Date();
    UserImageUploadDAO up = new UserImageUploadDAOImpl();
    String destpath = "";
    String imageExtension = "";
    if (picContentType != null && picContentType.contains("jpeg")) {
      imageExtension = ".jpeg";
    } else if (picContentType != null && picContentType.contains("png")) {
      imageExtension = ".png";
    } else if (picContentType != null && picContentType.contains("gif")) {
      imageExtension = ".gif";
    } else if (picContentType != null && picContentType.contains("jpg")) {
      imageExtension = ".jpg";
    }
    if (picFileName != null) {
      Random randomGenerator = new Random();
      Integer randomInt = randomGenerator.nextInt(1000000);
      picFileName = randomInt.toString() + imageExtension;
      System.out.println("UserPostAction Photo===>" + picFileName);

      String name = up.getAlbumName(getAlbumId());
      destpath = StringUtils.photoPath + File.separator + user.getUserId() + "_" + name;
      System.out.println("Server path:" + destpath);
      File destFile = new File(destpath, picFileName);
      try {
        FileUtils.copyFile(pic, destFile);
      } catch (IOException e) {
        System.out.println("error occurred");
        e.printStackTrace();
        return ERROR;
      }
    }
    // if(friendId==null || friendId=="")
    // {
    user_id = user.getUserId();
    setUser_id(user_id);
    up.uploadImage(df.format(dateobj).toString(), albumId, picFileName);
    Integer aid = albumId;
    HttpServletRequest request = ServletActionContext.getRequest();
    request.setAttribute("albumId", aid.toString());
    request.setAttribute("imageList", imageList);

    // }
    // else{
    /*NewsFeedDAOImpl nfd=new NewsFeedDAOImpl();
    String userName=nfd.getFullUserName(friendId);

    up.postOnWall(postDesc, user.getUserId(),friendId,  df.format(dateobj).toString(),userName+" status Update","timeline",youtubeLink,picFileName);*/
    // }
    addActionMessage("Content has been posted successfully.");
    return "success";
  }
 public String joinGroupAgain() {
   HttpSession session = ServletActionContext.getRequest().getSession(false);
   User u = (User) session.getAttribute("user");
   GroupDAO grp = new GroupDAOImpl();
   int grp_id = Integer.parseInt(group_id);
   grp.joinGroupAgain(Integer.parseInt(u.getUserId()), grp_id);
   return "success";
 }
 public String leaveGroup() throws Exception {
   HttpSession session = ServletActionContext.getRequest().getSession(false);
   User u = (User) session.getAttribute("user");
   GroupDAO grp = new GroupDAOImpl();
   int grp_id = Integer.parseInt(group_id);
   grp.leaveGroup(Integer.parseInt(u.getUserId()), grp_id);
   System.out.println("coming back" + grp_id);
   return "success";
 }
 public String getFriends() {
   HttpSession session = ServletActionContext.getRequest().getSession(false);
   User u = (User) session.getAttribute("user");
   GroupDAO grp = new GroupDAOImpl();
   setGrpUserList(grp.getUserForGroup(Integer.parseInt(u.getUserId())));
   /*for(int i=0;i<grpUserList.size();i++)
   {
   	System.out.println(grpUserList.get(i).getFirst_name());
   }*/
   return "success";
 }
 public String searchToAddMember() {
   System.out.println("search to add member  group_id" + group_id);
   HttpSession session = ServletActionContext.getRequest().getSession(false);
   User u = (User) session.getAttribute("user");
   GroupDAO grp = new GroupDAOImpl();
   setGrpAddUserList(grp.getUserToAddForGroup(Integer.parseInt(u.getUserId()), group_id));
   System.out.println("friends");
   for (int i = 0; i < grpAddUserList.size(); i++) {
     System.out.println(grpAddUserList.get(i).getFirstName());
   }
   return "success";
 }
 public String execute() throws NamingException, SQLException {
   HttpSession session = ServletActionContext.getRequest().getSession(false);
   User u = (User) session.getAttribute("user");
   GroupDAO grp = new GroupDAOImpl();
   System.out.println("icon " + icon);
   setGroup_id(
       String.valueOf(
           grp.insertGroupDetails(Integer.parseInt(u.getUserId()), grpName, grpMembers, icon)));
   GroupDAO grp1 = new GroupDAOImpl();
   setGrpList(grp1.getAllGroups(Integer.parseInt(u.getUserId())));
   System.out.println("after creation group id" + group_id);
   return "success";
 }
 public String getAllGroups() {
   System.out.println("groups");
   HttpSession session = ServletActionContext.getRequest().getSession(false);
   User u = (User) session.getAttribute("user");
   GroupDAO grp = new GroupDAOImpl();
   setGrpList(grp.getAllGroups(Integer.parseInt(u.getUserId())));
   int i = 0;
   while (i < grpList.size()) {
     System.out.println(grpList.get(i).getGroup_id());
     i++;
   }
   // HttpServletRequest request=ServletActionContext.getRequest();
   // request.setAttribute("grpList",grpList);
   return "success";
 }
  public void uploadProfileImage() throws IOException {

    System.out.println("1111" + albumId);
    HttpSession session = ServletActionContext.getRequest().getSession(false);
    User user = (User) session.getAttribute("user");
    System.out.println("UserPostAction Photo===>" + picFileName);
    System.out.println("UserPostAction Photo===>" + picContentType);
    System.out.println("UserPostAction Photo===>" + pic);
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date dateobj = new Date();
    UserImageUploadDAO up = new UserImageUploadDAOImpl();

    int albumid = up.getAlbumId("profilePicture", Integer.parseInt(user.getUserId()));

    String destpath = "";
    String imageExtension = "";
    if (picContentType != null && picContentType.contains("jpeg")) {
      imageExtension = ".jpeg";
    } else if (picContentType != null && picContentType.contains("png")) {
      imageExtension = ".png";
    } else if (picContentType != null && picContentType.contains("gif")) {
      imageExtension = ".gif";
    } else if (picContentType != null && picContentType.contains("jpg")) {
      imageExtension = ".jpg";
    }
    if (picFileName != null) {
      Random randomGenerator = new Random();
      Integer randomInt = randomGenerator.nextInt(1000000);
      picFileName = randomInt.toString() + imageExtension;

      System.out.println("UserPostAction Photo===>" + picFileName);

      String name = "profilePicture";
      destpath = StringUtils.photoPath + File.separator + user.getUserId() + "_" + name;
      System.out.println("Server path:" + destpath);
      File destFile = new File(destpath, picFileName);
      try {
        FileUtils.copyFile(pic, destFile);
      } catch (IOException e) {
        System.out.println("error occurred");
        e.printStackTrace();
        // return ERROR;
      }
    }
    // if(friendId==null || friendId=="")
    // {
    up.uploadImage(df.format(dateobj).toString(), albumid, picFileName);
    boolean j = up.updateProfilephoto(user.getUserId(), picFileName);
    LoginDAO ld = new LoginDAOimpl();
    String picPath = StringUtils.RetrivePhotoPath;
    System.out.println("hello1111" + user.getPassword());
    user.setProfilePic(
        picPath + "/" + user.getUserId() + "_" + "profilePicture" + "/" + picFileName);
    // User user1=ld.isValidUser(user.getUserId(),user.getPassword());

    // session.removeAttribute("user");
    // session.setAttribute("user",user);
    // session.setAttribute("login", true);

    // System.out.println("helloooooooooooooo"+user1.getUserId()+user1.getCoverPic());

    Integer aid = albumid;

    HttpServletRequest request = ServletActionContext.getRequest();
    request.setAttribute("albumId", aid.toString());

    // request.setAttribute("imageList", imageList);

    // }
    // else{
    /*NewsFeedDAOImpl nfd=new NewsFeedDAOImpl();
    String userName=nfd.getFullUserName(friendId);

    up.postOnWall(postDesc, user.getUserId(),friendId,  df.format(dateobj).toString(),userName+" status Update","timeline",youtubeLink,picFileName);*/
    // }
    // addActionMessage("Content has been posted successfully.");
    HttpServletResponse response = ServletActionContext.getResponse();
    response.sendRedirect(
        StringUtils.hostname + "/FacebookDemo/userNewsFeedAction?user_id=" + user.getUserId());
    /*if(j)
    return "success";
    else
    	return ERROR;*/
  }