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 2021/06/29 05:42:48 UTC

[isis] branch ISIS-2779 updated (9391bac -> 37dde17)

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

danhaywood pushed a change to branch ISIS-2779
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from 9391bac  ISIS-2483: removes incorrect use of @Nullable
     new c0ce962  ISIS-2773: registers UI subscribers
     new 37dde17  ISIS-2773: uses annotations for layout

The 2 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:
 .../org/apache/isis/applib/IsisModuleApplib.java   |  2 +
 .../isis/applib/services/user/RoleMemento.java     | 17 ++--
 .../services/user/RoleMemento.layout.fallback.xml  |  8 +-
 .../isis/applib/services/user/UserMemento.java     | 93 +++++++++++-----------
 .../services/user/UserMemento.layout.fallback.xml  | 14 +---
 5 files changed, 63 insertions(+), 71 deletions(-)

[isis] 02/02: ISIS-2773: uses annotations for layout

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

danhaywood pushed a commit to branch ISIS-2779
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 37dde17e019fe0314002d1ce20eb1dcb49df1023
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 06:42:20 2021 +0100

    ISIS-2773: uses annotations for layout
    
    also polishes non-null checks
---
 .../isis/applib/services/user/RoleMemento.java     | 17 ++--
 .../services/user/RoleMemento.layout.fallback.xml  |  8 +-
 .../isis/applib/services/user/UserMemento.java     | 93 +++++++++++-----------
 .../services/user/UserMemento.layout.fallback.xml  | 14 +---
 4 files changed, 61 insertions(+), 71 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.java b/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.java
index e2e28b6..fab13a0 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.java
@@ -19,6 +19,7 @@
 package org.apache.isis.applib.services.user;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 import org.springframework.context.event.EventListener;
 import org.springframework.core.annotation.Order;
@@ -31,6 +32,7 @@ import org.apache.isis.applib.annotation.PriorityPrecedence;
 import org.apache.isis.applib.annotation.PropertyLayout;
 
 import lombok.Getter;
+import lombok.NonNull;
 import lombok.Value;
 import lombok.val;
 
@@ -65,14 +67,10 @@ public class RoleMemento implements Serializable {
     /**
      * Creates a new role with the specified name and description.
      */
-    public RoleMemento(final String name, final String description) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name not specified");
-        }
+    public RoleMemento(
+            @NonNull final String name,
+            @NonNull final String description) {
         this.name = name;
-        if (description == null) {
-            throw new IllegalArgumentException("Description not specified");
-        }
         this.description = description;
     }
 
@@ -81,15 +79,16 @@ public class RoleMemento implements Serializable {
         @EventListener(RoleMemento.TitleUiEvent.class)
         public void on(RoleMemento.TitleUiEvent ev) {
             val roleMemento = ev.getSource();
+            assert roleMemento != null;
             ev.setTitle(roleMemento.getName());
         }
     }
 
-    @PropertyLayout(sequence = "1.1")
+    @PropertyLayout(fieldSetId = "identity", sequence = "1")
     @Getter
     String name;
 
-    @PropertyLayout(sequence = "1.2")
+    @PropertyLayout(fieldSetId = "details", sequence = "1")
     @Getter
     String description;
 
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.layout.fallback.xml b/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.layout.fallback.xml
index c683599..aa52fb9 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.layout.fallback.xml
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.layout.fallback.xml
@@ -29,12 +29,8 @@ under the License.
     </bs3:row>
     <bs3:row>
         <bs3:col span="6">
-            <cpt:fieldSet name="Identity" id="identity">
-                <cpt:property id="name"/>
-            </cpt:fieldSet>
-            <cpt:fieldSet name="Details" id="details">
-                <cpt:property id="description"/>
-            </cpt:fieldSet>
+            <cpt:fieldSet name="Identity" id="identity"/>
+            <cpt:fieldSet name="Details" id="details"/>
             <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
         </bs3:col>
         <bs3:col span="6">
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
index 5cae480..38825f7 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
@@ -149,7 +149,8 @@ public class UserMemento implements Serializable {
         @EventListener(UserMemento.TitleUiEvent.class)
         public void on(UserMemento.TitleUiEvent ev) {
             val userMemento = ev.getSource();
-            val title = String.format("%s %s", userMemento.getName(), userMemento.isImpersonating() ? " (impersonating)" : null);
+            assert userMemento != null;
+            val title = String.format("%s %s", userMemento.getName(), userMemento.isImpersonating() ? " (impersonating)" : "");
             ev.setTitle(title);
         }
     }
@@ -160,33 +161,74 @@ public class UserMemento implements Serializable {
      * The user's login name.
      */
     @Property
-    @PropertyLayout(sequence = "1.1")
+    @PropertyLayout(fieldSetId = "identity", sequence = "1")
     @Getter
     @NonNull
     String name;
 
     @Property(optionality = Optionality.OPTIONAL)
-    @PropertyLayout(sequence = "1.2")
+    @PropertyLayout(fieldSetId = "details", sequence = "1")
     @Getter @With(onMethod_ = {@Programmatic})
     @Nullable
     String realName;
 
     @Property(optionality = Optionality.OPTIONAL)
-    @PropertyLayout(sequence = "1.3")
+    @PropertyLayout(fieldSetId = "details", sequence = "2")
     @Getter @With(onMethod_ = {@Programmatic})
     @Nullable
     URL avatarUrl;
 
+    /**
+     * To support external security mechanisms such as keycloak,
+     * where the validity of the session is defined by headers in the request.
+     */
+    @Property
+    @PropertyLayout(fieldSetId = "authentication", sequence = "1")
+    @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
+    @NonNull
+    AuthenticationSource authenticationSource = AuthenticationSource.DEFAULT;
+
+
+    public enum AuthenticationSource {
+        DEFAULT,
+        /**
+         * Instructs the <code>AuthenticationManager</code>
+         * to <i>not</i> cache this session in its internal map of sessions by validation code,
+         * and therefore to ignore this aspect when considering if an {@link InteractionContext} is valid or not.
+         */
+        EXTERNAL;
+
+        public boolean isExternal() {
+            return this == EXTERNAL;
+        }
+    }
+
+
     @Property(optionality = Optionality.OPTIONAL)
-    @PropertyLayout(sequence = "1.4")
+    @PropertyLayout(fieldSetId = "authentication", sequence = "2")
     @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
     boolean impersonating = false;
 
+
+    private static final String DEFAULT_AUTH_VALID_CODE = "";
+
+    /**
+     * A unique code given to this user during authentication.
+     * <p>
+     * This can be used to confirm that the user has been authenticated.
+     * It should return an empty string {@literal ""}
+     * if this is an anonymous (unauthenticated) user.
+     */
+    @Property(hidden = Where.EVERYWHERE)
+    @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
+    @NonNull
+    String authenticationCode = DEFAULT_AUTH_VALID_CODE;
+
     /**
      * The roles associated with this user.
      */
     @Collection
-    @CollectionLayout(sequence = "1.4")
+    @CollectionLayout(sequence = "1")
     public List<RoleMemento> getRoles() {
         return roles.toList();
     }
@@ -225,46 +267,7 @@ public class UserMemento implements Serializable {
         return streamRoleNames().anyMatch(myRoleName->myRoleName.equals(roleName));
     }
 
-    // -- AUTHENTICATION
-
-    /**
-     * To support external security mechanisms such as keycloak,
-     * where the validity of the session is defined by headers in the request.
-     */
-    @Property
-    @PropertyLayout(sequence = "2.0")
-    @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
-    @NonNull AuthenticationSource authenticationSource = AuthenticationSource.DEFAULT;
-
-
-    public enum AuthenticationSource {
-        DEFAULT,
-        /**
-         * Instructs the {@link org.apache.isis.core.security.authentication.manager.AuthenticationManager}
-         * to not cache this session in its internal map of sessions by validation code,
-         * and therefore to ignore this aspect when considering if an {@link InteractionContext} is
-         * {@link org.apache.isis.core.security.authentication.manager.AuthenticationManager#isSessionValid(InteractionContext) valid}
-         * or not.
-         */
-        EXTERNAL;
-
-        public boolean isExternal() {
-            return this == EXTERNAL;
-        }
-    }
-
-    private static final String DEFAULT_AUTH_VALID_CODE = "";
 
-    /**
-     * A unique code given to this user during authentication.
-     * <p>
-     * This can be used to confirm that the user has been authenticated.
-     * It should return an empty string {@literal ""}
-     * if this is an anonymous (unauthenticated) user.
-     */
-    @Property(hidden = Where.EVERYWHERE)
-    @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
-    @NonNull String authenticationCode = DEFAULT_AUTH_VALID_CODE;
 
 
     // -- UTILITY
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml
index 507e0b7..1b2d386 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml
@@ -33,9 +33,7 @@ under the License.
                 <bs3:tab name="Identity">
                     <bs3:row>
                         <bs3:col span="12">
-                            <cpt:fieldSet name="Identity" id="identity">
-                                <cpt:property id="name"/>
-                            </cpt:fieldSet>
+                            <cpt:fieldSet name="Identity" id="identity"/>
                         </bs3:col>
                     </bs3:row>
                 </bs3:tab>
@@ -54,14 +52,8 @@ under the License.
                     </bs3:row>
                 </bs3:tab>
             </bs3:tabGroup>
-            <cpt:fieldSet name="Details" id="details">
-                <cpt:property id="realName"/>
-                <cpt:property id="avatarUrl"/>
-            </cpt:fieldSet>
-            <cpt:fieldSet name="Authentication" id="authentication">
-                <cpt:property id="authenticationSource"/>
-                <cpt:property id="impersonating"/>
-            </cpt:fieldSet>
+            <cpt:fieldSet name="Details" id="details"/>
+            <cpt:fieldSet name="Authentication" id="authentication"/>
         </bs3:col>
         <bs3:col span="6">
             <cpt:collection id="roles"/>

[isis] 01/02: ISIS-2773: registers UI subscribers

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

danhaywood pushed a commit to branch ISIS-2779
in repository https://gitbox.apache.org/repos/asf/isis.git

commit c0ce962d5e33f6974dc2e1f567b10e5fb957f82c
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 06:26:18 2021 +0100

    ISIS-2773: registers UI subscribers
---
 api/applib/src/main/java/org/apache/isis/applib/IsisModuleApplib.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/IsisModuleApplib.java b/api/applib/src/main/java/org/apache/isis/applib/IsisModuleApplib.java
index 1b36fea..ca69a72 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/IsisModuleApplib.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/IsisModuleApplib.java
@@ -120,6 +120,8 @@ import org.apache.isis.schema.IsisModuleSchema;
         SessionLoggingServiceLogging.class,
         SudoService.class,
         UserService.class,
+        UserMemento.UiSubscriber.class,
+        RoleMemento.UiSubscriber.class,
 
 })
 public class IsisModuleApplib {