001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.db;
029
030import org.opencms.util.CmsUUID;
031
032import java.util.Date;
033
034/**
035 * A bean which represents a user having visited a page.<p>
036 *
037 * @since 8.0.0
038 */
039public class CmsVisitEntry {
040
041    /** The entry's date in milliseconds. */
042    private final long m_date;
043
044    /** The structure id. */
045    private final CmsUUID m_structureId;
046
047    /** The user id. */
048    private final CmsUUID m_userId;
049
050    /**
051     * Public constructor, will use the current time for time stamp.<p>
052     *
053     * @param dbc the current database context with the current user
054     * @param structureId the structure id
055     */
056    public CmsVisitEntry(CmsDbContext dbc, CmsUUID structureId) {
057
058        m_userId = dbc.currentUser().getId();
059        m_date = System.currentTimeMillis();
060        m_structureId = structureId;
061    }
062
063    /**
064     * Public constructor.<p>
065     *
066     * @param userId the user id
067     * @param date the date in milliseconds
068     * @param structureId the structure id
069     */
070    public CmsVisitEntry(CmsUUID userId, long date, CmsUUID structureId) {
071
072        m_userId = userId;
073        m_date = date;
074        m_structureId = structureId;
075    }
076
077    /**
078     * Returns the date.<p>
079     *
080     * @return the date
081     */
082    public long getDate() {
083
084        return m_date;
085    }
086
087    /**
088     * Returns the structure id.<p>
089     *
090     * @return the structure id
091     */
092    public CmsUUID getStructureId() {
093
094        return m_structureId;
095    }
096
097    /**
098     * Returns the user id.<p>
099     *
100     * @return the user id
101     */
102    public CmsUUID getUserId() {
103
104        return m_userId;
105    }
106
107    /**
108     * @see java.lang.Object#toString()
109     */
110    @Override
111    public String toString() {
112
113        StringBuffer sb = new StringBuffer();
114        sb.append("[").append(getClass().getName()).append(":");
115        sb.append("user=").append(m_userId).append(",");
116        sb.append("date=").append(new Date(m_date)).append(",");
117        sb.append("structure=").append(m_structureId);
118        return sb.append("]").toString();
119    }
120
121}