001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.krad.labs.fileUploads; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.krad.labs.KradLabsController; 020import org.kuali.rice.krad.util.GlobalVariables; 021import org.kuali.rice.krad.util.KRADConstants; 022import org.kuali.rice.krad.web.form.UifFormBase; 023import org.springframework.stereotype.Controller; 024import org.springframework.validation.BindingResult; 025import org.springframework.web.bind.annotation.ModelAttribute; 026import org.springframework.web.bind.annotation.RequestMapping; 027import org.springframework.web.servlet.ModelAndView; 028 029import javax.servlet.http.HttpServletRequest; 030import javax.servlet.http.HttpServletResponse; 031 032/** 033 * Controller class for the file uploads lab view 034 * 035 * @author Kuali Rice Team (rice.collab@kuali.org) 036 */ 037@Controller 038@RequestMapping(value = "/fileUploads") 039public class LabsFileUploadsController extends KradLabsController { 040 041 @Override 042 protected LabsFileUploadsForm createInitialForm() { 043 return new LabsFileUploadsForm(); 044 } 045 046 @RequestMapping(params = "methodToCall=uploadOne") 047 public ModelAndView uploadOne(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, 048 HttpServletRequest request, HttpServletResponse response) { 049 LabsFileUploadsForm uploadForm = (LabsFileUploadsForm) form; 050 051 if ((uploadForm.getUploadOne() == null) || StringUtils.isBlank(uploadForm.getUploadOne().getName())) { 052 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, "labs.fileUpload", "one"); 053 } 054 055 return getModelAndView(form); 056 } 057 058 @RequestMapping(params = "methodToCall=uploadTwo") 059 public ModelAndView uploadTwo(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, 060 HttpServletRequest request, HttpServletResponse response) { 061 LabsFileUploadsForm uploadForm = (LabsFileUploadsForm) form; 062 063 if ((uploadForm.getUploadTwo() == null) || StringUtils.isBlank(uploadForm.getUploadTwo().getName())) { 064 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, "labs.fileUpload", "two"); 065 } 066 067 return getModelAndView(form); 068 } 069}