01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.quicklinks.web;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import javax.servlet.http.HttpServletRequest;
23: import javax.servlet.http.HttpServletResponse;
24:
25: import org.apache.struts.action.ActionForm;
26: import org.apache.struts.action.ActionForward;
27: import org.apache.struts.action.ActionMapping;
28: import org.apache.struts.action.ActionMessages;
29:
30: import edu.iu.uis.eden.KEWServiceLocator;
31: import edu.iu.uis.eden.quicklinks.QuickLinksService;
32: import edu.iu.uis.eden.user.WorkflowUser;
33: import edu.iu.uis.eden.web.KeyValue;
34: import edu.iu.uis.eden.web.WorkflowAction;
35:
36: /**
37: * A Struts Action for interfacing with the Quick Links system
38: *
39: * @author bmcgough
40: */
41: public class QuickLinksAction extends WorkflowAction {
42:
43: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
44: .getLogger(QuickLinksAction.class);
45:
46: public ActionForward start(ActionMapping mapping, ActionForm form,
47: HttpServletRequest request, HttpServletResponse response)
48: throws Exception {
49: return mapping.findForward("basic");
50: }
51:
52: public ActionMessages establishRequiredState(
53: HttpServletRequest request, ActionForm form)
54: throws Exception {
55: QuickLinksForm quickLinksForm = (QuickLinksForm) form;
56: WorkflowUser user = getUserSession(request).getWorkflowUser();
57: LOG.debug("getting Action List Stats");
58: quickLinksForm.setActionListStats(getQuickLinksService()
59: .getActionListStats(user));
60: LOG.debug("finished getting Action List Stats");
61:
62: LOG.debug("getting Initiated Document Types");
63: quickLinksForm.setInitiatedDocumentTypes(getQuickLinksService()
64: .getInitiatedDocumentTypesList(user));
65: LOG.debug("finished getting Initiated Document Types");
66:
67: LOG.debug("getting Named Searches");
68: List namedSearches = new ArrayList();
69: namedSearches.add(new KeyValue("", "Named Searches"));
70: namedSearches.addAll(getQuickLinksService().getNamedSearches(
71: user));
72: quickLinksForm.setNamedSearches(namedSearches);
73: request.setAttribute("namedSearches", namedSearches);
74: LOG.debug("finished getting Named Searches");
75:
76: LOG.debug("getting Recent Searches");
77: quickLinksForm.setRecentSearches(getQuickLinksService()
78: .getRecentSearches(user));
79: LOG.debug("finished getting Recent Searches");
80:
81: LOG.debug("getting Watched Documents");
82: quickLinksForm.setWatchedDocuments(getQuickLinksService()
83: .getWatchedDocuments(user));
84: LOG.debug("finished getting Watched Documents");
85: return null;
86: }
87:
88: private QuickLinksService getQuickLinksService() {
89: return ((QuickLinksService) KEWServiceLocator
90: .getService(KEWServiceLocator.QUICK_LINKS_SERVICE));
91: }
92: }
|