jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Brosius <dbros...@apache.org>
Subject Re: svn commit: r1299243 - in /jackrabbit/sandbox/jackrabbit-mongo-persistence: README.txt pom.xml src/main/java/org/apache/jackrabbit/core/persistence/mongo/MongoPersistenceManager.java
Date Sat, 10 Mar 2012 21:18:32 GMT
The drivers are apache2 if that matters any.

On 03/10/2012 02:38 PM, Roy T. Fielding wrote:
> Why MongoDB?  It is under an incompatible license, so we'd never be able to
> distribute this pm.
>
> ....Roy
>
> On Mar 10, 2012, at 9:56 AM, stefan@apache.org wrote:
>
>> Author: stefan
>> Date: Sat Mar 10 17:56:34 2012
>> New Revision: 1299243
>>
>> URL: http://svn.apache.org/viewvc?rev=1299243&view=rev
>> Log:
>> experimental mongo-based pm&  ds
>>
>> allow for db per pm
>>
>> Modified:
>>     jackrabbit/sandbox/jackrabbit-mongo-persistence/README.txt
>>     jackrabbit/sandbox/jackrabbit-mongo-persistence/pom.xml
>>     jackrabbit/sandbox/jackrabbit-mongo-persistence/src/main/java/org/apache/jackrabbit/core/persistence/mongo/MongoPersistenceManager.java
>>
>> Modified: jackrabbit/sandbox/jackrabbit-mongo-persistence/README.txt
>> URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mongo-persistence/README.txt?rev=1299243&r1=1299242&r2=1299243&view=diff
>> ==============================================================================
>> --- jackrabbit/sandbox/jackrabbit-mongo-persistence/README.txt (original)
>> +++ jackrabbit/sandbox/jackrabbit-mongo-persistence/README.txt Sat Mar 10 17:56:34
2012
>> @@ -6,8 +6,9 @@ committing changes the workspace may bec
>>
>> Both MongoPersistenceManager and MongoDataStore support the following parameters:
>>
>> -- host ->  defaults to 127.0.0.1
>> -- port ->  defaults to 27017
>> +- host ->  defaults to "127.0.0.1"
>> +- port ->  defaults to "27017"
>> +- dbName ->  defaults to "rep"
>> - TODO document all configuration parameters
>>
>> MongoPersistenceManager also supports the following parameters:
>>
>> Modified: jackrabbit/sandbox/jackrabbit-mongo-persistence/pom.xml
>> URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mongo-persistence/pom.xml?rev=1299243&r1=1299242&r2=1299243&view=diff
>> ==============================================================================
>> --- jackrabbit/sandbox/jackrabbit-mongo-persistence/pom.xml (original)
>> +++ jackrabbit/sandbox/jackrabbit-mongo-persistence/pom.xml Sat Mar 10 17:56:34 2012
>> @@ -35,7 +35,7 @@
>>
>>    <groupId>org.apache.jackrabbit</groupId>
>>    <artifactId>jackrabbit-mongo-persistence</artifactId>
>> -<name>Apache Jackrabbit</name>
>> +<name>Apache Jackrabbit MongoDB Persistence</name>
>>    <version>2.6-SNAPSHOT</version>
>>    <packaging>jar</packaging>
>>
>>
>> Modified: jackrabbit/sandbox/jackrabbit-mongo-persistence/src/main/java/org/apache/jackrabbit/core/persistence/mongo/MongoPersistenceManager.java
>> URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mongo-persistence/src/main/java/org/apache/jackrabbit/core/persistence/mongo/MongoPersistenceManager.java?rev=1299243&r1=1299242&r2=1299243&view=diff
>> ==============================================================================
>> --- jackrabbit/sandbox/jackrabbit-mongo-persistence/src/main/java/org/apache/jackrabbit/core/persistence/mongo/MongoPersistenceManager.java
(original)
>> +++ jackrabbit/sandbox/jackrabbit-mongo-persistence/src/main/java/org/apache/jackrabbit/core/persistence/mongo/MongoPersistenceManager.java
Sat Mar 10 17:56:34 2012
>> @@ -77,8 +77,18 @@ public class MongoPersistenceManager ext
>>
>>      protected MongoBlobStore blobStore;
>>
>> +    protected String dbName = "rep";
>> +
>>      //--------------------------------------<  configuration getters&  setters>
>>
>> +    public String getDbName() {
>> +        return dbName;
>> +    }
>> +
>> +    public void setDbName(String dbName) {
>> +        this.dbName = dbName;
>> +    }
>> +
>>      public String getHost() {
>>          return conf.getHost();
>>      }
>> @@ -222,7 +232,9 @@ public class MongoPersistenceManager ext
>>              log.error("failed to connect to mongodb", e);
>>              throw new RepositoryException("failed to initialize MongoPersistenceManager",
e);
>>          }
>> -        db = con.getDB("rep");
>> +
>> +
>> +        db = con.getDB(encodeName(dbName));
>>          db.setWriteConcern(WriteConcern.SAFE);
>>
>>          bundles = db.getCollection("bundles");
>> @@ -428,6 +440,67 @@ public class MongoPersistenceManager ext
>>          return (refs.findOne(key) != null);
>>      }
>>
>> +    //-------------------------------------------------------<  implementation>
>> +
>> +    protected final static String ENCODED_DOT = "_x46_";
>> +    protected final static String ENCODED_DOLLAR_SIGN = "_x36_";
>> +
>> +    /**
>> +     * see http://www.mongodb.org/display/DOCS/Legal+Key+Names
>> +     *
>> +     * @param name
>> +     * @return
>> +     */
>> +    protected static String encodeName(String name) {
>> +        StringBuilder buf = null;
>> +        for (int i = 0; i<  name.length(); i++) {
>> +            if (i == 0&&  name.charAt(i) == '$') {
>> +                // mongodb field names must not start with '$'
>> +                buf = new StringBuilder();
>> +                buf.append(ENCODED_DOLLAR_SIGN);
>> +            } else if (name.charAt(i) == '.') {
>> +                // . is a reserved char for mongodb field names
>> +                if (buf == null) {
>> +                    buf = new StringBuilder(name.substring(0, i));
>> +                }
>> +                buf.append(ENCODED_DOT);
>> +            } else {
>> +                if (buf != null) {
>> +                    buf.append(name.charAt(i));
>> +                }
>> +            }
>> +        }
>> +
>> +        return buf == null ? name : buf.toString();
>> +    }
>> +
>> +    protected static String decodeName(String name) {
>> +        StringBuilder buf = null;
>> +
>> +        int lastPos = 0;
>> +        if (name.startsWith(ENCODED_DOLLAR_SIGN)) {
>> +            buf = new StringBuilder("$");
>> +            lastPos = ENCODED_DOLLAR_SIGN.length();
>> +        }
>> +
>> +        int pos;
>> +        while ((pos = name.indexOf(ENCODED_DOT, lastPos)) != -1) {
>> +            if (buf == null) {
>> +                buf = new StringBuilder();
>> +            }
>> +            buf.append(name.substring(lastPos, pos));
>> +            buf.append('.');
>> +            lastPos = pos + ENCODED_DOT.length();
>> +        }
>> +
>> +        if (buf != null) {
>> +            buf.append(name.substring(lastPos));
>> +            return buf.toString();
>> +        } else {
>> +            return name;
>> +        }
>> +    }
>> +
>>      //--------------------------------------------------------<  inner classes>
>>
>>      protected class MongoBlobStore implements BLOBStore {
>>
>>
>


Mime
View raw message