/** * Sets the associated Profile. * * @param profile the associated Profile */ public void setProfile(Profile profile) { this.profileId = profile.getItemId(); this.profile = profile; }
/** * Sets the associated Profile. * * @param profile the associated Profile */ public void setProfile(Profile profile) { this.profileId = profile.getItemId(); this.profile = profile; }
/** * Instantiates a new Session. * * @param itemId the identifier for this Session * @param profile the associated {@link Profile} * @param timeStamp the time stamp * @param scope the scope */ public Session(String itemId, Profile profile, Date timeStamp, String scope) { super(itemId); this.profile = profile; this.profileId = profile.getItemId(); this.timeStamp = timeStamp; this.scope = scope; }
/** * Instantiates a new Session. * * @param itemId the identifier for this Session * @param profile the associated {@link Profile} * @param timeStamp the time stamp * @param scope the scope */ public Session(String itemId, Profile profile, Date timeStamp, String scope) { super(itemId); this.profile = profile; this.profileId = profile.getItemId(); this.timeStamp = timeStamp; this.scope = scope; }
private static void sendProfileCookie(Profile profile, ServletResponse response, String profileIdCookieName, String profileIdCookieDomain, int cookieAgeInSeconds) { if (response instanceof HttpServletResponse) { HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!(profile instanceof Persona)) { Cookie profileIdCookie = new Cookie(profileIdCookieName, profile.getItemId()); profileIdCookie.setPath("/"); if (profileIdCookieDomain != null && !profileIdCookieDomain.equals("")) { profileIdCookie.setDomain(profileIdCookieDomain); } profileIdCookie.setMaxAge(cookieAgeInSeconds); httpServletResponse.addCookie(profileIdCookie); } } }
private Profile save(Profile profile, boolean forceRefresh) { if (profile.getItemId() == null) { return null; } if (persistenceService.save(profile)) { if (forceRefresh) { // triggering a load will force an in-place refresh, that may be expensive in performance but will make data immediately available. return persistenceService.load(profile.getItemId(), Profile.class); } else { return profile; } } return null; }
private Profile save(Profile profile, boolean forceRefresh) { if (profile.getItemId() == null) { return null; } if (persistenceService.save(profile)) { if (forceRefresh) { // triggering a load will force an in-place refresh, that may be expensive in performance but will make data immediately available. return persistenceService.load(profile.getItemId(), Profile.class); } else { return profile; } } return null; }
/** * 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<>(); }
public Profile getAnonymousProfile(Profile profile) { Profile anonymousProfile = new Profile(); anonymousProfile.getSystemProperties().put("isAnonymousProfile", true); anonymousProfile.getProperties().putAll(profile.getProperties()); anonymousProfile.getProperties().keySet().removeAll(getDeniedProperties(profile.getItemId())); // profileService.save(anonymousProfile); return anonymousProfile; }
sb.append(profile.getItemId()); sb.append(";"); for (Map.Entry<String, PropertyType> propertyIdAndType : propertyTypesById.entrySet()) {
@Override public Boolean anonymizeProfile(String profileId, String scope) { Profile profile = profileService.load(profileId); if (profile == null) { return false; } // first we send out the anonymize profile event to make sure other systems can still use external identifiers to lookup the profile and anonymize it. Event anonymizeProfileEvent = new Event("anonymizeProfile", null, profile, scope, null, profile, new Date()); anonymizeProfileEvent.setPersistent(true); eventService.send(anonymizeProfileEvent); boolean res = profile.getProperties().keySet().removeAll(getDeniedProperties(profile.getItemId())); Event profileUpdatedEvent = new Event("profileUpdated", null, profile, scope, null, profile, new Date()); profileUpdatedEvent.setPersistent(false); eventService.send(profileUpdatedEvent); profileService.save(profile); return res; }
@java.lang.Override protected DataTable buildDataTable() { Query query = new Query(); query.setSortby("properties.lastVisit:desc"); query.setLimit(maxEntries); Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition")); query.setCondition(matchAllCondition); PartialList<Profile> lastModifiedProfiles = profileService.search(query, Profile.class); DataTable dataTable = new DataTable(); for (Profile profile : lastModifiedProfiles.getList()) { ArrayList<Comparable> rowData = new ArrayList<>(); rowData.add(profile.getItemId()); rowData.add(profile.getScope()); rowData.add(StringUtils.join(profile.getSegments(), ",")); rowData.add(StringUtils.join(profile.getConsents().keySet(), ",")); rowData.add((String) profile.getProperty("lastVisit")); dataTable.addRow(rowData.toArray(new Comparable[rowData.size()])); } return dataTable; } }
@Override public void delete(String listId) { Condition query = new Condition(definitionsService.getConditionType("profilePropertyCondition")); query.setParameter("propertyName", "systemProperties.lists"); query.setParameter("comparisonOperator", "equals"); query.setParameter("propertyValue", listId); List<Profile> profiles = persistenceService.query(query, null, Profile.class); Map<String, Object> profileProps; for (Profile p : profiles) { profileProps = p.getSystemProperties(); if(profileProps != null && profileProps.get("lists") != null) { int index = ((List) profileProps.get("lists")).indexOf(listId); if(index != -1){ ((List) profileProps.get("lists")).remove(index); persistenceService.update(p.getItemId(), null, Profile.class, "systemProperties", profileProps); } } } persistenceService.remove(listId, UserList.class); } }
@Override public void delete(String listId) { Condition query = new Condition(definitionsService.getConditionType("profilePropertyCondition")); query.setParameter("propertyName", "systemProperties.lists"); query.setParameter("comparisonOperator", "equals"); query.setParameter("propertyValue", listId); List<Profile> profiles = persistenceService.query(query, null, Profile.class); Map<String, Object> profileProps; for (Profile p : profiles) { profileProps = p.getSystemProperties(); if(profileProps != null && profileProps.get("lists") != null) { int index = ((List) profileProps.get("lists")).indexOf(listId); if(index != -1){ ((List) profileProps.get("lists")).remove(index); persistenceService.update(p.getItemId(), null, Profile.class, "systemProperties", profileProps); } } } persistenceService.remove(listId, UserList.class); } }
@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 Profile saveOrMerge(Profile profile) { Profile previousProfile = persistenceService.load(profile.getItemId(), Profile.class); if (previousProfile == null) { if (persistenceService.save(profile)) { return profile; } else { return null; } } else if (merge(previousProfile, profile)) { if (persistenceService.save(previousProfile)) { return previousProfile; } else { return null; } } return null; }
public Profile saveOrMerge(Profile profile) { Profile previousProfile = persistenceService.load(profile.getItemId(), Profile.class); if (previousProfile == null) { if (persistenceService.save(profile)) { return profile; } else { return null; } } else if (merge(previousProfile, profile)) { if (persistenceService.save(previousProfile)) { return previousProfile; } else { return null; } } return null; }
if (profileToImport.isProfileToDelete()) { logger.debug("Profile is to delete!"); persistenceService.remove(existingProfile.getItemId(), Profile.class); return true;
@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; }