You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jc...@apache.org on 2014/04/02 16:55:42 UTC

git commit: ISIS-758: auditing should handle deleted objects.

Repository: isis
Updated Branches:
  refs/heads/master 612dcbc5a -> 8c45cc01b
Updated Tags:  refs/tags/upstream/upstream/isis-0.1.2-incubating [created] 40c529018
  refs/tags/upstream/upstream/isis-0.2.0-incubating [created] 6dce716dd
  refs/tags/upstream/upstream/isis-1.0.0 [created] 53dddebcb
  refs/tags/upstream/upstream/isis-1.1.0 [created] 4859004d0
  refs/tags/upstream/upstream/isis-1.2.0 [created] 2241234dc
  refs/tags/upstream/upstream/isis-1.3.0 [created] 6141fb2f0
  refs/tags/upstream/upstream/isis-1.4.0 [created] c63925627
  refs/tags/upstream/upstream/isis-objectstore-jdo-1.0.0 [created] 423f7a110
  refs/tags/upstream/upstream/isis-objectstore-jdo-1.1.0 [created] 468d6f4ea
  refs/tags/upstream/upstream/isis-objectstore-jdo-1.3.0 [created] f5ff029aa
  refs/tags/upstream/upstream/isis-objectstore-jdo-1.4.0 [created] cc63fc46e
  refs/tags/upstream/upstream/isis-objectstore-jdo-1.4.1 [created] a92eeb98f
  refs/tags/upstream/upstream/isis-security-file-1.0.0 [created] b71ec3d05
  refs/tags/upstream/upstream/isis-security-file-1.0.1 [created] a2ee46dfb
  refs/tags/upstream/upstream/isis-security-file-1.4.0 [created] 91a8180ed
  refs/tags/upstream/upstream/isis-security-shiro-1.0.0 [created] d7afb7606
  refs/tags/upstream/upstream/isis-security-shiro-1.1.0 [created] 340f5709d
  refs/tags/upstream/upstream/isis-security-shiro-1.1.1 [created] 47dd14d9e
  refs/tags/upstream/upstream/isis-security-shiro-1.3.0 [created] ed21e0bc0
  refs/tags/upstream/upstream/isis-security-shiro-1.4.0 [created] ebfe33e2e
  refs/tags/upstream/upstream/isis-viewer-restfulobjects-1.0.0 [created] e21e1f19f
  refs/tags/upstream/upstream/isis-viewer-restfulobjects-2.0.0 [created] 61e41dac2
  refs/tags/upstream/upstream/isis-viewer-restfulobjects-2.1.0 [created] f09479a9d
  refs/tags/upstream/upstream/isis-viewer-restfulobjects-2.2.0 [created] dc1925cfe
  refs/tags/upstream/upstream/isis-viewer-wicket-1.0.0 [created] f12423d73
  refs/tags/upstream/upstream/isis-viewer-wicket-1.1.0 [created] e11c74411
  refs/tags/upstream/upstream/isis-viewer-wicket-1.2.0 [created] 5142ba9c2
  refs/tags/upstream/upstream/isis-viewer-wicket-1.3.0 [created] f16b2db6c
  refs/tags/upstream/upstream/isis-viewer-wicket-1.4.0 [created] 4b0985f7f
  refs/tags/upstream/upstream/isis-viewer-wicket-1.4.1 [created] cff8b21dc
  refs/tags/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.0 [created] cdb171f80
  refs/tags/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.1 [created] 86878f4c3
  refs/tags/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.2 [created] 87c2b682c
  refs/tags/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.3 [created] d13fdbf56
  refs/tags/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.3.0 [created] 34209efc7
  refs/tags/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.4.0 [created] 9de1db090
  refs/tags/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.4.1 [created] e5095a389
  refs/tags/upstream/upstream/simple_wicket_restful_jdo-archetype-1.3.0 [created] d33a79a75
  refs/tags/upstream/upstream/simple_wicket_restful_jdo-archetype-1.4.0 [created] 5b167f098
  refs/tags/upstream/upstream/simple_wicket_restful_jdo-archetype-1.4.1 [created] cff221ec1


ISIS-758: auditing should handle deleted objects.

Also:
- better exception handling within ObjectContracts for getValueOf(...).


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/8c45cc01
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/8c45cc01
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/8c45cc01

Branch: refs/heads/master
Commit: 8c45cc01b16cc95474894dc1a1033871a7e56500
Parents: 612dcbc
Author: Jeroen van der Wal <je...@stromboli.it>
Authored: Wed Apr 2 15:08:06 2014 +0200
Committer: Jeroen van der Wal <je...@stromboli.it>
Committed: Wed Apr 2 15:08:06 2014 +0200

----------------------------------------------------------------------
 .../isis/applib/util/ObjectContracts.java       | 11 +++++--
 .../system/transaction/IsisTransaction.java     | 34 +++++++++++++++++---
 2 files changed, 39 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/8c45cc01/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java b/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
index 5e73502..3e88c72 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/util/ObjectContracts.java
@@ -16,6 +16,7 @@
  */
 package org.apache.isis.applib.util;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Comparator;
 import java.util.List;
@@ -201,14 +202,20 @@ class Clause {
         try {
             final Method getterMethod = obj.getClass().getMethod(getMethodName);
             return getterMethod.invoke(obj);
-        } catch (Exception e) {
+        } catch (NoSuchMethodException e) {
             final String isMethodName = "is" + methodNameSuffix;
             try {
                 final Method getterMethod = obj.getClass().getMethod(isMethodName);
                 return getterMethod.invoke(obj);
-            } catch (Exception ex) {
+            } catch (NoSuchMethodException ex) {
                 throw new IllegalArgumentException("No such method ' " + getMethodName + "' or '" + isMethodName + "'", e);
+            } catch (Exception e1) {
+                // some other reason; for example, a JDOUserException if the object has been deleted and interaction with its properties is not permitted.
+                throw new RuntimeException(e1);
             }
+        } catch (Exception e) {
+            // some other reason; for example, a JDOUserException if the object has been deleted and interaction with its properties is not permitted.
+            throw new RuntimeException(e);
         }
     }
     private static String upperFirst(final String str) {

http://git-wip-us.apache.org/repos/asf/isis/blob/8c45cc01/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index cf492ff..6d2a5bd 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -603,8 +603,8 @@ public class IsisTransaction implements TransactionScopedComponent {
         final String objectType = oid.getObjectSpecId().asString();
         final String identifier = oid.getIdentifier();
         final PreAndPostValues papv = auditEntry.getValue();
-        final String preValue = asString(papv.getPre());
-        final String postValue = asString(papv.getPost());
+        final String preValue = papv.getPreString();
+        final String postValue = papv.getPostString();
         
         final ObjectAssociation property = aap.getProperty();
         final String memberId = property.getIdentifier().toClassAndNameIdentityString();
@@ -903,7 +903,20 @@ public class IsisTransaction implements TransactionScopedComponent {
             }};
             
         private final Object pre;
+        /**
+         * Eagerly calculated because it could be that the object referenced ends up being deleted by the time that the xactn completes.
+         */
+        private final String preString;
+
+        /**
+         * Updated in {@link #setPost(Object)} 
+         */
         private Object post;
+        /**
+         * Updated in {@link #setPost(Object)}, along with {@link #post}.
+         */
+        private String postString;
+
         
         public static PreAndPostValues pre(Object preValue) {
             return new PreAndPostValues(preValue, null);
@@ -912,17 +925,30 @@ public class IsisTransaction implements TransactionScopedComponent {
         private PreAndPostValues(Object pre, Object post) {
             this.pre = pre;
             this.post = post;
+            this.preString = asString(pre);
         }
+        /**
+         * The object that was referenced before this object was changed
+         * 
+         * <p>
+         * Note that this referenced object itself could end up being deleted in the course of the transaction; in which case use 
+         * {@link #getPreString()} which is the eagerly cached <tt>toString</tt> of said object. 
+         */
         public Object getPre() {
             return pre;
         }
-        
+        public String getPreString() {
+            return preString;
+        }
         public Object getPost() {
             return post;
         }
-        
+        public String getPostString() {
+            return postString;
+        }
         public void setPost(Object post) {
             this.post = post;
+            this.postString = asString(post);
         }
         
         @Override