Package org.apache.olio.webapp.util

Examples of org.apache.olio.webapp.util.UserBean


                    actionType = AT_READ_PARAMVALUE;
                }
            }
        } else {
            ModelFacade modelFacade = (ModelFacade) context.getAttribute(MF_KEY);
            UserBean userBean = (UserBean) request.getSession().getAttribute("userBean");
            Person loggedInPerson = userBean.getLoggedInPerson();
            if (loggedInPerson == null) {
                userBean.setDisplayMessage("Log in to manage invitations");
                return null;
            }
            String requestorUsername = request.getParameter(USER_NAME_PARAM);
            String friendUsername = request.getParameter(FRIEND_PARAM);
View Full Code Here


                    event = getEvent(modelFacade, htUpload);
                } else {
                */
                event = createEvent(request, modelFacade, htUpload);
                    if (request.getSession(true).getAttribute("userBean") != null) {
                        UserBean uBean = (UserBean) request.getSession(true).getAttribute("userBean");
                        uBean.setDisplayMessage("Event added successfully");
                        logger.log(Level.FINER, "A new Event has been added and persisted");
                    }
                //}

                String id = String.valueOf(event.getSocialEventID());
View Full Code Here

            response.getWriter().write(s);
            response.flushBuffer();

            // Before we return, set the userBean's upcomingEvents as dirty since
            // the event add/deleted may be in the list
            UserBean uBean = (UserBean) request.getSession(true).getAttribute("userBean");
            if (uBean != null) {
                uBean.setUpcomingEventsDirty(true);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
View Full Code Here

        }
    }
   
    public Person getLoggedInPerson(HttpServletRequest request) {
        HttpSession session=request.getSession(true);
        UserBean uBean = (UserBean) session.getAttribute ("userBean");
        if (uBean != null)
            return uBean.getLoggedInPerson();
        return null;
    }
View Full Code Here

        String returnURL = null;
        String path = request.getPathInfo();
        if (path != null && path.equals("/login")) {
            String fUrl = "/site.jsp";
            String user_name = request.getParameter("user_name");
            UserBean userBean = (UserBean) request.getSession(true).getAttribute("userBean");
            if (userBean == null) {
                userBean = new UserBean();
                userBean.setModelFacade(mf);
                request.getSession().setAttribute("userBean", userBean);
            }
            if (user_name != null && password != null) {
                Person p = mf.login(user_name, password);
                if (p != null) {
                    userBean.setDisplayMessage("Successfully logged in");
                    userBean.setLoggedInPerson(p);
                }
            } else {
                userBean.setDisplayMessage("Log in failed for user_name = " + user_name +
                        " password = " + password);
            }
            fUrl = userBean.getForwardingUrl();
            if (fUrl == null) {
                fUrl = request.getContextPath() + "/event/list";
            } else {
                fUrl = request.getContextPath() + fUrl;
            // We will do a redirect rather than a forward so that refreshing the browser
            // does not cause issues
            }
            response.sendRedirect(fUrl);
            return null;
        }

        if (actionType != null) {
            if (actionType.equalsIgnoreCase("display_person")) {
                String username = request.getParameter("user_name");
                Person displayUser = mf.findPerson(username);
                if (displayUser != null) {
                    //get posted events
                    Collection<SocialEvent> userEvents = mf.getPostedEvents(displayUser);
                    request.setAttribute("userEvents", userEvents);
                    //logger.finer("the size of the incoming friendships is "+ displayUser.getIncomingInvitations().size());
                    request.setAttribute("displayPerson", displayUser);
                    returnURL = "/site.jsp?page=personContent.jsp";
                }
            } else if (actionType.equalsIgnoreCase("display_friends")) {
                String username = request.getParameter("user_name");
                Person displayUser = mf.findPerson(username);
                request.setAttribute("displayPerson", displayUser);
                //addition here for pages
                 int index = WebappUtil.getIntProperty(request.getParameter("index"));
                
            List<Person> list = (List)displayUser.getFriends();
               
            if (list != null) {
                List friendList = WebappUtil.getPagedList(list, index);               
                request.setAttribute("numPages", WebappUtil.getNumPages(list));
                request.setAttribute("pageUrl", request.getContextPath() + "/person?user_name="+username+"&page=friends.jsp&actionType=display_friends");
                request.setAttribute("itemList", friendList);
                request.setAttribute("index", index);
            }
         
                returnURL = "/site.jsp?page=friends.jsp";

            } else if (actionType.equalsIgnoreCase("add_person")) {
                //should not go here - we are doing this via PersonRestAction
                //this.addPerson(request, response);
                returnURL = "/site.jsp?page=addPerson.jsp";

            } else if (actionType.equalsIgnoreCase("edit_person")) {
                request.setAttribute("isEditable", Boolean.TRUE);
                returnURL = "/site.jsp?page=addPerson.jsp";
            } else if (actionType.equalsIgnoreCase("display_myPostedEvents")) {
                String username = request.getParameter("user_name");
                Person displayUser = mf.findPerson(username);
                if (displayUser != null) {
                    //get posted events
                    Collection<SocialEvent> myPostedEvents = mf.getPostedEvents(displayUser);
                    logger.finer("the size of myPostedEvents is " + myPostedEvents.size());
                    request.setAttribute("myPostedEvents", myPostedEvents);
                }
                returnURL = "/site.jsp?page=eventsPostedByUser.jsp";
            } else if (actionType.equalsIgnoreCase("Search")) {
                String query = request.getParameter("query");
                //need to specify max results
                Collection<Person> searchResults = mf.searchUsers(query, 0);
                //have all of the users - now get the friends
                Person requestor = mf.findPerson(userName);
                UserBean userBean = (UserBean) request.getSession().getAttribute("userBean");
                Person loggedInPerson = userBean.getLoggedInPerson();
                String loggedInPersonUsername = loggedInPerson.getUserName();
                Collection<Person> friends = loggedInPerson.getFriends();
                logger.finer("the size of the loggedInPerson's friends  " + loggedInPerson.getUserName() + " is " + friends.size());
                //invitations
                Collection<Invitation> invites = loggedInPerson.getIncomingInvitations();
                logger.finer("the size of the invitations list is " + invites.size());

                //iterate through and remove the friends from the list
                //need to remove loggedInPerson too since you cannot have yourself as a friend
                Iterator<Person> it = searchResults.iterator();
                while (it.hasNext()) {
                    Person person = it.next();

                    Iterator<Person> friendIterator = friends.iterator();
                    Iterator<Invitation> invitationIter = invites.iterator();

                    while (friendIterator.hasNext()) {
                        String fUsername = friendIterator.next().getUserName();
                        if (fUsername.equalsIgnoreCase(person.getUserName()) || fUsername.equalsIgnoreCase(loggedInPerson.getUserName())) {
                            it.remove();
                        }
                    }
                    //determine whether they are received their invitation already
                    while (invitationIter.hasNext()) {
                        Invitation inv = invitationIter.next();
                        if (inv.getCandidate().getUserName().equalsIgnoreCase(person.getUserName())) {
                            person.setHasReceivedInvitation(true);
                        }
                    }
                }
                //logger.finer("after sorting, the size of the collection is " + searchResults.size());

                //not in session request.getSession().setAttribute("searchResults", searchResults);
                loggedInPerson.setNonFriendList(searchResults);


                if (searchResults != null) {
                    request.setAttribute("searchResults", searchResults);
                }
                returnURL = "/site.jsp?page=searchUsers.jsp";
            } else if (actionType.equalsIgnoreCase("addDeleteFriend")) {
                String query = request.getParameter("query");
                String friendUsername = request.getParameter("friend");
                //this is returning null - SecurityHandler.getInstance().getLoggedInPerson(request);
                UserBean userBean = (UserBean) request.getSession().getAttribute("userBean");
                Person loggedInPerson = userBean.getLoggedInPerson();
                Collection<Person> previousSearchResults = loggedInPerson.getNonFriendList();
                ///add or delete
                String flag = request.getParameter("flag");
                logger.finer("*** flag is " + flag);
                if (flag.equals("add")) {
View Full Code Here

TOP

Related Classes of org.apache.olio.webapp.util.UserBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.