Author: xlawrence
Date: Fri Aug 3 15:06:36 2007
New Revision: 18125
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18125&repname=
=3Djahia
Log:
added missing groovy scripts
Added:
branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/events/
branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/events/EventListener.groovy
branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/external_workflows/
branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/external_workflows/nstep_workflow_mailnotif.groovy
Added: branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/sc=
ripts/groovy/events/EventListener.groovy
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-MINEFI-5-0-2-SP%20BRANCH/core/src/webapp/WEB-INF/var/scripts/groovy/events=
/EventListener.groovy&rev=3D18125&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/events/EventListener.groovy (added)
+++ branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/events/EventListener.groovy Fri Aug 3 15:06:36 2007
@@ -0,0 +1,96 @@
+
+
+import org.jahia.services.events.GroovyEventListener
+// register comma separated list of events we want trap
+GroovyEventListener.registerEvents("dummyEventWeWontHandle");
+
+// The following code was deactivate because it was a performance problem =
when adding containers.
+
+/*
+// todo We need to cleanup the import, because the event listener implemen=
tation checks all dependencies
+// on each event, and for the moment this generates over 15'000 dependency=
checks !
+import org.jahia.services.containers.ContentContainer
+import org.jahia.services.fields.*
+import org.jahia.services.pages.*
+import org.jahia.params.*
+import org.jahia.data.containers.*
+import org.jahia.data.JahiaData
+import org.jahia.content.*
+import org.jahia.utils.*
+import org.jahia.registries.*
+import org.jahia.services.mail.*
+import org.apache.log4j.Logger
+
+// register comma separated list of events we want trap
+GroovyEventListener.registerEvents("fake_event");// desactivated by default
+
+if(eventName.equals("contentObjectCreated")) {
+logger =3D Logger.getLogger(getClass())
+
+
+if(jahiaEvent.getObject() instanceof ContentContainer) {
+logger.debug("Entering in groovy Eventlistener")
+ //get the pid
+ pid=3DjahiaEvent.getParams().getPageID()
+
+ if(pid=3D=3D-1) return;
+
+ //construct the jdata
+ jData =3D new JahiaData(jahiaEvent.getParams(),true)
+
+ //get the subscribers containerlist
+ subscribers=3DjData.containers().getAbsoluteContainerList(
"subscriber_li=
st", pid)
+ if(subscribers!=3Dnull && subscribers.size()>0) {
+ logger.debug(subscribers.size())
+ } else {
+ //logger.debug("no subscribers to push")
+ return
+ }
+ //got the mail service
+ mailService =3D ServicesRegistry.getInstance ().getMailService
();
+ // get recipients
+ sb =3Dnew StringBuffer();
+ subscriberEnum =3D subscribers.getContainers();
+
+ container =3D (ContentContainer) jahiaEvent.getObject()
+
mydef=3DJahiaContainerDefinitionsRegistry.getInstance().getDefinition(co=
ntainer.getDefinitionID(jahiaEvent.getParams().getEntryLoadRequest()))
+
+
+ defname=3Dmydef.getName()
+ logger.debug( "the definition found is "+defname);
+ //pid=3Dcontainer.getPageID()
+ // please edit this to your servername and port
+ url=3D
"http://localhost:8080"+jahiaEvent.getParams().composePageUrl(pid)
+
+
+ if (defname.equals("entries")) {
+ logger.debug("some changes in blogs on page
"+pid)
+ while (subscriberEnum.hasMoreElements()) {
+ subscriber =3D (JahiaContainer)
subscriberEnum.nextElement();
+ sub_adress =3D
subscriber.getFieldValue( "subscriber_mail", "" );
+ sb.append(
TextHtml.html2text(sub_adress)).append(",")
+ }
+
co1=3Dcontainer.getParent(jahiaEvent.getParams().getEntryLoadRequest())
+
co2=3Dco1.getParent(jahiaEvent.getParams().getEntryLoadRequest())
+ url+=3D"?entryId=3D"+co2.getID()
+ mailService.sendMessage(null, null,
sb.toString(), "",
+ "new post",
"smtp.free.fr", "a post is =
added on this blog \r"+url)
+ } else if (defname.equals("comments")){
+ while (subscriberEnum.hasMoreElements()) {
+ subscriber =3D (JahiaContainer)
subscriberEnum.nextElement();
+ sub_adress =3D subscriber.getFieldValue(
"subscriber_mail", "" );
+ sb.append(
TextHtml.html2text(sub_adress)).append(",")
+ }
+ logger.debug("some changes in comments")
+
co1=3Dcontainer.getParent(jahiaEvent.getParams().getEntryLoadRequest())
+
co2=3Dco1.getParent(jahiaEvent.getParams().getEntryLoadRequest())
+ logger.debug("parent.parent ctnlist
id:"+co2.getID())
+ url+=3D"?entryId=3D"+co2.getID()+"#comments"
+
+ mailService.sendMessage(null, null,
sb.toString(), "",
+ "new comment",
"smtp.free.fr", "a comme=
nt is added on this blog \r"+url)
+
+ }
+ }
+}
+*/
\ No newline at end of file
Added: branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/sc=
ripts/groovy/external_workflows/nstep_workflow_mailnotif.groovy
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-MINEFI-5-0-2-SP%20BRANCH/core/src/webapp/WEB-INF/var/scripts/groovy/extern=
al_workflows/nstep_workflow_mailnotif.groovy&rev=3D18125&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/external_workflows/nstep_workflow_mailnotif.groovy (added)
+++ branches/JAHIA-MINEFI-5-0-2-SP BRANCH/core/src/webapp/WEB-INF/var/scrip=
ts/groovy/external_workflows/nstep_workflow_mailnotif.groovy Fri Aug 3 15:=
06:36 2007
@@ -0,0 +1,125 @@
+import org.jahia.workflow.nstep.MailInfo;
+
+textBody =3D ""
+htmlBody =3D ""
+subject =3D evaluate(subjectText);
+textBody +=3D """\
+
+${evaluate(introduction)}
+
+"""
+ if (!"".equals(comment)) {
+ textBody +=3D """\
+${commentLabel}:${comment}
+"""
+ }
+htmlBody +=3D """\
+<html>
+ <head>
+ <style type=3D\"text/css\">
+ h1 {
+ background-color : rgb(152, 168, 192);
+ color : white;
+ font-size : 16px;
+ padding : 5px;
+ width : 100%;
+ }
+ h2 {
+ font-size: 14px;
+ padding-left : 10px;
+ }
+ p {
+ padding-left : 15px;
+ }
+ ul li {
+ padding-left : 15px;
+ padding-bottom : 5px;
+ }
+ body {
+ width : 800px;
+ margin: 0px;
+ padding : 0px;
+ font-family : Verdana, Arial, Helvetica, sans-serif;
+ font-size: 12px;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>${evaluate(introduction)}</h1>
+"""
+ if (!"".equals(comment)) {
+ htmlBody +=3D """\
+ <h2>${commentLabel}</h2>
+ <p>${comment}</p>
+"""
+ }
+ if(finished.size()>0) {
+ textBody +=3D bundle.getString("notification.elements.finished")
+ htmlBody +=3D "<h2>"+bundle.getString("notification.elements.finished"=
).replaceAll("\n","<br>")+"</h2"
+ htmlBody +=3D "<ul>\n";
+ finished.each(){mailInfo -> if(mailInfo.isFinished()) {
+ getBinding().setVariable("mailInfo",mailInfo)
+ message =3D evaluate(mailInfo.getText())
+ textBody
+=3Dmessage.replaceAll("PageLink",mailInfo.getPageLink())+"\=
n"
+ htmlBody +=3D
"<li>\n"+message.replaceAll("\n","<br>").replaceAll("Pa=
geLink","""<a href=3D\""""+mailInfo.getPageLink()+"""\">"""+mailInfo.getPag=
eLink()+"</a>")+"</li>\n"
+ }
+ }
+ htmlBody +=3D "</ul>\n";
+ }
+
+ if(advanced.size()>0) {
+ textBody +=3D bundle.getString("notification.elements.advanced")
+ htmlBody +=3D "<h2>"+bundle.getString("notification.elements.advanced"=
).replaceAll("\n","<br>")+"</h2"
+ htmlBody +=3D "<ul>\n";
+ advanced.each(){mailInfo -> if(mailInfo.isAdvanced()) {
+ getBinding().setVariable("mailInfo",mailInfo)
+ message =3D evaluate(mailInfo.getText())
+ textBody
+=3Dmessage.replaceAll("PageLink",mailInfo.getPageLink())+"\=
n"
+ htmlBody +=3D
"<li>\n"+message.replaceAll("\n","<br>").replaceAll("Pa=
geLink","""<a href=3D\""""+mailInfo.getPageLink()+"""\">"""+mailInfo.getPag=
eLink()+"</a>")+"</li>\n"
+ }
+ }
+ htmlBody +=3D "</ul>\n";
+ }
+
+ if(deleted.size()>0) {
+ textBody +=3D bundle.getString("notification.elements.deleted")
+ htmlBody +=3D "<h2>"+bundle.getString("notification.elements.deleted")=
.replaceAll("\n","<br>")+"</h2"
+ htmlBody +=3D "<ul>\n";
+ deleted.each(){mailInfo -> if(mailInfo.isDeleted()) {
+ getBinding().setVariable("mailInfo",mailInfo)
+ message =3D evaluate(mailInfo.getText())
+ textBody
+=3Dmessage.replaceAll("PageLink",mailInfo.getPageLink())+"\=
n"
+ htmlBody +=3D
"<li>\n"+message.replaceAll("\n","<br>").replaceAll("Pa=
geLink","""<a href=3D\""""+mailInfo.getPageLink()+"""\">"""+mailInfo.getPag=
eLink()+"</a>")+"</li>\n"
+ }
+ }
+ htmlBody +=3D "</ul>\n";
+ }
+
+ if(rollbacked.size()>0) {
+ textBody +=3D bundle.getString("notification.elements.rollbacked")
+ htmlBody +=3D "<h2>"+bundle.getString("notification.elements.rollbacke=
d").replaceAll("\n","<br>")+"</h2"
+ htmlBody +=3D "<ul>\n";
+ rollbacked.each(){mailInfo -> if(mailInfo.isRollbacked()) {
+ getBinding().setVariable("mailInfo",mailInfo)
+ message =3D evaluate(mailInfo.getText())
+ textBody
+=3Dmessage.replaceAll("PageLink",mailInfo.getPageLink())+"\=
n"
+ htmlBody +=3D
"<li>\n"+message.replaceAll("\n","<br>").replaceAll("Pa=
geLink","""<a href=3D\""""+mailInfo.getPageLink()+"""\">"""+mailInfo.getPag=
eLink()+"</a>")+"</li>\n"
+ }
+ }
+ htmlBody +=3D "</ul>\n";
+ }
+
+ if(rollbackedToAuthor.size()>0) {
+ textBody +=3D bundle.getString("notification.elements.rollbacked.to.au=
thor")
+ htmlBody +=3D "<h2>"+bundle.getString("notification.elements.rollbacke=
d.to.author").replaceAll("\n","<br>")+"</h2"
+ htmlBody +=3D "<ul>\n";
+ rollbackedToAuthor.each(){mailInfo -> if(mailInfo.isRollbackedToAuthor=
()) {
+ getBinding().setVariable("mailInfo",mailInfo)
+ message =3D evaluate(mailInfo.getText())
+ textBody
+=3Dmessage.replaceAll("PageLink",mailInfo.getPageLink())+"\=
n"
+ htmlBody +=3D
"<li>\n"+message.replaceAll("\n","<br>").replaceAll("Pa=
geLink","""<a href=3D\""""+mailInfo.getPageLink()+"""\">"""+mailInfo.getPag=
eLink()+"</a>")+"</li>\n"
+ }
+ }
+ htmlBody +=3D "</ul>\n";
+ }
+ htmlBody+=3D"</body><html>";
\ No newline at end of file
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list