You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/12/11 18:41:28 UTC

svn commit: r485769 [3/3] - in /lenya/trunk/src: impl/test/org/apache/lenya/cms/publication/ impl/test/org/apache/lenya/transaction/ java/org/apache/lenya/ac/ java/org/apache/lenya/cms/observation/ java/org/apache/lenya/cms/repository/ java/org/apache/...

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java Mon Dec 11 09:41:23 2006
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.inbox.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.Group;
+import org.apache.lenya.ac.Identifiable;
+import org.apache.lenya.ac.User;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.inbox.Inbox;
+import org.apache.lenya.notification.Message;
+import org.apache.lenya.notification.Notifier;
+import org.apache.lenya.util.Assert;
+import org.apache.lenya.xml.DocumentHelper;
+import org.apache.lenya.xml.NamespaceHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Inbox based on XML sources.
+ */
+public class XmlSourceInbox implements Inbox {
+
+    private ServiceManager manager;
+    private User user;
+
+    /**
+     * @param manager The service manager.
+     * @param user The user.
+     */
+    public XmlSourceInbox(ServiceManager manager, User user) {
+        this.manager = manager;
+        this.user = user;
+    }
+
+    public synchronized void add(Message message) {
+        messages().add(message);
+        save();
+    }
+
+    public synchronized void remove(Message message) {
+        messages().remove(message);
+        save();
+    }
+
+    public Message[] getMessages() {
+        List messages = messages();
+        return (Message[]) messages.toArray(new Message[messages.size()]);
+    }
+
+    private List messages;
+
+    protected List messages() {
+        if (this.messages == null) {
+            load();
+        }
+        return this.messages;
+    }
+
+    private long lastModified = -1;
+
+    protected synchronized void load() {
+        this.messages = new ArrayList();
+        try {
+
+            if (SourceUtil.exists(getSourceUri(), this.manager)) {
+
+                this.lastModified = SourceUtil.getLastModified(getSourceUri(), this.manager);
+                Document xml = SourceUtil.readDOM(getSourceUri(), this.manager);
+
+                Assert.isTrue("document element is <inbox>", xml.getDocumentElement()
+                        .getLocalName().equals("inbox"));
+                NamespaceHelper helper = new NamespaceHelper(Notifier.NAMESPACE, "", xml);
+
+                Element[] messageElements = helper.getChildren(xml.getDocumentElement(), "message");
+                for (int i = 0; i < messageElements.length; i++) {
+                    String senderId = messageElements[i].getAttribute("sender");
+                    User sender = getUser(senderId);
+
+                    Element recipientElement = helper.getFirstChild(messageElements[i],
+                            "recipients");
+
+                    Element[] userElements = helper.getChildren(recipientElement, "user");
+                    Element[] groupElements = helper.getChildren(recipientElement, "group");
+
+                    Identifiable[] recipients = new Identifiable[userElements.length
+                            + groupElements.length];
+
+                    for (int u = 0; u < userElements.length; u++) {
+                        String id = userElements[u].getAttribute("id");
+                        recipients[u] = getUser(id);
+                    }
+
+                    for (int g = 0; g < groupElements.length; g++) {
+                        String id = groupElements[g].getAttribute("id");
+                        recipients[userElements.length + g] = getGroup(id);
+                    }
+
+                    Element bodyElement = helper.getFirstChild(messageElements[i], "body");
+                    Element bodyTextElement = helper.getFirstChild(bodyElement, "text");
+                    String body = DocumentHelper.getSimpleElementText(bodyTextElement);
+                    Element[] bodyParamElements = helper.getChildren(bodyElement, "param");
+                    String[] bodyParams = new String[bodyParamElements.length];
+                    for (int p = 0; p < bodyParamElements.length; p++) {
+                        bodyParams[p] = DocumentHelper.getSimpleElementText(bodyParamElements[p]);
+                    }
+
+                    Element subjectElement = helper.getFirstChild(messageElements[i], "subject");
+                    Element subjectTextElement = helper.getFirstChild(subjectElement, "text");
+                    String subject = DocumentHelper.getSimpleElementText(subjectTextElement);
+                    Element[] subjectParamElements = helper.getChildren(subjectElement, "param");
+                    String[] subjectParams = new String[subjectParamElements.length];
+                    for (int p = 0; p < subjectParamElements.length; p++) {
+                        subjectParams[p] = DocumentHelper
+                                .getSimpleElementText(subjectParamElements[p]);
+                    }
+
+                    Message message = new Message(subject, subjectParams, body, bodyParams, sender,
+                            recipients);
+                    this.messages.add(message);
+                }
+            }
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected User getUser(String id) throws AccessControlException {
+        return this.user.getAccreditableManager().getUserManager().getUser(id);
+    }
+
+    protected Group getGroup(String id) throws AccessControlException {
+        return this.user.getAccreditableManager().getGroupManager().getGroup(id);
+    }
+
+    private String sourceUri;
+
+    protected String getSourceUri() {
+        if (this.sourceUri == null) {
+            String configUri = this.user.getAccreditableManager().getConfigurationCollectionUri();
+            if (configUri.endsWith("/")) {
+                configUri = configUri.substring(0, configUri.length() - 1);
+            }
+            this.sourceUri = configUri + "/inboxes/" + this.user.getId() + ".xml";
+        }
+        return this.sourceUri;
+    }
+
+    protected synchronized void save() {
+        try {
+
+            long newLastModified = SourceUtil.getLastModified(getSourceUri(), this.manager);
+            if (this.lastModified > -1 && newLastModified > this.lastModified) {
+                throw new RuntimeException("The inbox file [" + getSourceUri()
+                        + "] has been changed externally and can't be saved.");
+            }
+
+            NamespaceHelper helper = buildXml();
+            SourceUtil.writeDOM(helper.getDocument(), getSourceUri(), this.manager);
+            this.lastModified = SourceUtil.getLastModified(getSourceUri(), this.manager);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected NamespaceHelper buildXml() throws ParserConfigurationException {
+        NamespaceHelper helper = new NamespaceHelper(Notifier.NAMESPACE, "", "inbox");
+
+        Message[] messages = getMessages();
+        for (int i = 0; i < messages.length; i++) {
+            Element messageElement = helper.createElement("message");
+            helper.getDocument().getDocumentElement().appendChild(messageElement);
+            User sender = (User) messages[i].getSender();
+            messageElement.setAttribute("sender", sender.getId());
+
+            Element recipientsElement = helper.createElement("recipients");
+            messageElement.appendChild(recipientsElement);
+
+            Identifiable[] recipients = messages[i].getRecipients();
+            for (int r = 0; r < recipients.length; r++) {
+                if (recipients[r] instanceof User) {
+                    Element userElement = helper.createElement("user");
+                    userElement.setAttribute("id", ((User) recipients[r]).getId());
+                    recipientsElement.appendChild(userElement);
+                } else if (recipients[r] instanceof Group) {
+                    Element groupElement = helper.createElement("group");
+                    groupElement.setAttribute("id", ((Group) recipients[r]).getId());
+                    recipientsElement.appendChild(groupElement);
+                }
+            }
+
+            Element subjectElement = helper.createElement("subject");
+            messageElement.appendChild(subjectElement);
+            Element subjectTextElement = helper.createElement("text", messages[i].getSubject());
+            subjectElement.appendChild(subjectTextElement);
+            String[] subjectParams = messages[i].getSubjectParameters();
+            for (int p = 0; p < subjectParams.length; p++) {
+                Element paramElement = helper.createElement("param", subjectParams[p]);
+                subjectElement.appendChild(paramElement);
+            }
+
+            Element bodyElement = helper.createElement("body");
+            messageElement.appendChild(bodyElement);
+            Element bodyTextElement = helper.createElement("text", messages[i].getBody());
+            bodyElement.appendChild(bodyTextElement);
+            String[] bodyParams = messages[i].getBodyParameters();
+            for (int p = 0; p < bodyParams.length; p++) {
+                Element paramElement = helper.createElement("param", bodyParams[p]);
+                bodyElement.appendChild(paramElement);
+            }
+        }
+        return helper;
+    }
+}

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxManager.java?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxManager.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxManager.java Mon Dec 11 09:41:23 2006
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.inbox.xml;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.lenya.ac.User;
+import org.apache.lenya.inbox.AbstractInboxManager;
+import org.apache.lenya.inbox.Inbox;
+
+/**
+ * XML-source based inbox manager.
+ */
+public class XmlSourceInboxManager extends AbstractInboxManager implements Serviceable {
+
+    protected ServiceManager manager;
+
+    protected Inbox doGetInbox(User user) {
+        return new XmlSourceInbox(this.manager, user);
+    }
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+
+}

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java Mon Dec 11 09:41:23 2006
@@ -44,8 +44,6 @@
 public abstract class AbstractNotifier extends AbstractLogEnabled implements Notifier, Serviceable,
         Contextualizable {
 
-    protected static final String NAMESPACE = "http://apache.org/lenya/notification/2.0";
-
     protected Message translateMessage(String locale, Message message) throws NotificationException {
 
         SourceResolver resolver = null;
@@ -105,7 +103,8 @@
             bodyElement = helper.getFirstChild(doc.getDocumentElement(), "body");
             String body = DocumentHelper.getSimpleElementText(bodyElement);
 
-            return new Message(subject, new String[0], body, new String[0]);
+            return new Message(subject, new String[0], body, new String[0], message.getSender(),
+                    message.getRecipients());
         } catch (Exception e) {
             throw new NotificationException(e);
         } finally {

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java Mon Dec 11 09:41:23 2006
@@ -29,16 +29,21 @@
 import org.apache.lenya.ac.Group;
 import org.apache.lenya.ac.Identifiable;
 import org.apache.lenya.ac.User;
+import org.apache.lenya.inbox.InboxNotifier;
 
 /**
  * Default notifier implementation.
  */
-public class EmailNotifier extends AbstractNotifier implements Configurable {
+public class EmailNotifier extends InboxNotifier implements Configurable {
 
-    public void notify(Identifiable[] recipients, Identifiable sender, Message message)
+    public void notify(Message message)
             throws NotificationException {
+        
+        super.notify(message);
 
         Set noDuplicates = new HashSet();
+        
+        Identifiable[] recipients = message.getRecipients();
 
         for (int i = 0; i < recipients.length; i++) {
             if (recipients[i] instanceof Group) {
@@ -52,15 +57,22 @@
         for (Iterator i = noDuplicates.iterator(); i.hasNext();) {
             Identifiable identifiable = (Identifiable) i.next();
             if (identifiable instanceof User) {
-                notify((User) identifiable, sender, message);
+                notify((User) identifiable, message);
             }
         }
 
     }
 
-    protected void notify(User recipient, Identifiable sender, Message message)
+    protected void notify(User recipient, Message message)
             throws NotificationException {
 
+        Identifiable sender = message.getSender();
+        
+        if (!this.manager.hasService(MailSender.ROLE)) {
+            getLogger().error("Can't send mails - no MailSender service found.");
+            return;
+        }
+        
         MailSender mailer = null;
         try {
             mailer = (MailSender) this.manager.lookup(MailSender.ROLE);

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Message.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Message.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Message.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Message.java Mon Dec 11 09:41:23 2006
@@ -17,6 +17,11 @@
  */
 package org.apache.lenya.notification;
 
+import java.util.Arrays;
+import java.util.Date;
+
+import org.apache.lenya.ac.Identifiable;
+
 /**
  * A notification message.
  */
@@ -26,6 +31,9 @@
     private String[] subjectParams;
     private String body;
     private String[] bodyParams;
+    private Identifiable sender;
+    private Identifiable[] recipients;
+    private Date time;
 
     /**
      * Ctor.
@@ -33,12 +41,18 @@
      * @param subjectParams The subject parameters.
      * @param body The body.
      * @param bodyParams The body parameters.
+     * @param sender The sender.
+     * @param recipients The recipients.
      */
-    public Message(String subject, String[] subjectParams, String body, String[] bodyParams) {
+    public Message(String subject, String[] subjectParams, String body, String[] bodyParams,
+            Identifiable sender, Identifiable[] recipients) {
         this.subject = subject;
         this.subjectParams = subjectParams;
         this.body = body;
         this.bodyParams = bodyParams;
+        this.sender = sender;
+        this.recipients = recipients;
+        this.time = new Date();
     }
 
     /**
@@ -87,6 +101,29 @@
      */
     public String[] getSubjectParameters() {
         return subjectParams;
+    }
+    
+    /**
+     * @return The sender.
+     */
+    public Identifiable getSender() {
+        return this.sender;
+    }
+    
+    /**
+     * @return The recipients.
+     */
+    public Identifiable[] getRecipients() {
+        // don't expose the internal array
+        return (Identifiable[]) Arrays.asList(this.recipients).toArray(
+                new Identifiable[this.recipients.length]);
+    }
+    
+    /**
+     * @return The time when the message was sent.
+     */
+    public Date getTime() {
+        return this.time;
     }
 
 }

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationEventDescriptor.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationEventDescriptor.java?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationEventDescriptor.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationEventDescriptor.java Mon Dec 11 09:41:23 2006
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.notification;
+
+import org.apache.lenya.util.Assert;
+
+/**
+ * Descriptor for notification events.
+ */
+public class NotificationEventDescriptor {
+
+    private Message message;
+    
+    /**
+     * @param message The message.
+     */
+    public NotificationEventDescriptor(Message message) {
+        Assert.notNull("message", message);
+        this.message = message;
+    }
+    
+    /**
+     * @return The message.
+     */
+    public Message getMessage() {
+        return this.message;
+    }
+    
+}

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationListener.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationListener.java?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationListener.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationListener.java Mon Dec 11 09:41:23 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.notification;
+
+import org.apache.lenya.cms.observation.AbstractRepositoryListener;
+import org.apache.lenya.cms.observation.RepositoryEvent;
+
+/**
+ * Repository listener to distribute notification events.
+ */
+public class NotificationListener extends AbstractRepositoryListener {
+
+    public void eventFired(RepositoryEvent event) {
+
+        if (!(event.getDescriptor() instanceof NotificationEventDescriptor)) {
+            return;
+        }
+
+        NotificationEventDescriptor descriptor = (NotificationEventDescriptor) event
+                .getDescriptor();
+
+        Message message = descriptor.getMessage();
+
+        Notifier notifier = null;
+        try {
+            notifier = (Notifier) this.manager.lookup(Notifier.ROLE);
+            notifier.notify(message);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (notifier != null) {
+                this.manager.release(notifier);
+            }
+        }
+
+    }
+
+}

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationUtil.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationUtil.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/NotificationUtil.java Mon Dec 11 09:41:23 2006
@@ -19,7 +19,6 @@
 
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.lenya.ac.Identifiable;
 
 /**
  * Notification utility.
@@ -29,22 +28,19 @@
     /**
      * Invokes a notification.
      * @param manager The service manager.
-     * @param recipients The recipients.
-     * @param sender The sender.
      * @param message The message.
      * @throws NotificationException if an error occurs.
      */
-    public static final void notify(ServiceManager manager, Identifiable[] recipients,
-            Identifiable sender, Message message) throws NotificationException {
+    public static final void notify(ServiceManager manager, Message message)
+            throws NotificationException {
 
         Notifier notifier = null;
         try {
             notifier = (Notifier) manager.lookup(Notifier.ROLE);
-            notifier.notify(recipients, sender, message);
+            notifier.notify(message);
         } catch (ServiceException e) {
             throw new NotificationException(e);
-        }
-        finally {
+        } finally {
             if (notifier != null) {
                 manager.release(notifier);
             }

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Notifier.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Notifier.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Notifier.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/Notifier.java Mon Dec 11 09:41:23 2006
@@ -17,25 +17,26 @@
  */
 package org.apache.lenya.notification;
 
-import org.apache.lenya.ac.Identifiable;
-
 /**
  * Notification service.
  */
 public interface Notifier {
 
     /**
+     * The notification namespace.
+     */
+    String NAMESPACE = "http://apache.org/lenya/notification/2.0";
+
+    /**
      * The service role.
      */
     String ROLE = Notifier.class.getName();
     
     /**
      * Send a notification.
-     * @param recipients The recipients.
-     * @param sender The sender.
      * @param message The message.
      * @throws NotificationException if an error occurs.
      */
-    void notify(Identifiable[] recipients, Identifiable sender, Message message) throws NotificationException;
+    void notify(Message message) throws NotificationException;
     
 }

Added: lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java (added)
+++ lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java Mon Dec 11 09:41:23 2006
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.notification;
+
+import org.apache.lenya.ac.Identifiable;
+import org.apache.lenya.ac.User;
+import org.apache.lenya.ac.impl.AbstractAccessControlTest;
+import org.apache.lenya.cms.observation.RepositoryEvent;
+import org.apache.lenya.cms.observation.RepositoryEventFactory;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.inbox.Inbox;
+import org.apache.lenya.inbox.InboxManager;
+
+/**
+ * Notification test.
+ */
+public class NotificationTest extends AbstractAccessControlTest {
+
+    protected static final String SUBJECT = "hello";
+
+    /**
+     * The test.
+     * @throws Exception
+     */
+    public void testNotification() throws Exception {
+
+        login("lenya");
+
+        Session session = getFactory().getSession();
+
+        User lenya = getAccreditableManager().getUserManager().getUser("lenya");
+        User alice = getAccreditableManager().getUserManager().getUser("alice");
+
+        Identifiable[] recipients = { alice };
+
+        Message message = new Message(SUBJECT, new String[0], "body", new String[0], lenya,
+                recipients);
+        NotificationEventDescriptor descr = new NotificationEventDescriptor(message);
+        RepositoryEvent event = RepositoryEventFactory.createEvent(getManager(), session,
+                getLogger(), descr);
+
+        session.enqueueEvent(event);
+        
+        Inbox inbox = getInbox(alice);
+        cleanUp(inbox);
+        
+        assertFalse(containsMessage(inbox));
+        session.commit();
+        Thread.sleep(100);
+        assertTrue(containsMessage(inbox));
+        
+        cleanUp(inbox);
+
+    }
+
+    protected Inbox getInbox(User user) throws Exception {
+        InboxManager inboxManager = null;
+        try {
+            inboxManager = (InboxManager) getManager().lookup(InboxManager.ROLE);
+            return inboxManager.getInbox(user);
+        }
+        finally {
+            if (inboxManager != null) {
+                getManager().release(inboxManager);
+            }
+        }
+    }
+
+    protected boolean containsMessage(Inbox inbox) {
+        Message[] messages = inbox.getMessages();
+        if (messages.length == 0) {
+            return false;
+        }
+        return messages[messages.length - 1].getSubject().equals(SUBJECT);
+    }
+    
+    protected void cleanUp(Inbox inbox) {
+        Message[] messages = inbox.getMessages();
+        for (int i = 0; i < messages.length; i++) {
+            if (messages[i].getSubject().equals(SUBJECT)) {
+                inbox.remove(messages[i]);
+            }
+        }
+    }
+}

Modified: lenya/trunk/src/modules/notification/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/module.xml?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/notification/module.xml (original)
+++ lenya/trunk/src/modules/notification/module.xml Mon Dec 11 09:41:23 2006
@@ -20,9 +20,11 @@
 
 <module xmlns="http://apache.org/lenya/module/1.0">
   <id>org.apache.lenya.modules.notification</id>
+  <depends module="org.apache.lenya.modules.administration"/> <!-- necessary for tabs -->
+  <depends module="org.apache.lenya.modules.usecase"/>
   <package>org.apache.lenya.modules</package>
   <version>0.1-dev</version>
-  <name>Repository Module</name>
+  <name>Notification</name>
   <lenya-version>@lenya.version@</lenya-version>
-  <description>Lenya Repository API (Draft)</description>
+  <description>Notification module</description>
 </module>

Added: lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml (added)
+++ lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml Mon Dec 11 09:41:23 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: cmsui.xml 447395 2006-09-18 13:01:33Z andreas $ -->
+
+<catalogue xml:lang="en" xmlns:xhtml="http://www.w3.org/1999/xhtml">
+  
+  <message key="inbox-of">Inbox of User {0}</message>
+  <message key="Sender">Sender</message>
+  <message key="new-message">New Message</message>
+  <message key="From">From</message>
+  <message key="To">To</message>
+  <message key="Message">Message</message>
+  <message key="Messages">Messages</message>
+  <message key="Send">Send</message>
+  <message key="selected-message">Selected&#160;message</message>
+  
+</catalogue>

Added: lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml (added)
+++ lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml Mon Dec 11 09:41:23 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: cmsui.xml 447395 2006-09-18 13:01:33Z andreas $ -->
+
+<catalogue xml:lang="de" xmlns:xhtml="http://www.w3.org/1999/xhtml">
+  
+  <message key="inbox-of">Posteingang von Nutzer {0}</message>
+  <message key="Sender">Absender</message>
+  <message key="new-message">Neue Nachricht</message>
+  <message key="From">Von</message>
+  <message key="To">An</message>
+  <message key="Message">Nachricht</message>
+  <message key="Messages">Nachrichten</message>
+  <message key="Send">Senden</message>
+  <message key="selected-message">Ausgewählte&#160;Nachricht</message>
+  
+</catalogue>

Added: lenya/trunk/src/modules/notification/usecases/currentMessage.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/usecases/currentMessage.jx?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/usecases/currentMessage.jx (added)
+++ lenya/trunk/src/modules/notification/usecases/currentMessage.jx Mon Dec 11 09:41:23 2006
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id: groups.jx 473861 2006-11-12 03:51:14Z gregor $ -->
+
+<jx:template
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
+  >
+  
+  <jx:if test="${usecase.getName().getClass().isInstance(messageIndex)}">
+    <jx:set var="message" value="${java.util.Arrays.asList(inbox.getMessages()).get(java.lang.Integer.valueOf(messageIndex).intValue())}"/>
+    
+    <div class="lenya-box" style="width: 100%">
+      <div class="lenya-box-title"><i18n:text>selected-message</i18n:text></div>
+      <div class="lenya-box-body">
+        <table class="lenya-table-noborder">
+          <tr>
+            <td class="lenya-entry-caption"><i18n:text>From</i18n:text>:</td>
+            <td style="white-space: nowrap">
+              <jx:out value="${message.getSender().getName()}"/>
+              (<a href="?lenya.usecase=admin.user&amp;userId=${message.getSender().getId()}"><jx:out value="${message.getSender().getId()}"/></a>)
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption"><i18n:text>Subject</i18n:text>:</td>
+            <td>
+              <i18n:translate>
+                <i18n:text><jx:out value="${message.getSubject()}"/></i18n:text>
+                <jx:forEach var="param" items="${message.getSubjectParameters()}">
+                  <i18n:param><jx:out value="${param}"/></i18n:param>
+                </jx:forEach>
+              </i18n:translate>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption" valign="top"><i18n:text>Message</i18n:text>:</td>
+            <td>
+              <i18n:translate>
+                <i18n:text><jx:out value="${message.getBody()}"/></i18n:text>
+                <jx:forEach var="param" items="${message.getBodyParameters()}">
+                  <i18n:param><jx:out value="${param}"/></i18n:param>
+                </jx:forEach>
+              </i18n:translate>
+            </td>
+          </tr>
+        </table>
+      </div>
+    </div>
+    
+  </jx:if>
+  
+</jx:template>
\ No newline at end of file

Added: lenya/trunk/src/modules/notification/usecases/inbox.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/usecases/inbox.jx?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/usecases/inbox.jx (added)
+++ lenya/trunk/src/modules/notification/usecases/inbox.jx Mon Dec 11 09:41:23 2006
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id: groups.jx 473861 2006-11-12 03:51:14Z gregor $ -->
+
+<page:page
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
+  >
+  
+  <page:body>
+    <jx:import uri="fallback://lenya/usecases/templates/tabs.jx"/>
+    <div id="contentblock1" class="lenya-tab">
+      <h1>
+        <i18n:translate>
+          <i18n:text>inbox-of</i18n:text>
+          <i18n:param><jx:out value="${usecase.getParameter('user')}"/></i18n:param>
+        </i18n:translate>
+      </h1>
+      
+      <table class="lenya-table-noborder">
+        <tr>
+          <td colspan="2">
+            <jx:import uri="fallback://lenya/usecases/templates/messages.jx"/>
+          </td>
+        </tr>
+      </table>
+      
+      <p>
+        <a href="?lenya.usecase=notification.sendMessage"><i18n:text>new-message</i18n:text></a>
+      </p>
+      
+      <jx:set var="inbox" value="${usecase.getParameter('inbox')}"/>
+      <jx:set var="messageIndex" value="${request.getParameter('messageIndex')}"/>
+      
+      <table>
+        <tr>
+          <td valign="top" style="padding-right: 20px;">
+            <jx:import uri="fallback://lenya/modules/notification/usecases/messageList.jx"/>
+          </td>
+          <td valign="top" style="padding-left: 20px;">
+            <jx:import uri="fallback://lenya/modules/notification/usecases/currentMessage.jx"/>
+          </td>
+        </tr>
+      </table>
+            
+    </div>
+  </page:body>
+</page:page>
\ No newline at end of file

Added: lenya/trunk/src/modules/notification/usecases/messageList.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/usecases/messageList.jx?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/usecases/messageList.jx (added)
+++ lenya/trunk/src/modules/notification/usecases/messageList.jx Mon Dec 11 09:41:23 2006
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id: groups.jx 473861 2006-11-12 03:51:14Z gregor $ -->
+
+<jx:template
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
+  >
+  
+  <table class="lenya-table-list">
+    <tr>
+      <th style="text-align: left; padding-right: 20px;"><i18n:text>Subject</i18n:text></th>
+      <th style="text-align: left; padding-right: 20px;"><i18n:text>Sender</i18n:text></th>
+      <th style="text-align: left; padding-right: 20px;"><i18n:text>Date</i18n:text></th>
+    </tr>
+    <jx:set var="index" value="0"/>
+    <jx:forEach var="message" items="${inbox.getMessages()}">
+      
+      <jx:set var="class" value="normal"/>
+      <jx:if test="${index.toString().equals(messageIndex)}">
+        <jx:set var="class" value="highlight"/>
+      </jx:if>
+      
+      <form method="POST">
+        <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+        <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+        <tr class="${class}">
+          <td>
+            <a href="?lenya.usecase=notification.inbox&amp;messageIndex=${index}">
+              <i18n:translate>
+                <i18n:text><jx:out value="${message.getSubject()}"/></i18n:text>
+                <jx:forEach var="param" items="${message.getSubjectParameters()}">
+                  <i18n:param><jx:out value="${param}"/></i18n:param>
+                </jx:forEach>
+              </i18n:translate>
+            </a>
+          </td>
+          <td>
+            <a href="?lenya.usecase=admin.user&amp;userId=${message.getSender().getId()}"><jx:out value="${message.getSender().getId()}"/></a>
+          </td>
+          <td>
+            <jx:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${message.getTime()}"/>
+          </td>
+        </tr>
+      </form>
+      <jx:set var="index" value="${index + 1}"/>
+    </jx:forEach>
+  </table>
+  
+</jx:template>
\ No newline at end of file

Added: lenya/trunk/src/modules/notification/usecases/sendMessage.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/usecases/sendMessage.jx?view=auto&rev=485769
==============================================================================
--- lenya/trunk/src/modules/notification/usecases/sendMessage.jx (added)
+++ lenya/trunk/src/modules/notification/usecases/sendMessage.jx Mon Dec 11 09:41:23 2006
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id: groups.jx 473861 2006-11-12 03:51:14Z gregor $ -->
+
+<page:page
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
+  >
+  
+  <page:body>
+    <jx:import uri="fallback://lenya/usecases/templates/tabs.jx"/>
+    <div id="contentblock1" class="lenya-tab">
+      <h1><i18n:text>new-message</i18n:text></h1>
+      
+      <table class="lenya-table-noborder">
+        <tr>
+          <td colspan="2">
+            <jx:import uri="fallback://lenya/usecases/templates/messages.jx"/>
+          </td>
+        </tr>
+      </table>
+      
+      <jx:set var="sender" value="${usecase.getParameter('user')}"/>
+      
+      <form action="" method="POST">
+        <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+        <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+        <div style="margin: 10px 0px">
+          <table class="lenya-table-noborder">
+            <tr>
+              <td class="lenya-entry-caption"><i18n:text>From</i18n:text></td>
+              <td>
+                <jx:out value="${sender.getId()}"></jx:out>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption"><i18n:text>To</i18n:text></td>
+              <td>
+                <select class="lenya-form-element" name="recipient">
+                  <jx:forEach var="recipient" items="${usecase.getParameter('users')}">
+                    <option value="${recipient.getId()}"><jx:out value="${recipient.getId()}"/></option>
+                  </jx:forEach>
+                </select>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption"><i18n:text>Subject</i18n:text></td>
+              <td>
+                <input class="lenya-form-element" name="subject" type="text"/>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption" valign="top"><i18n:text>Message</i18n:text></td>
+              <td>
+                <textarea style="height: 300px" class="lenya-form-element" name="body"/>
+              </td>
+            </tr>
+            <tr>
+              <td/>
+              <td>
+                <input name="submit" type="submit" value="Send" i18n:attr="value"/>
+              </td>
+            </tr>
+          </table>
+        </div>
+      </form>
+      
+    </div>
+  </page:body>
+</page:page>
\ No newline at end of file

Modified: lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoNode.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoNode.java (original)
+++ lenya/trunk/src/modules/repository/java/src/org/apache/lenya/cms/repo/adapter/RepoNode.java Mon Dec 11 09:41:23 2006
@@ -28,12 +28,11 @@
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.metadata.MetaDataException;
-import org.apache.lenya.cms.observation.RepositoryEvent;
+import org.apache.lenya.cms.observation.RepositoryListener;
 import org.apache.lenya.cms.rc.RCML;
 import org.apache.lenya.cms.repo.Translation;
 import org.apache.lenya.cms.repository.History;
 import org.apache.lenya.cms.repository.Node;
-import org.apache.lenya.cms.repository.NodeListener;
 import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.repository.Session;
 
@@ -192,7 +191,7 @@
 
     private Set listeners = new HashSet();
 
-    public void addListener(NodeListener listener) throws RepositoryException {
+    public void addListener(RepositoryListener listener) throws RepositoryException {
         if (this.listeners.contains(listener)) {
             throw new RepositoryException("The listener [" + listener
                     + "] is already registered for node [" + this + "]!");
@@ -200,7 +199,7 @@
         this.listeners.add(listener);
     }
 
-    public boolean isListenerRegistered(NodeListener listener) {
+    public boolean isListenerRegistered(RepositoryListener listener) {
         return this.listeners.contains(listener);
     }
 
@@ -209,11 +208,6 @@
     }
 
     public History getHistory() {
-        return null;
-    }
-
-    public RepositoryEvent getEvent() {
-        // TODO Auto-generated method stub
         return null;
     }
 

Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java Mon Dec 11 09:41:23 2006
@@ -31,6 +31,7 @@
 import org.apache.lenya.ac.User;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.metadata.MetaDataException;
+import org.apache.lenya.cms.observation.DocumentEvent;
 import org.apache.lenya.cms.observation.RepositoryEvent;
 import org.apache.lenya.cms.observation.RepositoryEventFactory;
 import org.apache.lenya.cms.rc.RCML;
@@ -48,7 +49,7 @@
 public class SourceNode extends AbstractLogEnabled implements Node, Transactionable {
 
     protected ServiceManager manager;
-    
+
     private ContentSourceWrapper contentSource;
     private MetaSourceWrapper metaSource;
 
@@ -64,15 +65,15 @@
         this.manager = manager;
         enableLogging(logger);
         this.session = session;
-        
+
         this.contentSource = new ContentSourceWrapper(this, sourceUri, manager, logger);
         this.metaSource = new MetaSourceWrapper(this, sourceUri, manager, logger);
     }
-    
+
     protected ContentSourceWrapper getContentSource() {
         return this.contentSource;
     }
-    
+
     protected MetaSourceWrapper getMetaSource() {
         return this.metaSource;
     }
@@ -288,8 +289,8 @@
             java.util.Vector newChildren = new java.util.Vector();
             while (iterator.hasNext()) {
                 TraversableSource child = (TraversableSource) iterator.next();
-                newChildren.add(new SourceNode(getSession(), getSourceURI() + "/" + child.getName(),
-                        this.manager, getLogger()));
+                newChildren.add(new SourceNode(getSession(),
+                        getSourceURI() + "/" + child.getName(), this.manager, getLogger()));
             }
             return newChildren;
         } catch (Exception e) {
@@ -330,16 +331,25 @@
 
     public void registerDirty() throws RepositoryException {
         try {
-            getSession().registerDirty(this);
+            if (!getSession().isDirty(this)) {
+                getSession().registerDirty(this);
+                enqueueEvent(DocumentEvent.CHANGED);
+            }
         } catch (TransactionException e) {
             throw new RepositoryException(e);
         }
     }
 
+    protected void enqueueEvent(Object descriptor) {
+        RepositoryEvent event = RepositoryEventFactory.createEvent(this.manager, this,
+                getLogger(), descriptor);
+        getSession().enqueueEvent(event);
+    }
+
     public void registerRemoved() throws RepositoryException {
         try {
             getSession().registerRemoved(this);
-            //SourceUtil.delete(getMetaSourceUri(), this.manager);
+            enqueueEvent(DocumentEvent.REMOVED);
         } catch (Exception e) {
             throw new RepositoryException(e);
         }
@@ -366,15 +376,6 @@
         return this.metaSource.getMetaDataHandler().getMetaData(namespaceUri);
     }
 
-    private RepositoryEvent event;
-
-    public RepositoryEvent getEvent() {
-        if (this.event == null) {
-            this.event = RepositoryEventFactory.createEvent(this.manager, this, getLogger());
-        }
-        return this.event;
-    }
-
     public boolean exists() throws RepositoryException {
         return this.contentSource.exists() || this.metaSource.exists();
     }
@@ -392,11 +393,11 @@
     }
 
     public long getLastModified() throws RepositoryException {
-        
+
         if (!exists()) {
             throw new RepositoryException("The node [" + this + "] does not exist!");
         }
-        
+
         long contentLastModified = 0;
         if (this.contentSource.exists()) {
             contentLastModified = this.contentSource.getLastModified();
@@ -405,7 +406,7 @@
         if (this.metaSource.exists()) {
             metaLastModified = this.metaSource.getLastModified();
         }
-        
+
         return Math.max(contentLastModified, metaLastModified);
     }
 

Modified: lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml (original)
+++ lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml Mon Dec 11 09:41:23 2006
@@ -345,5 +345,15 @@
     <role id="edit" method="grant"/>
     <role id="review" method="grant"/>
   </usecase>
+  <usecase id="notification.inbox">
+    <role id="admin" method="grant"/>
+    <role id="edit" method="grant"/>
+    <role id="review" method="grant"/>
+  </usecase>
+  <usecase id="notification.sendMessage">
+    <role id="admin" method="grant"/>
+    <role id="edit" method="grant"/>
+    <role id="review" method="grant"/>
+  </usecase>
 </usecases>
     

Modified: lenya/trunk/src/pubs/default/config/publication.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/config/publication.xconf?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/pubs/default/config/publication.xconf (original)
+++ lenya/trunk/src/pubs/default/config/publication.xconf Mon Dec 11 09:41:23 2006
@@ -52,6 +52,7 @@
   <module name="sitetree"/>
   <module name="export"/>
   <module name="workflow-impl"/>
+  <module name="notification"/>
   <!-- TODO: The goal is to have a blog module ;-) -->
   <!--
   <module name="blog"/>

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Mon Dec 11 09:41:23 2006
@@ -37,6 +37,8 @@
 import org.apache.lenya.cms.linking.LinkManager;
 import org.apache.lenya.cms.linking.LinkResolver;
 import org.apache.lenya.cms.linking.LinkTarget;
+import org.apache.lenya.cms.observation.RepositoryEvent;
+import org.apache.lenya.cms.observation.RepositoryEventFactory;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.DocumentFactory;
@@ -58,8 +60,8 @@
 import org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
 import org.apache.lenya.notification.Message;
+import org.apache.lenya.notification.NotificationEventDescriptor;
 import org.apache.lenya.notification.NotificationException;
-import org.apache.lenya.notification.NotificationUtil;
 import org.apache.lenya.workflow.Version;
 import org.apache.lenya.workflow.WorkflowException;
 import org.apache.lenya.workflow.Workflowable;
@@ -87,7 +89,7 @@
     protected void initParameters() {
         super.initParameters();
 
-        if (hasErrors()) {
+        if (hasErrors() || getSourceDocument() == null) {
             return;
         }
 
@@ -343,9 +345,12 @@
             }
             String[] params = { url };
             Message message = new Message(MESSAGE_SUBJECT, new String[0], MESSAGE_DOCUMENT_PUBLISHED,
-                    params);
-    
-            NotificationUtil.notify(this.manager, recipients, sender, message);
+                    params, sender, recipients);
+            
+            NotificationEventDescriptor descriptor = new NotificationEventDescriptor(message);
+            RepositoryEvent event = RepositoryEventFactory
+                    .createEvent(this.manager, authoringDocument, getLogger(), descriptor);
+            getSession().enqueueEvent(event);
         }
     }
 

Modified: lenya/trunk/src/webapp/lenya/resources/css/tables.css
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/resources/css/tables.css?view=diff&rev=485769&r1=485768&r2=485769
==============================================================================
--- lenya/trunk/src/webapp/lenya/resources/css/tables.css (original)
+++ lenya/trunk/src/webapp/lenya/resources/css/tables.css Mon Dec 11 09:41:23 2006
@@ -61,3 +61,20 @@
 	font-size: small;
 }
 
+table.lenya-table-list {
+  border: none;
+	border-spacing: 0px;
+	border-collapse: collapse;
+}
+
+table.lenya-table-list th,
+table.lenya-table-list td {
+  text-align: left;
+  padding: 2px 2em 2px 5px;
+  border-bottom: solid 1px #CCCCCC;
+}
+
+table.lenya-table-list tr.highlight {
+  background-color: #DDDCCF;
+  color: Black;
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org