chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1573315 - /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
Date Sun, 02 Mar 2014 14:40:33 GMT
Author: fmui
Date: Sun Mar  2 14:40:33 2014
New Revision: 1573315

URL: http://svn.apache.org/r1573315
Log:
InMemory: allow loading types from the classpath

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java?rev=1573315&r1=1573314&r2=1573315&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
Sun Mar  2 14:40:33 2014
@@ -23,6 +23,7 @@ import static org.apache.chemistry.openc
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.InputStream;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -253,14 +254,26 @@ public class InMemoryServiceFactoryImpl 
         BufferedInputStream stream = null;
         TypeDefinition typeDef = null;
         File f = new File(typeDefsFileName);
+        InputStream typesStream = null;
 
-        if (!f.canRead()) {
+        if (!f.isFile()) {
+            typesStream = this.getClass().getResourceAsStream("/" + typeDefsFileName);
+        } else if (f.canRead()) {
+            try {
+                typesStream = new FileInputStream(f);
+            } catch (Exception e) {
+                LOG.error("Could not load type definitions from file '" + typeDefsFileName
+ "': " + e);
+            }
+        }
+
+        if (typesStream == null) {
             LOG.warn("Resource file with type definitions " + typeDefsFileName
                     + " could not be found, no types will be created.");
             return;
         }
+
         try {
-            stream = new BufferedInputStream(new FileInputStream(f));
+            stream = new BufferedInputStream(typesStream);
             XMLStreamReader parser = XMLUtils.createParser(stream);
             XMLUtils.findNextStartElemenet(parser);
 



Mime
View raw message