001/*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 1.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl1.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.module.purap.document.web.struts;
017
018import org.apache.struts.action.ActionForm;
019import org.kuali.ole.sys.context.SpringContext;
020import org.kuali.rice.kim.api.services.IdentityManagementService;
021import org.kuali.rice.kns.service.KNSServiceLocator;
022import org.kuali.rice.kns.web.struts.action.KualiLookupAction;
023import org.kuali.rice.kns.web.struts.form.LookupForm;
024import org.kuali.rice.krad.util.GlobalVariables;
025
026import java.util.HashMap;
027
028public class KualiLookupActions extends KualiLookupAction {
029
030
031    public void supressActionsIfNeeded(ActionForm form) throws ClassNotFoundException {
032        Class businessObjectClass = Class.forName(((LookupForm) form).getBusinessObjectClassName());
033        HashMap<String, String> permissionDetails = new HashMap<String, String>();
034        String nameSpaceCode = "OLE-VND";
035        if (businessObjectClass.getName().equalsIgnoreCase("org.kuali.ole.vnd.businessobject.VendorDetail")) {
036            if ((SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
037                    "Edit Vendor"))) {
038
039                if (!KNSServiceLocator.getDocumentHelperService().getDocumentAuthorizer("OLE_PVEN").canInitiate("OLE_PVEN", GlobalVariables.getUserSession().getPerson())) {
040                    ((LookupForm) form).setSupplementalActionsEnabled(true);
041                } else {
042               //     super.supressActionsIfNeeded(form);
043                }
044            } else {
045              //  super.supressActionsIfNeeded(form);
046                System.out.println("aefasfasdfsadfsdaf");
047            }
048        } else {
049            System.out.println("else part");
050         //   super.supressActionsIfNeeded(form);
051        }
052    }
053}
054
055    /* System.out.println("1111111111111111111111111111111111");
056System.out.println("1111111111111111111111111111111111"+( KIMServiceLocator.getIdentityManagementService().hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
057        "Edit Vendor", permissionDetails )));
058System.out.println(KNSServiceLocator.getDocumentHelperService().getDocumentAuthorizer("OLE_PVEN").canInitiate("OLE_PVEN", GlobalVariables.getUserSession().getPerson()));    */