KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > action > core > cache > FlushAllCacheAction


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 com.blandware.atleap.webapp.action.core.cache;
17
18 import com.blandware.atleap.webapp.action.core.BaseAction;
19 import com.blandware.atleap.webapp.util.core.CacheUtil;
20 import org.apache.struts.action.*;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24
25 /**
26  * <p>Flushes all cache
27  * </p>
28  * <p><a HREF="FlushAllCacheAction.java.htm"><i>View Source</i></a></p>
29  * <p/>
30  *
31  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
32  * @version $Revision: 1.6 $ $Date: 2006/03/26 11:47:34 $
33  * @struts.action path="/core/cache/flushAll"
34  * validate="false"
35  * roles="core-globalOperations-flushCache"
36  * @struts.action-forward name="unsatisfiable"
37  * path="/core/globalProperty/list.do"
38  */

39 public final class FlushAllCacheAction extends BaseAction {
40     /**
41      * @param mapping The ActionMapping used to select this instance
42      * @param form The optional ActionForm bean for this request (if any)
43      * @param request The HTTP request we are proceeding
44      * @param response The HTTP response we are creating
45      * @return an ActionForward instance describing where and how
46      * control should be forwarded, or null if response
47      * has already been completed
48      */

49     public ActionForward execute(ActionMapping mapping, ActionForm form,
50                                  HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
51
52         // flush all cache
53
CacheUtil.getInstance(request).flushAllCache();
54
55         ActionMessages messages = new ActionMessages();
56         messages.add("operationSuccessful", new ActionMessage("core.globalOperation.messages.flushAllCacheSuccessful"));
57         saveMessages(request, messages);
58
59         String JavaDoc redirectUrl = request.getParameter("redirectUrl");
60         if ( redirectUrl != null && redirectUrl.trim().length() != 0 ) {
61             ActionForward redirect = new ActionForward();
62             redirect.setRedirect(true);
63             redirect.setPath(redirectUrl);
64             return redirect;
65         } else {
66             return mapping.findForward("admin");
67         }
68     }
69 }
Popular Tags