jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: rev 55162 - in incubator/jackrabbit/trunk/src: java/org/apache/jackrabbit/core/state/xml test/org/apache/jackrabbit/test
Date Wed, 20 Oct 2004 16:36:29 GMT
Author: stefan
Date: Wed Oct 20 09:36:28 2004
New Revision: 55162

Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java
   incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JackrabbitRepositoryStub.java
Log:
fixing bug http://issues.apache.org/jira/browse/JCR-11:
wrong implementation of reload(PersistentPropertyState state) 
in XMLPersistenceManager

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java
Wed Oct 20 09:36:28 2004
@@ -474,10 +474,11 @@
             throw new IllegalStateException("not initialized");
         }
 
+        Exception e = null;
+        String propFilePath = buildPropFilePath(parentUUID, propName);
 /*
-	Exception e = null;
-	String propFilePath = buildPropFilePath(parentUUID, propName);
-	try {
+	// read property state from xml file
+        try {
 	    if (!fs.isFile(propFilePath)) {
 		throw new NoSuchItemStateException(parentUUID + "/" + propName);
 	    }
@@ -503,12 +504,8 @@
 	    e = fse;
 	    // fall through
 	}
-	String msg = "failed to read property state: " + parentUUID + "/" + propName;
-	log.error(msg, e);
-	throw new ItemStateException(msg, e);
 */
-        Exception e = null;
-        String propFilePath = buildPropFilePath(parentUUID, propName);
+        // read property state from java.util.Properties file
         try {
             if (!itemStateStore.isFile(propFilePath)) {
                 throw new NoSuchItemStateException(parentUUID + "/" + propName);
@@ -531,6 +528,7 @@
             e = fse;
             // fall through
         }
+
         String msg = "failed to read property state: " + parentUUID + "/" + propName;
         log.error(msg, e);
         throw new ItemStateException(msg, e);
@@ -548,6 +546,8 @@
         String parentUUID = state.getParentUUID();
         QName propName = state.getName();
         String propFilePath = buildPropFilePath(parentUUID, propName);
+/*
+	// read property state from xml file
         try {
             InputStream in = itemStateStore.getInputStream(propFilePath);
             try {
@@ -568,6 +568,29 @@
             e = fse;
             // fall through
         }
+*/
+        // read property state from java.util.Properties file
+        try {
+            if (!itemStateStore.isFile(propFilePath)) {
+                throw new NoSuchItemStateException(parentUUID + "/" + propName);
+            }
+            InputStream in = itemStateStore.getInputStream(propFilePath);
+            try {
+                Properties props = new Properties();
+                props.load(in);
+                readState(props, state);
+                return;
+            } finally {
+                in.close();
+            }
+        } catch (IOException ioe) {
+            e = ioe;
+            // fall through
+        } catch (FileSystemException fse) {
+            e = fse;
+            // fall through
+        }
+
         String msg = "failed to read property state: " + parentUUID + "/" + propName;
         log.error(msg, e);
         throw new ItemStateException(msg, e);
@@ -672,6 +695,7 @@
             propFile.makeParentDirs();
             OutputStream os = propFile.getOutputStream();
 /*
+            // write property state to xml file
 	    Writer writer = null;
 	    try {
 		String encoding = DEFAULT_ENCODING;
@@ -765,6 +789,7 @@
 		writer.close();
 	    }
 */
+            // write property state to java.util.Properties file
             Properties props = new Properties();
 
             // type
@@ -892,7 +917,7 @@
                 }
             }
         }
-        // delete property xml file
+        // delete property file
         String propFilePath = buildPropFilePath(state.getParentUUID(), state.getName());
         FileSystemResource propFile = new FileSystemResource(itemStateStore, propFilePath);
         try {

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JackrabbitRepositoryStub.java
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JackrabbitRepositoryStub.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JackrabbitRepositoryStub.java
Wed Oct 20 09:36:28 2004
@@ -16,16 +16,12 @@
 package org.apache.jackrabbit.test;
 
 import org.apache.jackrabbit.core.jndi.RegistryHelper;
-import org.apache.jackrabbit.core.config.RepositoryConfig;
-import org.apache.jackrabbit.core.RepositoryImpl;
 
 import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import javax.naming.Context;
-import java.util.Properties;
+import javax.naming.InitialContext;
 import java.util.Hashtable;
+import java.util.Properties;
 
 /**
  * Implements the <code>RepositoryStub</code> for the JCR Reference Implementation.

Mime
View raw message