01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.pluto.driver;
18:
19: import org.apache.pluto.driver.services.portal.admin.DriverAdministrationException;
20: import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
21: import org.apache.pluto.driver.config.AdminConfiguration;
22:
23: import javax.servlet.http.HttpServlet;
24: import javax.servlet.http.HttpServletRequest;
25: import javax.servlet.http.HttpServletResponse;
26: import javax.servlet.ServletException;
27: import java.io.IOException;
28:
29: /**
30: * Publishing administrative servlet.
31: * Allows external clients to connect and notify the portal
32: * of available portlet applications.
33: *
34: * @version 1.0
35: * @since Nov 23, 2005
36: */
37: public class PublishServlet extends HttpServlet {
38:
39: protected void doGet(HttpServletRequest req, HttpServletResponse res)
40: throws ServletException, IOException {
41:
42: String context = req.getParameter("context");
43: try {
44: doPublish(context);
45: } catch (Throwable t) {
46: StringBuffer sb = new StringBuffer();
47: sb
48: .append("Unable to publish portlet application bound to context '"
49: + context + "'.");
50: sb.append("Reason: ").append(t.getMessage());
51: res.getWriter().println(sb.toString());
52: }
53: }
54:
55: private void doPublish(String context)
56: throws DriverAdministrationException {
57: AdminConfiguration adminConfig = (AdminConfiguration) getServletContext()
58: .getAttribute(AttributeKeys.DRIVER_ADMIN_CONFIG);
59:
60: PortletRegistryAdminService admin = adminConfig
61: .getPortletRegistryAdminService();
62:
63: admin.addPortletApplication(context);
64: }
65: }
|