You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2006/10/26 11:11:20 UTC

svn commit: r467925 [5/6] - in /jackrabbit/trunk/jackrabbit: applications/test/ applications/test/workspaces/default/ applications/test/workspaces/test/ src/main/config/ src/main/java/org/apache/jackrabbit/core/ src/main/java/org/apache/jackrabbit/core...

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java?view=diff&rev=467925&r1=467924&r2=467925
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/mem/InMemPersistenceManager.java Thu Oct 26 02:11:18 2006
@@ -16,582 +16,11 @@
  */
 package org.apache.jackrabbit.core.state.mem;
 
-import org.apache.jackrabbit.core.ItemId;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.fs.FileSystem;
-import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
-import org.apache.jackrabbit.core.fs.FileSystemResource;
-import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
-import org.apache.jackrabbit.core.state.AbstractPersistenceManager;
-import org.apache.jackrabbit.core.state.ItemStateException;
-import org.apache.jackrabbit.core.state.NoSuchItemStateException;
-import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
-import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.state.PMContext;
-import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.state.util.BLOBStore;
-import org.apache.jackrabbit.core.state.util.FileSystemBLOBStore;
-import org.apache.jackrabbit.core.state.util.Serializer;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
-import org.apache.jackrabbit.core.value.InternalValue;
-import org.apache.jackrabbit.name.QName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jcr.PropertyType;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
 /**
- * <code>InMemPersistenceManager</code> is a very simple <code>HashMap</code>-based
- * <code>PersistenceManager</code> for Jackrabbit that keeps all data in memory
- * and that is capable of storing and loading its contents using a simple custom
- * binary serialization format (see {@link Serializer}).
- * <p/>
- * It is configured through the following properties:
- * <ul>
- * <li><code>initialCapacity</code>: initial capacity of the hash map used to store the data</li>
- * <li><code>loadFactor</code>: load factor of the hash map used to store the data</li>
- * <li><code>persistent</code>: if <code>true</code> the contents of the hash map
- * is loaded on startup and stored on shutdown;
- * if <code>false</code> nothing is persisted</li>
- * </ul>
- * <b>Please note that this class should only be used for testing purposes.</b>
+ * Legacy class kept for backward compatibility reasons.
+ * @deprecated use {@link org.apache.jackrabbit.core.persistence.mem.InMemPersistenceManager}
+ *             instead.
  */
-public class InMemPersistenceManager extends AbstractPersistenceManager {
-
-    private static Logger log = LoggerFactory.getLogger(InMemPersistenceManager.class);
-
-    protected boolean initialized;
-
-    protected Map stateStore;
-    protected Map refsStore;
-
-    // initial size of buffer used to serialize objects
-    protected static final int INITIAL_BUFFER_SIZE = 1024;
-
-    // some constants used in serialization
-    protected static final String STATE_FILE_PATH = "/data/.state.bin";
-    protected static final String REFS_FILE_PATH = "/data/.refs.bin";
-    protected static final byte NODE_ENTRY = 0;
-    protected static final byte PROP_ENTRY = 1;
-
-    // file system where BLOB data is stored
-    protected FileSystem blobFS;
-    // BLOBStore that manages BLOB data in the file system
-    protected BLOBStore blobStore;
-
-    /**
-     * file system where the content of the hash maps are read from/written to
-     * (if <code>persistent==true</code>)
-     */
-    protected FileSystem wspFS;
-
-    // initial capacity
-    protected int initialCapacity = 32768;
-    // load factor for the hash map
-    protected float loadFactor = 0.75f;
-    // should hash map be persisted?
-    protected boolean persistent = true;
-
-    /**
-     * Creates a new <code>InMemPersistenceManager</code> instance.
-     */
-    public InMemPersistenceManager() {
-        initialized = false;
-    }
-
-    public void setInitialCapacity(int initialCapacity) {
-        this.initialCapacity = initialCapacity;
-    }
-
-    public void setInitialCapacity(String initialCapacity) {
-        this.initialCapacity = Integer.valueOf(initialCapacity).intValue();
-    }
-
-    public String getInitialCapacity() {
-        return Integer.toString(initialCapacity);
-    }
-
-    public void setLoadFactor(float loadFactor) {
-        this.loadFactor = loadFactor;
-    }
-
-    public void setLoadFactor(String loadFactor) {
-        this.loadFactor = Float.valueOf(loadFactor).floatValue();
-    }
-
-    public String getLoadFactor() {
-        return Float.toString(loadFactor);
-    }
-
-    public boolean isPersistent() {
-        return persistent;
-    }
-
-    public void setPersistent(boolean persistent) {
-        this.persistent = persistent;
-    }
-
-    public void setPersistent(String persistent) {
-        this.persistent = Boolean.valueOf(persistent).booleanValue();
-    }
-
-    protected static String buildBlobFilePath(String parentUUID, QName propName, int index) {
-        StringBuffer sb = new StringBuffer();
-        char[] chars = parentUUID.toCharArray();
-        int cnt = 0;
-        for (int i = 0; i < chars.length; i++) {
-            if (chars[i] == '-') {
-                continue;
-            }
-            //if (cnt > 0 && cnt % 4 == 0) {
-            if (cnt == 2 || cnt == 4) {
-                sb.append(FileSystem.SEPARATOR_CHAR);
-            }
-            sb.append(chars[i]);
-            cnt++;
-        }
-        sb.append(FileSystem.SEPARATOR_CHAR);
-        sb.append(FileSystemPathUtil.escapeName(propName.toString()));
-        sb.append('.');
-        sb.append(index);
-        sb.append(".bin");
-        return sb.toString();
-    }
-
-    /**
-     * Reads the content of the hash maps from the file system
-     *
-     * @throws Exception if an error occurs
-     */
-    public synchronized void loadContents() throws Exception {
-        // read item states
-        FileSystemResource fsRes = new FileSystemResource(wspFS, STATE_FILE_PATH);
-        if (!fsRes.exists()) {
-            return;
-        }
-        BufferedInputStream bis = new BufferedInputStream(fsRes.getInputStream());
-        DataInputStream in = new DataInputStream(bis);
-
-        try {
-            int n = in.readInt();   // number of entries
-            while (n-- > 0) {
-                byte type = in.readByte();  // entry type
-                ItemId id;
-                if (type == NODE_ENTRY) {
-                    // entry type: node
-                    String s = in.readUTF();    // id
-                    id = NodeId.valueOf(s);
-                } else {
-                    // entry type: property
-                    String s = in.readUTF();    // id
-                    id = PropertyId.valueOf(s);
-                }
-                int length = in.readInt();  // data length
-                byte[] data = new byte[length];
-                in.readFully(data);  // data
-                // store in map
-                stateStore.put(id, data);
-            }
-        } finally {
-            in.close();
-        }
-
-        // read references
-        fsRes = new FileSystemResource(wspFS, REFS_FILE_PATH);
-        bis = new BufferedInputStream(fsRes.getInputStream());
-        in = new DataInputStream(bis);
-
-        try {
-            int n = in.readInt();   // number of entries
-            while (n-- > 0) {
-                String s = in.readUTF();    // target id
-                NodeReferencesId id = (NodeReferencesId) NodeReferencesId.valueOf(s);
-                int length = in.readInt();  // data length
-                byte[] data = new byte[length];
-                in.readFully(data);  // data
-                // store in map
-                refsStore.put(id, data);
-            }
-        } finally {
-            in.close();
-        }
-    }
-
-    /**
-     * Writes the content of the hash maps to the file system
-     *
-     * @throws Exception if an error occurs
-     */
-    public synchronized void storeContents() throws Exception {
-        // write item states
-        FileSystemResource fsRes = new FileSystemResource(wspFS, STATE_FILE_PATH);
-        fsRes.makeParentDirs();
-        BufferedOutputStream bos = new BufferedOutputStream(fsRes.getOutputStream());
-        DataOutputStream out = new DataOutputStream(bos);
-
-        try {
-
-            out.writeInt(stateStore.size());    // number of entries
-            // entries
-            Iterator iterKeys = stateStore.keySet().iterator();
-            while (iterKeys.hasNext()) {
-                ItemId id = (ItemId) iterKeys.next();
-                if (id.denotesNode()) {
-                    out.writeByte(NODE_ENTRY);  // entry type
-                } else {
-                    out.writeByte(PROP_ENTRY);  // entry type
-                }
-                out.writeUTF(id.toString());    // id
-                byte[] data = (byte[]) stateStore.get(id);
-                out.writeInt(data.length);  // data length
-                out.write(data);    // data
-            }
-        } finally {
-            out.close();
-        }
-
-        // write references
-        fsRes = new FileSystemResource(wspFS, REFS_FILE_PATH);
-        fsRes.makeParentDirs();
-        bos = new BufferedOutputStream(fsRes.getOutputStream());
-        out = new DataOutputStream(bos);
-
-        try {
-            out.writeInt(refsStore.size()); // number of entries
-            // entries
-            Iterator iterKeys = refsStore.keySet().iterator();
-            while (iterKeys.hasNext()) {
-                NodeReferencesId id = (NodeReferencesId) iterKeys.next();
-                out.writeUTF(id.toString());    // target id
-                byte[] data = (byte[]) refsStore.get(id);
-                out.writeInt(data.length);  // data length
-                out.write(data);    // data
-            }
-        } finally {
-            out.close();
-        }
-    }
-
-    //---------------------------------------------------< PersistenceManager >
-    /**
-     * {@inheritDoc}
-     */
-    public void init(PMContext context) throws Exception {
-        if (initialized) {
-            throw new IllegalStateException("already initialized");
-        }
-
-        stateStore = new HashMap(initialCapacity, loadFactor);
-        refsStore = new HashMap(initialCapacity, loadFactor);
-
-        wspFS = context.getFileSystem();
-
-        /**
-         * store BLOB data in local file system in a sub directory
-         * of the workspace home directory
-         */
-        LocalFileSystem blobFS = new LocalFileSystem();
-        blobFS.setRoot(new File(context.getHomeDir(), "blobs"));
-        blobFS.init();
-        this.blobFS = blobFS;
-        blobStore = new FileSystemBLOBStore(blobFS);
-
-        if (persistent) {
-            // deserialize contents of state and refs stores
-            loadContents();
-        }
-
-        initialized = true;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized void close() throws Exception {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            if (persistent) {
-                // serialize contents of state and refs stores
-                storeContents();
-            } else {
-                // clear out blob store
-                try {
-                    String[] folders = blobFS.listFolders("/");
-                    for (int i = 0; i < folders.length; i++) {
-                        blobFS.deleteFolder(folders[i]);
-                    }
-                    String[] files = blobFS.listFiles("/");
-                    for (int i = 0; i < files.length; i++) {
-                        blobFS.deleteFile(files[i]);
-                    }
-                } catch (Exception e) {
-                    // ignore
-                }
-            }
-
-            // close BLOB file system
-            blobFS.close();
-            blobFS = null;
-            blobStore = null;
-
-            stateStore.clear();
-            stateStore = null;
-            refsStore.clear();
-            refsStore = null;
-        } finally {
-            initialized = false;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized NodeState load(NodeId id)
-            throws NoSuchItemStateException, ItemStateException {
-
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        byte[] data = (byte[]) stateStore.get(id);
-        if (data == null) {
-            throw new NoSuchItemStateException(id.toString());
-        }
-
-        ByteArrayInputStream in = new ByteArrayInputStream(data);
-        try {
-            NodeState state = createNew(id);
-            Serializer.deserialize(state, in);
-            return state;
-        } catch (Exception e) {
-            String msg = "failed to read node state: " + id;
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized PropertyState load(PropertyId id)
-            throws NoSuchItemStateException, ItemStateException {
-
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        byte[] data = (byte[]) stateStore.get(id);
-        if (data == null) {
-            throw new NoSuchItemStateException(id.toString());
-        }
-
-        ByteArrayInputStream in = new ByteArrayInputStream(data);
-        try {
-            PropertyState state = createNew(id);
-            Serializer.deserialize(state, in, blobStore);
-            return state;
-        } catch (Exception e) {
-            String msg = "failed to read property state: " + id;
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void store(NodeState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            ByteArrayOutputStream out =
-                    new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
-            // serialize node state
-            Serializer.serialize(state, out);
-
-            // store in serialized format in map for better memory efficiency
-            stateStore.put(state.getNodeId(), out.toByteArray());
-            // there's no need to close a ByteArrayOutputStream
-            //out.close();
-        } catch (Exception e) {
-            String msg = "failed to write node state: " + state.getNodeId();
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void store(PropertyState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            ByteArrayOutputStream out =
-                    new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
-            // serialize property state
-            Serializer.serialize(state, out, blobStore);
-
-            // store in serialized format in map for better memory efficiency
-            stateStore.put(state.getPropertyId(), out.toByteArray());
-            // there's no need to close a ByteArrayOutputStream
-            //out.close();
-        } catch (Exception e) {
-            String msg = "failed to store property state: " + state.getPropertyId();
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void destroy(NodeState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        // remove node state
-        stateStore.remove(state.getNodeId());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void destroy(PropertyState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        // delete binary values (stored as files)
-        InternalValue[] values = state.getValues();
-        if (values != null) {
-            for (int i = 0; i < values.length; i++) {
-                InternalValue val = values[i];
-                if (val != null) {
-                    if (val.getType() == PropertyType.BINARY) {
-                        BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
-                        // delete blob file and prune empty parent folders
-                        blobVal.delete(true);
-                    }
-                }
-            }
-        }
-
-        // remove property state
-        stateStore.remove(state.getPropertyId());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized NodeReferences load(NodeReferencesId id)
-            throws NoSuchItemStateException, ItemStateException {
-
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        byte[] data = (byte[]) refsStore.get(id);
-        if (data == null) {
-            throw new NoSuchItemStateException(id.toString());
-        }
-
-        ByteArrayInputStream in = new ByteArrayInputStream(data);
-        try {
-            NodeReferences refs = new NodeReferences(id);
-            Serializer.deserialize(refs, in);
-            return refs;
-        } catch (Exception e) {
-            String msg = "failed to load references: " + id;
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void store(NodeReferences refs) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            ByteArrayOutputStream out =
-                    new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
-            // serialize references
-            Serializer.serialize(refs, out);
-
-            // store in serialized format in map for better memory efficiency
-            refsStore.put(refs.getId(), out.toByteArray());
-            // there's no need to close a ByteArrayOutputStream
-            //out.close();
-        } catch (Exception e) {
-            String msg = "failed to store references: " + refs.getId();
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void destroy(NodeReferences refs) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        // remove node references
-        refsStore.remove(refs.getId());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean exists(PropertyId id) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-        return stateStore.containsKey(id);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean exists(NodeId id) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-        return stateStore.containsKey(id);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean exists(NodeReferencesId id) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-        return refsStore.containsKey(id);
-    }
-}
+public class InMemPersistenceManager
+        extends org.apache.jackrabbit.core.persistence.mem.InMemPersistenceManager {
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java?view=diff&rev=467925&r1=467924&r2=467925
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java Thu Oct 26 02:11:18 2006
@@ -16,501 +16,11 @@
  */
 package org.apache.jackrabbit.core.state.obj;
 
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.fs.BasedFileSystem;
-import org.apache.jackrabbit.core.fs.FileSystem;
-import org.apache.jackrabbit.core.fs.FileSystemException;
-import org.apache.jackrabbit.core.fs.FileSystemResource;
-import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
-import org.apache.jackrabbit.core.state.AbstractPersistenceManager;
-import org.apache.jackrabbit.core.state.ItemStateException;
-import org.apache.jackrabbit.core.state.NoSuchItemStateException;
-import org.apache.jackrabbit.core.state.NodeReferences;
-import org.apache.jackrabbit.core.state.NodeReferencesId;
-import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.state.PMContext;
-import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.state.util.BLOBStore;
-import org.apache.jackrabbit.core.state.util.FileSystemBLOBStore;
-import org.apache.jackrabbit.core.state.util.Serializer;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
-import org.apache.jackrabbit.core.value.InternalValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jcr.PropertyType;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.OutputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
 /**
- * <code>ObjectPersistenceManager</code> is a <code>FileSystem</code>-based
- * <code>PersistenceManager</code> that persists <code>ItemState</code>
- * and <code>NodeReferences</code> objects using a simple custom binary
- * serialization format (see {@link Serializer}).
+ * Legacy class kept for backward compatibility reasons.
+ * @deprecated use {@link org.apache.jackrabbit.core.persistence.obj.ObjectPersistenceManager}
+ *             instead.
  */
-public class ObjectPersistenceManager extends AbstractPersistenceManager {
-
-    private static Logger log = LoggerFactory.getLogger(ObjectPersistenceManager.class);
-
-    /**
-     * hexdigits for toString
-     */
-    private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray();
-
-    private static final String NODEFILENAME = ".node";
-
-    private static final String NODEREFSFILENAME = ".references";
-
-    private boolean initialized;
-
-    // file system where the item state is stored
-    private FileSystem itemStateFS;
-    // file system where BLOB data is stored
-    private FileSystem blobFS;
-    // BLOBStore that manages BLOB data in the file system
-    private BLOBStore blobStore;
-
-    /**
-     * Creates a new <code>ObjectPersistenceManager</code> instance.
-     */
-    public ObjectPersistenceManager() {
-        initialized = false;
-    }
-
-    private static String buildNodeFolderPath(NodeId id) {
-        StringBuffer sb = new StringBuffer();
-        char[] chars = id.getUUID().toString().toCharArray();
-        int cnt = 0;
-        for (int i = 0; i < chars.length; i++) {
-            if (chars[i] == '-') {
-                continue;
-            }
-            //if (cnt > 0 && cnt % 4 == 0) {
-            if (cnt == 2 || cnt == 4) {
-                sb.append(FileSystem.SEPARATOR_CHAR);
-            }
-            sb.append(chars[i]);
-            cnt++;
-        }
-        return sb.toString();
-    }
-
-    private static String buildPropFilePath(PropertyId id) {
-        String fileName;
-        try {
-            MessageDigest md5 = MessageDigest.getInstance("MD5");
-            md5.update(id.getName().getNamespaceURI().getBytes());
-            md5.update(id.getName().getLocalName().getBytes());
-            byte[] bytes = md5.digest();
-            char[] chars = new char[32];
-            for (int i = 0, j = 0; i < 16; i++) {
-                chars[j++] = HEXDIGITS[(bytes[i] >> 4) & 0x0f];
-                chars[j++] = HEXDIGITS[bytes[i] & 0x0f];
-            }
-            fileName = new String(chars);
-        } catch (NoSuchAlgorithmException nsae) {
-            // should never get here as MD5 should always be available in the JRE
-            String msg = "MD5 not available: ";
-            log.error(msg, nsae);
-            throw new InternalError(msg + nsae);
-        }
-        return buildNodeFolderPath(id.getParentId()) + FileSystem.SEPARATOR + fileName;
-    }
-
-    private static String buildNodeFilePath(NodeId id) {
-        return buildNodeFolderPath(id) + FileSystem.SEPARATOR + NODEFILENAME;
-    }
-
-    private static String buildNodeReferencesFilePath(NodeReferencesId id) {
-        return buildNodeFolderPath(id.getTargetId()) + FileSystem.SEPARATOR + NODEREFSFILENAME;
-    }
-
-    //---------------------------------------------------< PersistenceManager >
-    /**
-     * {@inheritDoc}
-     */
-    public void init(PMContext context) throws Exception {
-        if (initialized) {
-            throw new IllegalStateException("already initialized");
-        }
-
-        FileSystem wspFS = context.getFileSystem();
-        itemStateFS = new BasedFileSystem(wspFS, "/data");
-
-        /**
-         * store BLOB data in local file system in a sub directory
-         * of the workspace home directory
-         */
-        LocalFileSystem blobFS = new LocalFileSystem();
-        blobFS.setRoot(new File(context.getHomeDir(), "blobs"));
-        blobFS.init();
-        this.blobFS = blobFS;
-        blobStore = new FileSystemBLOBStore(blobFS);
-
-        initialized = true;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized void close() throws Exception {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            // close BLOB file system
-            blobFS.close();
-            blobFS = null;
-            blobStore = null;
-            /**
-             * there's no need close the item state store because it
-             * is based in the workspace's file system which is
-             * closed by the repository
-             */
-        } finally {
-            initialized = false;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized NodeState load(NodeId id)
-            throws NoSuchItemStateException, ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String nodeFilePath = buildNodeFilePath(id);
-
-        try {
-            if (!itemStateFS.isFile(nodeFilePath)) {
-                throw new NoSuchItemStateException(nodeFilePath);
-            }
-        } catch (FileSystemException fse) {
-            String msg = "failed to read node state: " + nodeFilePath;
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-
-        try {
-            BufferedInputStream in =
-                    new BufferedInputStream(itemStateFS.getInputStream(nodeFilePath));
-            try {
-                NodeState state = createNew(id);
-                Serializer.deserialize(state, in);
-                return state;
-            } catch (Exception e) {
-                String msg = "failed to read node state: " + id.getUUID();
-                log.debug(msg);
-                throw new ItemStateException(msg, e);
-            } finally {
-                in.close();
-            }
-        } catch (Exception e) {
-            String msg = "failed to read node state: " + nodeFilePath;
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized PropertyState load(PropertyId id)
-            throws NoSuchItemStateException, ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String propFilePath = buildPropFilePath(id);
-
-        try {
-            if (!itemStateFS.isFile(propFilePath)) {
-                throw new NoSuchItemStateException(propFilePath);
-            }
-        } catch (FileSystemException fse) {
-            String msg = "failed to read property state: " + propFilePath;
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-
-        try {
-            BufferedInputStream in =
-                    new BufferedInputStream(itemStateFS.getInputStream(propFilePath));
-            try {
-                PropertyState state = createNew(id);
-                Serializer.deserialize(state, in, blobStore);
-                return state;
-            } finally {
-                in.close();
-            }
-        } catch (Exception e) {
-            String msg = "failed to read property state: " + propFilePath;
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized NodeReferences load(NodeReferencesId id)
-            throws NoSuchItemStateException, ItemStateException {
-
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String refsFilePath = buildNodeReferencesFilePath(id);
-
-        try {
-            if (!itemStateFS.isFile(refsFilePath)) {
-                throw new NoSuchItemStateException(id.toString());
-            }
-        } catch (FileSystemException fse) {
-            String msg = "failed to load references: " + id;
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-
-        try {
-            BufferedInputStream in =
-                    new BufferedInputStream(itemStateFS.getInputStream(refsFilePath));
-            try {
-                NodeReferences refs = new NodeReferences(id);
-                Serializer.deserialize(refs, in);
-                return refs;
-            } finally {
-                in.close();
-            }
-        } catch (Exception e) {
-            String msg = "failed to load references: " + id;
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void store(NodeState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String nodeFilePath = buildNodeFilePath(state.getNodeId());
-        FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
-        try {
-            nodeFile.makeParentDirs();
-            BufferedOutputStream out = new BufferedOutputStream(nodeFile.getOutputStream());
-            try {
-                // serialize node state
-                Serializer.serialize(state, out);
-            } finally {
-                out.close();
-            }
-        } catch (Exception e) {
-            String msg = "failed to write node state: " + state.getNodeId();
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void store(PropertyState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String propFilePath = buildPropFilePath(state.getPropertyId());
-        FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
-        try {
-            propFile.makeParentDirs();
-            BufferedOutputStream out = new BufferedOutputStream(propFile.getOutputStream());
-            try {
-                // serialize property state
-                Serializer.serialize(state, out, blobStore);
-            } finally {
-                out.close();
-            }
-        } catch (Exception e) {
-            String msg = "failed to store property state: " + state.getParentId() + "/" + state.getName();
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void store(NodeReferences refs) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String refsFilePath = buildNodeReferencesFilePath(refs.getId());
-        FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
-        try {
-            refsFile.makeParentDirs();
-            OutputStream out = new BufferedOutputStream(refsFile.getOutputStream());
-            try {
-                Serializer.serialize(refs, out);
-            } finally {
-                out.close();
-            }
-        } catch (Exception e) {
-            String msg = "failed to store references: " + refs.getId();
-            log.debug(msg);
-            throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void destroy(NodeState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String nodeFilePath = buildNodeFilePath(state.getNodeId());
-        FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
-        try {
-            if (nodeFile.exists()) {
-                // delete resource and prune empty parent folders
-                nodeFile.delete(true);
-            }
-        } catch (FileSystemException fse) {
-            String msg = "failed to delete node state: " + state.getNodeId();
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void destroy(PropertyState state) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        // delete binary values (stored as files)
-        InternalValue[] values = state.getValues();
-        if (values != null) {
-            for (int i = 0; i < values.length; i++) {
-                InternalValue val = values[i];
-                if (val != null) {
-                    if (val.getType() == PropertyType.BINARY) {
-                        BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
-                        // delete blob file and prune empty parent folders
-                        blobVal.delete(true);
-                    }
-                }
-            }
-        }
-        // delete property file
-        String propFilePath = buildPropFilePath(state.getPropertyId());
-        FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
-        try {
-            if (propFile.exists()) {
-                // delete resource and prune empty parent folders
-                propFile.delete(true);
-            }
-        } catch (FileSystemException fse) {
-            String msg = "failed to delete property state: " + state.getParentId() + "/" + state.getName();
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void destroy(NodeReferences refs) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        String refsFilePath = buildNodeReferencesFilePath(refs.getId());
-        FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
-        try {
-            if (refsFile.exists()) {
-                // delete resource and prune empty parent folders
-                refsFile.delete(true);
-            }
-        } catch (FileSystemException fse) {
-            String msg = "failed to delete node references: " + refs.getId();
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized boolean exists(PropertyId id) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            String propFilePath = buildPropFilePath(id);
-            FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
-            return propFile.exists();
-        } catch (FileSystemException fse) {
-            String msg = "failed to check existence of item state: " + id;
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized boolean exists(NodeId id) throws ItemStateException {
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            String nodeFilePath = buildNodeFilePath(id);
-            FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
-            return nodeFile.exists();
-        } catch (FileSystemException fse) {
-            String msg = "failed to check existence of item state: " + id;
-            log.error(msg, fse);
-            throw new ItemStateException(msg, fse);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized boolean exists(NodeReferencesId id)
-            throws ItemStateException {
-
-        if (!initialized) {
-            throw new IllegalStateException("not initialized");
-        }
-
-        try {
-            String refsFilePath = buildNodeReferencesFilePath(id);
-            FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
-            return refsFile.exists();
-        } catch (FileSystemException fse) {
-            String msg = "failed to check existence of references: " + id;
-            log.debug(msg);
-            throw new ItemStateException(msg, fse);
-        }
-    }
-}
+public class ObjectPersistenceManager
+        extends org.apache.jackrabbit.core.persistence.obj.ObjectPersistenceManager {
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/BLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/BLOBStore.java?view=diff&rev=467925&r1=467924&r2=467925
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/BLOBStore.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/BLOBStore.java Thu Oct 26 02:11:18 2006
@@ -16,57 +16,12 @@
  */
 package org.apache.jackrabbit.core.state.util;
 
-import org.apache.jackrabbit.core.PropertyId;
-
-import java.io.InputStream;
-
 /**
- * <code>BLOBStore</code> represents an abstract store for binary property
- * values (BLOBs).
- *
- * @see ResourceBasedBLOBStore
+ * Legacy interface kept for backward compatibility reasons.
+ * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.BLOBStore}
+ *             instead.
  */
-public interface BLOBStore {
-    /**
-     * Creates a unique identifier for the BLOB data associated with the given
-     * property id and value subscript.
-     *
-     * @param id    id of the property associated with the BLOB data
-     * @param index subscript of the value holding the BLOB data
-     * @return a string identifying the BLOB data
-     */
-    String createId(PropertyId id, int index);
-
-    /**
-     * Stores the BLOB data and returns a unique identifier.
-     *
-     * @param blobId identifier of the BLOB data as returned by
-     *               {@link #createId(PropertyId, int)}
-     * @param in     stream containing the BLOB data
-     * @param size   size of the BLOB data
-     * @throws Exception if an error occured
-     */
-    void put(String blobId, InputStream in, long size) throws Exception;
-
-    /**
-     * Retrieves the BLOB data with the specified id as a binary stream.
-     *
-     * @param blobId identifier of the BLOB data as returned by
-     *               {@link #createId(PropertyId, int)}
-     * @return an input stream that delivers the BLOB data
-     * @throws Exception if an error occured
-     */
-    InputStream get(String blobId) throws Exception;
+public interface BLOBStore
+        extends org.apache.jackrabbit.core.persistence.util.BLOBStore {
 
-    /**
-     * Removes the BLOB data with the specified id.
-     *
-     * @param blobId identifier of the BLOB data as returned by
-     *               {@link #createId(PropertyId, int)}
-     * @return <code>true</code> if BLOB data with the given id exists and has
-     *         been successfully removed, <code>false</code> if there's no BLOB
-     *         data with the given id.
-     * @throws Exception if an error occured
-     */
-    boolean remove(String blobId) throws Exception;
-}
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/FileSystemBLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/FileSystemBLOBStore.java?view=diff&rev=467925&r1=467924&r2=467925
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/FileSystemBLOBStore.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/FileSystemBLOBStore.java Thu Oct 26 02:11:18 2006
@@ -16,114 +16,16 @@
  */
 package org.apache.jackrabbit.core.state.util;
 
-import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystem;
-import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
-import org.apache.jackrabbit.core.fs.FileSystemResource;
-
-import java.io.BufferedOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
 
 /**
- * <code>FileSystemBLOBStore</code> is a <code>ResourceBasedBLOBStore</code>
- * implementation that stores BLOB data in a <code>FileSystem</code>.
+ * Legacy class kept for backward compatibility reasons.
+ * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore}
+ *             instead.
  */
-public class FileSystemBLOBStore implements ResourceBasedBLOBStore {
-
-    /**
-     * the file system where the BLOBs are stored
-     */
-    private final FileSystem fs;
+public class FileSystemBLOBStore extends org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore {
 
-    /**
-     * Creates a new <code>FileSystemBLOBStore</code> instance.
-     *
-     * @param fs file system for storing the BLOB data
-     */
     public FileSystemBLOBStore(FileSystem fs) {
-        this.fs = fs;
-    }
-
-    //------------------------------------------------------------< BLOBStore >
-    /**
-     * {@inheritDoc}
-     */
-    public String createId(PropertyId id, int index) {
-        // the blobId is an absolute file system path
-        StringBuffer sb = new StringBuffer();
-        sb.append(FileSystem.SEPARATOR_CHAR);
-        char[] chars = id.getParentId().getUUID().toString().toCharArray();
-        int cnt = 0;
-        for (int i = 0; i < chars.length; i++) {
-            if (chars[i] == '-') {
-                continue;
-            }
-            //if (cnt > 0 && cnt % 4 == 0) {
-            if (cnt == 2 || cnt == 4) {
-                sb.append(FileSystem.SEPARATOR_CHAR);
-            }
-            sb.append(chars[i]);
-            cnt++;
-        }
-        sb.append(FileSystem.SEPARATOR_CHAR);
-        sb.append(FileSystemPathUtil.escapeName(id.getName().toString()));
-        sb.append('.');
-        sb.append(index);
-        sb.append(".bin");
-        return sb.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public InputStream get(String blobId) throws Exception {
-        return getResource(blobId).getInputStream();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void put(String blobId, InputStream in, long size) throws Exception {
-        OutputStream out = null;
-        // the blobId is an absolute file system path
-        FileSystemResource internalBlobFile = new FileSystemResource(fs, blobId);
-        internalBlobFile.makeParentDirs();
-        try {
-            out = new BufferedOutputStream(internalBlobFile.getOutputStream());
-            byte[] buffer = new byte[8192];
-            int read;
-            while ((read = in.read(buffer)) > 0) {
-                out.write(buffer, 0, read);
-            }
-        } finally {
-            if (out != null) {
-                out.close();
-            }
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean remove(String blobId) throws Exception {
-        // the blobId is an absolute file system path
-        FileSystemResource res = new FileSystemResource(fs, blobId);
-        if (!res.exists()) {
-            return false;
-        }
-        // delete resource and prune empty parent folders
-        res.delete(true);
-        return true;
-    }
-
-    //-----------------------------------------------< ResourceBasedBLOBStore >
-    /**
-     * {@inheritDoc}
-     */
-    public FileSystemResource getResource(String blobId)
-            throws Exception {
-        // the blobId is an absolute file system path
-        return new FileSystemResource(fs, blobId);
+        super(fs);
     }
-}
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/ResourceBasedBLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/ResourceBasedBLOBStore.java?view=diff&rev=467925&r1=467924&r2=467925
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/ResourceBasedBLOBStore.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/ResourceBasedBLOBStore.java Thu Oct 26 02:11:18 2006
@@ -16,21 +16,11 @@
  */
 package org.apache.jackrabbit.core.state.util;
 
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.fs.FileSystemResource;
-
 /**
- * <code>ResourceBasedBLOBStore</code> extends the <code>BLOBStore</code>
- * interface with the method {@link #getResource(String)}
+ * Legacy interface kept for backward compatibility reasons.
+ * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.ResourceBasedBLOBStore}
+ *             instead.
  */
-public interface ResourceBasedBLOBStore extends BLOBStore {
-    /**
-     * Retrieves the BLOB data with the specified id as a permanent resource.
-     *
-     * @param blobId identifier of the BLOB data as returned by
-     *               {@link #createId(PropertyId, int)}
-     * @return a resource representing the BLOB data
-     * @throws Exception if an error occured
-     */
-    FileSystemResource getResource(String blobId) throws Exception;
-}
+public interface ResourceBasedBLOBStore
+        extends org.apache.jackrabbit.core.persistence.util.ResourceBasedBLOBStore {
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/Serializer.java?view=diff&rev=467925&r1=467924&r2=467925
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/Serializer.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/util/Serializer.java Thu Oct 26 02:11:18 2006
@@ -16,349 +16,70 @@
  */
 package org.apache.jackrabbit.core.state.util;
 
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.fs.FileSystemResource;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
+import org.apache.jackrabbit.core.persistence.util.BLOBStore;
 import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
-import org.apache.jackrabbit.core.value.InternalValue;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.uuid.UUID;
 
-import javax.jcr.PropertyType;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Arrays;
 
 /**
- * <code>Serializer</code> is a utility class that provides static methods
- * for serializing & deserializing <code>ItemState</code> and
- * <code>NodeReferences</code> objects using a simple binary serialization
- * format.
+ * Legacy class kept for backward compatibility reasons.
+ * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.Serializer}
+ *             instead.
  */
 public final class Serializer {
 
-    private static final byte[] NULL_UUID_PLACEHOLDER_BYTES = new byte[] {
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-    };
-
-    /**
-     * encoding used for serializing String values
-     */
-    private static final String ENCODING = "UTF-8";
-
     /**
-     * Serializes the specified <code>NodeState</code> object to the given
-     * binary <code>stream</code>.
-     *
-     * @param state  <code>state</code> to serialize
-     * @param stream the stream where the <code>state</code> should be
-     *               serialized to
-     * @throws Exception if an error occurs during the serialization
-     * @see #deserialize(NodeState, InputStream)
+     * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.Serializer#serialize(NodeState, OutputStream)}
      */
     public static void serialize(NodeState state, OutputStream stream)
             throws Exception {
-        DataOutputStream out = new DataOutputStream(stream);
-
-        // primaryType
-        out.writeUTF(state.getNodeTypeName().toString());
-        // parentUUID
-        if (state.getParentId() == null) {
-            out.write(NULL_UUID_PLACEHOLDER_BYTES);
-        } else {
-            out.write(state.getParentId().getUUID().getRawBytes());
-        }
-        // definitionId
-        out.writeUTF(state.getDefinitionId().toString());
-        // mixin types
-        Collection c = state.getMixinTypeNames();
-        out.writeInt(c.size()); // count
-        for (Iterator iter = c.iterator(); iter.hasNext();) {
-            out.writeUTF(iter.next().toString());   // name
-        }
-        // modCount
-        out.writeShort(state.getModCount());
-        // properties (names)
-        c = state.getPropertyNames();
-        out.writeInt(c.size()); // count
-        for (Iterator iter = c.iterator(); iter.hasNext();) {
-            QName propName = (QName) iter.next();
-            out.writeUTF(propName.toString());   // name
-        }
-        // child nodes (list of name/uuid pairs)
-        c = state.getChildNodeEntries();
-        out.writeInt(c.size()); // count
-        for (Iterator iter = c.iterator(); iter.hasNext();) {
-            NodeState.ChildNodeEntry entry = (NodeState.ChildNodeEntry) iter.next();
-            out.writeUTF(entry.getName().toString());   // name
-            out.write(entry.getId().getUUID().getRawBytes());    // uuid
-        }
+        serialize(state, stream);
     }
 
     /**
-     * Deserializes a <code>NodeState</code> object from the given binary
-     * <code>stream</code>.
-     *
-     * @param state  <code>state</code> to deserialize
-     * @param stream the stream where the <code>state</code> should be deserialized from
-     * @throws Exception if an error occurs during the deserialization
-     * @see #serialize(NodeState, OutputStream)
+     * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.Serializer#deserialize(NodeState, InputStream)}
      */
     public static void deserialize(NodeState state, InputStream stream)
             throws Exception {
-        DataInputStream in = new DataInputStream(stream);
-
-        // primaryType
-        String s = in.readUTF();
-        state.setNodeTypeName(QName.valueOf(s));
-        // parentUUID (may be null)
-        byte[] uuidBytes = new byte[UUID.UUID_BYTE_LENGTH];
-        in.readFully(uuidBytes);
-        if (!Arrays.equals(uuidBytes, NULL_UUID_PLACEHOLDER_BYTES)) {
-            state.setParentId(new NodeId(new UUID(uuidBytes)));
-        }
-        // definitionId
-        s = in.readUTF();
-        state.setDefinitionId(NodeDefId.valueOf(s));
-        // mixin types
-        int count = in.readInt();   // count
-        Set set = new HashSet(count);
-        for (int i = 0; i < count; i++) {
-            set.add(QName.valueOf(in.readUTF())); // name
-        }
-        if (set.size() > 0) {
-            state.setMixinTypeNames(set);
-        }
-        // modCount
-        short modCount = in.readShort();
-        state.setModCount(modCount);
-        // properties (names)
-        count = in.readInt();   // count
-        for (int i = 0; i < count; i++) {
-            state.addPropertyName(QName.valueOf(in.readUTF())); // name
-        }
-        // child nodes (list of name/uuid pairs)
-        count = in.readInt();   // count
-        for (int i = 0; i < count; i++) {
-            QName name = QName.valueOf(in.readUTF());    // name
-            // uuid
-            in.readFully(uuidBytes);
-            state.addChildNodeEntry(name, new NodeId(new UUID(uuidBytes)));
-        }
+        deserialize(state, stream);
     }
 
     /**
-     * Serializes the specified <code>PropertyState</code> object to the given
-     * binary <code>stream</code>. Binary values are stored in the specified
-     * <code>BLOBStore</code>.
-     *
-     * @param state     <code>state</code> to serialize
-     * @param stream    the stream where the <code>state</code> should be
-     *                  serialized to
-     * @param blobStore handler for BLOB data
-     * @throws Exception if an error occurs during the serialization
-     * @see #deserialize(PropertyState, InputStream, BLOBStore)
+     * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.Serializer#serialize(PropertyState, OutputStream, BLOBStore)}
      */
     public static void serialize(PropertyState state,
                                  OutputStream stream,
                                  BLOBStore blobStore)
             throws Exception {
-        DataOutputStream out = new DataOutputStream(stream);
-
-        // type
-        out.writeInt(state.getType());
-        // multiValued
-        out.writeBoolean(state.isMultiValued());
-        // definitionId
-        out.writeUTF(state.getDefinitionId().toString());
-        // modCount
-        out.writeShort(state.getModCount());
-        // values
-        InternalValue[] values = state.getValues();
-        out.writeInt(values.length); // count
-        for (int i = 0; i < values.length; i++) {
-            InternalValue val = values[i];
-            if (state.getType() == PropertyType.BINARY) {
-                // special handling required for binary value:
-                // put binary value in BLOB store
-                BLOBFileValue blobVal = (BLOBFileValue) val.internalValue();
-                InputStream in = blobVal.getStream();
-                String blobId = blobStore.createId(state.getPropertyId(), i);
-                try {
-                    blobStore.put(blobId, in, blobVal.getLength());
-                } finally {
-                    try {
-                        in.close();
-                    } catch (IOException e) {
-                        // ignore
-                    }
-                }
-                // store id of BLOB as property value
-                out.writeUTF(blobId);   // value
-                // replace value instance with value backed by resource
-                // in BLOB store and discard old value instance (e.g. temp file)
-                if (blobStore instanceof ResourceBasedBLOBStore) {
-                    // optimization: if the BLOB store is resource-based
-                    // retrieve the resource directly rather than having
-                    // to read the BLOB from an input stream
-                    FileSystemResource fsRes =
-                            ((ResourceBasedBLOBStore) blobStore).getResource(blobId);
-                    values[i] = InternalValue.create(fsRes);
-                } else {
-                    in = blobStore.get(blobId);
-                    try {
-                        values[i] = InternalValue.create(in, false);
-                    } finally {
-                        try {
-                            in.close();
-                        } catch (IOException e) {
-                            // ignore
-                        }
-                    }
-                }
-                blobVal.discard();
-            } else {
-                /**
-                 * because writeUTF(String) has a size limit of 65k,
-                 * Strings are serialized as <length><byte[]>
-                 */
-                //out.writeUTF(val.toString());   // value
-                byte[] bytes = val.toString().getBytes(ENCODING);
-                out.writeInt(bytes.length); // lenght of byte[]
-                out.write(bytes);   // byte[]
-            }
-        }
+        serialize(state, stream, blobStore);
     }
 
     /**
-     * Deserializes a <code>PropertyState</code> object from the given binary
-     * <code>stream</code>. Binary values are retrieved from the specified
-     * <code>BLOBStore</code>.
-     *
-     * @param state     <code>state</code> to deserialize
-     * @param stream    the stream where the <code>state</code> should be
-     *                  deserialized from
-     * @param blobStore handler for BLOB data
-     * @throws Exception if an error occurs during the deserialization
-     * @see #serialize(PropertyState, OutputStream, BLOBStore)
+     * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.Serializer#deserialize(PropertyState, InputStream, BLOBStore)}
      */
     public static void deserialize(PropertyState state,
                                    InputStream stream,
                                    BLOBStore blobStore)
             throws Exception {
-        DataInputStream in = new DataInputStream(stream);
-
-        // type
-        int type = in.readInt();
-        state.setType(type);
-        // multiValued
-        boolean multiValued = in.readBoolean();
-        state.setMultiValued(multiValued);
-        // definitionId
-        String s = in.readUTF();
-        state.setDefinitionId(PropDefId.valueOf(s));
-        // modCount
-        short modCount = in.readShort();
-        state.setModCount(modCount);
-        // values
-        int count = in.readInt();   // count
-        InternalValue[] values = new InternalValue[count];
-        for (int i = 0; i < count; i++) {
-            InternalValue val;
-            if (type == PropertyType.BINARY) {
-                s = in.readUTF();   // value (i.e. blobId)
-                // special handling required for binary value:
-                // the value stores the id of the BLOB data
-                // in the BLOB store
-                if (blobStore instanceof ResourceBasedBLOBStore) {
-                    // optimization: if the BLOB store is resource-based
-                    // retrieve the resource directly rather than having
-                    // to read the BLOB from an input stream
-                    FileSystemResource fsRes =
-                            ((ResourceBasedBLOBStore) blobStore).getResource(s);
-                    val = InternalValue.create(fsRes);
-                } else {
-                    InputStream is = blobStore.get(s);
-                    try {
-                        val = InternalValue.create(is, false);
-                    } finally {
-                        try {
-                            is.close();
-                        } catch (IOException e) {
-                            // ignore
-                        }
-                    }
-                }
-            } else {
-                /**
-                 * because writeUTF(String) has a size limit of 65k,
-                 * Strings are serialized as <length><byte[]>
-                 */
-                //s = in.readUTF();   // value
-                int len = in.readInt(); // lenght of byte[]
-                byte[] bytes = new byte[len];
-                in.readFully(bytes); // byte[]
-                s = new String(bytes, ENCODING);
-                val = InternalValue.valueOf(s, type);
-            }
-            values[i] = val;
-        }
-        state.setValues(values);
+        deserialize(state, stream, blobStore);
     }
 
     /**
-     * Serializes the specified <code>NodeReferences</code> object to the given
-     * binary <code>stream</code>.
-     *
-     * @param refs   object to serialize
-     * @param stream the stream where the object should be serialized to
-     * @throws Exception if an error occurs during the serialization
-     * @see #deserialize(NodeReferences, InputStream)
+     * @deprecated use {@link org.apache.jackrabbit.core.persistence.util.Serializer#serialize(NodeReferences, OutputStream)}
      */
     public static void serialize(NodeReferences refs, OutputStream stream)
             throws Exception {
-        DataOutputStream out = new DataOutputStream(stream);
-
-        // references
-        Collection c = refs.getReferences();
-        out.writeInt(c.size()); // count
-        for (Iterator iter = c.iterator(); iter.hasNext();) {
-            PropertyId propId = (PropertyId) iter.next();
-            out.writeUTF(propId.toString());   // propertyId
-        }
+        serialize(refs, stream);
     }
 
     /**
-     * Deserializes a <code>NodeReferences</code> object from the given
-     * binary <code>stream</code>.
-     *
-     * @param refs   object to deserialize
-     * @param stream the stream where the object should be deserialized from
-     * @throws Exception if an error occurs during the deserialization
-     * @see #serialize(NodeReferences, OutputStream)
+     * @deprecated user {@link org.apache.jackrabbit.core.persistence.util.Serializer#deserialize(NodeReferences, InputStream)}
      */
     public static void deserialize(NodeReferences refs, InputStream stream)
             throws Exception {
-        DataInputStream in = new DataInputStream(stream);
-
-        refs.clearAllReferences();
-
-        // references
-        int count = in.readInt();   // count
-        for (int i = 0; i < count; i++) {
-            refs.addReference(PropertyId.valueOf(in.readUTF()));    // propertyId
-        }
+        deserialize(refs, stream);
     }
-}
+}
\ No newline at end of file