Update of
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher
In directory james.mmbase.org:/tmp/cvs-serv14177
Modified Files:
NewsletterPublisher.java
Log Message:
CMSC-811,Create a newsletter publication,add cache
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher
See also: http://www.mmbase.org/jira/browse/CMSC-811
Index: NewsletterPublisher.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/NewsletterPublisher.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- NewsletterPublisher.java 7 May 2008 08:25:00 -0000 1.25
+++ NewsletterPublisher.java 20 May 2008 05:09:21 -0000 1.26
@@ -39,6 +39,8 @@
import com.finalist.newsletter.domain.Newsletter;
import com.finalist.newsletter.domain.Publication;
import com.finalist.newsletter.domain.Subscription;
+import com.finalist.newsletter.publisher.cache.CacheFactory;
+import com.finalist.newsletter.publisher.cache.ICache;
import com.finalist.newsletter.util.NewsletterUtil;
public class NewsletterPublisher {
@@ -149,23 +151,31 @@
throws MessagingException {
String url = NewsletterUtil.getTermURL(publication.getUrl(), subscription
.getTerms(), publication.getId());
-
- int articleCounts = NewsletterUtil.countArticlesByNewsletter(publication
- .getNewsletterId());
-
+ ICache cache = null;
+ String expiration =
PropertiesUtil.getProperty("publication.cache.expiration");
+ if(StringUtils.isEmpty(expiration)) {
+ cache = CacheFactory.getDefaultCache();
+ }
+ else {
+ cache = CacheFactory.getDefaultCache(Long.parseLong(expiration));
+ }
String content = " ";
+ if (!cache.contains(url)) {
+ int articleCounts =
NewsletterUtil.countArticlesByNewsletter(publication.getNewsletterId());
if (articleCounts == 0&&publication.getNewsletter().getSendempty()) {
content = publication.getNewsletter().getTxtempty();
}
else {
content = NewsletterGenerator.generate(url,
subscription.getMimeType());
}
-
if (null != getPersonalise()) {
- content = getPersonalise().personalise(content, subscription,
- publication);
+ content = getPersonalise().personalise(content,
subscription,publication);
+ }
+ cache.add(url, content);
+ }
+ else{
+ content=(String) cache.get(url);
}
-
return content + "\n";
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs