Liferay社区版中的用户跟踪

Liferay社区版中的用户跟踪,liferay,liferay-6,Liferay,Liferay 6,就像我们在liferay中有一个内置的用户跟踪功能一样,我们在community edition中也有类似的功能 你能推荐任何具有用户跟踪功能的第三方开源工具或插件吗 在这个问题上帮助我 非常感谢。我最终实现了自己的代码。而不是使用liferay内置功能。 1.这是我的文件的Jsp代码 //Page Imports & taglibs <%@page import="com.liferay.portal.service.persistence.UserTracker

就像我们在liferay中有一个内置的用户跟踪功能一样,我们在community edition中也有类似的功能

你能推荐任何具有用户跟踪功能的第三方开源工具或插件吗

在这个问题上帮助我


非常感谢。

我最终实现了自己的代码。而不是使用liferay内置功能。 1.这是我的文件的Jsp代码

    //Page Imports & taglibs
    <%@page import="com.liferay.portal.service.persistence.UserTrackerPathUtil"%>
    <%@page import="com.liferay.portal.service.UserLocalServiceUtil"%>
    <%@page import="com.liferay.portal.service.UserTrackerPathLocalServiceUtil"%>
    <%@page import="com.liferay.portal.service.UserTrackerLocalServiceUtil"%>
    <%@page import="com.liferay.counter.service.CounterLocalServiceUtil" %>
    <%@page import="com.liferay.portal.util.PortalUtil" %>
    <%@page import="java.util.ArrayList"%>
    <%@page import="com.liferay.portal.model.UserTracker" %>
    <%@page import="com.liferay.portal.model.UserTrackerPath" %>
    <%@ taglib uri="http://liferay.com/tld/theme" prefix="theme"%>
    <%-- <%@include file="/html/demo/one.jsp" %> --%>

    <theme:defineObjects/>
    // Define theme object to get user and other basic information
    <%
    HttpSession http_session = request.getSession();
    //Get the current session variable.

     String id = http_session.getId();
    //Getting id of session
         String path = themeDisplay.getLayout().getFriendlyURL();
    //Getting path that will be stored in path field of UserTrackerPath table.
        System.out.println("***==> Current Url => "+ themeDisplay.getURLCurrent());
    //path = path.substring(path.lastIndexOf("/"));
    String localhostname = java.net.InetAddress.getLocalHost().getHostName();
        //Getting the localhost name of machine from which user is acccessing site
    String ipAddress  = java.net.InetAddress.getLocalHost().getHostAddress();
        //Getting ip address of machine, In case of if user is using an proxy env you may need some other efforts to get exact ip. 
       if(ipAddress == null)  
       {  
          ipAddress = request.getRemoteAddr();  
       }  
    try {
            UserTracker user_tracker =     (UserTracker)http_session.getAttribute("user_tracker");
    //Now when user session creates for first time then you need to add an entry in UserTracker table and all the rest entries for path traversal are need to be added at UserTrackerPath with new userTrackerPathId and userTrackerId as foreignkey.
            if(user_tracker == null) 
            {
                    UserTracker tracker = null;
                    ArrayList<UserTrackerPath> userTrackerPath = new ArrayList<UserTrackerPath>();
    //Create an Array List of UserTrackerPath needs to be added in method of addUserTracker by UserTrackerLocalServiceUtil
                    UserTrackerPath utp= null;
                    utp = UserTrackerPathLocalServiceUtil.createUserTrackerPath(CounterLocalServiceUtil.increment());

                    utp.setPath(path);
                    utp.setPathDate(new java.util.Date());
                    userTrackerPath.add(utp);
    //Add an entry to array list                
            tracker = UserTrackerLocalServiceUtil.addUserTracker(themeDisplay.getCompanyId(),
                            themeDisplay.getUserId(),
                            new java.util.Date(),
                            id,
                            ipAddress,
                            localhostname,
                            userAgent,
                            userTrackerPath);
    //UserTracker will be added to database
                    http_session.setAttribute("user_tracker",tracker);
       //Adds value to session to check that next time session is null or not, so that it can decide whether to execute code of if or else.
            }
            else
            {
    //If session is not null then you already have an entry in UserTracker and you need to keep path track in UserTarckerPath Table
                UserTrackerPath utp  = UserTrackerPathLocalServiceUtil.createUserTrackerPath(CounterLocalServiceUtil.increment());
                utp.setUserTrackerId(user_tracker.getUserTrackerId());
                utp.setPath(path);
                utp.setPathDate(new java.util.Date());
                utp =     UserTrackerPathLocalServiceUtil.updateUserTrackerPath(utp, true);
    //Update path 
            }

    }
    catch(Exception e)
    {
        e.printStackTrace();
    }

    %>
  • 完成后,将Jsp包含到您的主题
    portal normal.vm
    ,以便随时随地都可以访问它。查看一下 并且它将成功地将跟踪数据添加到表中。:)

  • 注:如果有任何替代方案,行政长官将很高兴收到您的建议。 谢谢:)

    session.tracker.persistence.enabled=true
    
    live.users.enabled=false
    
    session.tracker.ignore.paths=\/portal/render_portlet,\/document_library/get_file