001 /* 002 * Copyright 2005-2008 The Kuali Foundation 003 * 004 * 005 * Licensed under the Educational Community License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.opensource.org/licenses/ecl2.php 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.kuali.rice.kew.quicklinks.web; 018 019 import java.util.ArrayList; 020 import java.util.List; 021 022 import javax.servlet.http.HttpServletRequest; 023 import javax.servlet.http.HttpServletResponse; 024 025 import org.apache.struts.action.ActionForm; 026 import org.apache.struts.action.ActionForward; 027 import org.apache.struts.action.ActionMapping; 028 import org.kuali.rice.kew.quicklinks.service.QuickLinksService; 029 import org.kuali.rice.kew.service.KEWServiceLocator; 030 import org.kuali.rice.kew.web.KewKualiAction; 031 import org.kuali.rice.krad.UserSession; 032 import org.kuali.rice.krad.util.GlobalVariables; 033 034 035 /** 036 * A Struts Action for interfacing with the Quick Links system 037 * 038 * @author Kuali Rice Team (rice.collab@kuali.org) 039 */ 040 public class QuickLinksAction extends KewKualiAction { 041 042 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(QuickLinksAction.class); 043 044 @Override 045 public ActionForward execute(ActionMapping mapping, ActionForm form, 046 HttpServletRequest request, HttpServletResponse response) 047 throws Exception { 048 initForm(request, form); 049 return super.execute(mapping, form, request, response); 050 } 051 052 public void initForm(HttpServletRequest request, ActionForm form) throws Exception { 053 QuickLinksForm quickLinksForm = (QuickLinksForm)form; 054 String principalId = getUserSession().getPrincipalId(); 055 LOG.debug("getting Action List Stats"); 056 quickLinksForm.setActionListStats(getQuickLinksService().getActionListStats(principalId)); 057 LOG.debug("finished getting Action List Stats"); 058 059 LOG.debug("getting Initiated Document Types"); 060 quickLinksForm.setInitiatedDocumentTypes(getQuickLinksService().getInitiatedDocumentTypesList(principalId)); 061 LOG.debug("finished getting Initiated Document Types"); 062 063 LOG.debug("getting Named Searches"); 064 List namedSearches = new ArrayList(); 065 namedSearches.addAll(getQuickLinksService().getNamedSearches(principalId)); 066 quickLinksForm.setNamedSearches(namedSearches); 067 request.setAttribute("namedSearches",namedSearches); 068 LOG.debug("finished getting Named Searches"); 069 070 LOG.debug("getting Recent Searches"); 071 quickLinksForm.setRecentSearches(getQuickLinksService().getRecentSearches(principalId)); 072 LOG.debug("finished getting Recent Searches"); 073 074 LOG.debug("getting Watched Documents"); 075 quickLinksForm.setWatchedDocuments(getQuickLinksService().getWatchedDocuments(principalId)); 076 LOG.debug("finished getting Watched Documents"); 077 } 078 079 080 081 private QuickLinksService getQuickLinksService() { 082 return ((QuickLinksService)KEWServiceLocator.getService(KEWServiceLocator.QUICK_LINKS_SERVICE)); 083 } 084 private static UserSession getUserSession() { 085 return GlobalVariables.getUserSession(); 086 } 087 088 }