/** * 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<>(); }
/** * 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<>(); }
@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; } }
@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; } });
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 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; }
@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; }