Revision: 17561
          http://sourceforge.net/p/gate/code/17561
Author:   markagreenwood
Date:     2014-03-06 14:35:08 +0000 (Thu, 06 Mar 2014)
Log Message:
-----------
proper chaining of exceptions, and now the persistance ID of documents is 
limited to 50 chars (plus the time and a random value) to ensure that we don't 
end up with filenames that are too long for the OS

Modified Paths:
--------------
    gate/trunk/src/main/gate/corpora/SerialCorpusImpl.java
    gate/trunk/src/main/gate/persist/SerialDataStore.java

Modified: gate/trunk/src/main/gate/corpora/SerialCorpusImpl.java
===================================================================
--- gate/trunk/src/main/gate/corpora/SerialCorpusImpl.java      2014-03-06 
13:58:16 UTC (rev 17560)
+++ gate/trunk/src/main/gate/corpora/SerialCorpusImpl.java      2014-03-06 
14:35:08 UTC (rev 17561)
@@ -248,11 +248,11 @@
       }
       catch(PersistenceException ex) {
         throw new GateRuntimeException("Error unloading document from corpus"
-                + "because document sync failed: " + ex.getMessage());
+                + "because document sync failed: " + ex.getMessage(), ex);
       }
       catch(gate.security.SecurityException ex1) {
         throw new GateRuntimeException("Error unloading document from corpus"
-                + "because of document access error: " + ex1.getMessage());
+                + "because of document access error: " + ex1.getMessage(), 
ex1);
       }
     }
     // 3. remove the document from the memory

Modified: gate/trunk/src/main/gate/persist/SerialDataStore.java
===================================================================
--- gate/trunk/src/main/gate/persist/SerialDataStore.java       2014-03-06 
13:58:16 UTC (rev 17560)
+++ gate/trunk/src/main/gate/persist/SerialDataStore.java       2014-03-06 
14:35:08 UTC (rev 17561)
@@ -16,23 +16,54 @@
 
 package gate.persist;
 
-import java.io.*;
+import gate.Corpus;
+import gate.DataStore;
+import gate.Document;
+import gate.Factory;
+import gate.FeatureMap;
+import gate.Gate;
+import gate.LanguageResource;
+import gate.corpora.SerialCorpusImpl;
+import gate.creole.ResourceData;
+import gate.event.DatastoreEvent;
+import gate.event.DatastoreListener;
+import gate.security.SecurityException;
+import gate.security.SecurityInfo;
+import gate.security.Session;
+import gate.util.AbstractFeatureBearer;
+import gate.util.Files;
+import gate.util.GateRuntimeException;
+import gate.util.Out;
+import gate.util.Strings;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.math.BigInteger;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.*;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.Vector;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
 
-import gate.*;
-import gate.corpora.SerialCorpusImpl;
-import gate.creole.ResourceData;
-import gate.event.DatastoreEvent;
-import gate.event.DatastoreListener;
-import gate.security.*;
-import gate.security.SecurityException;
-import gate.util.*;
-
 /**
  * A data store based on Java serialisation.
  */
@@ -435,7 +466,7 @@
       oos.writeObject(lr);
       oos.close();
     } catch(IOException e) {
-      throw new PersistenceException("Couldn't write to storage file: " + e);
+      throw new PersistenceException("Couldn't write to storage file: " + 
e.getMessage(),e);
     }
 
     // let the world know about it
@@ -449,7 +480,9 @@
   /** Create a persistent store Id from the name of a resource. */
   protected String constructPersistenceId(String lrName) {
     // change the persistence ID so that it can be used as a filename
-    lrName=lrName.replaceAll("[\\/:\\*\\?\"<>|]","_");
+    lrName =
+        lrName.substring(0, Math.min(50, lrName.length())).replaceAll(
+            "[\\/:\\*\\?\"<>|]", "_");
     return lrName + "___" + new Date().getTime() + "___" + random();
   } // constructPersistenceId
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to