You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/02/19 08:52:43 UTC

[isis] branch master updated (d81dd12 -> 6cb706a)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


 discard d81dd12  provide default fallback for SessionLoggingService + minor test fixes
     new 6cb706a  ISIS-1865 provide default fallback for SessionLoggingService + minor test fixes

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d81dd12)
            \
             N -- N -- N   refs/heads/master (6cb706a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.

[isis] 01/01: ISIS-1865 provide default fallback for SessionLoggingService + minor test fixes

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 6cb706a5933b7b3cb36ad9d488c61b051d11cd63
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Feb 19 09:48:37 2018 +0100

    ISIS-1865 provide default fallback for SessionLoggingService + minor
    test fixes
---
 .../wicket/AuthenticatedWebSessionForIsis.java     | 54 ++++++++++++++++------
 ...thenticatedWebSessionForIsis_Instantiation.java |  2 +-
 ...ageClassListDefault_RegistrationAndCaching.java |  2 +-
 3 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java
index d3470db..607f8c1 100644
--- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java
+++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java
@@ -22,6 +22,8 @@ package org.apache.isis.viewer.wicket.viewer.integration.wicket;
 import java.util.Arrays;
 import java.util.List;
 
+import javax.validation.constraints.NotNull;
+
 import org.apache.wicket.Session;
 import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
 import org.apache.wicket.authroles.authorization.strategies.role.Roles;
@@ -29,6 +31,7 @@ import org.apache.wicket.request.Request;
 import org.apache.wicket.request.cycle.RequestCycle;
 
 import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.internal.context._Context;
 import org.apache.isis.applib.services.session.SessionLoggingService;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.runtime.authentication.AuthenticationManager;
@@ -169,21 +172,35 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl
             final SessionLoggingService.Type type,
             final String username,
             final SessionLoggingService.CausedBy causedBy) {
+    	
+    	
+    	final IsisSessionFactory isisSessionFactory = getIsisSessionFactoryIfAny();
         final SessionLoggingService sessionLoggingService = getSessionLoggingService();
-        if (sessionLoggingService != null) {
-            getIsisSessionFactory().doInSession(new Runnable() {
-                    @Override
-                    public void run() {
-                        // use hashcode as session identifier, to avoid re-binding http sessions if using Session#getId()
-                        int sessionHashCode = System.identityHashCode(AuthenticatedWebSessionForIsis.this);
-                        sessionLoggingService.log(type, username, Clock.getTimeAsDateTime().toDate(), causedBy, Integer.toString(sessionHashCode));
-                    }
-                });
-        }
+        	
+    	final Runnable loggingTask = ()->{
+            // use hashcode as session identifier, to avoid re-binding http sessions if using Session#getId()
+            int sessionHashCode = System.identityHashCode(AuthenticatedWebSessionForIsis.this);
+            sessionLoggingService.log(type, username, Clock.getTimeAsDateTime().toDate(), causedBy, Integer.toString(sessionHashCode));        		
+    	};
+    	
+    	if(isisSessionFactory!=null) {
+    		isisSessionFactory.doInSession(loggingTask);
+    	} else {
+    		loggingTask.run();
+    	}
+        
     }
 
-    protected SessionLoggingService getSessionLoggingService() {
-        return getIsisSessionFactory().getServicesInjector().lookupService(SessionLoggingService.class);
+    protected @NotNull SessionLoggingService getSessionLoggingService() {
+    	try {
+    		final SessionLoggingService service = getIsisSessionFactory().getServicesInjector()
+    				.lookupService(SessionLoggingService.class);
+    		return (service!=null) ? service : new SessionLoggingService.Stderr();
+    	} catch (Exception e) {
+    		// fallback to System.err
+    		return new SessionLoggingService.Stderr(); 
+		}
+    	
     }
 
     @Override
@@ -191,11 +208,20 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl
         // do nothing here because this will lead to problems with Shiro
         // see https://issues.apache.org/jira/browse/ISIS-1018
     }
+    
+    // -- HELPER
 
-
-    IsisSessionFactory getIsisSessionFactory() {
+    private IsisSessionFactory getIsisSessionFactory() {
         return IsisContext.getSessionFactory();
     }
+    
+    private IsisSessionFactory getIsisSessionFactoryIfAny() {
+    	try { 
+    		return getIsisSessionFactory();
+    	} catch (Exception e) {
+    		return null;
+		}
+    }
 
 
 }
diff --git a/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java b/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java
index 4f5c860..0c5efde 100644
--- a/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java
+++ b/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java
@@ -55,7 +55,7 @@ public class AuthenticatedWebSessionForIsis_Instantiation {
         new AuthenticatedWebSessionForIsis(stubRequest);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = Exception.class)
     public void requestMustBeProvided() {
         new AuthenticatedWebSessionForIsis(null);
     }
diff --git a/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/pages/PageClassListDefault_RegistrationAndCaching.java b/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/pages/PageClassListDefault_RegistrationAndCaching.java
index b482435..1898edd 100644
--- a/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/pages/PageClassListDefault_RegistrationAndCaching.java
+++ b/core/viewer-wicket-impl/src/test/java/org/apache/isis/viewer/wicket/viewer/pages/PageClassListDefault_RegistrationAndCaching.java
@@ -62,7 +62,7 @@ public class PageClassListDefault_RegistrationAndCaching {
         registryImpl.registerPage(PageType.ACTION_PROMPT, TestingActionPage.class);
 
         final Class<? extends Page> pageClass = registryImpl.getPageClass(PageType.ACTION_PROMPT);
-        assertThat(pageClass, is(instanceOf(TestingActionPage.class)));
+        assertThat(pageClass, is(org.hamcrest.Matchers.equalTo(TestingActionPage.class)));
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.