Update of 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher
In directory 
james.mmbase.org:/tmp/cvs-serv30723/portlets-newsletter/src/java/com/finalist/newsletter/publisher

Modified Files:
        NewsletterPublisher.java NewsletterGenerator.java 
Log Message:
CMSC-818 remove unused file.


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-818


Index: NewsletterPublisher.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/NewsletterPublisher.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- NewsletterPublisher.java    5 May 2008 10:26:59 -0000       1.24
+++ NewsletterPublisher.java    7 May 2008 08:25:00 -0000       1.25
@@ -54,7 +54,8 @@
 
    enum MimeType {
       image, attachment
-   };
+   }
+
 
    public void deliver(Publication publication, Subscription subscription) {
       try {
@@ -71,9 +72,10 @@
          // setMIME(message, subscription.getMimeType());
 
          Transport.send(message);
-         log.debug("mail send! publication:" + publication.getId()
-               + "to subscription" + subscription.getId() + " in MIME"
-               + subscription.getMimeType());
+         log.debug(String.format(
+               "mail send! publication %s to %s in %s format",
+               publication.getId(), subscription.getId(), 
subscription.getMimeType())
+         );
       } 
       catch (MessagingException e) {
          log.error(e);
@@ -147,17 +149,16 @@
          throws MessagingException {
       String url = NewsletterUtil.getTermURL(publication.getUrl(), subscription
             .getTerms(), publication.getId());
+
       int articleCounts = NewsletterUtil.countArticlesByNewsletter(publication
             .getNewsletterId());
+
       String content = " ";
-      if (articleCounts == 0) {
-         if (publication.getNewsletter().getSendempty()) {
+      if (articleCounts == 0&&publication.getNewsletter().getSendempty()) {
             content = publication.getNewsletter().getTxtempty();
          }
-      } 
       else {
-         content = NewsletterGenerator
-               .generate(url, subscription.getMimeType());
+         content = NewsletterGenerator.generate(url, 
subscription.getMimeType());
       }
 
       if (null != getPersonalise()) {
@@ -190,7 +191,7 @@
 
       InternetAddress replyToAddress = new InternetAddress(emailReplyTo);
       replyToAddress.setPersonal(nameReplyTo);
-      message.setReplyTo(new InternetAddress[] { replyToAddress });
+      message.setReplyTo(new InternetAddress[]{replyToAddress});
 
    }
 
@@ -324,13 +325,15 @@
          }
          this.type = type;
       }
+
       /**
        * Return an InputStream for the data. Note - a new stream must be
        * returned each time.
        */
       public InputStream getInputStream() throws IOException {
-         if (data == null)
+         if (data == null) {
             throw new IOException("no data");
+         }
          return new ByteArrayInputStream(data);
       }
 


Index: NewsletterGenerator.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/NewsletterGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- NewsletterGenerator.java    29 Apr 2008 01:37:05 -0000      1.5
+++ NewsletterGenerator.java    7 May 2008 08:25:00 -0000       1.6
@@ -2,6 +2,7 @@
 
 import org.mmbase.util.logging.Logger;
 import org.mmbase.util.logging.Logging;
+import org.apache.commons.lang.StringUtils;
 
 import javax.mail.MessagingException;
 import java.io.InputStreamReader;
@@ -9,6 +10,8 @@
 import java.net.HttpURLConnection;
 import java.net.URL;
 
+import com.finalist.newsletter.util.NewsletterUtil;
+
 public class NewsletterGenerator {
 
    private static Logger log = 
Logging.getLoggerInstance(NewsletterGenerator.class.getName());
@@ -16,12 +19,12 @@
 
    public static String generate(String urlPath, String mimeType) throws 
MessagingException {
 
-      log.debug("generate newsletter from url:"+urlPath);
+      log.debug("generate newsletter from url:" + urlPath);
       
         String inputString = "";
       try {
 
-         log.debug("Try to get content from URL:"+urlPath);
+         log.debug("Try to get content from URL:" + urlPath);
 
          URL url = new URL(urlPath);
          HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
@@ -43,11 +46,19 @@
          reader.close();
 
          inputString = buffer.toString().trim();
+
+         inputString = calibrateRelativeURL(inputString);
          return (inputString);
       } catch (Exception e) {
-         log.debug("Error when try to get content from"+urlPath,e);
+         log.debug("Error when try to get content from" + urlPath, e);
       }
 
       return inputString;
    }
+
+   private static String calibrateRelativeURL(String inputString) {
+      String host = NewsletterUtil.getHostUrl();
+      host = StringUtils.remove(host,"\\\\","")
+      return StringUtils.replace(inputString, "<a href=\"/", "<a href=\"" + );
+   }
 }
\ No newline at end of file
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to