KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > portlets > ControlUpdateAction


1 /*
2  * Copyright 2000-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 package org.apache.jetspeed.modules.actions.portlets;
17
18 import org.apache.jetspeed.modules.actions.portlets.security.SecurityConstants;
19 import org.apache.jetspeed.om.registry.MediaTypeRegistry;
20 import org.apache.jetspeed.om.registry.PortletControlEntry;
21 import org.apache.jetspeed.om.registry.RegistryEntry;
22 import org.apache.jetspeed.portal.portlets.VelocityPortlet;
23 import org.apache.jetspeed.services.Registry;
24 import org.apache.turbine.util.RunData;
25 import org.apache.velocity.context.Context;
26
27 /**
28  * This action enables to update the control entries
29  *
30  * @author <a HREF="mailto:caius1440@hotmail.com">Jeremy Ford</a>
31  * @version $Id: ControlUpdateAction.java,v 1.2 2004/02/23 02:56:58 jford Exp $
32  */

33 public class ControlUpdateAction extends RegistryUpdateAction
34 {
35     private static final String JavaDoc CONTROL_UPDATE_PANE = "ControlForm";
36
37     public ControlUpdateAction()
38     {
39         registryEntryName = "control_name";
40         registry = Registry.PORTLET_CONTROL;
41         pane = CONTROL_UPDATE_PANE;
42     }
43
44     /**
45      * @see org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction#buildNormalContext(org.apache.jetspeed.portal.portlets.VelocityPortlet, org.apache.velocity.context.Context, org.apache.turbine.util.RunData)
46      */

47     protected void buildNormalContext(
48         VelocityPortlet portlet,
49         Context context,
50         RunData rundata)
51         throws Exception JavaDoc
52     {
53         super.buildNormalContext(portlet, context, rundata);
54
55         String JavaDoc mode =
56             rundata.getParameters().getString(SecurityConstants.PARAM_MODE);
57
58         if (mode != null
59             && (mode.equals(SecurityConstants.PARAM_MODE_DELETE)
60                 || mode.equals(SecurityConstants.PARAM_MODE_UPDATE)))
61         {
62             String JavaDoc controllerName =
63                 rundata.getParameters().getString(registryEntryName);
64             PortletControlEntry controlEntry =
65                 (PortletControlEntry) Registry.getEntry(
66                     registry,
67                     controllerName);
68             context.put("entry", controlEntry);
69
70             MediaTypeRegistry mediaTypeReg =
71                 (MediaTypeRegistry) Registry.get(Registry.MEDIA_TYPE);
72             context.put(
73                 "media_types",
74                 iteratorToCollection(mediaTypeReg.listEntryNames()));
75         }
76     }
77
78     protected void updateRegistryEntry(
79         RunData rundata,
80         RegistryEntry registryEntry)
81         throws Exception JavaDoc
82     {
83         super.updateRegistryEntry(rundata, registryEntry);
84
85         PortletControlEntry controllerEntry =
86             (PortletControlEntry) registryEntry;
87         String JavaDoc className = rundata.getParameters().getString("class_name");
88         if (hasChanged(controllerEntry.getClassname(), className))
89         {
90             controllerEntry.setClassname(className);
91         }
92     }
93
94     /**
95      * @see org.apache.jetspeed.modules.actions.portlets.RegistryUpdateAction#resetForm(org.apache.turbine.util.RunData)
96      */

97     protected void resetForm(RunData rundata)
98     {
99         super.resetForm(rundata);
100     }
101
102     /**
103      * @see org.apache.jetspeed.modules.actions.portlets.RegistryUpdateAction#clearUserData(org.apache.turbine.util.RunData)
104      */

105     protected void clearUserData(RunData rundata)
106     {
107         super.clearUserData(rundata);
108     }
109
110 }
111
Popular Tags