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.portals.applications.rss;
18:
19: import java.io.IOException;
20:
21: import javax.portlet.ActionRequest;
22: import javax.portlet.ActionResponse;
23: import javax.portlet.PortletConfig;
24: import javax.portlet.PortletException;
25: import javax.portlet.RenderRequest;
26: import javax.portlet.RenderResponse;
27:
28: import org.apache.portals.applications.rss.servlets.SpringInitServlet;
29: import org.apache.portals.applications.transform.Transform;
30: import org.apache.portals.applications.transform.TransformCache;
31: import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
32: import org.springframework.beans.factory.BeanFactory;
33:
34: /**
35: * AbstractRssPortlet
36: *
37: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
38: * @version $Id: AbstractRssPortlet.java 516448 2007-03-09 16:25:47Z ate $
39: */
40: public abstract class AbstractRssPortlet extends GenericVelocityPortlet {
41: protected TransformCache cache;
42: protected Transform transform;
43:
44: public void init(PortletConfig config) throws PortletException {
45: super .init(config);
46: BeanFactory factory = SpringInitServlet.getSpringFactory();
47: cache = (TransformCache) factory.getBean("transformCache");
48: transform = (Transform) factory.getBean("transform");
49: }
50:
51: public void doEdit(RenderRequest request, RenderResponse response)
52: throws PortletException, IOException {
53: response.setContentType("text/html");
54: doPreferencesEdit(request, response);
55: }
56:
57: /**
58: * Save the prefs
59: */
60: public void processAction(ActionRequest request,
61: ActionResponse actionResponse) throws PortletException,
62: IOException {
63: processPreferencesAction(request, actionResponse);
64: String url = request.getPreferences().getValue("url",
65: "http://www.npr.org/rss/rss.php?topicId=4");
66: String stylesheet = getPortletConfig().getInitParameter(
67: "stylesheet");
68: String key = cache.constructKey(url, stylesheet); // TODO: use the entire parameter list
69: cache.remove(key);
70: }
71:
72: }
|