You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/07/03 17:01:09 UTC

[03/63] [abbrv] [partial] ISIS-832: mothballing components

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoDb.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoDb.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoDb.java
new file mode 100644
index 0000000..776057f
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoDb.java
@@ -0,0 +1,263 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.db.mongo;
+
+import java.net.UnknownHostException;
+import java.util.Iterator;
+import java.util.List;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.Mongo;
+import com.mongodb.MongoException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.objectstore.nosql.NoSqlCommandContext;
+import org.apache.isis.objectstore.nosql.NoSqlStoreException;
+import org.apache.isis.objectstore.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.objectstore.nosql.db.StateReader;
+import org.apache.isis.objectstore.nosql.db.StateWriter;
+import org.apache.isis.objectstore.nosql.keys.KeyCreatorDefault;
+
+public class MongoDb implements NoSqlDataDatabase {
+
+	private static final String SERIALNUMBERS_COLLECTION_NAME = "serialnumbers";
+
+	private static final Logger LOG = LoggerFactory.getLogger(MongoDb.class);
+	
+	private static final int DEFAULT_PORT = 27017;
+
+    private final String host;
+    private final int port;
+    private final String dbName;
+    private final KeyCreatorDefault keyCreator;
+    
+	private Mongo mongo;
+	private DB db;
+
+    public MongoDb(final String host, final int port, final String name, final KeyCreatorDefault keyCreator) {
+        this.host = host;
+        this.port = port == 0 ? DEFAULT_PORT : port;
+        this.dbName = name;
+        this.keyCreator = keyCreator;
+    }
+
+    public KeyCreatorDefault getKeyCreator() {
+        return keyCreator;
+    }
+
+    @Override
+    public void open() {
+        try {
+            if (mongo == null) {
+                mongo = new Mongo(host, port);
+                db = mongo.getDB(dbName);
+                db.setWriteConcern(com.mongodb.WriteConcern.SAFE);
+                LOG.info("opened database (" + dbName + "): " + mongo);
+            } else {
+                LOG.info(" using opened database " + db);
+            }
+        } catch (final UnknownHostException e) {
+            throw new NoSqlStoreException(e);
+        } catch (final MongoException e) {
+            throw new NoSqlStoreException(e);
+        }
+    }
+
+    @Override
+    public void close() {
+    }
+
+    public NoSqlCommandContext createTransactionContext() {
+        return null;
+    }
+
+    //////////////////////////////////////////////////
+    // contains data
+    //////////////////////////////////////////////////
+
+    @Override
+    public boolean containsData() {
+        return db.getCollectionNames().size() > 0;
+    }
+
+    
+    //////////////////////////////////////////////////
+    // serial numbers
+    //////////////////////////////////////////////////
+    
+    @Override
+    public long nextSerialNumberBatch(final ObjectSpecId name, final int batchSize) {
+        long next = readSerialNumber();
+        writeSerialNumber(next + batchSize);
+        return next + 1;
+    }
+
+    private void writeSerialNumber(final long serialNumber) {
+        final DBCollection system = db.getCollection(SERIALNUMBERS_COLLECTION_NAME);
+        DBObject object = system.findOne();
+        if (object == null) {
+            object = new BasicDBObject();
+        }
+        object.put("next-id", Long.toString(serialNumber));
+        system.save(object);
+        LOG.info("serial number written: " + serialNumber);
+    }
+
+    private long readSerialNumber() {
+        final DBCollection system = db.getCollection(SERIALNUMBERS_COLLECTION_NAME);
+        final DBObject data = system.findOne();
+        if (data == null) {
+            return 0;
+        } else {
+            final String number = (String) data.get("next-id");
+            LOG.info("serial number read: " + number);
+            return Long.valueOf(number);
+        }
+    }
+
+    //////////////////////////////////////////////////
+    // hasInstances, instancesOf
+    //////////////////////////////////////////////////
+
+    @Override
+    public boolean hasInstances(final ObjectSpecId objectSpecId) {
+        final DBCollection instances = db.getCollection(objectSpecId.asString());
+        return instances.getCount() > 0;
+    }
+
+    @Override
+    public Iterator<StateReader> instancesOf(final ObjectSpecId objectSpecId) {
+        final DBCollection instances = db.getCollection(objectSpecId.asString());
+        final DBCursor cursor = instances.find();
+        LOG.info("searching for instances of: " + objectSpecId);
+        return new Iterator<StateReader>() {
+            @Override
+            public boolean hasNext() {
+                return cursor.hasNext();
+            }
+
+            @Override
+            public StateReader next() {
+                return new MongoStateReader(cursor.next());
+            }
+
+            @Override
+            public void remove() {
+                throw new NoSqlStoreException("Can't remove elements");
+            }
+
+        };
+    }
+    
+    @Override
+    public Iterator<StateReader> instancesOf(ObjectSpecId objectSpecId, ObjectAdapter pattern) {
+        final DBCollection instances = db.getCollection(objectSpecId.asString());
+
+        // REVIEW check the right types are used in matches 
+        final BasicDBObject query = new BasicDBObject();
+        for ( ObjectAssociation association  : pattern.getSpecification().getAssociations(Contributed.EXCLUDED)) {
+            ObjectAdapter field = association.get(pattern);
+            if (!association.isEmpty(pattern)) {
+                if (field.isValue()) {
+                    query.put(association.getIdentifier().getMemberName(), field.titleString());
+                } else if (association.isOneToOneAssociation()) {
+                    query.put(association.getIdentifier().getMemberName(), field.getOid());
+                }
+            }
+        }
+        final DBCursor cursor = instances.find(query);
+        LOG.info("searching for instances of: " + objectSpecId);
+        return new Iterator<StateReader>() {
+            @Override
+            public boolean hasNext() {
+                return cursor.hasNext();
+            }
+
+            @Override
+            public StateReader next() {
+                return new MongoStateReader(cursor.next());
+            }
+
+            @Override
+            public void remove() {
+                throw new NoSqlStoreException("Can't remove elements");
+            }
+
+        };
+    }
+
+    @Override
+    public StateReader getInstance(final String key, final ObjectSpecId objectSpecId) {
+        return new MongoStateReader(db, objectSpecId, key);
+    }
+
+    //////////////////////////////////////////////////
+    // write, delete
+    //////////////////////////////////////////////////
+
+    public StateWriter createStateWriter(final ObjectSpecId objectSpecId) {
+        return new MongoStateWriter(db, objectSpecId);
+    }
+
+
+    @Override
+    public void write(final List<PersistenceCommand> commands) {
+        final NoSqlCommandContext context = new MongoClientCommandContext(db);
+        for (final PersistenceCommand command : commands) {
+            command.execute(context);
+        }
+    }
+
+
+    //////////////////////////////////////////////////
+    // services
+    //////////////////////////////////////////////////
+
+    @Override
+    public void addService(final ObjectSpecId objectSpecId, final String key) {
+        final DBCollection services = db.getCollection("services");
+        services.insert(new BasicDBObject().append("name", objectSpecId.asString()).append("key", key));
+        LOG.info("service added " + objectSpecId + ":" + key);
+    }
+
+    @Override
+    public String getService(final ObjectSpecId objectSpecId) {
+        final DBCollection services = db.getCollection("services");
+        final DBObject object = services.findOne(new BasicDBObject().append("name", objectSpecId.asString()));
+        if (object == null) {
+            return null;
+        } else {
+            final String id = (String) object.get("key");
+            LOG.info("service found " + objectSpecId + ":" + id);
+            return id;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoPersistorMechanismInstaller.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoPersistorMechanismInstaller.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoPersistorMechanismInstaller.java
new file mode 100644
index 0000000..135f07a
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoPersistorMechanismInstaller.java
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.db.mongo;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.objectstore.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.objectstore.nosql.db.NoSqlPersistorMechanismInstaller;
+import org.apache.isis.objectstore.nosql.keys.KeyCreatorDefault;
+
+public class MongoPersistorMechanismInstaller extends NoSqlPersistorMechanismInstaller {
+
+    private static final String STRING = ConfigurationConstants.ROOT + "nosql.mongodb.";
+    private static final String DB_HOST = STRING + "host";
+    private static final String DB_PORT = STRING + "port";
+    private static final String DB_NAME = STRING + "name";
+
+    public MongoPersistorMechanismInstaller() {
+        super("mongodb");
+    }
+
+    @Override
+    protected NoSqlDataDatabase createNoSqlDatabase(final IsisConfiguration configuration) {
+        NoSqlDataDatabase db;
+        final String host = configuration.getString(DB_HOST, "localhost");
+        final int port = configuration.getInteger(DB_PORT, 0);
+        final String name = configuration.getString(DB_NAME, "isis");
+        final KeyCreatorDefault keyCreator = new KeyCreatorDefault();
+        db = new MongoDb(host, port, name, keyCreator);
+        return db;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateReader.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateReader.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateReader.java
new file mode 100644
index 0000000..345d3fb
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateReader.java
@@ -0,0 +1,123 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.db.mongo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.mongodb.BasicDBList;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.objectstore.nosql.db.StateReader;
+
+public class MongoStateReader implements StateReader {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(MongoStateReader.class);
+    private final DBObject instance;
+
+    public MongoStateReader(final DB db, final ObjectSpecId objectSpecId, final String mongoId) {
+        final DBCollection instances = db.getCollection(objectSpecId.asString());
+        instance = instances.findOne(mongoId);
+        if (instance == null) {
+            throw new ObjectNotFoundException(mongoId);
+        }
+        if(LOG.isDebugEnabled()) {
+            LOG.debug("loading " + instance);
+        }
+    }
+
+    public MongoStateReader(final DBObject instance) {
+        this.instance = instance;
+        if(LOG.isDebugEnabled()) {
+            LOG.debug("loading " + instance);
+        }
+    }
+
+    @Override
+    public long readLongField(final String id) {
+        final Object value = instance.get(id);
+        if (value == null || value.equals("null")) {
+            return 0;
+        } 
+        return Long.valueOf((String) value);
+    }
+
+    @Override
+    public String readField(final String name) {
+        final Object value = instance.get(name);
+        if (value == null || value.equals("null")) {
+            return null;
+        } else {
+            return (String) value;
+        }
+    }
+
+    @Override
+    public String readEncrytionType() {
+        return (String) instance.get(PropertyNames.ENCRYPT);
+    }
+
+    @Override
+    public String readOid() {
+        return readField(PropertyNames.OID);
+    }
+
+    @Override
+    public String readVersion() {
+        return readField(PropertyNames.VERSION);
+    }
+
+    @Override
+    public String readUser() {
+        return readField(PropertyNames.USER);
+    }
+
+    @Override
+    public String readTime() {
+        return readField(PropertyNames.TIME);
+    }
+
+    @Override
+    public StateReader readAggregate(final String id) {
+        DBObject object = (DBObject) instance.get(id);
+        return object == null ? null : new MongoStateReader(object);
+    }
+
+    @Override
+    public List<StateReader> readCollection(final String id) {
+        BasicDBList array = (BasicDBList) instance.get(id);
+        final List<StateReader> readers = new ArrayList<StateReader>();
+        if (array != null) {
+            final int size = array.size();
+            for (int i = 0; i < size; i++) {
+                readers.add(new MongoStateReader((DBObject) array.get(i)));
+            }
+        }
+        return readers;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateWriter.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateWriter.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateWriter.java
new file mode 100644
index 0000000..69cafca
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/MongoStateWriter.java
@@ -0,0 +1,131 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.db.mongo;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.nosql.db.StateWriter;
+
+public class MongoStateWriter implements StateWriter {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(MongoStateWriter.class);
+    private final DB db;
+    private final BasicDBObject dbObject;
+    private DBCollection instances;
+
+    public MongoStateWriter(final DB db, final ObjectSpecId objectSpecId) {
+        this(db);
+        instances = db.getCollection(objectSpecId.asString());
+    }
+
+    private MongoStateWriter(final DB db) {
+        this.db = db;
+        dbObject = new BasicDBObject();
+    }
+
+    public void flush() {
+        instances.save(dbObject);
+        if(LOG.isDebugEnabled()) {
+            LOG.debug("saved " + dbObject);
+        }
+    }
+
+    @Override
+    public void writeOid(final TypedOid typedOid) {
+        writeField(PropertyNames.OID, typedOid.enString(getOidMarshaller()));
+        if(typedOid instanceof RootOid) {
+            RootOid rootOid = (RootOid) typedOid;
+            writeField(PropertyNames.MONGO_INTERNAL_ID, rootOid.getIdentifier());
+        }
+    }
+
+    @Override
+    public void writeField(final String id, final String data) {
+        dbObject.put(id, data);
+    }
+
+    @Override
+    public void writeField(final String id, final long l) {
+        dbObject.put(id, Long.toString(l));
+    }
+
+    @Override
+    public void writeEncryptionType(final String type) {
+        writeField(PropertyNames.ENCRYPT, type);
+    }
+
+    @Override
+    public void writeVersion(final String currentVersion, final String newVersion) {
+         writeField(PropertyNames.VERSION, newVersion);
+    }
+
+    @Override
+    public void writeTime(final String time) {
+        writeField(PropertyNames.TIME, time);
+    }
+
+    @Override
+    public void writeUser(final String user) {
+        writeField(PropertyNames.USER, user);
+    }
+
+    @Override
+    public StateWriter addAggregate(final String id) {
+        final MongoStateWriter stateWriter = new MongoStateWriter(db);
+        dbObject.put(id, stateWriter.dbObject);
+        return stateWriter;
+    }
+
+    @Override
+    public StateWriter createElementWriter() {
+        return new MongoStateWriter(db);
+    }
+
+    @Override
+    public void writeCollection(final String id, final List<StateWriter> elements) {
+        final List<BasicDBObject> collection = Lists.newArrayList();
+        for (final StateWriter writer : elements) {
+            collection.add(((MongoStateWriter) writer).dbObject);
+        }
+        dbObject.put(id, collection);
+    }
+    
+    // ///////////////////////////////////////////////////////////////////
+    // dependencies
+    // ///////////////////////////////////////////////////////////////////
+
+    protected OidMarshaller getOidMarshaller() {
+		return IsisContext.getOidMarshaller();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/PropertyNames.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/PropertyNames.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/PropertyNames.java
new file mode 100644
index 0000000..e613227
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/db/mongo/PropertyNames.java
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.db.mongo;
+
+public final class PropertyNames {
+    
+    private PropertyNames(){}
+    
+    static final String ENCRYPT = "_encrypt";
+    
+//    static final String TYPE = "_type";
+//    static final String ID = "_id";
+    
+    static final String MONGO_INTERNAL_ID = "_id";
+    static final String OID = "_oid";
+    static final String VERSION = "_version";
+    static final String TIME = "_time";
+    static final String USER = "_user";
+}
+

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/DataEncryption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/DataEncryption.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/DataEncryption.java
new file mode 100644
index 0000000..e32d090
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/DataEncryption.java
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.objectstore.nosql.encryption;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+
+public interface DataEncryption {
+
+    void init(IsisConfiguration configuration);
+    
+    String getType();
+
+    String encrypt(String plainText);
+
+    String decrypt(String encryptedText);
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/aes/DataEncryptionAes.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/aes/DataEncryptionAes.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/aes/DataEncryptionAes.java
new file mode 100644
index 0000000..49cf4af
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/aes/DataEncryptionAes.java
@@ -0,0 +1,74 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.objectstore.nosql.encryption.aes;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.objectstore.nosql.NoSqlStoreException;
+import org.apache.isis.objectstore.nosql.encryption.DataEncryption;
+
+/**
+ * NOTE this does not work at the moment
+ */
+public class DataEncryptionAes implements DataEncryption {
+
+    private static final String AES = "AES";
+    private final byte[] specKey;
+
+    public DataEncryptionAes() {
+        specKey = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 };
+    }
+
+    @Override
+    public void init(final IsisConfiguration configuration) {
+    }
+
+    @Override
+    public String getType() {
+        return AES;
+    }
+
+    @Override
+    public String encrypt(final String plainText) {
+        try {
+            final SecretKeySpec key = new SecretKeySpec(specKey, AES);
+            final Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
+            cipher.init(Cipher.ENCRYPT_MODE, key);
+            return new String(cipher.doFinal(plainText.getBytes()));
+        } catch (final Exception e) {
+            throw new NoSqlStoreException(e);
+        }
+    }
+
+    @Override
+    public String decrypt(final String encryptedText) {
+        try {
+            final SecretKeySpec key = new SecretKeySpec(specKey, AES);
+            final Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
+            cipher.init(Cipher.DECRYPT_MODE, key);
+            final byte[] decrypted = cipher.doFinal(encryptedText.getBytes());
+            return new String(decrypted);
+        } catch (final Exception e) {
+            throw new NoSqlStoreException(e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishAbstract.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishAbstract.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishAbstract.java
new file mode 100644
index 0000000..b5426db
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishAbstract.java
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.objectstore.nosql.encryption.blowfish;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.objectstore.nosql.NoSqlStoreException;
+import org.apache.isis.objectstore.nosql.encryption.DataEncryption;
+
+public abstract class DataEncryptionBlowfishAbstract implements DataEncryption {
+
+    private static final String BLOWFISH = "Blowfish";
+    private byte[] specKey;
+
+    @Override
+    public void init(final IsisConfiguration configuration) {
+        specKey = secretKey(configuration);
+    }
+
+    public abstract byte[] secretKey(IsisConfiguration configuration);
+
+    @Override
+    public String getType() {
+        return BLOWFISH;
+    }
+
+    @Override
+    public String encrypt(final String plainText) {
+        try {
+            final SecretKeySpec key = new SecretKeySpec(specKey, BLOWFISH);
+            final Cipher cipher = Cipher.getInstance(BLOWFISH);
+            cipher.init(Cipher.ENCRYPT_MODE, key);
+            return new String(cipher.doFinal(plainText.getBytes()));
+        } catch (final Exception e) {
+            throw new NoSqlStoreException(e);
+        }
+    }
+
+    @Override
+    public String decrypt(final String encryptedText) {
+        try {
+            final SecretKeySpec key = new SecretKeySpec(specKey, BLOWFISH);
+            final Cipher cipher = Cipher.getInstance(BLOWFISH);
+            cipher.init(Cipher.DECRYPT_MODE, key);
+            final byte[] decrypted = cipher.doFinal(encryptedText.getBytes());
+            return new String(decrypted);
+        } catch (final Exception e) {
+            throw new NoSqlStoreException(e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java
new file mode 100644
index 0000000..501481d
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.objectstore.nosql.encryption.blowfish;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.objectstore.nosql.NoSqlStoreException;
+
+public class DataEncryptionBlowfishUsingConfiguration extends DataEncryptionBlowfishAbstract {
+
+    private static final String ENCRYPTION_KEY = ConfigurationConstants.ROOT + "nosql.encryption.blowfish-key";
+
+    @Override
+    public byte[] secretKey(final IsisConfiguration configuration) {
+        final String key = configuration.getString(ENCRYPTION_KEY);
+        if (key == null) {
+            throw new NoSqlStoreException("No blowfish encryption key specified in the configuration file (key: " + ENCRYPTION_KEY + ")");
+        }
+        return key.getBytes();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java
new file mode 100644
index 0000000..9d5cfd1
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.objectstore.nosql.encryption.blowfish;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.objectstore.nosql.NoSqlStoreException;
+
+public class DataEncryptionBlowfishUsingKeyFile extends DataEncryptionBlowfishAbstract {
+
+    private static final String ENCRYPTION_KEY_FILE = ConfigurationConstants.ROOT + "nosql.encryption.blowfish-key-file";
+
+    @Override
+    public byte[] secretKey(final IsisConfiguration configuration) {
+        final String fileName = configuration.getString(ENCRYPTION_KEY_FILE, "./blowfish.key");
+        final File file = new File(fileName);
+        if (file.exists()) {
+            try {
+                final InputStream fileInput = new FileInputStream(file);
+                final byte[] buffer = new byte[1024];
+                final int length = fileInput.read(buffer);
+                final byte[] key = new byte[length];
+                System.arraycopy(buffer, 0, key, 0, length);
+                return key;
+            } catch (final IOException e) {
+                throw new NoSqlStoreException("Failed to read in encryption file: " + file.getAbsolutePath(), e);
+            }
+        } else {
+            throw new NoSqlStoreException("Cannot find encryption file: " + file.getAbsolutePath());
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/none/DataEncryptionNone.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/none/DataEncryptionNone.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/none/DataEncryptionNone.java
new file mode 100644
index 0000000..2048cb5
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/none/DataEncryptionNone.java
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.objectstore.nosql.encryption.none;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.objectstore.nosql.encryption.DataEncryption;
+
+public class DataEncryptionNone implements DataEncryption {
+
+    @Override
+    public void init(final IsisConfiguration configuration) {
+    }
+    
+    @Override
+    public String getType() {
+        return "none";
+    }
+
+    @Override
+    public String encrypt(final String plainText) {
+        return plainText;
+    }
+
+    @Override
+    public String decrypt(final String encryptedText) {
+        return encryptedText;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/rot13/Rot13Encryption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/rot13/Rot13Encryption.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/rot13/Rot13Encryption.java
new file mode 100644
index 0000000..0551634
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/encryption/rot13/Rot13Encryption.java
@@ -0,0 +1,68 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.objectstore.nosql.encryption.rot13;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.objectstore.nosql.encryption.DataEncryption;
+
+public class Rot13Encryption implements DataEncryption {
+
+    @Override
+    public String getType() {
+        return "rot13";
+    }
+
+    @Override
+    public void init(final IsisConfiguration configuration) {
+    }
+
+    @Override
+    public String encrypt(final String plainText) {
+        return encode(plainText);
+    }
+
+    @Override
+    public String decrypt(final String encryptedText) {
+        return encode(encryptedText);
+    }
+
+    private String encode(final String plainText) {
+        if (plainText == null) {
+            return plainText;
+        }
+
+        // encode plainText
+        String encodedMessage = "";
+        for (int i = 0; i < plainText.length(); i++) {
+            char c = plainText.charAt(i);
+            if (c >= 'a' && c <= 'm') {
+                c += 13;
+            } else if (c >= 'n' && c <= 'z') {
+                c -= 13;
+            } else if (c >= 'A' && c <= 'M') {
+                c += 13;
+            } else if (c >= 'N' && c <= 'Z') {
+                c -= 13;
+            }
+            encodedMessage += c;
+        }
+        return encodedMessage;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/keys/KeyCreatorDefault.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/keys/KeyCreatorDefault.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/keys/KeyCreatorDefault.java
new file mode 100644
index 0000000..8605e19
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/keys/KeyCreatorDefault.java
@@ -0,0 +1,99 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.keys;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.nosql.NoSqlStoreException;
+
+public class KeyCreatorDefault {
+
+    /**
+     * returns {@link RootOid#getIdentifier()} (oid must be {@link RootOid}, and must be persistent). 
+     */
+    public String getIdentifierForPersistentRoot(final Oid oid) {
+        if (!(oid instanceof RootOid)) {
+            throw new NoSqlStoreException("Oid is not a RootOid: " + oid);
+        } 
+        RootOid rootOid = (RootOid) oid;
+        if (rootOid.isTransient()) {
+            throw new NoSqlStoreException("Oid is not for a persistent object: " + oid);
+        }
+        return rootOid.getIdentifier();
+    }
+
+    /**
+     * Equivalent to the {@link Oid#enString(OidMarshaller)} for the adapter's Oid.
+     */
+    public String oidStrFor(final ObjectAdapter adapter) {
+        if(adapter == null) {
+            return null;
+        }
+        try {
+            //return adapter.getSpecification().getFullIdentifier() + "@" + key(adapter.getOid());
+            return adapter.getOid().enString(getOidMarshaller());
+        } catch (final NoSqlStoreException e) {
+            throw new NoSqlStoreException("Failed to create refence for " + adapter, e);
+        }
+    }
+
+    public RootOid createRootOid(ObjectSpecification objectSpecification, final String identifier) {
+        final ObjectSpecId objectSpecId = objectSpecification.getSpecId();
+        return RootOidDefault.create(objectSpecId, identifier);
+    }
+
+    public RootOid unmarshal(final String oidStr) {
+//        final ObjectSpecification objectSpecification = specificationFromReference(ref);
+//        final String id = ref.split("@")[1];
+//        return oid(objectSpecification, id);
+        return getOidMarshaller().unmarshal(oidStr, RootOid.class);
+    }
+
+    public ObjectSpecification specificationFromOidStr(final String oidStr) {
+//        final String name = ref.split("@")[0];
+//        return getSpecificationLoader().loadSpecification(name);
+        final TypedOid oid = getOidMarshaller().unmarshal(oidStr, TypedOid.class);
+        return getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());
+    }
+
+    
+    /////////////////////////////////////////////////
+    // dependencies (from context)
+    /////////////////////////////////////////////////
+    
+    
+    protected SpecificationLoaderSpi getSpecificationLoader() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+    protected OidMarshaller getOidMarshaller() {
+        return IsisContext.getOidMarshaller();
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreator.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreator.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreator.java
new file mode 100644
index 0000000..87719b7
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreator.java
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.versions;
+
+import org.apache.isis.core.metamodel.adapter.version.Version;
+
+public interface VersionCreator {
+
+    Version version(String versionString, String user, String time);
+    String versionString(Version version);
+
+    String timeString(Version version);
+
+    Version newVersion(String user);
+
+    Version nextVersion(Version version, final String user);
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreatorDefault.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreatorDefault.java b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreatorDefault.java
new file mode 100644
index 0000000..14d7f97
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/main/java/org/apache/isis/objectstore/nosql/versions/VersionCreatorDefault.java
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql.versions;
+
+import java.util.Date;
+
+import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+
+public class VersionCreatorDefault implements VersionCreator {
+
+    @Override
+    public String versionString(final Version version) {
+        final long sequence = version.getSequence();
+        return Long.toHexString(sequence);
+    }
+
+    @Override
+    public String timeString(final Version version) {
+        final Date time = version.getTime();
+        return Long.toHexString(time.getTime());
+    }
+
+    @Override
+    public Version version(final String versionString, final String user, final String timeString) {
+        final Long sequence = Long.valueOf(versionString, 16);
+        final Long time = Long.valueOf(timeString, 16);
+        final Date date = new Date(time);
+        return SerialNumberVersion.create(sequence, user, date);
+    }
+
+    @Override
+    public Version newVersion(final String user) {
+        return SerialNumberVersion.create(1, user, new Date());
+    }
+
+    @Override
+    public Version nextVersion(final Version version, final String user) {
+        final long sequence = version.getSequence() + 1;
+        return SerialNumberVersion.create(sequence, user, new Date());
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/site/apt/index.apt b/mothballed/component/objectstore/nosql/src/site/apt/index.apt
new file mode 100644
index 0000000..9df5853
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/site/apt/index.apt
@@ -0,0 +1,37 @@
+~~  Licensed to the Apache Software Foundation (ASF) under one
+~~  or more contributor license agreements.  See the NOTICE file
+~~  distributed with this work for additional information
+~~  regarding copyright ownership.  The ASF licenses this file
+~~  to you under the Apache License, Version 2.0 (the
+~~  "License"); you may not use this file except in compliance
+~~  with the License.  You may obtain a copy of the License at
+~~
+~~        http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~  Unless required by applicable law or agreed to in writing,
+~~  software distributed under the License is distributed on an
+~~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~  KIND, either express or implied.  See the License for the
+~~  specific language governing permissions and limitations
+~~  under the License.
+
+
+
+NoSQL Objectstore Implementation
+ 
+ The <nosql> objectstore module provides an implementation of the object store
+ API that persists domain objects using JSON.
+
+Alternatives
+
+  Alternatives include:
+  
+  * the {{{../dflt/index.html}dflt}} in-memory object store (for prototyping only)
+
+  * the {{{../sql/index.html}SQL}} object store
+
+  * the {{{../xml/index.html}XML}} object store
+
+  []
+ 
+ []
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/site/apt/jottings.apt b/mothballed/component/objectstore/nosql/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/site/apt/jottings.apt
@@ -0,0 +1,24 @@
+~~  Licensed to the Apache Software Foundation (ASF) under one
+~~  or more contributor license agreements.  See the NOTICE file
+~~  distributed with this work for additional information
+~~  regarding copyright ownership.  The ASF licenses this file
+~~  to you under the Apache License, Version 2.0 (the
+~~  "License"); you may not use this file except in compliance
+~~  with the License.  You may obtain a copy of the License at
+~~
+~~        http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~  Unless required by applicable law or agreed to in writing,
+~~  software distributed under the License is distributed on an
+~~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~  KIND, either express or implied.  See the License for the
+~~  specific language governing permissions and limitations
+~~  under the License.
+
+
+
+Jottings
+ 
+  This page is to capture any random jottings relating to this module prior 
+  to being moved into formal documentation. 
+ 

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/site/site.xml
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/site/site.xml b/mothballed/component/objectstore/nosql/src/site/site.xml
new file mode 100644
index 0000000..419f3ca
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/site/site.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+         http://www.apache.org/licenses/LICENSE-2.0
+         
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project>
+
+	<body>
+		<breadcrumbs>
+			<item name="NoSQL" href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="NoSQL Objectstore">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="Objectstore Modules">
+            <item name="Default (in-mem)" href="../dflt/index.html" />
+            <item name="XML" href="../xml/index.html" />
+            <item name="SQL" href="../sql/index.html" />
+            <item name="NoSQL" href="../nosql/index.html" />
+        </menu>
+
+        <menu name="Documentation">
+            <item name="${docbkxGuideTitle} (PDF)" href="docbkx/pdf/${docbkxGuideName}.pdf" />
+            <item name="${docbkxGuideTitle} (HTML)" href="docbkx/html/guide/${docbkxGuideName}.html" />
+        </menu>
+
+        <menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/DestroyObjectCommandImplementationTest.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/DestroyObjectCommandImplementationTest.java b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/DestroyObjectCommandImplementationTest.java
new file mode 100644
index 0000000..1eff942
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/DestroyObjectCommandImplementationTest.java
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.objectstore.nosql.versions.VersionCreatorDefault;
+
+public class DestroyObjectCommandImplementationTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    @Mock
+    private NoSqlCommandContext commandContext;
+    @Mock
+    private ObjectSpecification specification;
+    @Mock
+    private ObjectAdapter adapter;
+    
+    @Mock
+    private VersionCreatorDefault versionCreator;
+    @Mock
+    private Version version;
+
+    //private KeyCreatorDefault keyCreator;
+
+    private final ObjectSpecId specId = ObjectSpecId.of("com.foo.bar.SomeClass");
+
+    private long id = 123;
+    private String keyStr = Long.toString(id, 16);
+
+    private RootOid rootOid = RootOidDefault.create(specId, keyStr);
+
+    private NoSqlDestroyObjectCommand command;
+
+    @Before
+    public void setup() {
+        //keyCreator = new KeyCreatorDefault();
+        
+        context.checking(new Expectations(){{
+
+            allowing(specification).getFullIdentifier();
+            will(returnValue("com.foo.bar.SomeClass"));
+
+            allowing(specification).getSpecId();
+            will(returnValue(specId));
+
+            allowing(adapter).getSpecification();
+            will(returnValue(specification));
+            
+            allowing(adapter).getOid();
+            will(returnValue(rootOid));
+
+            allowing(adapter).getVersion();
+            will(returnValue(version));
+
+        }});
+    }
+
+    @Test
+    public void execute() throws Exception {
+        
+        final String versionStr = "3";
+
+        context.checking(new Expectations() {
+            {
+                one(versionCreator).versionString(version);
+                will(returnValue(versionStr));
+
+                one(commandContext).delete(specification.getSpecId(), keyStr, versionStr, rootOid);
+            }
+        });
+
+        command = new NoSqlDestroyObjectCommand(versionCreator, adapter);
+        command.execute(commandContext);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlIdentifierGeneratorTest.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlIdentifierGeneratorTest.java b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlIdentifierGeneratorTest.java
new file mode 100644
index 0000000..bad4876
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlIdentifierGeneratorTest.java
@@ -0,0 +1,142 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.runtime.system.persistence.IdentifierGenerator;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.objectstore.nosql.db.NoSqlDataDatabase;
+
+public class NoSqlIdentifierGeneratorTest {
+
+    public static class ExamplePojo {
+    }
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+
+    @Mock
+    private NoSqlDataDatabase db;
+    @Mock
+    private SpecificationLoaderSpi mockSpecificationLoader;
+    @Mock
+    private ObjectSpecification mockSpecification;
+
+    private final ObjectSpecId sequenceNumbersSpecId = ObjectSpecId.of("_id");
+    private IdentifierGenerator identifierGenerator;
+
+    @Before
+    public void setup() {
+        org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
+
+        context.checking(new Expectations() {
+            {
+                allowing(mockSpecificationLoader).loadSpecification(with(ExamplePojo.class));
+                will(returnValue(mockSpecification));
+
+                allowing(mockSpecification).getCorrespondingClass();
+                will(returnValue(ExamplePojo.class));
+
+                allowing(mockSpecification).getCorrespondingClass();
+                will(returnValue(sequenceNumbersSpecId));
+            }
+        });
+
+        identifierGenerator = new NoSqlIdentifierGenerator(db, -999, 4);
+    }
+
+    @Test
+    public void transientIdentifier() throws Exception {
+        String identifier = identifierGenerator.createTransientIdentifierFor(sequenceNumbersSpecId, new ExamplePojo());
+        assertEquals("-999", identifier);
+        
+        identifier = identifierGenerator.createTransientIdentifierFor(sequenceNumbersSpecId, new ExamplePojo());
+        assertEquals("-998", identifier);
+    }
+
+    @Test
+    public void batchCreatedAndReused() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).nextSerialNumberBatch(sequenceNumbersSpecId, 4);
+                will(returnValue(1L));
+            }
+        });
+
+        RootOid transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-998");
+        String identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("1", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-997");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("2", identifier);
+    }
+
+    @Test
+    public void secondBatchCreated() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).nextSerialNumberBatch(sequenceNumbersSpecId, 4);
+                will(returnValue(1L));
+            }
+        });
+
+        RootOid transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-998");
+        String identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("1", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-997");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("2", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-996");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("3", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-995");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("4", identifier);
+
+        context.checking(new Expectations() {
+            {
+                one(db).nextSerialNumberBatch(sequenceNumbersSpecId, 4);
+                will(returnValue(5L));
+            }
+        });
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-994");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("5", identifier);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest.java b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest.java
new file mode 100644
index 0000000..dd231c1
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest.java
@@ -0,0 +1,98 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.objectstore.nosql.keys.KeyCreatorDefault;
+
+public class NoSqlKeyCreatorTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+    @Mock
+    private OidMarshaller mockOidMarshaller;
+    @Mock
+    private SpecificationLoaderSpi mockSpecificationLoader;
+    @Mock
+    private ObjectSpecification mockSpecification;
+
+    private final RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("ERP"), "3");
+    private final String oidStr = oid.enString(new OidMarshaller());
+
+    private KeyCreatorDefault keyCreatorDefault;
+
+    
+    @Before
+    public void setUp() throws Exception {
+        keyCreatorDefault = new KeyCreatorDefault() {
+            @Override
+            protected OidMarshaller getOidMarshaller() {
+                return mockOidMarshaller;
+            }
+            @Override
+            protected SpecificationLoaderSpi getSpecificationLoader() {
+                return mockSpecificationLoader;
+            }
+        };
+    }
+
+    @Test
+    public void unmarshal() throws Exception {
+        context.checking(new Expectations() {
+
+            {
+                one(mockOidMarshaller).unmarshal(oidStr, RootOid.class);
+                will(returnValue(oid));
+            }
+        });
+        assertEquals(oid, keyCreatorDefault.unmarshal(oidStr));
+    }
+
+    @Test
+    public void specification() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(mockOidMarshaller).unmarshal(oidStr, TypedOid.class);
+                will(returnValue(oid));
+                one(mockSpecificationLoader).lookupBySpecId(oid.getObjectSpecId());
+                will(returnValue(mockSpecification));
+            }
+        });
+        final ObjectSpecification spec = keyCreatorDefault.specificationFromOidStr(oidStr);
+        assertEquals(mockSpecification, spec);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest_reference.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest_reference.java b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest_reference.java
new file mode 100644
index 0000000..83d67f8
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlKeyCreatorTest_reference.java
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.objectstore.nosql.keys.KeyCreatorDefault;
+
+public class NoSqlKeyCreatorTest_reference {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+
+    @Mock
+    private ObjectSpecification specification;
+    @Mock
+    private ObjectAdapter adapter;
+    
+    private final String className = "com.foo.bar.SomeClass";
+    private final String objectType = "SCL";
+    
+    private final RootOidDefault rootOidDefault = RootOidDefault.create(ObjectSpecId.of(objectType), ""+123);
+    
+    private KeyCreatorDefault keyCreatorDefault;
+
+    @Before
+    public void setup() {
+        keyCreatorDefault = new KeyCreatorDefault();
+        
+        context.checking(new Expectations() {
+            {
+                allowing(adapter).getSpecification();
+                will(returnValue(specification));
+
+                allowing(adapter).getOid();
+                will(returnValue(rootOidDefault));
+
+                allowing(specification).getFullIdentifier();
+                will(returnValue(className));
+            }
+        });
+    }
+
+    @Test
+    public void reference() throws Exception {
+        final String expectedReference = objectType + ":" + rootOidDefault.getIdentifier();
+        assertEquals(expectedReference, keyCreatorDefault.oidStrFor(adapter));
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/680f0c8d/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlObjectStoreTest_constructor.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlObjectStoreTest_constructor.java b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlObjectStoreTest_constructor.java
new file mode 100644
index 0000000..05f9178
--- /dev/null
+++ b/mothballed/component/objectstore/nosql/src/test/java/org/apache/isis/objectstore/nosql/NoSqlObjectStoreTest_constructor.java
@@ -0,0 +1,103 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.nosql;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.runtime.system.persistence.OidGenerator;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.objectstore.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.objectstore.nosql.encryption.DataEncryption;
+import org.apache.isis.objectstore.nosql.versions.VersionCreator;
+
+public class NoSqlObjectStoreTest_constructor {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    @Mock
+    private NoSqlDataDatabase db;
+    
+    @Mock
+    private VersionCreator versionCreator;
+
+    private Map<String, DataEncryption> dataEncrypter = Maps.newHashMap();
+
+    private NoSqlObjectStore store;
+
+    @Before
+    public void setup() {
+        org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
+    }
+
+    @Test
+    public void withFixturesNotInstalled() throws Exception {
+        final Sequence constructor = context.sequence("<init>");
+        context.checking(new Expectations() {
+            {
+                one(db).open();
+                inSequence(constructor);
+                
+                one(db).containsData();
+                will(returnValue(false));
+                inSequence(constructor);
+                
+                one(db).close();
+                inSequence(constructor);
+            }
+        });
+        store = new NoSqlObjectStore(db, new OidGenerator(new NoSqlIdentifierGenerator(db)), versionCreator, null, dataEncrypter);
+        assertFalse(store.isFixturesInstalled());
+    }
+
+    @Test
+    public void withFixturesInstalled() throws Exception {
+        final Sequence constructor = context.sequence("<init>");
+        context.checking(new Expectations() {
+            {
+                one(db).open();
+                inSequence(constructor);
+                
+                one(db).containsData();
+                will(returnValue(true));
+                inSequence(constructor);
+                
+                one(db).close();
+                inSequence(constructor);
+            }
+        });
+        store = new NoSqlObjectStore(db, new OidGenerator(new NoSqlIdentifierGenerator(db)), versionCreator, null, dataEncrypter);
+        assertTrue(store.isFixturesInstalled());
+    }
+
+}