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 2007/08/28 13:54:45 UTC

svn commit: r570392 - /lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java

Author: andreas
Date: Tue Aug 28 04:54:45 2007
New Revision: 570392

URL: http://svn.apache.org/viewvc?rev=570392&view=rev
Log:
Fixed revision writability check in DocumentImpl

Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.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=570392&r1=570391&r2=570392&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 Tue Aug 28 04:54:45 2007
@@ -61,9 +61,8 @@
     public static final String METADATA_NAMESPACE = "http://apache.org/lenya/metadata/document/1.0";
 
     /**
-     * The name of the resource type attribute. A resource has a resource type;
-     * this information can be used e.g. for different rendering of different
-     * types.
+     * The name of the resource type attribute. A resource has a resource type; this information can
+     * be used e.g. for different rendering of different types.
      */
     protected static final String METADATA_RESOURCE_TYPE = "resourceType";
 
@@ -73,15 +72,13 @@
     protected static final String METADATA_MIME_TYPE = "mimeType";
 
     /**
-     * The name of the content type attribute. Any content managed by Lenya has
-     * a type; this information can be used e.g. to provide an appropriate
-     * management interface.
+     * The name of the content type attribute. Any content managed by Lenya has a type; this
+     * information can be used e.g. to provide an appropriate management interface.
      */
     protected static final String METADATA_CONTENT_TYPE = "contentType";
 
     /**
-     * The number of seconds from the request that a document can be cached
-     * before it expires
+     * The number of seconds from the request that a document can be cached before it expires
      */
     protected static final String METADATA_EXPIRES = "expires";
 
@@ -416,8 +413,7 @@
     private ResourceType resourceType;
 
     /**
-     * Convenience method to read the document's resource type from the
-     * meta-data.
+     * Convenience method to read the document's resource type from the meta-data.
      * @see Document#getResourceType()
      */
     public ResourceType getResourceType() throws DocumentException {
@@ -533,18 +529,17 @@
         }
         return this.repositoryNode;
     }
-    
+
     protected ContentHolder getContentHolder() {
         Node node = getRepositoryNode();
-        if (this.revision == -1) {
-            return node;
-        }
-        else {
+        if (isRevisionSpecified()) {
             try {
                 return node.getHistory().getRevision(revision);
             } catch (RepositoryException e) {
                 throw new RuntimeException(e);
             }
+        } else {
+            return node;
         }
     }
 
@@ -652,11 +647,15 @@
     }
 
     protected void checkWritability() {
-        if (this.revision == -1) {
+        if (isRevisionSpecified()) {
             throw new UnsupportedOperationException();
         }
     }
 
+    protected boolean isRevisionSpecified() {
+        return this.revision != -1;
+    }
+
     public InputStream getInputStream() {
         try {
             return getRepositoryNode().getInputStream();
@@ -668,14 +667,13 @@
     public Session getSession() {
         return getFactory().getSession();
     }
-    
+
     public int getRevisionNumber() {
-        if (this.revision == -1) {
-            return getRepositoryNode().getHistory().getLatestRevision().getNumber();
-        }
-        else {
-            return this.revision;
+        if (!isRevisionSpecified()) {
+            throw new UnsupportedOperationException(
+                    "This is not a particular revision of the document [" + this + "].");
         }
+        return this.revision;
     }
 
 }



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