1 package org.kuali.student.lum.lu.ui.browseprogram.client.controllers; 2 3 import org.kuali.student.common.ui.client.application.Application; 4 import org.kuali.student.common.ui.client.configurable.mvc.layouts.BasicLayout; 5 import org.kuali.student.common.ui.client.mvc.Callback; 6 import org.kuali.student.common.ui.client.security.AuthorizationCallback; 7 import org.kuali.student.common.ui.client.security.RequiresAuthorization; 8 import org.kuali.student.lum.common.client.lu.LUUIPermissions; 9 import org.kuali.student.lum.lu.ui.browseprogram.client.views.BrowseProgramView; 10 11 public class BrowseProgramController extends BasicLayout implements RequiresAuthorization { 12 13 public enum BrowseProgramViews { 14 MAIN 15 } 16 17 public BrowseProgramController(String controllerId) { 18 super(controllerId); 19 addView(new BrowseProgramView(this, "Browse Majors and Specializations", BrowseProgramViews.MAIN)); 20 setDefaultView(BrowseProgramViews.MAIN); 21 } 22 23 @Override 24 public boolean isAuthorizationRequired() { 25 return true; 26 } 27 28 @Override 29 public void setAuthorizationRequired(boolean required) { 30 throw new UnsupportedOperationException(); 31 } 32 33 @Override 34 public void checkAuthorization(final AuthorizationCallback authCallback) { 35 Application.getApplicationContext().getSecurityContext().checkScreenPermission(LUUIPermissions.USE_BROWSE_PROGRAM_SCREEN, new Callback<Boolean>() { 36 @Override 37 public void exec(Boolean result) { 38 39 final boolean isAuthorized = result; 40 41 if(isAuthorized){ 42 authCallback.isAuthorized(); 43 } 44 else 45 authCallback.isNotAuthorized("User is not authorized: " + LUUIPermissions.USE_BROWSE_PROGRAM_SCREEN); 46 } 47 }); 48 } 49 50 }