Author: jvdrean
Date: 2008-02-26 18:36:16 +0100 (Tue, 26 Feb 2008)
New Revision: 7970

Added:
   xwiki-platform/xwiki-applications/trunk/watchlist/
   xwiki-platform/xwiki-applications/trunk/watchlist/pom.xml
   xwiki-platform/xwiki-applications/trunk/watchlist/src/
   xwiki-platform/xwiki-applications/trunk/watchlist/src/main/
   xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/
   xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/
   
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
   
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/WatchListTest.java
Modified:
   xwiki-platform/xwiki-applications/trunk/pom.xml
   
xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/xwiki/plugin/watchlist/WatchListPlugin.java
   
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/AllTests.java
   xwiki-products/xwiki-enterprise/trunk/wiki/pom.xml
Log:
XPWATCHLIST-10 : Move the email template to a xwiki-application instead of 
creating it from java

Modified: xwiki-platform/xwiki-applications/trunk/pom.xml
===================================================================
--- xwiki-platform/xwiki-applications/trunk/pom.xml     2008-02-26 16:40:28 UTC 
(rev 7969)
+++ xwiki-platform/xwiki-applications/trunk/pom.xml     2008-02-26 17:36:16 UTC 
(rev 7970)
@@ -68,9 +68,10 @@
         <module>panels</module>
         <module>application-manager</module>
         <module>wiki-manager</module>
-        <module>scheduler</module>
+        <module>scheduler</module>        
         <module>s5</module>
         <module>statistics</module>
+        <module>watchlist</module>
       </modules>
     </profile>
     <profile>

Added: xwiki-platform/xwiki-applications/trunk/watchlist/pom.xml
===================================================================
--- xwiki-platform/xwiki-applications/trunk/watchlist/pom.xml                   
        (rev 0)
+++ xwiki-platform/xwiki-applications/trunk/watchlist/pom.xml   2008-02-26 
17:36:16 UTC (rev 7970)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.xpn.xwiki.platform.applications</groupId>
+    <artifactId>xwiki-applications</artifactId>
+    <version>9-SNAPSHOT</version>
+  </parent>
+  <artifactId>xwiki-application-watchlist</artifactId>
+  <name>XWiki Platform - Applications - WatchList</name>
+  <version>1.2-SNAPSHOT</version>
+  <packaging>xar</packaging>
+  <description>WatchList email template</description>
+  <dependencies>
+    <dependency>
+      <groupId>com.xpn.xwiki.platform.plugins</groupId>
+      <artifactId>xwiki-plugin-watchlist</artifactId>
+      <!-- We want to release the Watchlist plugin and application together. 
Hence they should have the same version -->
+      <version>1.2-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: 
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
===================================================================
--- 
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
                         (rev 0)
+++ 
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
 2008-02-26 17:36:16 UTC (rev 7970)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xwikidoc>
+<web>XWiki</web>
+<name>WatchListMessage</name>
+<language></language>
+<defaultLanguage></defaultLanguage>
+<translation>0</translation>
+<parent></parent>
+<creator></creator>
+<author></author>
+<customClass></customClass>
+<contentAuthor></contentAuthor>
+<creationDate>1197307330000</creationDate>
+<date>1197307330000</date>
+<contentUpdateDate>1197307330000</contentUpdateDate>
+<version>1.1</version>
+<title></title>
+<template></template>
+<defaultTemplate></defaultTemplate>
+<validationScript></validationScript>
+<comment></comment>
+<minorEdit>false</minorEdit>
+<object>
+<class>
+<name>XWiki.Mail</name>
+<customClass></customClass>
+<customMapping></customMapping>
+<defaultViewSheet></defaultViewSheet>
+<defaultEditSheet></defaultEditSheet>
+<defaultWeb></defaultWeb>
+<nameField></nameField>
+<validationScript></validationScript>
+<html>
+<name>html</name>
+<number>4</number>
+<prettyName>HTML</prettyName>
+<rows>15</rows>
+<size>80</size>
+<unmodifiable>0</unmodifiable>
+<classType>com.xpn.xwiki.objects.classes.TextAreaClass</classType>
+</html>
+<language>
+<name>language</name>
+<number>2</number>
+<prettyName>Language</prettyName>
+<size>5</size>
+<unmodifiable>0</unmodifiable>
+<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
+</language>
+<subject>
+<name>subject</name>
+<number>1</number>
+<prettyName>Subject</prettyName>
+<size>40</size>
+<unmodifiable>0</unmodifiable>
+<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
+</subject>
+<text>
+<name>text</name>
+<number>3</number>
+<prettyName>Text</prettyName>
+<rows>15</rows>
+<size>80</size>
+<unmodifiable>0</unmodifiable>
+<classType>com.xpn.xwiki.objects.classes.TextAreaClass</classType>
+</text>
+</class>
+<name>XWiki.WatchListMessage</name>
+<number>0</number>
+<className>XWiki.Mail</className>
+<property>
+<html>&lt;b&gt;Hello $pseudo,&lt;/b&gt;&lt;br/&gt;
+&lt;i&gt;This message is sent by XWiki. Here are the documents in your 
watchlist that have been created or updated since the last notification 
:&lt;/i&gt;&lt;br/&gt;
+&lt;br/&gt;
+&lt;table width="100%"&gt;
+&lt;tr style="background-color:#EFEFEF;font-weight:bold;"&gt;
+&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Space&lt;/td&gt;&lt;td&gt;Modified 
by&lt;/td&gt;&lt;td&gt;Comment&lt;/td&gt;&lt;td&gt;Modified on&lt;/td&gt;
+&lt;/tr&gt;
+#foreach ($udocname in $documents)
+#set ($udoc = $xwiki.getDocument($udocname))
+#if ($velocityCount % 2 == 0)
+  #set ($color = "#E5F0FE")
+#else
+  #set ($color = "#FFF")
+#end
+&lt;tr style="background-color:${color};"&gt;
+&lt;td&gt;&lt;a 
href="${udoc.getExternalURL()}"&gt;$udoc.getDisplayTitle()&lt;/a&gt;&lt;/td&gt;
+&lt;td&gt;$udoc.web&lt;/td&gt;
+&lt;td&gt;$xwiki.getLocalUserName($udoc.author, true)&lt;/td&gt;
+&lt;td&gt;$udoc.getComment()&lt;/td&gt;
+&lt;td&gt;$xwiki.formatDate($udoc.date)&lt;/td&gt;
+&lt;/tr&gt;
+#end
+&lt;/table&gt;</html>
+</property>
+<property>
+<language>en</language>
+</property>
+<property>
+<subject>XWiki : Watchlist Updates, #set($format="dd/MM/yyyy")#if ($interval 
== 1)#set($format="${format} hh:mm")#end$xwiki.formatDate($xwiki.date, 
$format)</subject>
+</property>
+<property>
+<text>Hello $pseudo,
+This message is sent by XWiki. Here are the documents in your watchlist that 
have been created or updated since the last notification :
+
+#foreach ($udocname in $documents)
+#set ($udoc = $xwiki.getDocument($udocname))$udoc.getDisplayTitle() : 
${udoc.getExternalURL()}
+#end</text>
+</property>
+</object>
+<content>
+</content></xwikidoc>
\ No newline at end of file

Modified: 
xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/xwiki/plugin/watchlist/WatchListPlugin.java
===================================================================
--- 
xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/xwiki/plugin/watchlist/WatchListPlugin.java
      2008-02-26 16:40:28 UTC (rev 7969)
+++ 
xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/xwiki/plugin/watchlist/WatchListPlugin.java
      2008-02-26 17:36:16 UTC (rev 7970)
@@ -121,7 +121,6 @@
         try {
             // Main wiki
             initWatchListClass(context);
-            initEmailTemplate(context);
             initWatchlistJobs(context);
             sanitizeWatchlists(context);
         } catch (XWikiException e) {
@@ -281,74 +280,6 @@
     }
 
     /**
-     * Creates the email notification template (XWiki Object)
-     */
-    protected void initEmailTemplate(XWikiContext context) throws 
XWikiException
-    {
-        XWikiDocument doc;
-        boolean needsUpdate = false;
-
-        try {
-            doc =
-                context.getWiki().getDocument(WATCHLIST_EMAIL_TEMPLATE, 
context);
-            BaseObject obj = 
doc.getObject(MailSenderPlugin.EMAIL_XWIKI_CLASS_NAME);
-            if (obj == null) {
-                needsUpdate = true;
-            }
-        } catch (Exception e) {
-            doc = new XWikiDocument();
-            String[] spaceAndName = WATCHLIST_EMAIL_TEMPLATE.split(".");
-            doc.setSpace(spaceAndName[0]);
-            doc.setName(spaceAndName[1]);
-            needsUpdate = true;
-        }
-
-        if (needsUpdate) {
-
-            int index = 
doc.createNewObject(MailSenderPlugin.EMAIL_XWIKI_CLASS_NAME, context);
-            BaseObject mail = 
doc.getObject(MailSenderPlugin.EMAIL_XWIKI_CLASS_NAME, index);
-            mail.setStringValue("language", "en");
-            mail.setStringValue("subject",
-                "XWiki : Watchlist Updates, #set($format=\"dd/MM/yyyy\")#if 
($interval == 1)" +
-                    "#set($format=\"${format} 
hh:mm\")#end$xwiki.formatDate($xwiki.date, $format)");
-            mail.setLargeStringValue("text", "Hello $pseudo,\n" +
-                "This message is sent by XWiki. Here are the documents in your 
watchlist that have been created or updated since the last notification :\n" +
-                "\n" +
-                "#foreach ($udocname in $documents)\n" +
-                "#set ($udoc = 
$xwiki.getDocument($udocname))$udoc.getDisplayTitle() : 
${udoc.getExternalURL()}\n" +
-                "#end");
-            mail.setLargeStringValue("html", "<b>Hello $pseudo,</b><br/>\n" +
-                "<i>This message is sent by XWiki. Here are the documents in 
your watchlist that have been created or updated since the last notification 
:</i><br/>\n" +
-                "<br/>\n" +
-                "<table width=\"100%\">\n" +
-                "<tr style=\"background-color:#EFEFEF;font-weight:bold;\">\n" +
-                "<td>Name</td><td>Space</td><td>Modified 
by</td><td>Comment</td><td>Modified on</td>\n" +
-                "</tr>\n" +
-                "#foreach ($udocname in $documents)\n" +
-                "#set ($udoc = $xwiki.getDocument($udocname))\n" +
-                "#if ($velocityCount % 2 == 0)\n" +
-                "  #set ($color = \"#E5F0FE\")\n" +
-                "#else\n" +
-                "  #set ($color = \"#FFF\")\n" +
-                "#end\n" +
-                "<tr style=\"background-color:${color};\">\n" +
-                "<td><a 
href=\"${udoc.getExternalURL()}\">$udoc.getDisplayTitle()</a></td>\n" +
-                "<td>$udoc.web</td>\n" +
-                "<td>$xwiki.getLocalUserName($udoc.author, false)</td>\n" +
-                "<td>$udoc.getComment()</td>\n" +
-                "<td>$xwiki.formatDate($udoc.date)</td>\n" +
-                "</tr>\n" +
-                "#end\n" +
-                "</table>");
-            String content = doc.getContent();
-            if ((content == null) || (content.equals(""))) {
-                doc.setContent("1 Notification message");
-            }
-            context.getWiki().saveDocument(doc, "", true, context);
-        }
-    }
-
-    /**
      * Is the watchedDocument in user WatchList ?
      *
      * @param user XWiki User
@@ -544,47 +475,7 @@
         BaseObject watchListObject = this.getWatchListObject(user, context);
 
         if (context.getWiki().isVirtual()) {
-            // TODO : code getWatchListWhatsNew for virtual mode
-            /* List results = new ArrayList();
-            List watchedElements = 
Arrays.asList(watchListObject.getLargeStringValue("documents")
-                .trim().replaceFirst("^,", "").replaceAll(",$", 
"").split(","));
-            
watchedElements.addAll(Arrays.asList(watchListObject.getLargeStringValue("spaces")
-                .trim().replaceFirst("^,", "").replaceAll(",$", 
"").split(",")));
-            Collections.sort(watchedElements);
-
-            Iterator it = watchedElements.iterator();
-            String previousWiki = "";
-            String currentWiki = "";
-            List currentWikiDocList = new ArrayList();
-            List currentWikiSpaceList = new ArrayList();
-
-            while (it.hasNext()) {
-                String currentEl = (String) it.next();
-                String docWiki = currentEl.split(":")[0];
-                if (!docWiki.equals(currentWiki)) {
-                    if (!previousWiki.equals("")) {
-                        String request =
-                            "select doc.fullName from XWikiDocument as doc 
where doc.web in (?) " +
-                                "or doc.fullName in (?) order by doc.date 
desc";
-                        List values = new ArrayList();
-                        // TODO : format docs and spaces lists
-                        values.add(currentWikiSpaceList);
-                        values.add(currentWikiSpaceList);
-                        results.addAll(globalSearchDocuments(request, 20, 0, 
values, context));
-                        currentWikiDocList.clear();
-                        currentWikiSpaceList.clear();
-                    }
-                    previousWiki = currentWiki;
-                    currentWiki = docWiki;
-                }
-
-                if (currentEl.contains(".")) {
-                    currentWikiDocList.add(currentEl);
-                } else {
-                    currentWikiSpaceList.add(currentEl);
-                }
-            }
-            return results; */
+            // TODO : code getWatchListWhatsNew for virtual mode using 
LucenePlugin
             return new ArrayList();
         } else {
             String watchedDocuments =

Modified: 
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/AllTests.java
===================================================================
--- 
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/AllTests.java
  2008-02-26 16:40:28 UTC (rev 7969)
+++ 
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/AllTests.java
  2008-02-26 17:36:16 UTC (rev 7970)
@@ -60,6 +60,7 @@
         addTestCase(suite, SkinCustomizationsTest.class);
         addTestCase(suite, XObjectsTest.class);
         addTestCase(suite, VersionTest.class);
+        addTestCase(suite, WatchListTest.class);
 
         return new XWikiTestSetup(suite);
     }

Added: 
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/WatchListTest.java
===================================================================
--- 
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/WatchListTest.java
                             (rev 0)
+++ 
xwiki-products/xwiki-enterprise/trunk/distribution-test/selenium-tests/src/test/it/com/xpn/xwiki/it/selenium/WatchListTest.java
     2008-02-26 17:36:16 UTC (rev 7970)
@@ -0,0 +1,65 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.it.selenium;
+
+import junit.framework.Test;
+import com.xpn.xwiki.it.selenium.framework.AbstractXWikiTestCase;
+import com.xpn.xwiki.it.selenium.framework.AlbatrossSkinExecutor;
+import com.xpn.xwiki.it.selenium.framework.XWikiTestSuite;
+
+/**
+ * Verify the watchlist feature of XWiki.
+ *
+ * @version $Id: $
+ */
+public class WatchListTest extends AbstractXWikiTestCase
+{
+    public static Test suite()
+    {
+        XWikiTestSuite suite = new XWikiTestSuite("Verify the watchlist 
feature of XWiki");
+        suite.addTestSuite(WatchListTest.class, AlbatrossSkinExecutor.class);
+        return suite;
+    }
+
+    public void testWatchThisPageAndWholeSpace()
+    {
+        loginAsAdmin();
+
+        // Test if the email template exists
+        open("/xwiki/bin/edit/XWiki/WatchListMessage?editor=object");
+        assertTextPresent("XWiki.Mail[0]");
+
+        // Watch Test.TestWatchThisPage
+        open("/xwiki/bin/edit/Test/TestWatchThisPage?editor=wiki");
+        setFieldValue("content", "TestWatchThisPage selenium");
+        clickEditSaveAndView();
+        getSelenium().click("link=Watch this page");
+
+        // Watch TestWatchWholeSpace
+        open("/xwiki/bin/edit/TestWatchWholeSpace/Test1?editor=wiki");
+        setFieldValue("content", "TestWatchWholeSpace selenium");
+        clickEditSaveAndView();
+        getSelenium().click("link=Watch whole space");
+
+        getSelenium().click("link=Manage your watchlist");
+        assertTextPresent("TestWatchThisPage");
+        assertTextPresent("TestWatchWholeSpace");
+    }
+}

Modified: xwiki-products/xwiki-enterprise/trunk/wiki/pom.xml
===================================================================
--- xwiki-products/xwiki-enterprise/trunk/wiki/pom.xml  2008-02-26 16:40:28 UTC 
(rev 7969)
+++ xwiki-products/xwiki-enterprise/trunk/wiki/pom.xml  2008-02-26 17:36:16 UTC 
(rev 7970)
@@ -45,6 +45,12 @@
       <artifactId>xwiki-application-scheduler</artifactId>
       <version>${platform.scheduler.version}</version>
       <type>xar</type>
+    </dependency>
+    <dependency>
+      <groupId>com.xpn.xwiki.platform.applications</groupId>
+      <artifactId>xwiki-application-watchlist</artifactId>
+      <version>${platform.watchlist.version}</version>
+      <type>xar</type>
     </dependency>
     <dependency>
       <groupId>com.xpn.xwiki.platform.applications</groupId>

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to