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/07/26 13:57:11 UTC
svn commit: r425714 - in /lenya/trunk/src:
impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
Author: andreas
Date: Wed Jul 26 04:57:09 2006
New Revision: 425714
URL: http://svn.apache.org/viewvc?rev=425714&view=rev
Log:
Get content length from source node data, not from source. This also works when the node has not been saved.
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
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=425714&r1=425713&r2=425714&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 Jul 26 04:57:09 2006
@@ -27,8 +27,6 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceNotFoundException;
import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.cms.cocoon.source.RepositorySource;
import org.apache.lenya.cms.cocoon.source.SourceUtil;
@@ -36,6 +34,7 @@
import org.apache.lenya.cms.metadata.MetaDataException;
import org.apache.lenya.cms.publication.util.DocumentVisitor;
import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.RepositoryException;
import org.apache.lenya.cms.site.SiteManager;
/**
@@ -584,26 +583,10 @@
}
public long getContentLength() throws DocumentException {
- SourceResolver resolver = null;
- Source source = null;
try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = resolver.resolveURI(getSourceURI());
- if (source.exists()) {
- return source.getContentLength();
- } else {
- throw new SourceNotFoundException("The source [" + getSourceURI()
- + "] does not exist!");
- }
- } catch (Exception e) {
+ return getRepositoryNode().getContentLength();
+ } catch (RepositoryException e) {
throw new DocumentException(e);
- } finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
- }
}
}
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=425714&r1=425713&r2=425714&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 Wed Jul 26 04:57:09 2006
@@ -547,27 +547,8 @@
* @see org.apache.lenya.cms.repository.Node#getContentLength()
*/
public long getContentLength() throws RepositoryException {
- SourceResolver resolver = null;
- Source source = null;
- try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = resolver.resolveURI(getRealSourceURI());
- if (source.exists()) {
- return source.getContentLength();
- } else {
- throw new SourceNotFoundException("The source [" + getRealSourceURI()
- + "] does not exist!");
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
- }
- }
+ loadData();
+ return this.data.length;
}
private long lastModified = -1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org