View Javadoc
1   package org.kuali.ole.deliver.controller.checkout;
2   
3   import org.apache.commons.collections.CollectionUtils;
4   import org.kuali.ole.deliver.controller.PermissionsValidatorUtil;
5   import org.kuali.ole.deliver.form.CircForm;
6   import org.kuali.rice.krad.web.form.UifFormBase;
7   import org.springframework.validation.BindingResult;
8   import org.springframework.web.bind.annotation.ModelAttribute;
9   import org.springframework.web.bind.annotation.RequestMapping;
10  import org.springframework.web.servlet.ModelAndView;
11  
12  import javax.servlet.http.HttpServletRequest;
13  import javax.servlet.http.HttpServletResponse;
14  
15  /**
16   * Created by hemalathas on 6/21/15.
17   */
18  public class CheckoutValidationController extends CheckoutPatronController {
19  
20      @RequestMapping(params = "methodToCall=validateOveridePermission")
21      public ModelAndView validateOveridePermission(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
22                                                    HttpServletRequest request, HttpServletResponse response) throws Exception {
23          CircForm circForm = (CircForm) form;
24          boolean hasValidOverridePermissions = new PermissionsValidatorUtil().hasValidOverridePermissions(circForm);
25          if(CollectionUtils.isEmpty(circForm.getErrorMessage().getPermissions())){
26              return handleProxyPatronsIfExists(circForm, result, request, response);
27          } else {
28              if ((hasValidOverridePermissions)) {
29                  if (circForm.isProxyCheckDone() && circForm.isItemValidationDone() && !circForm.isItemOverride() && !circForm.isRequestExistOrLoanedCheck()) {
30                      circForm.getErrorMessage().clearErrorMessage();
31                      return proceedToSaveLoan(circForm, result, request, response);
32                  } else if (circForm.isItemOverride()) {
33                      circForm.setItemOverride(false);
34                      circForm.getErrorMessage().clearErrorMessage();
35                      return proceedToSaveLoan(circForm, result, request, response);
36                  }else if(circForm.isRequestExistOrLoanedCheck()){
37                      circForm.setRequestExistOrLoanedCheck(false);
38                      return proceedToValidateItemAndSaveLoan(circForm, result, request, response);
39                  }
40                  return handleProxyPatronsIfExists(circForm, result, request, response);
41              } else {
42                  circForm.setOverridingPrincipalName(null);
43                  return showDialog("overrideMessageDialog", circForm, request, response);
44              }
45          }
46      }
47  }