View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.krad.web.controller;
17  
18  import javax.servlet.http.HttpServletRequest;
19  import javax.servlet.http.HttpServletResponse;
20  
21  import org.apache.log4j.Logger;
22  import org.kuali.rice.krad.document.Copyable;
23  import org.kuali.rice.krad.util.KRADConstants;
24  import org.kuali.rice.krad.web.form.TransactionalDocumentFormBase;
25  import org.springframework.validation.BindingResult;
26  import org.springframework.web.bind.annotation.ModelAttribute;
27  import org.springframework.web.bind.annotation.RequestMapping;
28  import org.springframework.web.servlet.ModelAndView;
29  
30  /**
31  * Controller for <code>TransactionalDocumentView</code> screens which operate on
32  * <code>TransactionalDocument</code> instances.
33  *
34  * <p>
35  *    Provides controller implementations for transactional document actions including: doc handler
36  *    (retrieve from doc search and action list), save, route (and other KEW actions), and copy.
37  * </p>
38  *
39  * @see DocumentControllerBase
40  * @author Kuali Rice Team (rice.collab@kuali.org)
41  */
42  public abstract class TransactionalDocumentControllerBase extends DocumentControllerBase {
43      protected static final Logger LOG = Logger.getLogger(TransactionalDocumentControllerBase.class);
44  
45      /**
46      * Method to call copy.
47      *
48      * <p>
49      *     Method that will take the current document and call its copy method if Copyable.
50      * </p>
51      *
52      * @param form : a TransactionalDocumentFormBase
53      * @param result : a BindingResult
54      * @throws java.lang.Exception : an exception
55      * @return a ModelAndView object
56      */
57      @RequestMapping(params = "methodToCall=" + KRADConstants.Maintenance.METHOD_TO_CALL_COPY)
58      public ModelAndView copy(@ModelAttribute("KualiForm") TransactionalDocumentFormBase form, BindingResult result,
59              HttpServletRequest request, HttpServletResponse response) throws Exception {
60          ((Copyable) form.getDocument()).toCopy();
61  
62          return getUIFModelAndView(form);
63      }
64  
65  }