KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > action > core > applicationResource > ReloadResourcesAction


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.applicationResource;
17
18 import com.blandware.atleap.webapp.action.core.BaseAction;
19 import com.blandware.atleap.webapp.util.core.ApplicationResources;
20 import org.apache.struts.action.*;
21 import org.apache.commons.validator.GenericValidator;
22
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.http.HttpServletResponse JavaDoc;
25
26 /**
27  * <p>Reloads all application resources from file system. All changes, made through admin console, will be lost
28  * </p>
29  * <p><a HREF="ReloadResourcesAction.java.htm"><i>View Source</i></a></p>
30  * <p/>
31  *
32  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
33  * @version $Revision: 1.7 $ $Date: 2006/03/26 11:47:33 $
34  * @struts.action path="/core/applicationResource/reload"
35  * validate="false"
36  * roles="core-globalOperations-reloadResources"
37  * @struts.action-forward name="unsatisfiable"
38  * path="/core/globalProperty/list.do"
39  */

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

50     public ActionForward execute(ActionMapping mapping, ActionForm form,
51                                  HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
52
53         // reindex all entities
54
ApplicationResources.getInstance(servlet.getServletContext()).reloadResources();
55
56         ActionMessages messages = new ActionMessages();
57         messages.add("operationSuccessful", new ActionMessage("core.globalOperation.messages.reloadResourcesSuccessful"));
58         saveMessages(request, messages);
59
60         String JavaDoc redirectUrl = request.getParameter("redirectUrl");
61         if ( !GenericValidator.isBlankOrNull(redirectUrl) ) {
62             ActionForward redirect = new ActionForward();
63             redirect.setRedirect(true);
64             redirect.setPath(redirectUrl);
65             return redirect;
66         } else {
67             return mapping.findForward("admin");
68         }
69     }
70 }
Popular Tags