1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.modules.actions.controls;
1819// Turbine stuff20import org.apache.turbine.modules.Action;
21import org.apache.turbine.util.DynamicURI;
22import org.apache.turbine.util.RunData;
2324// Jetspeed stuff25import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
26import org.apache.jetspeed.services.logging.JetspeedLogger;
27import org.apache.jetspeed.services.rundata.JetspeedRunData;
28import org.apache.jetspeed.util.template.JetspeedLink;
29import org.apache.jetspeed.util.template.JetspeedLinkFactory;
3031/***32 * This action must be invoked to clean up the customization33 * state and redirect the user to his portal hompage34 *35 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>36 * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>37 * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>38 */39publicclassEndCustomizeextends Action
40 {
4142/***43 * Static initialization of the logger for this class44 */45privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(EndCustomize.class.getName());
4647/***48 * @param rundata The RunData object for the current request49 */50publicvoid doPerform( RunData data ) throws Exception
51 {
52 ((JetspeedRunData) data).cleanupFromCustomization();
5354// bring logged on user to homepage via HTTP redirect5556try57 {
58JetspeedLink jsLink = JetspeedLinkFactory.getInstance(data);
59 DynamicURI duri = jsLink.getLink(JetspeedLink.CURRENT,null,null,JetspeedLink.CURRENT,null);
60 String mtype = data.getParameters().getString("mtype");
61if (mtype != null)
62 {
63 jsLink.setMediaType(mtype);
64 duri = jsLink.addQueryData("mtype", mtype);
65 duri = duri.addPathInfo("media-type", mtype);
66 String language = data.getParameters().getString("language");
67if(language != null)
68 {
69 duri = duri.addQueryData("language",language);
70 String country = data.getParameters().getString("country");
71if(country != null)
72 {
73 duri = duri.addQueryData("country", country);
74 }
75 }
76 }
7778 data.setRedirectURI(duri.toString());
79 JetspeedLinkFactory.putInstance(jsLink);
80 jsLink = null;
81 }
82catch (Exception e)
83 {
84 logger.error("Error while trying to bring user back to home page", e);
85 }
86 }
87 }
88