You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by "Setera, Craig" <Cr...@Kingland.com> on 2002/01/14 23:29:14 UTC
Please Help: Howto Expire RSS Portlets Programmatically?
Hello all,
I asked about this once before, but received no response. Not sure if
people just don't know the answer or if my original request was missed.
Hopefully it was the latter and my asking again won't be too much of a
bother.
My company is busy building things around the excellent Jetspeed 1.3a2
release of the portal. We have built a number of "local" OCS content feeds
that are managed on the local disk. In addition, we have built a very
simple content management front-end to add content to the OCS/RSS stream.
We would like to be able to flush all of the affected RSS portlets
immediately following an update to one of the RSS files such that the next
load of the portlet will show the new/removed items. Unfortunately, I can't
seem to get this to work. I've coded up the following in hopes of clearing
the changed portlet, but it doesn't seem to work for some reason.
/**
* Flush the cached version of the portlet that wraps
* the specified RSS content stream.
*/
protected void flushRssPortlet(String rss) {
// Get access the the portlet factory service
ServiceBroker serviceBroker = TurbineServices.getInstance();
PortletFactoryService portletFactory =
(PortletFactoryService)
serviceBroker.getService(PortletFactoryService.SERVICE_NAME);
// Look up the portlet in the factory
Portlet portlet = null;
try {
portlet = portletFactory.getPortlet(rss);
} catch (PortletException e) {
// munch
}
// If we found it, pull its cache key and remove
// it from the caches
if (portlet != null) {
// First, clear the disk cache
String diskCacheURL = portlet.getPortletConfig().getURL();
JetspeedDiskCache.getInstance().refresh(diskCacheURL);
// Then the portlet cache
if (portlet instanceof Cacheable) {
String cacheKey = ((Cacheable) portlet).getHandle();
// OK. We have the cache key now. Remove from the
// portlet cache
PortletCache.removeCacheable(cacheKey);
}
}
}
Part of this *may* be due to the fact that the FileWatcherExpire object does
not seem to be intialized when the portlet is initially created.
Unfortunately, even forcing the expire object to be created/initialized
didn't fix things.
Can anyone offer any insights or thoughts on how to solve this? I have run
out of ideas and could really use some help.
Thanks,
Craig
Craig Setera
Sun Certified Java Programmer/Developer/Web Component Developer
Senior Software Architect, Kingland Systems Corporation
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Please Help: Howto Expire RSS Portlets Programmatically?
Posted by Paul Spencer <pa...@apache.org>.
Craig,
In the case of an RSS feed, I think you can set a expiration date in the
HTTP header. Thus, the RSS Content can be refreshed every 5 minutes.
You can manually "expire" the "cache" by deleting the related files in
<jetspeed-home>/WEB-INF/cache
> PortletCache.removeCacheable(cacheKey);
This is just removing the portlet header form the cache, the content is
still in the disk cache.
Paul Spencer
Setera, Craig wrote:
> Hello all,
>
> I asked about this once before, but received no response. Not sure if
> people just don't know the answer or if my original request was missed.
> Hopefully it was the latter and my asking again won't be too much of a
> bother.
>
> My company is busy building things around the excellent Jetspeed 1.3a2
> release of the portal. We have built a number of "local" OCS content feeds
> that are managed on the local disk. In addition, we have built a very
> simple content management front-end to add content to the OCS/RSS stream.
> We would like to be able to flush all of the affected RSS portlets
> immediately following an update to one of the RSS files such that the next
> load of the portlet will show the new/removed items. Unfortunately, I can't
> seem to get this to work. I've coded up the following in hopes of clearing
> the changed portlet, but it doesn't seem to work for some reason.
>
> /**
> * Flush the cached version of the portlet that wraps
> * the specified RSS content stream.
> */
> protected void flushRssPortlet(String rss) {
> // Get access the the portlet factory service
> ServiceBroker serviceBroker = TurbineServices.getInstance();
> PortletFactoryService portletFactory =
> (PortletFactoryService)
> serviceBroker.getService(PortletFactoryService.SERVICE_NAME);
>
> // Look up the portlet in the factory
> Portlet portlet = null;
> try {
> portlet = portletFactory.getPortlet(rss);
> } catch (PortletException e) {
> // munch
> }
>
> // If we found it, pull its cache key and remove
> // it from the caches
> if (portlet != null) {
> // First, clear the disk cache
> String diskCacheURL = portlet.getPortletConfig().getURL();
> JetspeedDiskCache.getInstance().refresh(diskCacheURL);
>
> // Then the portlet cache
> if (portlet instanceof Cacheable) {
> String cacheKey = ((Cacheable) portlet).getHandle();
>
> // OK. We have the cache key now. Remove from the
> // portlet cache
> PortletCache.removeCacheable(cacheKey);
> }
> }
> }
>
> Part of this *may* be due to the fact that the FileWatcherExpire object does
> not seem to be intialized when the portlet is initially created.
> Unfortunately, even forcing the expire object to be created/initialized
> didn't fix things.
>
> Can anyone offer any insights or thoughts on how to solve this? I have run
> out of ideas and could really use some help.
>
> Thanks,
> Craig
>
> Craig Setera
> Sun Certified Java Programmer/Developer/Web Component Developer
> Senior Software Architect, Kingland Systems Corporation
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Please Help: Howto Expire RSS Portlets Programmatically?
Posted by David Sean Taylor <da...@bluesunrise.com>.
Are you using the RSSPortlet or NewRSSPortlet?
I believe you should be using the new.
To control the expiration, override the getExpire() method.
----- Original Message -----
From: "Setera, Craig" <Cr...@Kingland.com>
To: "Jetspeed Developers List" <je...@jakarta.apache.org>
Sent: Monday, January 14, 2002 2:29 PM
Subject: Please Help: Howto Expire RSS Portlets Programmatically?
> Hello all,
>
> I asked about this once before, but received no response. Not sure if
> people just don't know the answer or if my original request was missed.
> Hopefully it was the latter and my asking again won't be too much of a
> bother.
>
> My company is busy building things around the excellent Jetspeed 1.3a2
> release of the portal. We have built a number of "local" OCS content
feeds
> that are managed on the local disk. In addition, we have built a very
> simple content management front-end to add content to the OCS/RSS stream.
> We would like to be able to flush all of the affected RSS portlets
> immediately following an update to one of the RSS files such that the next
> load of the portlet will show the new/removed items. Unfortunately, I
can't
> seem to get this to work. I've coded up the following in hopes of
clearing
> the changed portlet, but it doesn't seem to work for some reason.
>
> /**
> * Flush the cached version of the portlet that wraps
> * the specified RSS content stream.
> */
> protected void flushRssPortlet(String rss) {
> // Get access the the portlet factory service
> ServiceBroker serviceBroker = TurbineServices.getInstance();
> PortletFactoryService portletFactory =
> (PortletFactoryService)
> serviceBroker.getService(PortletFactoryService.SERVICE_NAME);
>
> // Look up the portlet in the factory
> Portlet portlet = null;
> try {
> portlet = portletFactory.getPortlet(rss);
> } catch (PortletException e) {
> // munch
> }
>
> // If we found it, pull its cache key and remove
> // it from the caches
> if (portlet != null) {
> // First, clear the disk cache
> String diskCacheURL = portlet.getPortletConfig().getURL();
> JetspeedDiskCache.getInstance().refresh(diskCacheURL);
>
> // Then the portlet cache
> if (portlet instanceof Cacheable) {
> String cacheKey = ((Cacheable) portlet).getHandle();
>
> // OK. We have the cache key now. Remove from the
> // portlet cache
> PortletCache.removeCacheable(cacheKey);
> }
> }
> }
>
> Part of this *may* be due to the fact that the FileWatcherExpire object
does
> not seem to be intialized when the portlet is initially created.
> Unfortunately, even forcing the expire object to be created/initialized
> didn't fix things.
>
> Can anyone offer any insights or thoughts on how to solve this? I have
run
> out of ideas and could really use some help.
>
> Thanks,
> Craig
>
> Craig Setera
> Sun Certified Java Programmer/Developer/Web Component Developer
> Senior Software Architect, Kingland Systems Corporation
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>