Coverage Report - com.buckosoft.PicMan.web.ScanForNewPicsFormController
 
Classes in this File Line Coverage Branch Coverage Complexity
ScanForNewPicsFormController
0%
0/34
0%
0/4
1.429
 
 1  
 /******************************************************************************
 2  
  * ScanForNewPicsController.java - The Spring controller for the ScanForNewPics page
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2005 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.web;
 9  
 
 10  
 import java.util.HashMap;
 11  
 import java.util.Map;
 12  
 
 13  
 import javax.servlet.http.HttpServletRequest;
 14  
 import javax.servlet.http.HttpServletResponse;
 15  
 
 16  
 import org.apache.commons.logging.Log;
 17  
 import org.apache.commons.logging.LogFactory;
 18  
 import org.springframework.validation.BindException;
 19  
 import org.springframework.web.servlet.ModelAndView;
 20  
 
 21  
 import com.buckosoft.BSAccount.web.BSAccountSimpleFormController;
 22  
 import com.buckosoft.BSAccount.web.BSAccountUserWebSession;
 23  
 import com.buckosoft.PicMan.business.NewPicScannerImpl;
 24  
 import com.buckosoft.PicMan.business.PicManFacade;
 25  
 
 26  
 public class ScanForNewPicsFormController extends BSAccountSimpleFormController {
 27  
         
 28  
         /** Logger for this class and subclasses */
 29  0
         protected final Log logger = LogFactory.getLog(getClass());
 30  
         
 31  
         private PicManFacade pmf;
 32  
         
 33  0
         public void setPicMan(PicManFacade pmf) { this.pmf = pmf; }
 34  0
         public PicManFacade getPicMan() { return(pmf); }
 35  
         
 36  0
         public ScanForNewPicsFormController() {
 37  0
                 setSessionForm(true);
 38  0
                 setValidateOnBinding(false);
 39  0
                 setCommandName("scanForNewPicsForm");
 40  0
                 setFormView("ScanForNewPicsForm");
 41  0
         }
 42  
         
 43  
         protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors)
 44  
         throws Exception {
 45  0
         }
 46  
         
 47  
         protected Object formBackingObject(HttpServletRequest request) throws Exception {
 48  0
             BSAccountUserWebSession userWebSession = this.bsAccountMan.getUserWebSession(request);
 49  0
                 logger.info("formBackingObject with session " + userWebSession);
 50  0
                 ScanForNewPicsForm smf = new ScanForNewPicsForm();
 51  
                 
 52  0
                 smf.setUserWebSession(userWebSession);
 53  0
                 smf.setNewPicScanner(new NewPicScannerImpl(pmf));
 54  0
                 return(smf);
 55  
         }
 56  
         
 57  
         
 58  
         protected Map<String, Object> referenceData(HttpServletRequest request) throws Exception {
 59  0
             BSAccountUserWebSession userWebSession = this.bsAccountMan.getUserWebSession(request);
 60  0
                 Map<String, Object> myModel = new HashMap<String, Object>();
 61  0
                 myModel.put("userWebSession", userWebSession);
 62  0
                 logger.info("referenceData with session " + userWebSession);
 63  
                 
 64  0
                 return myModel;
 65  
         }
 66  
         
 67  
         protected ModelAndView onSubmit(
 68  
                         HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
 69  
         throws Exception {
 70  
                 
 71  0
                 ScanForNewPicsForm setupForm = (ScanForNewPicsForm) command;
 72  
                 
 73  
                 //UserSession userSession = new UserSession(this.pmf.getAccount(setupForm.getAccount().getUsername()));
 74  
                 //request.getSession().setAttribute("userSession", userSession);
 75  
                 //logger.info("Set to delete = '" + setupForm.getSetToDelete() + "'");
 76  
                 
 77  0
                 errors.setNestedPath("ScanForNewPics");
 78  
                 //getValidator().validate(account, errors);
 79  0
                 errors.setNestedPath("");
 80  
                 
 81  
                 boolean success;
 82  0
                 success = setupForm.getNewPicScanner().processNewPics();
 83  0
                 if (!success) {
 84  0
                         logger.info("Error processing new pics");
 85  0
                         errors.reject("NEW_PIC_SCANNER_FAILED",
 86  
                         "An error occured processing the new pics");
 87  0
                         errors.reject("NEW_PICS_SCANNER_FAILED_INFO", 
 88  0
                                         setupForm.getNewPicScanner().getProcessNewPicsErrorMessage());
 89  
                         
 90  
                 }
 91  0
                 if (success)
 92  
                 {
 93  0
                         response.sendRedirect("home.do");
 94  0
                         return(null);
 95  
                 }
 96  
                 else
 97  0
                         return(showForm(request, response, errors));
 98  
 //                return super.onSubmit(request, response, command, errors);
 99  
         }
 100  
 
 101  
 }