Skip to content

Commit

Permalink
SAK-23921 - iSyllabus NPE if user has no role in the site
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/textarea/trunk@307759 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
jonespm committed Apr 3, 2014
1 parent 0e1954d commit 317d2bd
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.sakaiproject.authz.api.AuthzGroupService;
import org.sakaiproject.authz.api.Role;

import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.entitybroker.EntityBroker;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class ConnectorHelper {
private static Log M_log = LogFactory.getLog(ConnectorHelper.class);
private SiteService siteService = null;
private AssignmentService assignmentService = null;
private SecurityService securityService = null;
private AuthzGroupService authzGroupService = null;

private EntityBroker entityBroker = null;
Expand All @@ -63,7 +65,6 @@ public class ConnectorHelper {
private List sites = null;
private String loggedInUserId = null;
private String loggedInUserEid = null;
private Set instructorRoles = null;
private boolean userKnown = true;

// private final String ASSIGNMENT_ENTITY_PREFIX = "site_assignments";
Expand All @@ -77,13 +78,11 @@ public void init() {
siteService = (SiteService) ComponentManager.get("org.sakaiproject.site.api.SiteService");
assignmentService = (AssignmentService) ComponentManager.get("org.sakaiproject.assignment.api.AssignmentService");
authzGroupService = (AuthzGroupService) ComponentManager.get("org.sakaiproject.authz.api.AuthzGroupService");
securityService = (SecurityService) ComponentManager.get("org.sakaiproject.authz.api.SecurityService");
sites = siteService.getSites(org.sakaiproject.site.api.SiteService.SelectionType.UPDATE, null, null, null, SortType.TITLE_ASC, null);
loggedInUserId = SessionManager.getCurrentSession().getUserId();

entityBroker = (EntityBroker) ComponentManager.get(EntityBroker.class);

instructorRoles = authzGroupService.getMaintainRoles();

}

public List getAssignments(){
Expand All @@ -109,9 +108,8 @@ public List getAssignments(){
}
}
}
String thisUserRole = thisSite.getUserRole(loggedInUserId).getId();
if(!instructorRoles.contains(thisUserRole)){
System.out.println("Assignment - no show"+loggedInUserEid+" is not an instructor. Role is:"+thisUserRole);
if(!securityService.unlock(loggedInUserId, "site.upd", "/site/" + thisSite.getId())){
System.out.println("Assignment - no show"+loggedInUserEid+" is not an instructor.");
return returnAssignmentList;
}

Expand Down Expand Up @@ -173,9 +171,9 @@ public List getSiteAssignments(String siteId){
}catch(Exception e){
assignmentToolNotFound = true;
}
String thisUserRole = thisSite.getUserRole(loggedInUserId).getId();
if(!instructorRoles.contains(thisUserRole)){
System.out.println("Assignment - no show"+loggedInUserEid+" is not an instructor. Role is:"+thisUserRole);

if(!securityService.unlock(loggedInUserId, "site.upd", "/site/" + siteId)){
System.out.println("Assignment - no show"+loggedInUserEid+" is not an instructor.");
return returnAssignmentList;
}

Expand Down Expand Up @@ -241,9 +239,9 @@ public List getPublishedAssements(String siteId){
} catch (IdUnusedException e) {
return new Vector();
}
String thisUserRole = thisSite.getUserRole(loggedInUserId).getId();
if(!instructorRoles.contains(thisUserRole)){
System.out.println("Assignment - no show"+loggedInUserEid+" is not an instructor. Role is:"+thisUserRole);

if(!securityService.unlock(loggedInUserId, "site.upd", "/site/" + siteId)){
System.out.println("Assignment - no show"+loggedInUserEid+" is not an instructor.");
return new Vector();
}

Expand Down

0 comments on commit 317d2bd

Please sign in to comment.