incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmatth...@apache.org
Subject svn commit: r1097414 - in /incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql: NoSqlObjectStore.java SerialKeyCreator.java WriteObjectCommand.java
Date Thu, 28 Apr 2011 11:08:41 GMT
Author: rmatthews
Date: Thu Apr 28 11:08:41 2011
New Revision: 1097414

URL: http://svn.apache.org/viewvc?rev=1097414&view=rev
Log:
Added some exceptions to make failure more immediate.

Modified:
    incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java
    incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SerialKeyCreator.java
    incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java?rev=1097414&r1=1097413&r2=1097414&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java
Thu Apr 28 11:08:41 2011
@@ -92,6 +92,9 @@ public class NoSqlObjectStore implements
     public SaveObjectCommand createSaveObjectCommand(final ObjectAdapter adapter) {
         // TODO should this be done at a higher level so it is applicable for all OSes
         final ObjectAdapter rootAdapter = aggregateRootAdapterFor(adapter);
+        if (rootAdapter.getOid() instanceof AggregatedOid) {
+            throw new NoSqlStoreException("Unexpected aggregated object to save: " + rootAdapter
+ " (" + adapter + ")");
+        }
         return new NoSqlSaveObjectCommand(keyCreator, versionCreator, rootAdapter);
     }
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SerialKeyCreator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SerialKeyCreator.java?rev=1097414&r1=1097413&r2=1097414&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SerialKeyCreator.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SerialKeyCreator.java
Thu Apr 28 11:08:41 2011
@@ -32,12 +32,20 @@ public class SerialKeyCreator implements
         if (oid.isTransient()) {
             throw new NoSqlStoreException("Oid is not for a persistent object: " + oid);
         }
-        long serialNo = ((SerialOid) oid).getSerialNo();
-        return Long.toString(serialNo, 16);
+        if (oid instanceof SerialOid) {
+            long serialNo = ((SerialOid) oid).getSerialNo();
+            return Long.toString(serialNo, 16);
+        } else {
+            throw new NoSqlStoreException("Oid is not a SerialOid: " + oid);            
+        }
     }
 
     public String reference(ObjectAdapter object) {
-        return object.getSpecification().getFullIdentifier() + "@" + key(object.getOid());
+        try {
+            return object.getSpecification().getFullIdentifier() + "@" + key(object.getOid());
+        } catch (NoSqlStoreException e) {
+            throw new NoSqlStoreException("Failed to create refence for " + object, e);
+        }
     }
     
     public SerialOid oid(String id) {

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java?rev=1097414&r1=1097413&r2=1097414&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java
Thu Apr 28 11:08:41 2011
@@ -103,11 +103,13 @@ class WriteObjectCommand implements Pers
             KeyCreator keyCreator) {
         if (field == null) {
             writer.writeField(association.getId(), null);
-        } else {
+        } else if (field.getOid() instanceof AggregatedOid) {
             String specName = field.getSpecification().getFullIdentifier();
             StateWriter aggregateWriter = writer.addAggregate(association.getId());
             aggregateWriter.writeId(((AggregatedOid) field.getOid()).getId());
             writeFields(aggregateWriter, specName, field);
+        } else {
+            throw new NoSqlStoreException("Object type is inconsistent with it OID - it should
have an AggregatedOid: " + field);
         }
     }
 



Mime
View raw message