001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.model.UserTracker;
026: import com.liferay.portal.model.UserTrackerPath;
027: import com.liferay.portal.service.base.UserTrackerLocalServiceBaseImpl;
028: import com.liferay.portal.util.PropsValues;
029:
030: import java.util.Date;
031: import java.util.Iterator;
032: import java.util.List;
033:
034: /**
035: * <a href="UserTrackerLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
036: *
037: * @author Brian Wing Shun Chan
038: *
039: */
040: public class UserTrackerLocalServiceImpl extends
041: UserTrackerLocalServiceBaseImpl {
042:
043: public UserTracker addUserTracker(long companyId, long userId,
044: Date modifiedDate, String sessionId, String remoteAddr,
045: String remoteHost, String userAgent, List userTrackerPaths)
046: throws SystemException {
047:
048: if (PropsValues.SESSION_TRACKER_PERSISTENCE_ENABLED) {
049: long userTrackerId = counterLocalService
050: .increment(UserTracker.class.getName());
051:
052: UserTracker userTracker = userTrackerPersistence
053: .create(userTrackerId);
054:
055: userTracker.setCompanyId(companyId);
056: userTracker.setUserId(userId);
057: userTracker.setModifiedDate(modifiedDate);
058: userTracker.setSessionId(sessionId);
059: userTracker.setRemoteAddr(remoteAddr);
060: userTracker.setRemoteHost(remoteHost);
061: userTracker.setUserAgent(userAgent);
062:
063: userTrackerPersistence.update(userTracker);
064:
065: Iterator itr = userTrackerPaths.iterator();
066:
067: while (itr.hasNext()) {
068: UserTrackerPath userTrackerPath = (UserTrackerPath) itr
069: .next();
070:
071: long pathId = counterLocalService
072: .increment(UserTrackerPath.class.getName());
073:
074: userTrackerPath.setUserTrackerPathId(pathId);
075: userTrackerPath.setUserTrackerId(userTrackerId);
076:
077: userTrackerPathPersistence.update(userTrackerPath);
078: }
079:
080: return userTracker;
081: } else {
082: return null;
083: }
084: }
085:
086: public void deleteUserTracker(long userTrackerId)
087: throws PortalException, SystemException {
088:
089: // Paths
090:
091: userTrackerPathPersistence.removeByUserTrackerId(userTrackerId);
092:
093: // User tracker
094:
095: userTrackerPersistence.remove(userTrackerId);
096: }
097:
098: public List getUserTrackers(long companyId, int begin, int end)
099: throws SystemException {
100:
101: return userTrackerPersistence.findByCompanyId(companyId, begin,
102: end);
103: }
104:
105: }
|