@java.lang.Override protected DataTable buildDataTable() { Query query = new Query(); query.setSortby("lastEventDate:desc"); query.setLimit(maxEntries); Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition")); query.setCondition(matchAllCondition); PartialList<Session> lastModifiedProfiles = profileService.searchSessions(query); DataTable dataTable = new DataTable(); for (Session session : lastModifiedProfiles.getList()) { ArrayList<Comparable> rowData = new ArrayList<>(); rowData.add(session.getItemId()); rowData.add(session.getScope()); rowData.add(session.getLastEventDate()); rowData.add(session.getDuration()); rowData.add(session.getProfileId()); rowData.add(session.getTimeStamp()); dataTable.addRow(rowData.toArray(new Comparable[rowData.size()])); } return dataTable; } }
public Session saveSession(Session session) { if (session.getItemId() == null) { return null; } if (session.getProfile() != null && session.getProfile().getProperties() != null) { session.getProfile().setProperties(removePersonalIdentifiersFromSessionProfile(session.getProfile().getProperties())); } return persistenceService.save(session) ? session : null; }
ipLookupInDatabase(remoteAddr, session); } else { session.setProperty("sessionCountryCode", defaultSessionCountryCode); session.setProperty("sessionCountryName", defaultSessionCountryName); session.setProperty("sessionCity", defaultSessionCity); session.setProperty("sessionAdminSubDiv1", defaultSessionAdminSubDiv1); session.setProperty("sessionAdminSubDiv2", defaultSessionAdminSubDiv2); session.setProperty("sessionIsp", defaultSessionIsp); Map<String, Double> location = new HashMap<String, Double>(); location.put("lat", defaultLatitude); location.put("lon", defaultLongitude); session.setProperty("location", location); session.setProperty("countryAndCity", session.getProperty("sessionCountryName") + "@@" + session.getProperty("sessionCity") + "@@" + session.getProperty("sessionAdminSubDiv1") + "@@" + session.getProperty("sessionAdminSubDiv2")); } catch (Exception e) { logger.error("Cannot lookup IP", e); session.setProperty("operatingSystemFamily", agent.getOperatingSystem().getFamilyName()); session.setProperty("operatingSystemName", agent.getOperatingSystem().getName()); session.setProperty("userAgentName", agent.getName()); session.setProperty("userAgentVersion", agent.getVersionNumber().toVersionString()); session.setProperty("userAgentNameAndVersion", session.getProperty("userAgentName") + "@@" + session.getProperty("userAgentVersion")); session.setProperty("deviceCategory", agent.getDeviceCategory().getName());
Map<String, Object> sessionProperties = session.getProperties(); if (!sessionProperties.containsKey(LOCATION)) { logger.warn("No location info found in the session."); Map<String, Double> location = (Map<String, Double>) session.getProperty(LOCATION); JsonNode currentWeatherData = getWeather(location); if (currentWeatherData == null) {
@Override public Boolean anonymizeBrowsingData(String profileId) { Profile profile = profileService.load(profileId); if (profile == null) { return false; } List<Session> sessions = profileService.getProfileSessions(profileId, null, 0, -1, null).getList(); if (sessions.isEmpty()) { return false; } for (Session session : sessions) { Profile newProfile = getAnonymousProfile(session.getProfile()); session.setProfile(newProfile); persistenceService.save(session); List<Event> events = eventService.searchEvents(session.getItemId(), new String[0], null, 0, -1, null).getList(); for (Event event : events) { persistenceService.update(event.getItemId(), event.getTimeStamp(), Event.class, "profileId", newProfile.getItemId()); } } return true; }
Session session = (Session) item; if ("timeStamp".equals(expression)) { return session.getTimeStamp(); return session.getDuration(); return session.getSize(); return getNestedPropertyValue(expression.substring("properties.".length()), session.getProperties()); return getNestedPropertyValue(expression.substring("systemProperties.".length()), session.getSystemProperties());
profile.setProperty("firstVisit", currentSession.getTimeStamp()); profile.getSystemProperties().put(mergeProfilePropertyName, mergeProfilePropertyValue); event.setProfile(profile); currentSession.setProfile(profile); sendProfileCookie(currentSession.getProfile(), httpServletResponse, profileIdCookieName, profileIdCookieDomain, profileIdCookieMaxAgeInSeconds); event.setProfile(masterProfile); currentSession.setProfile(masterProfile); if (privacyService.isRequireAnonymousBrowsing(profile)) { privacyService.setRequireAnonymousBrowsing(masterProfileId, true, event.getScope()); currentSession.setProfile(privacyService.getAnonymousProfile(masterProfile)); event.setProfileId(null); persistenceService.save(event);
@Override public boolean execute() { try { for (Profile profile : profiles) { String profileId = profile.getItemId(); if (!StringUtils.equals(profileId, masterProfileId)) { List<Session> sessions = persistenceService.query("profileId", profileId, null, Session.class); if (masterProfileId.equals(profileId) && !sessions.contains(currentSession)) { sessions.add(currentSession); } for (Session session : sessions) { persistenceService.update(session.getItemId(), session.getTimeStamp(), Session.class, "profileId", anonymousBrowsing ? null : masterProfileId); } List<Event> events = persistenceService.query("profileId", profileId, null, Event.class); for (Event event : events) { persistenceService.update(event.getItemId(), event.getTimeStamp(), Event.class, "profileId", anonymousBrowsing ? null : masterProfileId); } // we must mark all the profiles that we merged into the master as merged with the master, and they will // be deleted upon next load profile.setMergedWith(masterProfileId); persistenceService.update(profile.getItemId(), null, Profile.class, "mergedWith", masterProfileId); } } } catch (Exception e) { logger.error("unable to execute callback action, profile and session will not be saved", e); return false; } return true; } });
session.setLastEventDate(event.getTimeStamp()); profileUpdated.getAttributes().putAll(event.getAttributes()); changes |= send(profileUpdated, depth + 1); if (session != null && session.getProfileId() != null) { changes |= SESSION_UPDATED; session.setProfile(event.getProfile());
/** * Instantiates a new Event. * * @param eventType the event type identifier * @param session the session associated with the event * @param profile the profile associated with the event * @param scope the scope from which the event is issued * @param source the source of the event * @param target the target of the event if any * @param timestamp the timestamp associated with the event if provided */ public Event(String eventType, Session session, Profile profile, String scope, Item source, Item target, Date timestamp) { super(UUID.randomUUID().toString()); this.eventType = eventType; this.profile = profile; this.session = session; this.profileId = profile.getItemId(); this.scope = scope; this.source = source; this.target = target; if (session != null) { this.sessionId = session.getItemId(); } this.timeStamp = timestamp; this.properties = new HashMap<String, Object>(); actionPostExecutors = new ArrayList<>(); }
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getSession().getProperty(valueAsString); } });
/** * Update the session info with the weather infos * * @param currentWeatherData the response from the API * @param session */ private void updateSessionWithWeatherData(JsonNode currentWeatherData, Session session) { String temperature = extractTemperature(currentWeatherData); String weatherLike = extractWeatherLike(currentWeatherData); String windDirection = extractWindDirection(currentWeatherData); String windSpeed = extractWindSpeed(currentWeatherData); if (temperature != null) { session.setProperty(WEATHER_TEMPERATURE, temperature); } if (weatherLike != null) { session.setProperty(WEATHER_LIKE, weatherLike); } if (windDirection != null) { session.setProperty(WEATHER_WIND_DIRECTION, windDirection); } if (windSpeed != null) { session.setProperty(WEATHER_WIND_SPEED, windSpeed); } }
session.setLastEventDate(event.getTimeStamp()); profileUpdated.getAttributes().putAll(event.getAttributes()); changes |= send(profileUpdated); if (session != null && session.getProfileId() != null) { changes |= SESSION_UPDATED; session.setProfile(event.getProfile());
/** * Instantiates a new Event. * * @param eventType the event type identifier * @param session the session associated with the event * @param profile the profile associated with the event * @param scope the scope from which the event is issued * @param source the source of the event * @param target the target of the event if any * @param timestamp the timestamp associated with the event if provided */ public Event(String eventType, Session session, Profile profile, String scope, Item source, Item target, Date timestamp) { super(UUID.randomUUID().toString()); this.eventType = eventType; this.profile = profile; this.session = session; this.profileId = profile.getItemId(); this.scope = scope; this.source = source; this.target = target; if (session != null) { this.sessionId = session.getItemId(); } this.timeStamp = timestamp; this.properties = new HashMap<String, Object>(); actionPostExecutors = new ArrayList<>(); }
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getSession().getProperty(valueAsString); } });
session.setProperty("sessionCountryCode", cityResponse.getCountry().getIsoCode()); session.setProperty("sessionCountryName", cityResponse.getCountry().getName()); session.setProperty("sessionCity", cityResponse.getCity().getName()); session.setProperty("sessionCityId", cityResponse.getCity().getGeoNameId()); session.setProperty("sessionAdminSubDiv1", cityResponse.getSubdivisions().get(0).getGeoNameId()); session.setProperty("sessionAdminSubDiv2", cityResponse.getSubdivisions().get(1).getGeoNameId()); session.setProperty("sessionIsp", isp); locationMap.put("lat", cityResponse.getLocation().getLatitude()); locationMap.put("lon", cityResponse.getLocation().getLongitude()); session.setProperty("location", locationMap);
public Session saveSession(Session session) { if (session.getItemId() == null) { return null; } if (session.getProfile() != null && session.getProfile().getProperties() != null) { session.getProfile().setProperties(removePersonalIdentifiersFromSessionProfile(session.getProfile().getProperties())); } return persistenceService.save(session) ? session : null; }
public int execute(Action action, Event event) { boolean changed = false; HttpServletRequest httpServletRequest = (HttpServletRequest) event.getAttributes().get(Event.HTTP_REQUEST_ATTRIBUTE); if (httpServletRequest == null) { return EventService.NO_CHANGE; } String requestHeaderName = (String) action.getParameterValues().get("requestHeaderName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); String sessionPropertyName = (String) action.getParameterValues().get("sessionPropertyName"); String requestHeaderValue = httpServletRequest.getHeader(requestHeaderName); if (requestHeaderValue != null) { if (profilePropertyName != null) { if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(requestHeaderValue)) { event.getProfile().setProperty(profilePropertyName, requestHeaderValue); return EventService.PROFILE_UPDATED; } } else if (sessionPropertyName != null) { if (event.getSession().getProperty(sessionPropertyName) == null || !event.getSession().getProperty(sessionPropertyName).equals(requestHeaderValue)) { event.getSession().setProperty(sessionPropertyName, requestHeaderValue); return EventService.SESSION_UPDATED; } } } return EventService.NO_CHANGE; } }
public int execute(Action action, Event event) { boolean changed = false; HttpServletRequest httpServletRequest = (HttpServletRequest) event.getAttributes().get(Event.HTTP_REQUEST_ATTRIBUTE); if (httpServletRequest == null) { return EventService.NO_CHANGE; } String requestParameterName = (String) action.getParameterValues().get("requestParameterName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); String sessionPropertyName = (String) action.getParameterValues().get("sessionPropertyName"); String requestParameterValue = httpServletRequest.getParameter(requestParameterName); if (requestParameterValue != null) { if (profilePropertyName != null) { if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(requestParameterValue)) { event.getProfile().setProperty(profilePropertyName, requestParameterValue); return EventService.PROFILE_UPDATED; } } else if (sessionPropertyName != null) { if (event.getSession().getProperty(sessionPropertyName) == null || !event.getSession().getProperty(sessionPropertyName).equals(requestParameterValue)) { event.getSession().setProperty(sessionPropertyName, requestParameterValue); return EventService.SESSION_UPDATED; } } } return EventService.NO_CHANGE; } }