Author: andreas
Date: Wed Aug 29 15:31:41 2007
New Revision: 570957
URL: http://svn.apache.org/viewvc?rev=570957&view=rev
Log:
Store publication ID instead of publication object in DocumentIdentifier. See bug 43240.
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/DefaultDocumentTest.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentifier.java
lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/ObservationManager.java
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?rev=570957&r1=570956&r2=570957&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Wed Aug 29 15:31:41 2007
@@ -262,7 +262,7 @@
try {
Publication publication = getPublication(publicationId);
DocumentBuilder builder = publication.getDocumentBuilder();
- DocumentIdentifier identifier = new DocumentIdentifier(publication, area, uuid,
+ DocumentIdentifier identifier = new DocumentIdentifier(publicationId, area, uuid,
language);
document = buildDocument(this, identifier, revision, builder);
} catch (Exception e) {
@@ -298,8 +298,12 @@
}
public Document get(DocumentIdentifier identifier) throws DocumentBuildException {
- return get(identifier.getPublication(), identifier.getArea(), identifier.getUUID(),
- identifier.getLanguage());
+ try {
+ Publication pub = getPublication(identifier.getPublicationId());
+ return get(pub, identifier.getArea(), identifier.getUUID(), identifier.getLanguage());
+ } catch (PublicationException e) {
+ throw new DocumentBuildException(e);
+ }
}
public String getItemType() {
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java?rev=570957&r1=570956&r2=570957&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java Wed Aug 29 15:31:41 2007
@@ -164,11 +164,20 @@
}
}
+ private Publication publication;
+
/**
* @see org.apache.lenya.cms.publication.Document#getPublication()
*/
public Publication getPublication() {
- return this.identifier.getPublication();
+ if (this.publication == null) {
+ try {
+ this.publication = getFactory().getPublication(getIdentifier().getPublicationId());
+ } catch (PublicationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return this.publication;
}
/**
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/DefaultDocumentTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/DefaultDocumentTest.java?rev=570957&r1=570956&r2=570957&view=diff
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/DefaultDocumentTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/DefaultDocumentTest.java Wed Aug 29 15:31:41 2007
@@ -81,9 +81,9 @@
Publication pub = getPublication("test");
String uuid = pub.getArea(testSet.getArea()).getSite().getNode(testSet.getPath()).getUuid();
- DocumentIdentifier id = new DocumentIdentifier(pub, testSet.getArea(), uuid, testSet
+ DocumentIdentifier id = new DocumentIdentifier(pub.getId(), testSet.getArea(), uuid, testSet
.getLanguage());
- DocumentImpl document = new DocumentImpl(getManager(), getFactory(), id, getLogger());
+ DocumentImpl document = new DocumentImpl(getManager(), getFactory(), id, -1, getLogger());
document.setExtension(testSet.getExtension());
return document;
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentifier.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentifier.java?rev=570957&r1=570956&r2=570957&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentifier.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentifier.java Wed Aug 29 15:31:41 2007
@@ -17,31 +17,24 @@
*/
package org.apache.lenya.cms.publication;
-import java.util.Arrays;
-
/**
* Value object to identify documents.
*/
public class DocumentIdentifier {
- private Publication publication;
+ private String publicationId;
private String area;
private String language;
private String uuid;
/**
* Ctor.
- * @param publication The publication.
+ * @param pubId The publication ID.
* @param area The area.
* @param uuid The document UUID.
* @param language The language.
*/
- public DocumentIdentifier(Publication publication, String area, String uuid, String language) {
-
- if (!Arrays.asList(publication.getLanguages()).contains(language)) {
- throw new IllegalArgumentException("The language [" + language
- + "] is not supported by publication [" + publication.getId() + "]!");
- }
+ public DocumentIdentifier(String pubId, String area, String uuid, String language) {
if (uuid.startsWith("/") && uuid.split("-").length == 4) {
throw new IllegalArgumentException("The UUID [" + uuid + "] must not begin with a '/'!");
@@ -51,7 +44,7 @@
+ "] must not contain a '/' after the first position!");
}
- this.publication = publication;
+ this.publicationId = pubId;
this.area = area;
this.language = language;
this.uuid = uuid;
@@ -79,10 +72,10 @@
}
/**
- * @return The publication.
+ * @return The publication ID.
*/
- public Publication getPublication() {
- return publication;
+ public String getPublicationId() {
+ return publicationId;
}
public boolean equals(Object obj) {
@@ -94,7 +87,7 @@
}
protected String getKey() {
- return this.publication.getId() + ":" + this.area + ":" + this.uuid + ":" + this.language;
+ return this.publicationId + ":" + this.area + ":" + this.uuid + ":" + this.language;
}
public String toString() {
Modified: lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/ObservationManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/ObservationManager.java?rev=570957&r1=570956&r2=570957&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/ObservationManager.java (original)
+++ lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/ObservationManager.java Wed Aug 29 15:31:41 2007
@@ -24,24 +24,16 @@
import java.util.Set;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentIdentifier;
-import org.apache.lenya.cms.publication.DocumentUtil;
-import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.util.Assert;
/**
- * Observation manager. Works as an observation registry and sends the
- * notifications.
+ * Observation manager. Works as an observation registry and sends the notifications.
*/
public class ObservationManager extends AbstractLogEnabled implements ObservationRegistry,
- ThreadSafe, Serviceable {
+ ThreadSafe {
private Map identifier2listeners = new HashMap();
private Set listeners = new HashSet();
@@ -76,17 +68,8 @@
protected DocumentIdentifier getIdentifier(DocumentEvent event) {
Assert.notNull("event", event);
-
- DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, event
- .getSession());
- Publication pub;
- try {
- pub = factory.getPublication(event.getPublicationId());
- } catch (PublicationException e) {
- throw new RuntimeException(e);
- }
- DocumentIdentifier id = new DocumentIdentifier(pub, event.getArea(), event.getUuid(), event
- .getLanguage());
+ DocumentIdentifier id = new DocumentIdentifier(event.getPublicationId(), event.getArea(),
+ event.getUuid(), event.getLanguage());
return id;
}
@@ -125,8 +108,7 @@
if (event instanceof DocumentEvent) {
DocumentIdentifier id = getIdentifier((DocumentEvent) event);
listeners = getAllListeners(id);
- }
- else {
+ } else {
listeners = this.listeners;
}
Notifier notifier = new Notifier(listeners, event) {
@@ -135,12 +117,6 @@
}
};
new Thread(notifier).run();
- }
-
- private ServiceManager manager;
-
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.