Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r426130 - in /lenya/trunk/src: modules-core/observation-impl/ja: msg#00200

cms.lenya.cvs

Subject: svn commit: r426130 - in /lenya/trunk/src: modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ modules/sourcerepository/java/src/org/apache/lenya/cms/repository/

Author: andreas
Date: Thu Jul 27 09:35:12 2006
New Revision: 426130

URL: http://svn.apache.org/viewvc?rev=426130&view=rev
Log:
Fixed notification for deleted documents

Modified:

lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java

lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java

lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java

Modified:
lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java?rev=426130&r1=426129&r2=426130&view=diff
==============================================================================
---
lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java
(original)
+++
lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/ObservationTest.java
Thu Jul 27 09:35:12 2006
@@ -28,6 +28,7 @@
import org.apache.lenya.cms.cocoon.source.SourceUtil;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationUtil;
@@ -55,7 +56,7 @@

// check if it works if only the allListener is registered
registry.registerListener(allListener);
- testListener(doc, allListener);
+ testChanged(doc, allListener);

registry.registerListener(docListener, doc);
Exception e = null;
@@ -67,8 +68,8 @@
}
assertNotNull(e);

- testListener(doc, docListener);
- testListener(doc, allListener);
+ testChanged(doc, docListener);
+ testChanged(doc, allListener);

}
finally {
@@ -80,7 +81,7 @@

}

- protected void testListener(Document doc, TestListener listener) throws
Exception {
+ protected void testChanged(Document doc, TestListener listener) throws
Exception {
listener.reset();
NamespaceHelper xml = new
NamespaceHelper("http://apache.org/lenya/test";, "", "test");
doc.getRepositoryNode().lock();
@@ -90,13 +91,38 @@
doc.setMimeType("");
doc.setMimeType(mimeType);

- assertFalse(listener.wasNotified());
-
+ assertFalse(listener.wasChanged());
doc.getRepositoryNode().getSession().commit();
-
Thread.currentThread().sleep(100);
+ assertTrue(listener.wasChanged());
+ }
+
+ protected void testRemoved(Document doc, TestListener listener) throws
Exception {
+ listener.reset();
+
+ DocumentManager docManager = null;
+ try {
+ docManager = (DocumentManager)
getManager().lookup(DocumentManager.ROLE);
+ Document target = doc.getIdentityMap().get(doc.getPublication(),
doc.getArea(), "/testTarget", doc.getLanguage());
+ docManager.move(doc, target);
+
+ assertFalse(listener.wasRemoved());
+ doc.getRepositoryNode().getSession().commit();
+ Thread.currentThread().sleep(100);
+ assertTrue(listener.wasRemoved());
+
+ docManager.move(target, doc);
+ assertFalse(listener.wasChanged());
+ doc.getRepositoryNode().getSession().commit();
+ Thread.currentThread().sleep(100);
+ assertTrue(listener.wasChanged());
+ }
+ finally {
+ if (docManager != null) {
+ getManager().release(docManager);
+ }
+ }

- assertTrue(listener.wasNotified());
}

}

Modified:
lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java?rev=426130&r1=426129&r2=426130&view=diff
==============================================================================
---
lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java
(original)
+++
lenya/trunk/src/modules-core/observation-impl/java/test/org/apache/lenya/cms/observation/TestListener.java
Thu Jul 27 09:35:12 2006
@@ -5,18 +5,28 @@

public class TestListener implements RepositoryListener {

- private boolean notified = false;
+ private boolean changed = false;
+ private boolean removed = false;

public void documentChanged(RepositoryEvent event) {
- this.notified = true;
+ this.changed = true;
}

- public boolean wasNotified() {
- return this.notified;
+ public boolean wasChanged() {
+ return this.changed;
+ }
+
+ public boolean wasRemoved() {
+ return this.removed;
}

public void reset() {
- this.notified = false;
+ this.changed = false;
+ this.removed = false;
+ }
+
+ public void documentRemoved(RepositoryEvent event) {
+ this.removed = true;
}

}

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?rev=426130&r1=426129&r2=426130&view=diff
==============================================================================
---
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
Thu Jul 27 09:35:12 2006
@@ -234,7 +234,7 @@
Node node = getDocumentNode();
for (Iterator i = this.listeners.iterator(); i.hasNext(); ) {
NodeListener listener = (NodeListener) i.next();
- listener.nodeChanged(node, getSession().getIdentity());
+ listener.nodeRemoved(node, getSession().getIdentity());
}

} catch (Exception e) {


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
user-groups.jax...    php.zend.framew...    os.solaris.open...    web.quixote.use...    java.openjdk.ho...    ietf.secmech/20...    gnu.glpk/2004-0...    recreation.cars...    network.smokepi...    linux.drivers.i...    cms.opencms.dev...    fonts.gfontview...    text.xml.soap.u...    voip.nist-sip/2...    debian.ports.hp...    xfree86.interna...    science.biology...    qnx.openqnx.dev...    mail.sylpheed.c...    busybox/bios/20...    emulators.kvm.s...    hardware.openco...    apple.fink.begi...    kde.german/2006...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation