View Javadoc

1   /**
2    * Copyright 2005-2012 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.kew.quicklinks.web;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import org.apache.struts.action.ActionForm;
25  import org.apache.struts.action.ActionForward;
26  import org.apache.struts.action.ActionMapping;
27  import org.kuali.rice.kew.quicklinks.service.QuickLinksService;
28  import org.kuali.rice.kew.service.KEWServiceLocator;
29  import org.kuali.rice.kew.web.KewKualiAction;
30  import org.kuali.rice.krad.UserSession;
31  import org.kuali.rice.krad.util.GlobalVariables;
32  
33  
34  /**
35   * A Struts Action for interfacing with the Quick Links system
36   *
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   */
39  public class QuickLinksAction extends KewKualiAction {
40  
41      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(QuickLinksAction.class);
42  
43      @Override
44      public ActionForward execute(ActionMapping mapping, ActionForm form,
45              HttpServletRequest request, HttpServletResponse response)
46              throws Exception {
47          initForm(request, form);
48          return super.execute(mapping, form, request, response);
49      }
50  
51      public void initForm(HttpServletRequest request, ActionForm form) throws Exception {
52          QuickLinksForm quickLinksForm = (QuickLinksForm)form;
53          String principalId = getUserSession().getPrincipalId();
54          LOG.debug("getting Action List Stats");
55          quickLinksForm.setActionListStats(getQuickLinksService().getActionListStats(principalId));
56          LOG.debug("finished getting Action List Stats");
57  
58          LOG.debug("getting Initiated Document Types");
59          quickLinksForm.setInitiatedDocumentTypes(getQuickLinksService().getInitiatedDocumentTypesList(principalId));
60          LOG.debug("finished getting Initiated Document Types");
61  
62          LOG.debug("getting Named Searches");
63          List namedSearches = new ArrayList();
64          namedSearches.addAll(getQuickLinksService().getNamedSearches(principalId));
65          quickLinksForm.setNamedSearches(namedSearches);
66          request.setAttribute("namedSearches",namedSearches);
67          LOG.debug("finished getting Named Searches");
68  
69          LOG.debug("getting Recent Searches");
70          quickLinksForm.setRecentSearches(getQuickLinksService().getRecentSearches(principalId));
71          LOG.debug("finished getting Recent Searches");
72  
73          LOG.debug("getting Watched Documents");
74          quickLinksForm.setWatchedDocuments(getQuickLinksService().getWatchedDocuments(principalId));
75          LOG.debug("finished getting Watched Documents");
76      }
77  
78  
79  
80      private QuickLinksService getQuickLinksService() {
81          return ((QuickLinksService)KEWServiceLocator.getService(KEWServiceLocator.QUICK_LINKS_SERVICE));
82      }
83      private static UserSession getUserSession() {
84          return GlobalVariables.getUserSession();
85      }
86  
87  }