1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 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
52 {
53 super.buildNormalContext(portlet, context, rundata);
54
55 String 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 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
82 {
83 super.updateRegistryEntry(rundata, registryEntry);
84
85 PortletControlEntry controllerEntry =
86 (PortletControlEntry) registryEntry;
87 String 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 }