Skip to content

Commit

Permalink
SAK-33578 Load the auth templates dynamically. (sakaiproject#4972)
Browse files Browse the repository at this point in the history
Rather than just looking for a set list of templates we ask the SiteService what all the known templates are. We then use these template to get an idea of what roles exist in the sites.
  • Loading branch information
buckett authored and ottenhoff committed Nov 10, 2017
1 parent 76a8e50 commit 49f24be
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ public class SitePermsService {
private long maxUpdateTimeMS = DEFAULT_MAX_UPDATE_TIME_SECS * 1000L;
private int sitesUntilPause = DEFAULT_SITES_BEFORE_PAUSE;

public static String[] templates = {
"!site.template",
"!site.template.course",
"!site.template.portfolio",
public static final String SITE_TEMPLATE_PREFIX = "!site.template";

public static final String[] DEFAULT_SITE_TEMPLATES = {
SITE_TEMPLATE_PREFIX,
SITE_TEMPLATE_PREFIX+ "."+ "course",
"!site.user"
};

Expand Down Expand Up @@ -307,12 +308,18 @@ public List<String> getPermissions() {
return perms;
}

private List<String> getTemplateRoles() {
Set<String> templates = new HashSet<>(Arrays.asList(DEFAULT_SITE_TEMPLATES));
siteService.getSiteTypes().stream().map(s -> SITE_TEMPLATE_PREFIX + "."+ s).forEach(templates::add);
return new ArrayList<>(templates);
}

/**
* @return a list of all valid roles names
*/
public List<String> getValidRoles() {
HashSet<String> roleIds = new HashSet<String>();
for (String templateRef : templates) {
for (String templateRef : getTemplateRoles()) {
AuthzGroup ag;
try {
ag = authzGroupService.getAuthzGroup(templateRef);
Expand Down

0 comments on commit 49f24be

Please sign in to comment.