/** EventTrackingService observer for cache invalidation. */ public void update(Observable obs, Object o) { if(o instanceof Event){ Event e = (Event) o; String event = LOG_APP + '.' + LOG_OBJ_PREFSDATA + '.' + LOG_ACTION_EDIT; if(e.getEvent() != null && e.getEvent().equals(event)) { String siteId = e.getResource().split("/")[2]; cachePrefsData.remove(siteId); LOG.debug("Expiring preferences cache for site: "+siteId); } } }
/** Method called whenever an new event is generated from EventTrackingService: do not call this method! */ public void update(Observable obs, Object o) { // At the moment this isn't threadsafe, but as sakai event handling is single threaded this shoudn't be a problem, // but it's not a formal contract. if(o instanceof Event){ Event e = (Event) o; Event eventWithPreciseDate = buildEvent(getToday(), e.getEvent(), e.getResource(), e.getContext(), e.getUserId(), e.getSessionId()); collectThreadQueue.add(eventWithPreciseDate); } }
/** * Constructor * * Converts an Event object into a SimpleEvent object * in order to be serializable for distribution * * @param event the event object * @param serverId the server id this event originated from */ public SimpleEvent(Event event, String serverId) { if (event == null) { throw new IllegalArgumentException("The SimpleEvent event cannot be null."); } if (serverId == null) { throw new IllegalArgumentException("The SimpleEvent serverId cannot be null."); } setEvent(event.getEvent()); setResource(event.getResource()); setSessionId(event.getSessionId()); setUserId(event.getUserId()); setContext(event.getContext()); setModify(event.getModify()); setPriority(event.getPriority()); setEventTime(event.getEventTime()); setServerId(serverId); setLRSStatement(event.getLrsStatement()); }
private boolean isMyWorkspaceEvent(Event e) { return e.getResource() != null && e.getResource().startsWith("/site/~"); }
/** * Ensure that the provided event is an instance of BaseEvent. If not, create a new BaseEvent * and transfer state. * * @param e * @return */ protected BaseEvent ensureBaseEvent(Event e) { BaseEvent event = null; if (e instanceof BaseEvent) { event = (BaseEvent) e; } else { event = new BaseEvent(e.getEvent(), e.getResource(), e.getModify(), e.getPriority(),null); event.setSessionId(e.getSessionId()); event.setUserId(e.getUserId()); } return event; }
public void update(Observable o, final Object arg) { if (arg instanceof Event) { Event e = (Event) arg; String event = e.getEvent(); if (ProfileConstants.EVENT_FRIEND_CONFIRM.equals(event) || ProfileConstants.EVENT_FRIEND_REMOVE.equals(event)) { String ref = e.getResource(); String[] pathParts = ref.split("/"); String from = e.getUserId(); String to = pathParts[2]; List<String> contextIds = new ArrayList(); contextIds.add(from); contextIds.add(to); removeContextIdsFromCache(contextIds); } } } }
private void noEventHandlerFor(Notification notification, Event event) { // Really shouldn't ever happen ... registerEventCallbacks() filters out events we're not interested in, // so would be either a static bug in this class or a change in behavior of Sakai's notification system. // Either way, we don't care about the event, so just a debug message. log.debug("Unexpected event type: " + event.getEvent()); return; }
/** * Check to see if we want to process or ignore this update. * * @param arg * The arg from the update. * @return true to continue, false to quit. */ public boolean check(Object arg) { // arg is Event if (!(arg instanceof Event)) return false; Event event = (Event) arg; // if this is just a read, not a modify event, we can ignore it if (!event.getModify()) return false; String key = null; // filter out events not for us if (m_resourcePattern != null) { key = event.getResource(); // if this resource is not in my pattern of resources, we can ignore it if (!key.startsWith(m_resourcePattern)) return false; } return true; }
Event e = (Event) o; String userId = e.getUserId(); log.debug("No userId for event, getting from the UsageSession instead: " + e.getEvent()); UsageSession session = usageSessionService.getSession(e.getSessionId()); if(session != null) { userId = session.getUserId(); log.debug("Couldn't get a userId for event, cannot update cache - skipping: " + e.getEvent()); return; if(StringUtils.equals(e.getEvent(), UsageSessionService.EVENT_LOGOUT)) { userActivityCache.remove(userId); log.debug("Removed from user activity cache: " + userId);
/** * @param event * @return a valid context for the event (based on the site/course) OR null if one cannot be determined */ private LRS_Context getEventContext(Event event) { LRS_Context context = null; if (event != null && event.getContext() != null) { String eventContext = event.getContext(); String e = StringUtils.lowerCase(event.getEvent()); // NOTE: wiki puts /site/ in front of the context, others are just the site_id if (StringUtils.startsWith(e, "wiki")) { eventContext = StringUtils.replace(eventContext, "/site/", ""); } // the site is the parent for all event activities context = new LRS_Context("parent", serverConfigurationService.getPortalUrl()+"/site/"+eventContext); } return context; }
/** * Cause this new event to get to wherever it has to go for persistence, etc. * * @param event * The new event to post. */ protected void postEvent(Event event) { String reportId = null; if (event.getSessionId() != null) { reportId = event.getSessionId(); } else { reportId = "~" + event.getUserId(); } log.info(m_logId + reportId + "@" + event); // notify observers, sending the event notifyObservers(event, true); } }
String priStr = Integer.toString(event.getPriority()); String eventContext = event.getContext(); if (eventContext != null) { props = prefs.getProperties(NotificationService.PREFS_TYPE + type + NotificationService.NOTI_OVERRIDE_EXTENSION);
String userEmail = null; String userId = event.getUserId();
public void notify(Notification notification, Event event) { removeSessionPresence(event.getSessionId()); }
protected void validateResourceName(Event event, Map<String, Object> validationContext) throws IllegalArgumentException, IllegalStateException { String resourceName = event.getResource(); if (resourceName == null) { // default if null (historical behavior) resourceName = ""; } if (resourceName.length() > 255) { throw new IllegalArgumentException("Entity Reference is longer than 255 characters. Reference=" + resourceName); } validationContext.put(ADD_RESOURCE_VALIDATION_KEY_RESOURCE_NAME, resourceName); }
private void noEventHandlerFor(Notification notification, Event event) { // Really shouldn't ever happen ... registerEventCallbacks() filters out events we're not interested in, // so would be either a static bug in this class or a change in behavior of Sakai's notification system. // Either way, we don't care about the event, so just a debug message. log.debug("Unexpected event type: " + event.getEvent()); return; }
public void update(Observable arg0, Object arg1) { if (arg1 instanceof Event) { Event event = (Event) arg1; /* * Modified? If so, reload if it's one of our hierarchy files */ if (event.getModify()) { String refstr = event.getResource(); synchronized (this) { if (this.updatableResources.contains(refstr)) { m_log.debug("Updating configuration from " + refstr); this.updateHierarchy(refstr); } } } } }