forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-30775 Clear caches as site membership updated
- Loading branch information
1 parent
1dd45e2
commit 2f577fa
Showing
2 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,18 +19,7 @@ | |
|
||
package org.sakaiproject.roster.impl; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.*; | ||
|
||
import org.apache.commons.lang.ArrayUtils; | ||
import org.apache.commons.logging.Log; | ||
|
@@ -49,6 +38,8 @@ | |
import org.sakaiproject.coursemanagement.api.Section; | ||
import org.sakaiproject.coursemanagement.api.exception.IdNotFoundException; | ||
import org.sakaiproject.exception.IdUnusedException; | ||
import org.sakaiproject.event.api.Event; | ||
import org.sakaiproject.event.api.EventTrackingService; | ||
import org.sakaiproject.memory.api.Cache; | ||
import org.sakaiproject.memory.api.MemoryService; | ||
import org.sakaiproject.memory.api.SimpleConfiguration; | ||
|
@@ -82,11 +73,12 @@ | |
* @author Adrian Fish ([email protected]) | ||
*/ | ||
@Setter | ||
public class SakaiProxyImpl implements SakaiProxy { | ||
public class SakaiProxyImpl implements SakaiProxy, Observer { | ||
|
||
private static final Log log = LogFactory.getLog(SakaiProxyImpl.class); | ||
|
||
private CourseManagementService courseManagementService; | ||
private EventTrackingService eventTrackingService; | ||
private FunctionManager functionManager; | ||
private GroupProvider groupProvider; | ||
private PrivacyManager privacyManager; | ||
|
@@ -141,6 +133,8 @@ public void init() { | |
functionManager.registerFunction(RosterFunctions.ROSTER_FUNCTION_VIEWSITEVISITS, true); | ||
} | ||
|
||
eventTrackingService.addObserver(this); | ||
|
||
memberComparator = new RosterMemberComparator(getFirstNameLastName()); | ||
} | ||
|
||
|
@@ -1148,4 +1142,35 @@ public Map<String, SitePresenceTotal> getPresenceTotalsForSite(String siteId) { | |
public boolean getShowVisits() { | ||
return serverConfigurationService.getBoolean("roster.showVisits", false); | ||
} | ||
|
||
public void update(Observable o, Object arg) { | ||
|
||
if (arg instanceof Event) { | ||
Event event = (Event) arg; | ||
if (SiteService.SECURE_UPDATE_SITE_MEMBERSHIP.equals(event.getEvent())) { | ||
if (log.isDebugEnabled()) log.debug("Site membership updated. Clearing caches ..."); | ||
String siteId = event.getContext(); | ||
|
||
Cache enrollmentsCache = getCache(ENROLLMENTS_CACHE); | ||
enrollmentsCache.remove(siteId); | ||
|
||
Cache searchIndexCache = memoryService.getCache(SEARCH_INDEX_CACHE); | ||
searchIndexCache.remove(siteId); | ||
|
||
Cache membershipsCache = getCache(MEMBERSHIPS_CACHE); | ||
membershipsCache.remove(siteId); | ||
Site site = getSite(siteId); | ||
if (site != null) { | ||
Set<Role> roles = site.getRoles(); | ||
for (Group group : site.getGroups()) { | ||
String gId = group.getId(); | ||
membershipsCache.remove(siteId + "#" + gId); | ||
for (Role role : roles) { | ||
membershipsCache.remove(siteId + "#" + gId + "#" + role.getId()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters