Hi andreas

The export.importContent usecase does not work after this commit. It
throws a RepositoryException:

Exception during commit or rollback:
org.apache.lenya.cms.repository.RepositoryException: The node [node
lenya://lenya/pubs/default/content/authoring/sitetree.xml] hasn't been
checked in yet.

That might be due to getRcml().getLatestCheckInEntry(); because no rcml
entry exist at that time.

Jann


> Author: andreas
> Date: Tue Mar  4 08:46:08 2008
> New Revision: 633542
> 
> URL: http://svn.apache.org/viewvc?rev=633542&view=rev
> Log:
> Source node meta data: obtain last modification date from RCML instead of 
> source (much cheaper).
> 
> Modified:
>     
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java
>     
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
>     
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
>     
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java
>     
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
> 
> Modified: 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java
> URL: 
> http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java?rev=633542&r1=633541&r2=633542&view=diff
> ==============================================================================
> --- 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java
>  (original)
> +++ 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java
>  Tue Mar  4 08:46:08 2008
> @@ -42,7 +42,7 @@
>       * @param sourceWrapper The source wrapper.
>       */
>      public ModifiableMetaDataHandler(ServiceManager manager, 
> MetaSourceWrapper sourceWrapper) {
> -        super(manager, sourceWrapper.getRealSourceUri());
> +        super(manager, sourceWrapper.getRealSourceUri(), 
> sourceWrapper.getNode());
>          this.sourceWrapper = sourceWrapper;
>          try {
>              this.sourceWrapper.getNode().setPersistable(this);
> 
> 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=633542&r1=633541&r2=633542&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
>  Tue Mar  4 08:46:08 2008
> @@ -409,18 +409,17 @@
>      }
>  
>      public long getLastModified() throws RepositoryException {
> -
> -        if (!exists()) {
> -            throw new RepositoryException("The node [" + this + "] does not 
> exist!");
> -        }
> -
> -        long contentLastModified = this.contentSource.getLastModified();
> -        long metaLastModified = 0;
> -        if (this.metaSource.exists()) {
> -            metaLastModified = this.metaSource.getLastModified();
> +        try {
> +            CheckInEntry entry = getRcml().getLatestCheckInEntry();
> +            if (entry != null) {
> +                return entry.getTime();
> +            }
> +            else {
> +                throw new RepositoryException("The node [" + this + "] 
> hasn't been checked in yet.");
> +            }
> +        } catch (RevisionControlException e) {
> +            throw new RepositoryException(e);
>          }
> -
> -        return Math.max(contentLastModified, metaLastModified);
>      }
>  
>      public String getMimeType() throws RepositoryException {
> @@ -498,6 +497,10 @@
>  
>      public Persistable getPersistable() {
>          return this.persistable;
> +    }
> +
> +    public String getCacheKey() {
> +        return getSourceURI();
>      }
>  
>  }
> 
> Modified: 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
> URL: 
> http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java?rev=633542&r1=633541&r2=633542&view=diff
> ==============================================================================
> --- 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
>  (original)
> +++ 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
>  Tue Mar  4 08:46:08 2008
> @@ -43,15 +43,18 @@
>  public class SourceNodeMetaDataHandler implements MetaDataOwner {
>  
>      private ServiceManager manager;
> +    private ContentHolder content;
>      private String sourceUri;
>  
>      /**
>       * @param manager The service manager.
> -     * @param sourceUri The soure URI.
> +     * @param sourceUri The source URI.
> +     * @param content The content these meta data apply for.
>       */
> -    public SourceNodeMetaDataHandler(ServiceManager manager, String 
> sourceUri) {
> +    public SourceNodeMetaDataHandler(ServiceManager manager, String 
> sourceUri, ContentHolder content) {
>          this.manager = manager;
>          this.sourceUri = sourceUri;
> +        this.content = content;
>      }
>  
>      private Map namespace2metadata = new HashMap();
> @@ -259,11 +262,7 @@
>      }
>  
>      protected long getLastModified() throws RepositoryException {
> -        try {
> -            return SourceUtil.getLastModified(this.sourceUri, this.manager);
> -        } catch (Exception e) {
> -            throw new RepositoryException(e);
> -        }
> +        return this.content.getLastModified();
>      }
>  
>  }
> 
> Modified: 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java
> URL: 
> http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java?rev=633542&r1=633541&r2=633542&view=diff
> ==============================================================================
> --- 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java
>  (original)
> +++ 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRevision.java
>  Tue Mar  4 08:46:08 2008
> @@ -131,7 +131,7 @@
>  
>      protected SourceNodeMetaDataHandler getMetaDataHandler() {
>          if (this.metaDataHandler == null) {
> -            this.metaDataHandler = new 
> SourceNodeMetaDataHandler(this.manager, getMetaSourceUri());
> +            this.metaDataHandler = new 
> SourceNodeMetaDataHandler(this.manager, getMetaSourceUri(), this);
>          }
>          return this.metaDataHandler;
>      }
> 
> Modified: 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
> URL: 
> http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java?rev=633542&r1=633541&r2=633542&view=diff
> ==============================================================================
> --- 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
>  (original)
> +++ 
> lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
>  Tue Mar  4 08:46:08 2008
> @@ -24,7 +24,6 @@
>  import java.io.InputStream;
>  import java.io.OutputStream;
>  import java.net.MalformedURLException;
> -import java.util.Date;
>  import java.util.Map;
>  import java.util.WeakHashMap;
>  
> @@ -39,8 +38,6 @@
>  import org.apache.lenya.cms.publication.DocumentFactory;
>  import org.apache.lenya.cms.publication.DocumentUtil;
>  import org.apache.lenya.cms.publication.Publication;
> -import org.apache.lenya.cms.rc.CheckInEntry;
> -import org.apache.lenya.cms.rc.RevisionControlException;
>  import org.apache.lenya.util.Assert;
>  
>  /**
> @@ -348,7 +345,6 @@
>           */
>          public synchronized void close() throws IOException {
>              SourceWrapper.this.data = super.toByteArray();
> -            SourceWrapper.this.lastModified = new Date().getTime();
>              try {
>                  SourceWrapper.this.getNode().registerDirty();
>              } catch (RepositoryException e) {
> @@ -366,25 +362,6 @@
>      public long getContentLength() throws RepositoryException {
>          loadData();
>          return this.data.length;
> -    }
> -
> -    private long lastModified = -1;
> -
> -    /**
> -     * @return The last modification date.
> -     * @throws RepositoryException if an error occurs.
> -     * @see org.apache.lenya.cms.repository.Node#getLastModified()
> -     */
> -    public long getLastModified() throws RepositoryException {
> -        try {
> -            CheckInEntry entry = this.node.getRcml().getLatestCheckInEntry();
> -            if (entry != null) {
> -                this.lastModified = entry.getTime();
> -            }
> -        } catch (RevisionControlException e) {
> -            throw new RepositoryException(e);
> -        }
> -        return this.lastModified;
>      }
>  
>      private String mimeType;
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


-- 
Jann Forrer
Informatikdienste
Universität Zürich
Winterthurerstr. 190
CH-8057 Zürich

oooO   mail:  [EMAIL PROTECTED]
(  )   phone: +41 44 63 56772
 \ (   fax:   +41 44 63 54505
  \_)  http://www.id.unizh.ch

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to