r1033 - in xwiki/trunk: . src/main/java/com/xpn/xwiki src/main/java/com/xpn/xwiki/notify src/main/java/com/xpn/xwiki/render/groovy src/main/resources src/main/web/templates
Ludovic Dubost
ludovic at users.forge.objectweb.org
Sat Apr 8 21:50:16 CEST 2006
Author: ludovic
Date: 2006-04-08 21:50:15 +0200 (Sat, 08 Apr 2006)
New Revision: 1033
Added:
xwiki/trunk/src/main/java/com/xpn/xwiki/notify/XWikiPageNotification.java
Modified:
xwiki/trunk/build.xml
xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java
xwiki/trunk/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java
xwiki/trunk/src/main/resources/ApplicationResources.properties
xwiki/trunk/src/main/resources/ApplicationResources_en.properties
xwiki/trunk/src/main/resources/ApplicationResources_fr.properties
xwiki/trunk/src/main/resources/xwiki.hbm.xml
xwiki/trunk/src/main/web/templates/editprefs.vm
xwiki/trunk/src/main/web/templates/inline.vm
xwiki/trunk/src/main/web/templates/preview.vm
Log:
Fixed parseGroovyString to be able to reload modified scripts
Added new preferences
Added fields in the preference page
Added text in the ApplicationResources.properties
Added notification features which allows to call groovy notifications on XWiki Actions
Added xnotification field in inline and preview action which allows to call groovy scripts after save
Modified: xwiki/trunk/build.xml
===================================================================
--- xwiki/trunk/build.xml 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/build.xml 2006-04-08 19:50:15 UTC (rev 1033)
@@ -148,7 +148,6 @@
</target>
<!-- Define the Cactus tasks -->
-<!--
<taskdef resource="cactus.tasks">
<classpath>
<pathelement location="${lib.dir}/junit-3.8.1.jar"/>
@@ -159,7 +158,6 @@
<pathelement location="${lib.dir}/aspectjrt-1.2.1.jar"/>
</classpath>
</taskdef>
--->
<target name="prepare">
<propertyfile file="src/main/web/WEB-INF/version.properties" >
@@ -205,11 +203,11 @@
<target name="xwiki.nonjava" depends="prepare">
<copy todir="${classes.dir}">
- <fileset dir="${resources.main.src.dir}"/>
+ <fileset dir="${resources.main.src.dir}" />
</copy>
<copy todir="${build.dir}/web">
- <fileset includes="**"
+ <fileset includes="**" excludes="JSTrim*.*,**/*_src.js"
dir="${web.main.src.dir}" />
</copy>
@@ -387,7 +385,7 @@
</junitreport>
</target>
- <target name="javadoc" depends="xwiki">
+ <target name="javadoc" depends="">
<mkdir dir="${javadoc.dir}" />
<javadoc packagenames="com.xpn.xwiki.*"
sourcepath="${java.main.src.dir}"
@@ -459,7 +457,7 @@
</tar>
</target>
- <target name="src.dist" depends="release, test, javadoc">
+ <target name="src.dist" depends="javadoc">
<mkdir dir="${dist.dir}" />
<property name="src.tarfile" value="${dist.dir}/xwiki-${version}-src.tar.gz" />
<delete file="${src.tarfile}" />
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java 2006-04-08 19:50:15 UTC (rev 1033)
@@ -38,10 +38,7 @@
import com.xpn.xwiki.cache.impl.OSCacheService;
import com.xpn.xwiki.doc.XWikiAttachment;
import com.xpn.xwiki.doc.XWikiDocument;
-import com.xpn.xwiki.notify.PropertyChangedRule;
-import com.xpn.xwiki.notify.XWikiDocChangeNotificationInterface;
-import com.xpn.xwiki.notify.XWikiNotificationManager;
-import com.xpn.xwiki.notify.XWikiNotificationRule;
+import com.xpn.xwiki.notify.*;
import com.xpn.xwiki.objects.BaseObject;
import com.xpn.xwiki.objects.PropertyInterface;
import com.xpn.xwiki.objects.classes.*;
@@ -499,10 +496,13 @@
getStatsService(context);
}
+ // Add a notification rule if the preference property plugin is modified
+ getNotificationManager().addGeneralRule(
+ new XWikiActionRule(new XWikiPageNotification()));
+
+
String ro = Param("xwiki.readonly", "no");
-
isReadOnly = ("yes".equalsIgnoreCase(ro) || "true".equalsIgnoreCase(ro) || "1".equalsIgnoreCase(ro));
-
}
public void resetRenderingEngine(XWikiContext context) throws XWikiException {
@@ -1494,6 +1494,7 @@
needsUpdate |= bclass.addTextField("default_language", "Default Language", 5);
needsUpdate |= bclass.addBooleanField("authenticate_edit", "Authenticated Edit", "yesno");
needsUpdate |= bclass.addBooleanField("authenticate_view", "Authenticated View", "yesno");
+ needsUpdate |= bclass.addBooleanField("auth_active_check", "Authentication Active Check", "yesno");
needsUpdate |= bclass.addBooleanField("backlinks", "Backlinks", "yesno");
needsUpdate |= bclass.addTextField("skin", "Skin", 30);
@@ -1526,9 +1527,11 @@
needsUpdate |= bclass.addTextField("macros_languages", "Macros Languages", 60);
needsUpdate |= bclass.addTextField("macros_velocity", "Macros for Velocity", 60);
needsUpdate |= bclass.addTextField("macros_groovy", "Macros for Groovy", 60);
- needsUpdate |= bclass.addTextField("macros_wiki2", "Macros for new Wiki Parser", 60);
+ needsUpdate |= bclass.addTextField("macros_wiki", "Macros for the Wiki Parser", 60);
needsUpdate |= bclass.addTextAreaField("macros_mapping", "Macros Mapping", 60, 15);
+ needsUpdate |= bclass.addTextField("notification_pages", "Notification Pages", 60);
+
String content = doc.getContent();
if ((content == null) || (content.equals(""))) {
needsUpdate = true;
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java 2006-04-08 19:50:15 UTC (rev 1033)
@@ -64,7 +64,8 @@
public static final int MODULE_XWIKI_APP = 11;
public static final int MODULE_XWIKI_EXPORT = 12;
public static final int MODULE_XWIKI_DIFF = 13;
- public static final int MODULE_GROOVY = 14;
+ public static final int MODULE_XWIKI_GROOVY = 14;
+ public static final int MODULE_XWIKI_NOTIFICATION = 15;
public static final int MODULE_PLUGIN_LASZLO = 21;
@@ -188,10 +189,14 @@
public static final int ERROR_XWIKI_STORE_HIBERNATE_LOADING_BACKLINKS = 13014;
public static final int ERROR_XWIKI_GROOVY_COMPILE_FAILED = 14001;
-
+ public static final int ERROR_XWIKI_GROOVY_EXECUTION_FAILED = 14002;
+
+ public static final int ERROR_XWIKI_NOTIFICATION = 15001;
+
public static final int ERROR_LASZLO_INVALID_XML = 21001;
public static final int ERROR_LASZLO_INVALID_DOTDOT = 21002;
+
public XWikiException(int module, int code, String message, Throwable e, Object[] args) {
setModule(module);
setCode(code);
Added: xwiki/trunk/src/main/java/com/xpn/xwiki/notify/XWikiPageNotification.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/notify/XWikiPageNotification.java 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/notify/XWikiPageNotification.java 2006-04-08 19:50:15 UTC (rev 1033)
@@ -0,0 +1,63 @@
+package com.xpn.xwiki.notify;
+
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWiki;
+import com.xpn.xwiki.XWikiException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: ludovic
+ * Date: 8 avr. 2006
+ * Time: 00:13:39
+ * To change this template use File | Settings | File Templates.
+ */
+public class XWikiPageNotification implements XWikiActionNotificationInterface {
+ private static final Log log = LogFactory.getLog(XWikiPageNotification.class);
+
+ public void notify(XWikiNotificationRule rule, XWikiDocument doc, String action, XWikiContext context) {
+ try {
+ String notifpages = context.getWiki().getXWikiPreference("notification_pages", context);
+ if ((notifpages!=null)&&(!notifpages.equals(""))) {
+ String[] notifpages2 = StringUtils.split(notifpages, " ,");
+ for (int i=0;i<notifpages2.length;i++) {
+ notifyPage(notifpages2[i], rule, doc, action, context);
+ }
+ }
+ String xnotif = context.getRequest().getParameter("xnotification");
+ if ((xnotif!=null)&&(!xnotif.equals(""))) {
+ notifyPage(xnotif, rule, doc, action, context);
+ }
+ } catch (Throwable e) {
+ XWikiException e2 = new XWikiException(XWikiException.MODULE_XWIKI_NOTIFICATION, XWikiException.ERROR_XWIKI_NOTIFICATION, "Error executing notifications", e);
+ if (log.isErrorEnabled())
+ log.error(e2.getFullMessage());
+ }
+ }
+
+ protected void notifyPage(String page, XWikiNotificationRule rule, XWikiDocument doc, String action, XWikiContext context) {
+ XWikiActionNotificationInterface notif = null;
+ try {
+ XWiki xwiki = context.getWiki();
+ XWikiDocument pagedoc = xwiki.getDocument(page, context);
+ if (xwiki.getRightService().hasProgrammingRights(pagedoc, context))
+ notif = (XWikiActionNotificationInterface) xwiki.parseGroovyFromString(pagedoc.getContent(), context);
+ } catch (Throwable e) {
+ Object[] args = { page };
+ XWikiException e2 = new XWikiException(XWikiException.MODULE_XWIKI_GROOVY, XWikiException.ERROR_XWIKI_GROOVY_COMPILE_FAILED, "Error parsing groovy notification for page {0}", e, args);
+ if (log.isErrorEnabled())
+ log.error(e2.getFullMessage());
+ }
+ try {
+ notif.notify(rule, doc, action, context);
+ } catch (Throwable e) {
+ Object[] args = { page };
+ XWikiException e2 = new XWikiException(XWikiException.MODULE_XWIKI_GROOVY, XWikiException.ERROR_XWIKI_GROOVY_EXECUTION_FAILED, "Error executing groovy notification for page {0}", e, args);
+ if (log.isErrorEnabled())
+ log.error(e2.getFullMessage());
+ }
+ }
+}
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java 2006-04-08 19:50:15 UTC (rev 1033)
@@ -54,7 +54,6 @@
private static final Log log = LogFactory.getLog(com.xpn.xwiki.render.groovy.XWikiGroovyRenderer.class);
private XWikiCache cache;
private XWikiCache classCache;
- private final GroovyClassLoader gcl = new GroovyClassLoader();
public XWikiGroovyRenderer() {
}
@@ -256,6 +255,7 @@
gc = (Class) classCache.getFromCache(script);
}
catch (XWikiCacheNeedsRefreshException e) {
+ GroovyClassLoader gcl = new GroovyClassLoader();
gc = gcl.parseClass(script);
classCache.putInCache(script, gc);
} finally {
@@ -264,7 +264,7 @@
return gc.newInstance();
} catch (Exception e) {
- throw new XWikiException(XWikiException.MODULE_GROOVY,
+ throw new XWikiException(XWikiException.MODULE_XWIKI_GROOVY,
XWikiException.ERROR_XWIKI_GROOVY_COMPILE_FAILED,
"Failed compiling groovy script", e);
}
Modified: xwiki/trunk/src/main/resources/ApplicationResources.properties
===================================================================
--- xwiki/trunk/src/main/resources/ApplicationResources.properties 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/resources/ApplicationResources.properties 2006-04-08 19:50:15 UTC (rev 1033)
@@ -200,6 +200,12 @@
notsupportcharacters=File name does not support characters '\\' '/' ';'
youcanclicktoedit=You can click on "Edit this Page" to create it.
thistemplatedoesnotexist=This template does not exist
+macros_languages=Macro Languages
+macros_velocity=Velocity Macro Pages
+macros_groovy=Groovy Macro Pages
+macros_mapping=Macro Mapping
+notification_pages=Notification Pages
+auth_active_check=Check Active fields for user authentication
chartwizard=Chart Wizard
chwhide=hide
Modified: xwiki/trunk/src/main/resources/ApplicationResources_en.properties
===================================================================
--- xwiki/trunk/src/main/resources/ApplicationResources_en.properties 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/resources/ApplicationResources_en.properties 2006-04-08 19:50:15 UTC (rev 1033)
@@ -190,8 +190,8 @@
nocommentwithnewdoc=You cannot comment on a document or article that does not exist.
actiondoesnotexist=This action does not exist !
thiswikidoesnotexist=This Wiki does not exist on this server.
+thispagedoesnotexist=This document does not exist in this Wiki.
thispagealreadyexists=This document already exist in this Wiki.
-thispagedoesnotexist=This document does not exist in this Wiki.
availableversionsattachment=The available versions of file '$attachment.filename' are:
attachmentdoesnotexist=The attachment does not exist.
wikicontentcannotbeempty= The content of a wiki page is not allowed to be completely empty.
@@ -200,6 +200,12 @@
notsupportcharacters=File name does not support characters '\\' '/' ';'
youcanclicktoedit=You can click on "Edit this Page" to create it.
thistemplatedoesnotexist=This template does not exist
+macros_languages=Macro Languages
+macros_velocity=Velocity Macro Pages
+macros_groovy=Groovy Macro Pages
+macros_mapping=Macro Mapping
+notification_pages=Notification Pages
+auth_active_check=Check Active fields for user authentication
chartwizard=Chart Wizard
chwhide=hide
Modified: xwiki/trunk/src/main/resources/ApplicationResources_fr.properties
===================================================================
--- xwiki/trunk/src/main/resources/ApplicationResources_fr.properties 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/resources/ApplicationResources_fr.properties 2006-04-08 19:50:15 UTC (rev 1033)
@@ -201,4 +201,9 @@
notsupportcharacters=Les pièces jointes de peuvent pas contenir les caractères '\\' '/' ';'
youcanclicktoedit=Vous pouvez cliquer sur "Editer cette page" pour la créer.
thistemplatedoesnotexist=Cette template n'existe pas.
-
+macros_languages=Language de Macros
+macros_velocity=Pages de Macros Velocity
+macros_groovy=Pages de Macros Groovy
+macros_mapping=Correspondance des Macros
+notification_pages=Pages de Notifications
+auth_active_check=Verifier le champ 'Actif' lors de l'authentification
\ No newline at end of file
Modified: xwiki/trunk/src/main/resources/xwiki.hbm.xml
===================================================================
--- xwiki/trunk/src/main/resources/xwiki.hbm.xml 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/resources/xwiki.hbm.xml 2006-04-08 19:50:15 UTC (rev 1033)
@@ -600,6 +600,9 @@
<property name="authenticate_view" type="integer">
<column name="XWP_AUTHENTICATE_VIEW" />
</property>
+ <property name="auth_active_check" type="integer">
+ <column name="XWP_AUTH_ACTIVE_CHECK" />
+ </property>
<property name="backlinks" type="integer">
<column name="XWP_BACKLINKS" />
</property>
@@ -666,6 +669,37 @@
<property name="macros_mapping" type="string">
<column name="XWP_MACROS_MAPPING" length="60000" />
</property>
+ <property name="notification_pages" type="string">
+ <column name="XWP_NOTIFICATION_PAGES" length="255" />
+ </property>
</class>
+
+ <!-- XWikiPreferences custom mapping -->
+ <!--
+ <class entity-name="XWiki.XWikiUsers" table="xwikiusers">
+ <id name="id" type="integer" unsaved-value="any">
+ <column name="XWU_ID" not-null="true" />
+ <generator class="assigned" />
+ </id>
+ <property name="first_name" type="string" unique="false" optimistic-lock="true" lazy="false" generated="never">
+ <column name="XWU_FIRST_NAME" length="255" not-null="false" />
+ </property>
+ <property name="last_name" type="string" unique="false" optimistic-lock="true" lazy="false" generated="never">
+ <column name="XWU_LAST_NAME" length="255" not-null="false" />
+ </property>
+ <property name="email" type="string" unique="false" optimistic-lock="true" lazy="false" generated="never">
+ <column name="XWU_EMAIL" length="50" />
+ </property>
+ <property name="company" type="string" unique="false" optimistic-lock="true" lazy="false" generated="never">
+ <column name="XWU_COMPANY" length="255" />
+ </property>
+ <property name="password" type="string" unique="false" optimistic-lock="true" lazy="false" generated="never">
+ <column name="XWU_PASSWORD" length="255" />
+ </property>
+ <property name="validationKey" type="string" unique="false" optimistic-lock="true" lazy="false" generated="never">
+ <column name="XWU_VALIDATION_KEY" />
+ </property>
+ </class>
+ -->
</hibernate-mapping>
Modified: xwiki/trunk/src/main/web/templates/editprefs.vm
===================================================================
--- xwiki/trunk/src/main/web/templates/editprefs.vm 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/web/templates/editprefs.vm 2006-04-08 19:50:15 UTC (rev 1033)
@@ -30,11 +30,11 @@
#set($class = $obj.xWikiClass)
#set($sections = ["params", "skin", "presentation", "editing", "advanced", "registration"])
#set($sectionitemsmap = $xwiki.hashMap)
-#set($sectionitemsmap.params = ["multilingual", "language" , "default_language", "authenticate_view", "authenticate_edit" ])
+#set($sectionitemsmap.params = ["multilingual", "language" , "default_language", "authenticate_view", "authenticate_edit", "auth_active_check" ])
#set($sectionitemsmap.skin = ["skin", "baseskin", "stylesheet", "stylesheets"])
#set($sectionitemsmap.presentation = [ "title", "version", "webcopyright", "menu", "meta" ])
#set($sectionitemsmap.editing = ["editor", "editbox_width","editbox_height"])
-#set($sectionitemsmap.advanced = ["macros_languages", "macros_velocity","macros_groovy", "macros_wiki2", "macros_mapping"])
+#set($sectionitemsmap.advanced = ["macros_languages", "macros_velocity","macros_groovy", "macros_mapping", "notification_pages" ])
#set($sectionitemsmap.registration = [ "use_email_verification", "admin_email", "smtp_server", "validation_email_content", "confirmation_email_content"])
#macro(showsection $section $sectionitemsmap)
<h3>$msg.get($section)</h3>
Modified: xwiki/trunk/src/main/web/templates/inline.vm
===================================================================
--- xwiki/trunk/src/main/web/templates/inline.vm 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/web/templates/inline.vm 2006-04-08 19:50:15 UTC (rev 1033)
@@ -6,9 +6,11 @@
</div>
#end
#set($xredirect=$!request.getParameter("xredirect"))
+#set($xnotification=$!request.getParameter("xnotification"))
<form id="edit" method="post" action="$doc.getURL("preview")">
<p>
<input type="hidden" name="xredirect" value="$!xredirect" />
+<input type="hidden" name="xnotification" value="$!xnotification" />
<input type="hidden" name="template" value="$!request.template" />
<input type="hidden" name="language" value="$!doc.language" />
#set($force = $!request.get("force"))
Modified: xwiki/trunk/src/main/web/templates/preview.vm
===================================================================
--- xwiki/trunk/src/main/web/templates/preview.vm 2006-04-07 09:37:56 UTC (rev 1032)
+++ xwiki/trunk/src/main/web/templates/preview.vm 2006-04-08 19:50:15 UTC (rev 1033)
@@ -13,6 +13,7 @@
<input type="hidden" name="defaultLanguage" value="$!doc.getDefaultLanguage()" />
<input type="hidden" name="template" value="$!tdoc.getTemplate()" />
<input type="hidden" name="xredirect" value="$!request.getParameter("xredirect")" />
+<input type="hidden" name="xnotification" value="$!request.getParameter("xnotification")" />
<input type="hidden" name="language" value="$!request.getParameter("language")" />
</p>
More information about the Xwiki-notifications
mailing list