vgritsenko    2003/08/13 11:52:53

  Modified:    java/src/org/apache/xindice/core Collection.java
               .        status.xml
  Log:
  Fix collection creation time bug
  
  Revision  Changes    Path
  1.35      +37 -30    
xml-xindice/java/src/org/apache/xindice/core/Collection.java
  
  Index: Collection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/Collection.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Collection.java   12 Aug 2003 02:57:30 -0000      1.34
  +++ Collection.java   13 Aug 2003 18:52:53 -0000      1.35
  @@ -553,8 +553,8 @@
           }
           MetaSystemCollection metacol = getMetaSystemCollection();
           meta = metacol.getCollectionMeta(this);
  -        long now = System.currentTimeMillis();
           if (null == meta) {
  +            long now = System.currentTimeMillis();
               meta = new MetaData(MetaData.COLLECTION, getCanonicalName(), 
now, now);
               metacol.setCollectionMeta(this, meta);
           }
  @@ -663,14 +663,12 @@
           */
   
           // this is wrong.. but it should work for now...
  -        long created = System.currentTimeMillis();
  -        long modified = System.currentTimeMillis();
  -
  +        long now = System.currentTimeMillis();
           if (null == meta) {
  -            meta = new MetaData(MetaData.DOCUMENT, path, created, modified);
  +            meta = new MetaData(MetaData.DOCUMENT, path, now, now);
               metacol.setDocumentMeta(this, id, meta);
           } else if (!meta.hasContext()) {
  -            meta.setContext(created, modified);
  +            meta.setContext(now, now);
           }
   
           return meta;
  @@ -1120,7 +1118,7 @@
   
           if (inlineMetaService == null) {
               throw new DBException(FaultCodes.COL_CANNOT_STORE,
  -                                  "Cannot store a binary resource in 
collection " + name + ": inline-metadata is not enabled");
  +                                  "Cannot store a binary resource in 
collection " + getCanonicalName() + ": inline-metadata is not enabled");
           }
   
           if (!create) {
  @@ -1129,9 +1127,9 @@
                   /*
                    * TODO: Do we need a COL_KEY_ALREADY_PRESENT fault so that 
the caller can interpret this exception?
                    */
  -                throw new DBException(
  -                        FaultCodes.COL_CANNOT_STORE,
  -                        "Error storing binary object with key '" + key + "': 
the 'create' flag is false and" + " the key is not in the database");
  +                throw new DBException(FaultCodes.COL_CANNOT_STORE,
  +                                      "Error storing binary object with key 
'" + key + "': the 'create' flag is false and" +
  +                                      " the key is not in the database");
               }
           }
   
  @@ -1181,7 +1179,6 @@
   
           if (compressed) {
               try {
  -
                   packedDocument = DOMCompressor.Compress(document, symbols);
                   log.debug(localDebugHeader + "length=" + 
packedDocument.length);
   
  @@ -1358,13 +1355,17 @@
               }
               return;
           }
  +
           if (null != meta) {
               if (meta.getType() != MetaData.COLLECTION) {
  -                throw new DBException(FaultCodes.GEN_UNKNOWN, "Mismatch type 
of meta data for collection " + getCanonicalName());
  +                throw new DBException(FaultCodes.GEN_UNKNOWN,
  +                                      "Mismatch type of meta data for 
collection " + getCanonicalName());
               }
               
               MetaSystemCollection metacol = getMetaSystemCollection();
  -            metacol.setCollectionMeta(this, meta);
  +            MetaData current = metacol.getCollectionMeta(this);
  +            current.copyDataFrom(meta);
  +            metacol.setCollectionMeta(this, current);
           }
       }
   
  @@ -1519,18 +1520,23 @@
               }
               return;
           }
  +
           Document doc = getDocument(id);
           if (null == doc) {
  -            throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND, 
"Document " + id + " does not exist");
  -           }
  +            throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND,
  +                                  "Document " + id + " does not exist in 
collection " + getCanonicalName());
  +        }
   
           if (null != meta) {
               if (meta.getType() == MetaData.UNKNOWN || meta.getType() == 
MetaData.COLLECTION) {
  -                throw new DBException(FaultCodes.GEN_UNKNOWN, "Mismatch type 
of meta data for document " + getCanonicalDocumentName(id));
  +                throw new DBException(FaultCodes.GEN_UNKNOWN,
  +                                      "Mismatch type of meta data for 
document " + getCanonicalDocumentName(id));
               }
               
               MetaSystemCollection metacol = getMetaSystemCollection();
  -            metacol.setDocumentMeta(this, id, meta);
  +            MetaData current = metacol.getDocumentMeta(this, id);
  +            current.copyDataFrom(meta);
  +            metacol.setDocumentMeta(this, id, current);
           }
       }
   
  @@ -1567,17 +1573,20 @@
                   // something strange has happened.. can't get the
                   // meta data for this collection
                   if (log.isWarnEnabled()) {
  -                    log.warn("Error fetching collection meta. " + e);
  +                    log.warn("Error fetching meta for collection '" + 
getCanonicalName() + "'", e);
                   }
                   return;
               }
   
  -            log.info("Updating modified time for this collection's meta");
  +            log.info("Updating modified time for collection '" + 
getCanonicalName() + "'");
               long now = System.currentTimeMillis();
               if (null == meta) {
                   meta = new MetaData(MetaData.COLLECTION, getCanonicalName(), 
now, now);
  +            } else if (!meta.hasContext()) {
  +                // Newly created meta. Update its created and modified time.
  +                meta.setContext(now, now);
               } else {
  -                // this collection already has a meta.  so update its 
modified time.
  +                // This collection already has a meta. So update its 
modified time.
                   meta.setContext(0, now);
               }
   
  @@ -1585,7 +1594,7 @@
                   metacol.setCollectionMeta(this, meta);
               } catch (DBException e) {
                   if (log.isWarnEnabled()) {
  -                    log.warn("Error setting the collection meta", e);
  +                    log.warn("Error setting meta for collection '" + 
getCanonicalName() + "'", e);
                   }
                   return;
               }
  @@ -1604,7 +1613,7 @@
           Document doc = getDocument(id);
           if (null == doc) {
               throw new DBException(FaultCodes.COL_DOCUMENT_NOT_FOUND,
  -                                  "Document " + id + " does not exist");
  +                                  "Document " + id + " does not exist in " + 
getCanonicalName());
           }
   
           MetaSystemCollection metacol = getMetaSystemCollection();
  @@ -1621,15 +1630,13 @@
           */
   
           // this is wrong.. but it should work for now...
  -        long created = System.currentTimeMillis();
  -        long modified = System.currentTimeMillis();
  -
  +        long now = System.currentTimeMillis();
           if (null == meta) {
  -            meta = new MetaData(MetaData.DOCUMENT, path, created, modified);
  +            meta = new MetaData(MetaData.DOCUMENT, path, now, now);
           } else if (!meta.hasContext()) {
  -            meta.setContext(created, modified);
  +            meta.setContext(now, now);
           } else {
  -            meta.setContext(0, modified);
  +            meta.setContext(0, now);
           }
           metacol.setDocumentMeta(this, id, meta);
       }
  
  
  
  1.6       +3 -0      xml-xindice/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/xml-xindice/status.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- status.xml        13 Aug 2003 18:49:34 -0000      1.5
  +++ status.xml        13 Aug 2003 18:52:53 -0000      1.6
  @@ -60,6 +60,9 @@
         <changes>
               <!-- Add new releases here -->
               <release version="1.1-dev" date="August 6 2003">
  +                  <action dev="VG" type="fix">
  +                        Collection meta data now has correct collection 
creation time.
  +                  </action>
                     <action dev="VG" type="update">
                           Added XINDICE_DB_HOME environment variable and 
corresponding
                           xindice.db.home system property. This property takes 
precedence
  
  
  

Reply via email to