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

Modified Files:
        NewsletterUtil.java 
Log Message:
CMSC-725 fix a bug.


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/util
See also: http://www.mmbase.org/jira/browse/CMSC-725


Index: NewsletterUtil.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/util/NewsletterUtil.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- NewsletterUtil.java 14 May 2008 05:32:48 -0000      1.27
+++ NewsletterUtil.java 15 May 2008 06:42:50 -0000      1.28
@@ -326,7 +326,7 @@
       if (number > 0) {
          Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
          Node newsletterNode = cloud.getNode(number);
-         return isPaused(newsletterNode);
+         return "true".equals(newsletterNode.getStringValue("paused"));
       }
       return (false);
    }
@@ -341,11 +341,13 @@
    }
 
    public static void pauseNewsletter(int number) {
+
       if (number > 0) {
+         log.debug("Pause newsletter " + number);
          Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
          Node newsletterNode = cloud.getNode(number);
          if (newsletterNode != null) {
-            newsletterNode.setBooleanValue("paused", true);
+            newsletterNode.setStringValue("paused", "true");
             newsletterNode.commit();
          }
       }
@@ -356,7 +358,7 @@
          Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
          Node newsletterNode = cloud.getNode(number);
          if (newsletterNode != null) {
-            newsletterNode.setBooleanValue("paused", false);
+            newsletterNode.setStringValue("paused", "false");
             newsletterNode.commit();
          }
       }
@@ -391,25 +393,14 @@
    }
 
 
-   public static String getHostUrl() {
-      String url = getServerURL();
-      if (StringUtils.isNotBlank(getApplicatoinURL())) {
-         url += getApplicatoinURL();
-      }
-      if (!url.endsWith("/")) {
-         url += "/";
-      }
-      return url;
-   }
-
    public static String getServerURL() {
-      String hostUrl = PropertiesUtil.getProperty("host");
+         String hostUrl = PropertiesUtil.getProperty("system.livepath");
 
       if (StringUtils.isEmpty(hostUrl)) {
-         throw new NewsletterSendFailException("get property <host> from 
system property and get nothing");
+         throw new NewsletterSendFailException("get property <system.livepath> 
from system property and get nothing");
       }
 
-      log.debug("get property <host> from system property and get:" + hostUrl);
+      log.debug("get property <system.livepath> from system property and get:" 
+ hostUrl);
 
       if (!hostUrl.endsWith("/")) {
          hostUrl += "/";
@@ -417,24 +408,35 @@
       return hostUrl;
    }
 
-   public static String getApplicatoinURL() {
-      String application = PropertiesUtil.getProperty("application");
-
-      if (StringUtils.isEmpty(application)) {
-         throw new NewsletterSendFailException("get property <application> 
from system property and get nothing");
-      }
-
-      log.debug("get property <host> from system property and get:" + 
application);
-
-      return application;
-   }
 
        public static void logPubliction(int newsletterId, HANDLE handle) {
       StatisticServiceImpl service = new StatisticServiceImpl();
-      NewsLetterStatisticCAOImpl statisticCAO= new 
NewsLetterStatisticCAOImpl();
+      NewsLetterStatisticCAOImpl statisticCAO = new 
NewsLetterStatisticCAOImpl();
       Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
       statisticCAO.setCloud(cloud);
       service.setStatisticCAO(statisticCAO);
-      service.logPubliction(newsletterId,handle);
+      service.logPubliction(newsletterId, handle);
+   }
+
+
+   public static String calibrateRelativeURL(String inputString) {
+      return calibrateRelativeURL(inputString, NewsletterUtil.getServerURL());
+   }
+
+   public static String calibrateRelativeURL(String inputString, String 
liveURL) {
+
+      if (liveURL.charAt(liveURL.length() - 1) == '/') {
+         liveURL = liveURL.substring(0, liveURL.lastIndexOf("/"));
+      }
+
+      if (StringUtils.split(liveURL, "/").length > 2) {
+         liveURL = liveURL.substring(0, liveURL.lastIndexOf("/"));
+      }
+
+      liveURL += "/";
+
+      inputString = StringUtils.replace(inputString, "href=\"/", "href=\"" + 
liveURL);
+      inputString = StringUtils.replace(inputString, "src=\"/", "src=\"" + 
liveURL);
+      return inputString;
    }
 }
\ No newline at end of file
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to