View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.document.web.struts;
17  
18  import org.apache.struts.action.ActionForm;
19  import org.kuali.ole.sys.context.SpringContext;
20  import org.kuali.rice.kim.api.services.IdentityManagementService;
21  import org.kuali.rice.kns.service.KNSServiceLocator;
22  import org.kuali.rice.kns.web.struts.action.KualiLookupAction;
23  import org.kuali.rice.kns.web.struts.form.LookupForm;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  
26  import java.util.HashMap;
27  
28  public class KualiLookupActions extends KualiLookupAction {
29  
30  
31      public void supressActionsIfNeeded(ActionForm form) throws ClassNotFoundException {
32          Class businessObjectClass = Class.forName(((LookupForm) form).getBusinessObjectClassName());
33          HashMap<String, String> permissionDetails = new HashMap<String, String>();
34          String nameSpaceCode = "OLE-VND";
35          if (businessObjectClass.getName().equalsIgnoreCase("org.kuali.ole.vnd.businessobject.VendorDetail")) {
36              if ((SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
37                      "Edit Vendor"))) {
38  
39                  if (!KNSServiceLocator.getDocumentHelperService().getDocumentAuthorizer("OLE_PVEN").canInitiate("OLE_PVEN", GlobalVariables.getUserSession().getPerson())) {
40                      ((LookupForm) form).setSupplementalActionsEnabled(true);
41                  } else {
42                 //     super.supressActionsIfNeeded(form);
43                  }
44              } else {
45                //  super.supressActionsIfNeeded(form);
46                  System.out.println("aefasfasdfsadfsdaf");
47              }
48          } else {
49              System.out.println("else part");
50           //   super.supressActionsIfNeeded(form);
51          }
52      }
53  }
54  
55      /* System.out.println("1111111111111111111111111111111111");
56  System.out.println("1111111111111111111111111111111111"+( KIMServiceLocator.getIdentityManagementService().hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
57          "Edit Vendor", permissionDetails )));
58  System.out.println(KNSServiceLocator.getDocumentHelperService().getDocumentAuthorizer("OLE_PVEN").canInitiate("OLE_PVEN", GlobalVariables.getUserSession().getPerson()));    */