public List<String> getSitesForUser(String userId, String permission) { log.debug("userId: " + userId + ", permission: " + permission); List<String> l = new ArrayList<String>(); // get the groups from Sakai Set<String> authzGroupIds = authzGroupService.getAuthzGroupsIsAllowed(userId, permission, null); Iterator<String> it = authzGroupIds.iterator(); while (it.hasNext()) { String authzGroupId = it.next(); Reference r = entityManager.newReference(authzGroupId); if (r.isKnownType()) { // check if this is a Sakai Site or Group if (r.getType().equals(SiteService.APPLICATION_ID)) { String type = r.getSubType(); if (SAKAI_SITE_TYPE.equals(type)) { // this is a Site String siteId = r.getId(); l.add(siteId); } } } } if (l.isEmpty()) log.info("Empty list of siteIds for user:" + userId + ", permission: " + permission); return l; }
/** * Return the url unchanged, unless it's a reference, then return the reference url */ protected String convertReferenceUrl(String url) { // make a reference Reference ref = entityManager().newReference(url); // if it didn't recognize this, return it unchanged if (!ref.isKnownType()) return url; // return the reference's url return ref.getUrl(); }