KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > portlet > AdminPortlet


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.core.portlet;
10
11 import java.io.IOException JavaDoc;
12
13 import javax.portlet.ActionRequest;
14 import javax.portlet.ActionResponse;
15 import javax.portlet.GenericPortlet;
16 import javax.portlet.PortletException;
17 import javax.portlet.PortletSecurityException;
18 import javax.portlet.RenderRequest;
19 import javax.portlet.RenderResponse;
20
21 /**
22  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
23  * @version $Revision: 1.3 $
24  */

25 public class AdminPortlet extends GenericPortlet {
26
27     public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException JavaDoc {
28 // PortalObjectContainer metaData = (PortalObjectContainer) req.getAttribute("CONTAINER");
29
// PropertyStore store = (PropertyStore) req.getAttribute("STORE");
30
//
31
// String instanceName = req.getParameter("instance");
32
// String windowName = req.getParameter("window");
33
// String add = req.getParameter("add");
34
// String remove = req.getParameter("remove");
35
//
36
// Application application = null;
37
// if (req.getParameter("application") != null) {
38
// application = metaData.getApplication(req.getParameter("application"));
39
// }
40
//
41
// CorePortal portal = null;
42
// if (req.getParameter("portal") != null) {
43
// portal = (CorePortal) metaData.getPortal(req.getParameter("portal"));
44
// }
45
//
46
// if ("portal".equals(add)) {
47
// try {
48
// String portalName = req.getParameter("portal");
49
// PortalObjectID portalID = PortalObjectID.createPortalID(portalName);
50
// PortalMetaData portalMD = new PortalMetaData(portalName);
51
// portal = (CorePortal) metaData.getManager().getObjectFactory().create(portalMD);
52
// metaData.getManager().getKernel().register(portalID, portal, new ServiceID[]{PortalObjectID.createPortalContainerID()});
53
// metaData.getManager().getKernel().start(portalID);
54
// } catch (KernelException e) {
55
// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
56
// }
57
// }
58
// if ("instance".equals(add)) {
59
// for (Iterator i = application.getComponents().iterator(); i.hasNext();) {
60
// Component component = (Component) i.next();
61
// if (req.getParameter(component.getKey()) != null) {
62
// try {
63
// Instance instance = application.createInstance(instanceName);
64
// PortalObjectID instanceID = PortalObjectID.createInstanceID(portal.getID(), instance.getKey());
65
// metaData.getManager().getKernel().register(instanceID, instance, new ServiceID[]{portal.getID(), component.getID()});
66
// metaData.getManager().getKernel().start(instanceID);
67
// } catch (KernelException e) {
68
// e.printStackTrace();
69
// }
70
// }
71
// }
72
//// InstanceMetaData instanceMD = new InstanceMetaData(instance, application, component, portal);
73
//// try
74
//// {
75
//// metaData.getInstanceSet().addObject(instanceMD);
76
//// resp.setRenderParameter("application", application);
77
//// resp.setRenderParameter("component", component);
78
//// }
79
//// catch (DuplicateMetaDataException e)
80
//// {
81
//// e.printStackTrace();
82
//// }
83
// } else if ("window".equals(add)) {
84
// String region = req.getParameter("region");
85
// String height = req.getParameter("height");
86
//
87
// MutablePropertySet props = null;
88
//
89
// try {
90
// Instance instance = portal.getInstance(instanceName);
91
// Window window = instance.getComponent().getApplication().createWindow(windowName);
92
// PortalObjectID instanceID = instance.getID();
93
// PortalObjectID windowID = PortalObjectID.createWindowID(instanceID, windowName);
94
//
95
//// resp.setRenderParameter("application", application);
96
//// resp.setRenderParameter("component", component);
97
//// resp.setRenderParameter("instance", instance);
98
//// resp.setRenderParameter("portal", portal);
99
////
100
// PropertySetContext ctx = store.getContext(windowID);
101
// props = ctx.getBinding("MAMBO").getMutablePropertySet();
102
// props.setProperty("region", new StringValues(region));
103
// props.setProperty("height", new StringValues(height));
104
// props.flush();
105
//
106
// metaData.getManager().getKernel().register(windowID, window, new ServiceID[]{instanceID});
107
// metaData.getManager().getKernel().start(windowID);
108
//
109
// // Add to the page
110
// Page page = portal.getPageRepository().getDefaultPage();
111
// page.addWindow(windowID);
112
// } catch (Exception e) {
113
// e.printStackTrace();
114
// } finally {
115
// PortalUtils.safeClose(props);
116
// }
117
// } else if ("window".equals(remove)) {
118
// try {
119
// PortalObjectID windowID = PortalObjectID.createWindowID(portal.getKey(), instanceName, windowName);
120
// metaData.getManager().getKernel().destroy(windowID);
121
// metaData.getManager().getKernel().unregister(windowID);
122
// } catch (KernelException e) {
123
// e.printStackTrace();
124
// }
125
// } else if ("instance".equals(remove)) {
126
// try {
127
// PortalObjectID instanceID = PortalObjectID.createInstanceID(portal.getID(), instanceName);
128
// metaData.getManager().getKernel().destroy(instanceID);
129
// metaData.getManager().getKernel().unregister(instanceID);
130
// } catch (KernelException e) {
131
// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
132
// }
133
// }
134
}
135
136     public void render(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException JavaDoc {
137 // WindowState windowState = req.getWindowState();
138
// if (!WindowState.MINIMIZED.equals(windowState)) {
139
// String dest = "normal";
140
// AnnotatedPortletMode portletMode = req.getPortletMode();
141
// if (AnnotatedPortletMode.HELP.equals(portletMode)) {
142
// dest = "help";
143
// } else {
144
// String page = req.getParameter("page");
145
// if (WindowState.MAXIMIZED.equals(windowState)) {
146
// if ("component".equals(page)) {
147
// dest = "component";
148
// } else {
149
// dest = "index";
150
// }
151
// }
152
// }
153
// resp.setTitle("Admin portlet");
154
// resp.setContentType("text/html");
155
// PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/admin/" + dest + ".jsp");
156
// dispatcher.include(req, resp);
157
// }
158
}
159 }
160
Popular Tags