View Javadoc

1   package org.kuali.student.lum.lu.ui.browseprogram.client.controllers;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import org.kuali.student.common.rice.StudentIdentityConstants;
7   import org.kuali.student.common.rice.authorization.PermissionType;
8   import org.kuali.student.common.ui.client.application.Application;
9   import org.kuali.student.common.ui.client.application.KSAsyncCallback;
10  import org.kuali.student.common.ui.client.application.ViewContext;
11  import org.kuali.student.common.ui.client.configurable.mvc.layouts.BasicLayout;
12  import org.kuali.student.common.ui.client.mvc.Callback;
13  import org.kuali.student.common.ui.client.mvc.View;
14  import org.kuali.student.common.ui.client.security.AuthorizationCallback;
15  import org.kuali.student.common.ui.client.security.RequiresAuthorization;
16  import org.kuali.student.common.ui.shared.IdAttributes.IdType;
17  import org.kuali.student.lum.common.client.lu.LUUIPermissions;
18  import org.kuali.student.lum.lu.LUConstants;
19  import org.kuali.student.lum.lu.ui.browseprogram.client.views.BrowseProgramView;
20  
21  import com.google.gwt.core.client.GWT;
22  import com.google.gwt.user.client.Window;
23  
24  public class BrowseProgramController extends BasicLayout implements RequiresAuthorization{
25  
26  	public enum BrowseProgramViews {
27  		MAIN
28  	}
29  	
30  	public BrowseProgramController(String controllerId) {
31  		
32  		super(controllerId);
33  		addView(new BrowseProgramView(this, "Browse Majors and Specializations", BrowseProgramViews.MAIN));
34  		setDefaultView(BrowseProgramViews.MAIN);
35  		//super.permissionType=
36  	}
37  	
38  	@Override
39  	public boolean isAuthorizationRequired() {
40  		return true;
41  	}
42  
43  	@Override
44  	public void setAuthorizationRequired(boolean required) {
45  		throw new UnsupportedOperationException();
46  	}
47  	
48  	@Override
49  	public void checkAuthorization(final AuthorizationCallback authCallback) {
50  		Application.getApplicationContext().getSecurityContext().checkScreenPermission(LUUIPermissions.USE_BROWSE_PROGRAM_SCREEN, new Callback<Boolean>() {
51  			@Override
52  			public void exec(Boolean result) {
53  
54  				final boolean isAuthorized = result;
55  	        
56  				if(isAuthorized){
57  					authCallback.isAuthorized();
58  				}
59  				else
60  					authCallback.isNotAuthorized("User is not authorized: " + LUUIPermissions.USE_BROWSE_PROGRAM_SCREEN);
61  			}	
62  		});
63  	}
64  }