KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > controls > EndCustomize


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 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
17 package org.apache.jetspeed.modules.actions.controls;
18
19 // Turbine stuff
20
import org.apache.turbine.modules.Action;
21 import org.apache.turbine.util.DynamicURI;
22 import org.apache.turbine.util.RunData;
23
24 // Jetspeed stuff
25
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
26 import org.apache.jetspeed.services.logging.JetspeedLogger;
27 import org.apache.jetspeed.services.rundata.JetspeedRunData;
28 import org.apache.jetspeed.util.template.JetspeedLink;
29 import org.apache.jetspeed.util.template.JetspeedLinkFactory;
30
31 /**
32  * This action must be invoked to clean up the customization
33  * state and redirect the user to his portal hompage
34  *
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  */

39 public class EndCustomize extends Action
40 {
41     
42     /**
43      * Static initialization of the logger for this class
44      */

45     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(EndCustomize.class.getName());
46     
47     /**
48      * @param rundata The RunData object for the current request
49      */

50     public void doPerform( RunData data ) throws Exception JavaDoc
51     {
52         ((JetspeedRunData) data).cleanupFromCustomization();
53
54         // bring logged on user to homepage via HTTP redirect
55

56         try
57         {
58             JetspeedLink jsLink = JetspeedLinkFactory.getInstance(data);
59             DynamicURI duri = jsLink.getLink(JetspeedLink.CURRENT,null,null,JetspeedLink.CURRENT,null);
60             String JavaDoc mtype = data.getParameters().getString("mtype");
61             if (mtype != null)
62             {
63                 jsLink.setMediaType(mtype);
64                 duri = jsLink.addQueryData("mtype", mtype);
65                 duri = duri.addPathInfo("media-type", mtype);
66                 String JavaDoc language = data.getParameters().getString("language");
67                 if(language != null)
68                 {
69                     duri = duri.addQueryData("language",language);
70                     String JavaDoc country = data.getParameters().getString("country");
71                     if(country != null)
72                     {
73                         duri = duri.addQueryData("country", country);
74                     }
75                 }
76             }
77             
78             data.setRedirectURI(duri.toString());
79             JetspeedLinkFactory.putInstance(jsLink);
80             jsLink = null;
81         }
82         catch (Exception JavaDoc e)
83         {
84             logger.error("Error while trying to bring user back to home page", e);
85         }
86     }
87 }
88
89
Popular Tags