Author: andreas
Date: Fri Feb 8 16:16:51 2008
New Revision: 620050
URL: http://svn.apache.org/viewvc?rev=620050&view=rev
Log:
Simplified validity generation in SitetreeFragmentGenerator (use provided resolver instead of looking up a new one).
Modified:
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java?rev=620050&r1=620049&r2=620050&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java Fri Feb 8 16:16:51 2008
@@ -80,6 +80,7 @@
private String path;
+ private String cacheKey;
private SourceValidity validity;
protected static final String PARAM_PUB = "pub";
@@ -169,6 +170,7 @@
this.getLogger().debug("Parameter areas: " + areasStr.toString());
}
+ Source source = null;
try {
Session session = RepositoryUtil.getSession(this.manager, request);
DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
@@ -192,10 +194,19 @@
"Path parameter not provided, no node for UUID and language found.");
}
}
+
+ this.cacheKey = pubId + "/" + area + this.path;
+ source = resolver.resolveURI(this.site.getRepositoryNode().getSourceURI());
+ this.validity = source.getValidity();
+
} catch (ProcessingException e) {
throw e;
} catch (Exception e) {
throw new ProcessingException("Could not create publication: ", e);
+ } finally {
+ if (source != null) {
+ resolver.release(source);
+ }
}
this.attributes = new AttributesImpl();
@@ -512,31 +523,15 @@
}
public Serializable getKey() {
- String s = ":";
- String pubId = this.site.getPublication().getId();
- String area = this.site.getArea();
- return pubId + s + area + this.path;
+ if (this.cacheKey == null) {
+ throw new IllegalStateException("setup() has not been called.");
+ }
+ return this.cacheKey;
}
public SourceValidity getValidity() {
if (this.validity == null) {
- String sourceUri = this.site.getRepositoryNode().getSourceURI();
- SourceResolver resolver = null;
- Source source = null;
- try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = resolver.resolveURI(sourceUri);
- this.validity = source.getValidity();
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
- }
- }
+ throw new IllegalStateException("setup() has not been called.");
}
return this.validity;
}
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.