就像我们在 liferay 中有一个用户跟踪内置设施一样,我们在社区版中是否有任何具有此类功能的东西。
您能否推荐任何具有用户跟踪功能的第三方开源工具或插件。
帮我解决这个问题。
非常感谢。
我最终实现了自己的代码。而不是使用 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();
}
%>
所以现在去你的portal-ext.properties
并添加以下属性
session.tracker.persistence.enabled=true
live.users.enabled=false
session.tracker.ignore.paths=\/portal/render_portlet,\/document_library/get_file
完成后将 Jsp 包含到您的主题portal-normal.vm
中,以便它在每个地方都可以访问。查看
添加全局 Jsp 以包含在 Liferay tomcat-6 中
,它将成功地将跟踪数据添加到表中。:)
注意:如果在 CE 中有任何替代方案,将很高兴收到您对此的建议。谢谢 :)