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:56:05 UTC

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

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.


 discard 37dde17  ISIS-2773: uses annotations for layout
 discard c0ce962  ISIS-2773: registers UI subscribers
 discard 9391bac  ISIS-2483: removes incorrect use of @Nullable
 discard f1ea610  ISIS-2733: adds some icons
 discard 144802e  ISIS-2733: surfaces UserMemento via new "me" action.
 discard 054d765  ISIS-2779: adds bookmarkers and loaders for serializable view models.
 discard 665e130  ISIS-2760: ensure that there is, though, some spacing after tabGroups.
 discard 27a4aec  ISIS-2483: adds a guard for bootstrap grid menu loading
 discard c112ec2  ISIS-2619: partially revert, show the logicalTypeName for view models.
     add 3ee8471  Bump camel.version from 3.10.0 to 3.11.0
     add c950b08  Merge pull request #644 from apache/dependabot/maven/master/camel.version-3.11.0
     add c7f16a3  ISIS-1720: minor: optimizations for TranslationPostProcessor
     new 95746c2  ISIS-2619: partially revert, show the logicalTypeName for view models.
     new 4970200  ISIS-2483: adds a guard for bootstrap grid menu loading
     new 4644993  ISIS-2760: ensure that there is, though, some spacing after tabGroups.
     new 6a39aae  ISIS-2779: adds bookmarkers and loaders for serializable view models.
     new 9094e29  ISIS-2733: surfaces UserMemento via new "me" action.
     new ced84fb  ISIS-2733: adds some icons
     new c38eca5  ISIS-2483: removes incorrect use of @Nullable
     new aabbc84  ISIS-2773: registers UI subscribers
     new 8130767  ISIS-2773: uses annotations for layout
     new ea26ae5  ISIS-2773: suppress default UserMenu me action if secman is configured

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   (37dde17)
            \
             N -- N -- N   refs/heads/ISIS-2779 (ea26ae5)

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 10 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:
 .../apache/isis/core/config/IsisConfiguration.java | 19 ++++++++
 .../all/i18n/TranslationPostProcessor.java         | 55 +++++++++++++---------
 core/pom.xml                                       |  2 +-
 .../secman/applib/IsisModuleExtSecmanApplib.java   |  1 +
 .../secman/applib/user/menu/MeService.java         | 25 +++++++++-
 5 files changed, 77 insertions(+), 25 deletions(-)

[isis] 05/10: ISIS-2733: surfaces UserMemento via new "me" action.

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 9094e296829903bb9d6f4d16eee6d1479909592a
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jun 28 19:39:33 2021 +0100

    ISIS-2733: surfaces UserMemento via new "me" action.
    
    (cherry picked from commit 4fc27cfb8657ab3656429c67942695a503af35c8)
---
 .../org/apache/isis/applib/IsisModuleApplib.java   |  4 +-
 .../isis/applib/services/user/RoleMemento.java     | 32 +++++++--
 .../services/user/RoleMemento.layout.fallback.xml  | 48 +++++++++++++
 .../isis/applib/services/user/UserMemento.java     | 46 +++++++++++--
 .../services/user/UserMemento.layout.fallback.xml  | 75 ++++++++++++++++++++
 .../isis/applib/services/user/package-info.java    | 37 ----------
 .../applib/services/userprof/package-info.java     | 28 --------
 .../isis/applib/services/userui/UserMenu.java      | 79 ++++++++++++++++++++++
 8 files changed, 271 insertions(+), 78 deletions(-)

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 9f0fd67..1b36fea 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
@@ -59,6 +59,7 @@ import org.apache.isis.applib.services.user.ImpersonateStopMenu;
 import org.apache.isis.applib.services.user.RoleMemento;
 import org.apache.isis.applib.services.user.UserMemento;
 import org.apache.isis.applib.services.user.UserService;
+import org.apache.isis.applib.services.userui.UserMenu;
 import org.apache.isis.schema.IsisModuleSchema;
 
 /**
@@ -104,8 +105,8 @@ import org.apache.isis.schema.IsisModuleSchema;
         ImpersonateStopMenu.class,
         MetaModelServiceMenu.class,
         QueryResultsCache.class,
-        UserService.class,
         ApplicationFeatureMenu.class,
+        UserMenu.class,
 
 
         // @Service(s)
@@ -118,6 +119,7 @@ import org.apache.isis.schema.IsisModuleSchema;
         ExecutionLogger.class,
         SessionLoggingServiceLogging.class,
         SudoService.class,
+        UserService.class,
 
 })
 public class IsisModuleApplib {
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 7cec066..e2e28b6 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
@@ -18,24 +18,39 @@
  */
 package org.apache.isis.applib.services.user;
 
-import lombok.Getter;
-import lombok.Value;
+import java.io.Serializable;
+
+import org.springframework.context.event.EventListener;
+import org.springframework.core.annotation.Order;
+
 import org.apache.isis.applib.IsisModuleApplib;
 import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.DomainObjectLayout;
 import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.annotation.PriorityPrecedence;
 import org.apache.isis.applib.annotation.PropertyLayout;
 
-import java.io.Serializable;
+import lombok.Getter;
+import lombok.Value;
+import lombok.val;
 
 /**
  * Immutable serializable value held by {@link UserMemento}.
  *
  * @since 1.x revised for 2.0 {@index}
  */
-@DomainObject(nature = Nature.VIEW_MODEL, logicalTypeName = RoleMemento.LOGICAL_TYPE_NAME)
+@DomainObject(
+        nature = Nature.VIEW_MODEL,
+        logicalTypeName = RoleMemento.LOGICAL_TYPE_NAME
+)
+@DomainObjectLayout(
+        titleUiEvent = RoleMemento.TitleUiEvent.class
+)
 @Value
 public class RoleMemento implements Serializable {
 
+    public static class TitleUiEvent extends IsisModuleApplib.TitleUiEvent<RoleMemento> {}
+
     public static final String LOGICAL_TYPE_NAME = IsisModuleApplib.NAMESPACE + ".RoleMemento";
 
     private static final long serialVersionUID = -3876856609238378274L;
@@ -61,8 +76,13 @@ public class RoleMemento implements Serializable {
         this.description = description;
     }
 
-    public String title() {
-        return name;
+    public static class UiSubscriber {
+        @Order(PriorityPrecedence.LATE)
+        @EventListener(RoleMemento.TitleUiEvent.class)
+        public void on(RoleMemento.TitleUiEvent ev) {
+            val roleMemento = ev.getSource();
+            ev.setTitle(roleMemento.getName());
+        }
     }
 
     @PropertyLayout(sequence = "1.1")
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
new file mode 100644
index 0000000..c683599
--- /dev/null
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.layout.fallback.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+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.
+-->
+<bs3:grid
+        xsi:schemaLocation="http://isis.apache.org/applib/layout/component http://isis.apache.org/applib/layout/component/component.xsd   http://isis.apache.org/applib/layout/grid/bootstrap3 http://isis.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
+        xmlns:bs3="http://isis.apache.org/applib/layout/grid/bootstrap3"
+        xmlns:cpt="http://isis.apache.org/applib/layout/component"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <bs3:row>
+        <bs3:col span="12" unreferencedActions="true">
+            <cpt:domainObject/>
+        </bs3:col>
+    </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="Other" id="other" unreferencedProperties="true"/>
+        </bs3:col>
+        <bs3:col span="6">
+        </bs3:col>
+    </bs3:row>
+    <bs3:row>
+        <bs3:col span="12">
+            <bs3:tabGroup unreferencedCollections="true"/>
+        </bs3:col>
+    </bs3:row>
+</bs3:grid>
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 cee114f..5cae480 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
@@ -18,6 +18,8 @@
  */
 package org.apache.isis.applib.services.user;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.io.Serializable;
 import java.net.URL;
 import java.util.List;
@@ -25,8 +27,21 @@ import java.util.stream.Stream;
 
 import javax.annotation.Nullable;
 
+import org.springframework.context.event.EventListener;
+import org.springframework.core.annotation.Order;
+
 import org.apache.isis.applib.IsisModuleApplib;
-import org.apache.isis.applib.annotation.*;
+import org.apache.isis.applib.annotation.Collection;
+import org.apache.isis.applib.annotation.CollectionLayout;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.DomainObjectLayout;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.annotation.Optionality;
+import org.apache.isis.applib.annotation.PriorityPrecedence;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.applib.annotation.PropertyLayout;
+import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.applib.services.iactnlayer.InteractionContext;
 import org.apache.isis.commons.collections.Can;
 import org.apache.isis.commons.internal.base._Strings;
@@ -35,16 +50,29 @@ import lombok.Builder;
 import lombok.Getter;
 import lombok.NonNull;
 import lombok.With;
+import lombok.val;
 
 /**
  * Immutable serializable value holding details about a user and its roles.
  *
  * @since 1.x revised for 2.0 {@index}
  */
-@DomainObject(nature = Nature.VIEW_MODEL, logicalTypeName = UserMemento.LOGICAL_TYPE_NAME)
+@DomainObject(
+        nature = Nature.VIEW_MODEL,
+        logicalTypeName = UserMemento.LOGICAL_TYPE_NAME
+)
+@DomainObjectLayout(
+        titleUiEvent = UserMemento.TitleUiEvent.class
+)
 @lombok.Value @lombok.Builder
 public class UserMemento implements Serializable {
 
+    public static class TitleUiEvent extends IsisModuleApplib.TitleUiEvent<UserMemento> {}
+
+    private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
+        ois.defaultReadObject();
+    }
+
     public static final String LOGICAL_TYPE_NAME = IsisModuleApplib.NAMESPACE + ".UserMemento";
 
     private static final long serialVersionUID = 7190090455587885367L;
@@ -116,8 +144,14 @@ public class UserMemento implements Serializable {
 
     // -- UI TITLE
 
-    public String title() {
-        return name;
+    public static class UiSubscriber {
+        @Order(PriorityPrecedence.LATE)
+        @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);
+            ev.setTitle(title);
+        }
     }
 
     // -- PROPERTIES
@@ -202,6 +236,7 @@ public class UserMemento implements Serializable {
     @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
     @NonNull AuthenticationSource authenticationSource = AuthenticationSource.DEFAULT;
 
+
     public enum AuthenticationSource {
         DEFAULT,
         /**
@@ -227,8 +262,7 @@ public class UserMemento implements Serializable {
      * It should return an empty string {@literal ""}
      * if this is an anonymous (unauthenticated) user.
      */
-    @Property
-    @PropertyLayout(sequence = "2.1")
+    @Property(hidden = Where.EVERYWHERE)
     @Getter @Builder.Default @With(onMethod_ = {@Programmatic})
     @NonNull String authenticationCode = DEFAULT_AUTH_VALID_CODE;
 
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
new file mode 100644
index 0000000..507e0b7
--- /dev/null
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.layout.fallback.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+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.
+-->
+<bs3:grid
+        xsi:schemaLocation="http://isis.apache.org/applib/layout/component http://isis.apache.org/applib/layout/component/component.xsd   http://isis.apache.org/applib/layout/grid/bootstrap3 http://isis.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
+        xmlns:bs3="http://isis.apache.org/applib/layout/grid/bootstrap3"
+        xmlns:cpt="http://isis.apache.org/applib/layout/component"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <bs3:row>
+        <bs3:col span="12" unreferencedActions="true">
+            <cpt:domainObject/>
+        </bs3:col>
+    </bs3:row>
+    <bs3:row>
+        <bs3:col span="6">
+            <bs3:tabGroup>
+                <bs3:tab name="Identity">
+                    <bs3:row>
+                        <bs3:col span="12">
+                            <cpt:fieldSet name="Identity" id="identity">
+                                <cpt:property id="name"/>
+                            </cpt:fieldSet>
+                        </bs3:col>
+                    </bs3:row>
+                </bs3:tab>
+                <bs3:tab name="Other">
+                    <bs3:row>
+                        <bs3:col span="12">
+                            <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+                        </bs3:col>
+                    </bs3:row>
+                </bs3:tab>
+                <bs3:tab name="Metadata">
+                    <bs3:row>
+                        <bs3:col span="12">
+                            <cpt:fieldSet name="Metadata" id="metadata"/>
+                        </bs3:col>
+                    </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>
+        </bs3:col>
+        <bs3:col span="6">
+            <cpt:collection id="roles"/>
+        </bs3:col>
+    </bs3:row>
+    <bs3:row>
+        <bs3:col span="12">
+            <bs3:tabGroup unreferencedCollections="true"/>
+        </bs3:col>
+    </bs3:row>
+</bs3:grid>
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/package-info.java b/api/applib/src/main/java/org/apache/isis/applib/services/user/package-info.java
deleted file mode 100644
index 3fd69e1..0000000
--- a/api/applib/src/main/java/org/apache/isis/applib/services/user/package-info.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *  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.
- */
-
-/**
- * This package defines types that represent the
- * currently logged-in {@link org.apache.isis.applib.services.user.UserMemento user}
- * and their {@link org.apache.isis.applib.services.user.RoleMemento role}s, as well as
- * {@link org.apache.isis.applib.services.user.UserService} to obtain the current user.
- *
- * <p>
- * Typically domain objects do not need to have any knowledge of <i>who</i>
- * is using them, because authorization is provided declaratively by the
- * framework and is type-based.  However, there are occasions; for example,
- * only an <tt>Employee</tt> and his superiors might be allowed to view their salary.
- *
- * <p>
- * The types are suffixed &quot;Memento&quot; because they snapshot the user
- * and roles at the time that the user logs in, but are not updated after that
- * point.
- */
-package org.apache.isis.applib.services.user;
\ No newline at end of file
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/userprof/package-info.java b/api/applib/src/main/java/org/apache/isis/applib/services/userprof/package-info.java
deleted file mode 100644
index ac15bb5..0000000
--- a/api/applib/src/main/java/org/apache/isis/applib/services/userprof/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  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.
- */
-
-/**
- * The {@link org.apache.isis.applib.services.userprof.UserProfileService} provides the ability for the domain
- * application to return supplementary metadata about the current user. This information is used (by the Wicket viewer)
- * to customize the appearance of the tertiary "Me" menu bar (top right). For example, rather than display the
- * username, instead the user’s first and last name could be displayed.
- *
- *
- */
-package org.apache.isis.applib.services.userprof;
\ No newline at end of file
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/userui/UserMenu.java b/api/applib/src/main/java/org/apache/isis/applib/services/userui/UserMenu.java
new file mode 100644
index 0000000..09d4cfe
--- /dev/null
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/userui/UserMenu.java
@@ -0,0 +1,79 @@
+/*
+ *  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.applib.services.userui;
+
+import javax.inject.Inject;
+
+import org.apache.isis.applib.IsisModuleApplib;
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.DomainServiceLayout;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.PriorityPrecedence;
+import org.apache.isis.applib.annotation.SemanticsOf;
+import org.apache.isis.applib.services.user.UserMemento;
+import org.apache.isis.applib.services.user.UserService;
+
+import lombok.RequiredArgsConstructor;
+
+/**
+ * @since 2.0 {@index}
+ */
+@DomainService(
+        nature = NatureOfService.VIEW,
+        logicalTypeName = UserMenu.LOGICAL_TYPE_NAME
+)
+@DomainServiceLayout(
+        menuBar = DomainServiceLayout.MenuBar.TERTIARY
+)
+@javax.annotation.Priority(PriorityPrecedence.EARLY)
+@RequiredArgsConstructor(onConstructor_ = { @Inject })
+public class UserMenu {
+
+    public static final String LOGICAL_TYPE_NAME = IsisModuleApplib.NAMESPACE + ".UserMenu";
+
+    public static abstract class ActionDomainEvent extends IsisModuleApplib.ActionDomainEvent<UserMenu> {}
+
+    final UserService userService;
+
+
+    public static class MeDomainEvent extends ActionDomainEvent {}
+
+    @Action(
+            domainEvent = MeDomainEvent.class,
+            semantics = SemanticsOf.SAFE
+            )
+    @ActionLayout(
+            cssClassFa = "fa-user",
+            describedAs = "Returns your user account details",
+            sequence = "100"
+        )
+    public UserMemento me() {
+        return userService.currentUser().orElse(null);
+    }
+
+    public String disableMe() {
+        return userService.currentUser().isPresent() ? null : "Current user not available";
+    }
+
+
+
+
+}

[isis] 08/10: 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 aabbc84f0e62fdfe2bf4f17c0ce2369387009595
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 {

[isis] 01/10: ISIS-2619: partially revert, show the logicalTypeName for view models.

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 95746c2f886ac54659b9681acc4b6573803d03d4
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jun 28 19:42:31 2021 +0100

    ISIS-2619: partially revert, show the logicalTypeName for view models.
    
    Otherwise metadata tabgroup collapses to nothing and we can't see any of the contributed actions on the metadata panel.
    
    (cherry picked from commit 093e81d72fcfea911faaff84f5e9e248706cdfa8)
---
 .../apache/isis/applib/mixins/metamodel/Object_logicalTypeName.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_logicalTypeName.java b/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_logicalTypeName.java
index c687726..e75db1d 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_logicalTypeName.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_logicalTypeName.java
@@ -28,6 +28,7 @@ import org.apache.isis.applib.annotation.PropertyLayout;
 import org.apache.isis.applib.annotation.Where;
 import org.apache.isis.applib.mixins.layout.LayoutMixinConstants;
 import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.metamodel.BeanSort;
 import org.apache.isis.applib.services.metamodel.MetaModelService;
 
 import lombok.RequiredArgsConstructor;
@@ -78,7 +79,8 @@ public class Object_logicalTypeName {
 
     @MemberSupport public boolean hideProp() {
         val bookmark = bookmarkService.bookmarkForElseFail(this.holder);
-        return !metaModelService.sortOf(bookmark, MetaModelService.Mode.RELAXED).isEntity();
+        val beanSort = metaModelService.sortOf(bookmark, MetaModelService.Mode.RELAXED);
+        return !beanSort.isEntity() && !beanSort.isViewModel();
     }
 
 }

[isis] 09/10: 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 8130767e6fbb797ed90a49712d6b6d56ebeba22d
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] 02/10: ISIS-2483: adds a guard for bootstrap grid menu loading

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 4970200682dff6b20736ea247b70ca716b0c62f4
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jun 28 19:43:11 2021 +0100

    ISIS-2483: adds a guard for bootstrap grid menu loading
    
    (cherry picked from commit 0249d32bfbeab4c568943b3928b014ea275fb795)
---
 .../services/grid/bootstrap3/GridSystemServiceBootstrap.java      | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/grid/bootstrap3/GridSystemServiceBootstrap.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/grid/bootstrap3/GridSystemServiceBootstrap.java
index 0640888..a276139 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/grid/bootstrap3/GridSystemServiceBootstrap.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/grid/bootstrap3/GridSystemServiceBootstrap.java
@@ -354,8 +354,12 @@ public class GridSystemServiceBootstrap extends GridSystemServiceAbstract<BS3Gri
 
                 if(layoutGroupFacet.isExplicitBinding()) {
                     final PropertyLayoutData propertyLayoutData = propertyLayoutDataById.get(layoutGroupName);
-                    final ActionLayoutData actionLayoutData = new ActionLayoutData(actionId);
-                    final ActionPositionFacet actionPositionFacet = objectAction.getFacet(ActionPositionFacet.class);
+                    if(propertyLayoutData == null) {
+                        log.warn(String.format("Could not find propertyLayoutData for layoutGroupName of '%s'", layoutGroupName));
+                        continue;
+                    }
+                    val actionLayoutData = new ActionLayoutData(actionId);
+                    val actionPositionFacet = objectAction.getFacet(ActionPositionFacet.class);
                     final ActionLayoutDataOwner owner;
                     final ActionLayout.Position position;
                     if(actionPositionFacet != null) {

[isis] 07/10: ISIS-2483: removes incorrect use of @Nullable

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 c38eca55a339cb49c3d119f24bc0be417f9412f4
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 06:21:07 2021 +0100

    ISIS-2483: removes incorrect use of @Nullable
---
 .../java/org/apache/isis/applib/services/inject/ServiceInjector.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/inject/ServiceInjector.java b/api/applib/src/main/java/org/apache/isis/applib/services/inject/ServiceInjector.java
index 6f9a305..c1fb2e6 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/inject/ServiceInjector.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/inject/ServiceInjector.java
@@ -37,7 +37,7 @@ public interface ServiceInjector {
      * @param <T>
      * @return domainObject with injection points resolved
      */
-    <T> @Nullable T injectServicesInto(final @Nullable T domainObject);
+    <T> T injectServicesInto(final @Nullable T domainObject);
 
 
 }

[isis] 06/10: ISIS-2733: adds some icons

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 ced84fbc69e6a0a692f45cb3e0080e38c6245873
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 06:20:50 2021 +0100

    ISIS-2733: adds some icons
---
 .../services/appfeatui/ApplicationFeatureViewModel.png   | Bin 0 -> 1170 bytes
 .../org/apache/isis/applib/services/user/RoleMemento.png | Bin 0 -> 1287 bytes
 .../org/apache/isis/applib/services/user/UserMemento.png | Bin 0 -> 864 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/appfeatui/ApplicationFeatureViewModel.png b/api/applib/src/main/java/org/apache/isis/applib/services/appfeatui/ApplicationFeatureViewModel.png
new file mode 100644
index 0000000..ef48796
Binary files /dev/null and b/api/applib/src/main/java/org/apache/isis/applib/services/appfeatui/ApplicationFeatureViewModel.png differ
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.png b/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.png
new file mode 100644
index 0000000..9cd459a
Binary files /dev/null and b/api/applib/src/main/java/org/apache/isis/applib/services/user/RoleMemento.png differ
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.png b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.png
new file mode 100644
index 0000000..6d8a33b
Binary files /dev/null and b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.png differ

[isis] 04/10: ISIS-2779: adds bookmarkers and loaders for serializable view models.

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 6a39aae328fbcb34b1b64d773bf1d9ae6ef84c61
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jun 28 19:36:40 2021 +0100

    ISIS-2779: adds bookmarkers and loaders for serializable view models.
    
    (cherry picked from commit 4235fcf6dcb1f2a5edc1ff46d57176b41afd8cd2)
---
 .../objectmanager/identify/ObjectBookmarker.java   |  1 +
 .../identify/ObjectBookmarker_builtinHandlers.java | 30 ++++++++++++++++--
 .../metamodel/objectmanager/load/ObjectLoader.java |  1 +
 .../load/ObjectLoader_builtinHandlers.java         | 37 ++++++++++++++++++++++
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker.java
index 5cc6b12..8addc57 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker.java
@@ -46,6 +46,7 @@ public interface ObjectBookmarker {
                 new ObjectBookmarker_builtinHandlers.GuardAgainstOid(),
                 new ObjectBookmarker_builtinHandlers.BookmarkForServices(),
                 new ObjectBookmarker_builtinHandlers.BookmarkForValues(),
+                new ObjectBookmarker_builtinHandlers.BookmarkForSerializable(),
                 new ObjectBookmarker_builtinHandlers.BookmarkForViewModels(),
                 new ObjectBookmarker_builtinHandlers.BookmarkForEntities(),
                 new ObjectBookmarker_builtinHandlers.BookmarkForOthers());
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker_builtinHandlers.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker_builtinHandlers.java
index a910832..bc22d18 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker_builtinHandlers.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/identify/ObjectBookmarker_builtinHandlers.java
@@ -18,10 +18,15 @@
  */
 package org.apache.isis.core.metamodel.objectmanager.identify;
 
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.UUID;
 
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.bookmark.Oid;
+import org.apache.isis.commons.internal.base._Bytes;
+import org.apache.isis.commons.internal.base._Strings;
 import org.apache.isis.commons.internal.exceptions._Exceptions;
 import org.apache.isis.core.metamodel.facets.object.entity.EntityFacet;
 import org.apache.isis.core.metamodel.facets.object.value.ValueFacet;
@@ -29,6 +34,7 @@ import org.apache.isis.core.metamodel.facets.object.viewmodel.ViewModelFacet;
 import org.apache.isis.core.metamodel.objectmanager.identify.ObjectBookmarker.Handler;
 import org.apache.isis.core.metamodel.spec.ManagedObject;
 
+import lombok.SneakyThrows;
 import lombok.val;
 
 class ObjectBookmarker_builtinHandlers {
@@ -110,6 +116,28 @@ class ObjectBookmarker_builtinHandlers {
 
     }
 
+    static class BookmarkForSerializable implements Handler {
+
+        @Override
+        public boolean isHandling(ManagedObject managedObject) {
+            val spec = managedObject.getSpecification();
+            return spec.isViewModel() && java.io.Serializable.class.isAssignableFrom(spec.getCorrespondingClass());
+        }
+
+        @SneakyThrows
+        @Override
+        public Bookmark handle(ManagedObject managedObject) {
+            val spec = managedObject.getSpecification();
+            val baos = new ByteArrayOutputStream();
+            val oos = new ObjectOutputStream(baos);
+            oos.writeObject(managedObject.getPojo());
+            val identifier = _Strings.ofBytes(_Bytes.asUrlBase64.apply(baos.toByteArray()), StandardCharsets.UTF_8);
+            oos.close();
+            return Bookmark.forLogicalTypeAndIdentifier(spec.getLogicalType(), identifier);
+        }
+
+    }
+
     static class BookmarkForViewModels implements Handler {
 
         @Override
@@ -140,8 +168,6 @@ class ObjectBookmarker_builtinHandlers {
             val identifier = UUID.randomUUID().toString();
             return Bookmark.forLogicalTypeAndIdentifier(spec.getLogicalType(), identifier);
         }
-
     }
 
-
 }
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader.java
index 69a824e..536818a 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader.java
@@ -62,6 +62,7 @@ public interface ObjectLoader {
                 new ObjectLoader_builtinHandlers.GuardAgainstNull(mmc),
                 new ObjectLoader_builtinHandlers.LoadService(mmc),
                 new ObjectLoader_builtinHandlers.LoadValue(mmc),
+                new ObjectLoader_builtinHandlers.LoadSerializable(mmc),
                 new ObjectLoader_builtinHandlers.LoadViewModel(mmc),
                 new ObjectLoader_builtinHandlers.LoadEntity(mmc),
                 new ObjectLoader_builtinHandlers.LoadOther(mmc));
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader_builtinHandlers.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader_builtinHandlers.java
index 1d2b680..1611c34 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader_builtinHandlers.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/objectmanager/load/ObjectLoader_builtinHandlers.java
@@ -18,10 +18,15 @@
  */
 package org.apache.isis.core.metamodel.objectmanager.load;
 
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
 import java.lang.reflect.Array;
 import java.lang.reflect.Modifier;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.isis.commons.collections.Can;
+import org.apache.isis.commons.internal.base._Bytes;
+import org.apache.isis.commons.internal.base._Strings;
 import org.apache.isis.commons.internal.exceptions._Exceptions;
 import org.apache.isis.commons.internal.ioc._ManagedBeanAdapter;
 import org.apache.isis.core.metamodel.context.MetaModelContext;
@@ -31,6 +36,7 @@ import org.apache.isis.core.metamodel.spec.ManagedObject;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 
 import lombok.NonNull;
+import lombok.SneakyThrows;
 import lombok.Value;
 import lombok.val;
 
@@ -136,6 +142,37 @@ final class ObjectLoader_builtinHandlers {
     // -- VIEW MODELS
 
     @Value
+    public static class LoadSerializable implements ObjectLoader.Handler {
+
+        private final @NonNull MetaModelContext metaModelContext;
+
+        @Override
+        public boolean isHandling(final ObjectLoader.Request objectLoadRequest) {
+
+            val spec = objectLoadRequest.getObjectSpecification();
+            return spec.isViewModel()
+                   && java.io.Serializable.class.isAssignableFrom(spec.getCorrespondingClass());
+        }
+
+        @SneakyThrows
+        @Override
+        public ManagedObject handle(final ObjectLoader.Request objectLoadRequest) {
+
+            val spec = objectLoadRequest.getObjectSpecification();
+
+            val memento = objectLoadRequest.getObjectIdentifier();
+            val bytes = _Bytes.ofUrlBase64.apply(_Strings.toBytes(memento, StandardCharsets.UTF_8));
+            val ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
+            val viewModelPojo = ois.readObject();
+            ois.close();
+            metaModelContext.getServiceInjector().injectServicesInto(viewModelPojo);
+
+            return ManagedObject.of(spec, viewModelPojo);
+        }
+
+    }
+
+    @Value
     public static class LoadViewModel implements ObjectLoader.Handler {
 
         private final @NonNull MetaModelContext metaModelContext;

[isis] 10/10: ISIS-2773: suppress default UserMenu me action if secman is configured

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 ea26ae5c0c191c4ede5e20682013ad326901c900
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 06:52:59 2021 +0100

    ISIS-2773: suppress default UserMenu me action if secman is configured
---
 .../apache/isis/core/config/IsisConfiguration.java | 19 ++++++++++++++++
 .../secman/applib/IsisModuleExtSecmanApplib.java   |  1 +
 .../secman/applib/user/menu/MeService.java         | 25 +++++++++++++++++++++-
 3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
index 01a06e5..574e872 100644
--- a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
+++ b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
@@ -67,6 +67,7 @@ import org.apache.isis.applib.services.publishing.spi.EntityChangesSubscriber;
 import org.apache.isis.applib.services.publishing.spi.EntityPropertyChangeSubscriber;
 import org.apache.isis.applib.services.userreg.EmailNotificationService;
 import org.apache.isis.applib.services.userreg.UserRegistrationService;
+import org.apache.isis.applib.services.userui.UserMenu;
 import org.apache.isis.commons.internal.context._Context;
 import org.apache.isis.core.config.metamodel.facets.DefaultViewConfiguration;
 import org.apache.isis.core.config.metamodel.facets.EditingObjectsConfiguration;
@@ -3352,6 +3353,24 @@ public class IsisConfiguration {
                  */
                 private final List<String> initialRoleNames = new ArrayList<>();
             }
+
+            public enum UserMenuMeActionPolicy {
+                HIDE,
+                DISABLE,
+                ENABLE
+            }
+
+            /**
+             * Whether the presence of SecMan should result in the automatic suppression of the {@link org.apache.isis.applib.services.userui.UserMenu}'s
+             * {@link UserMenu#me() me} action.
+             *
+             * <p>
+             *     This is normally what is required as SecMan's <code>ApplicationUser</code> is a more comprehensive
+             *     representation of the current user.  If the default {@link UserMenu#me() me} action is not
+             *     suppressed, then the end-user will see two actions with the name &quot;me&quot; in the tertiary menu.
+             * </p>
+             */
+            private UserMenuMeActionPolicy userMenuMeActionPolicy = UserMenuMeActionPolicy.HIDE;
         }
     }
 
diff --git a/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/IsisModuleExtSecmanApplib.java b/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/IsisModuleExtSecmanApplib.java
index 8cf0dbc..c26d878 100644
--- a/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/IsisModuleExtSecmanApplib.java
+++ b/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/IsisModuleExtSecmanApplib.java
@@ -91,6 +91,7 @@ import org.apache.isis.extensions.secman.applib.user.menu.MeService;
         ApplicationUserMenu.class,
 
         MeService.class,
+        MeService.UserMenuMeActionAdvisor.class,
 
 
         // -- ViewModels
diff --git a/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/user/menu/MeService.java b/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/user/menu/MeService.java
index 8b3ad05..7629a72 100644
--- a/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/user/menu/MeService.java
+++ b/extensions/security/secman/applib/src/main/java/org/apache/isis/extensions/secman/applib/user/menu/MeService.java
@@ -20,9 +20,11 @@ package org.apache.isis.extensions.secman.applib.user.menu;
 
 import java.util.concurrent.Callable;
 
-import javax.annotation.Priority;
 import javax.inject.Inject;
 
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
 import org.apache.isis.applib.annotation.Action;
 import org.apache.isis.applib.annotation.ActionLayout;
 import org.apache.isis.applib.annotation.DomainService;
@@ -32,6 +34,8 @@ import org.apache.isis.applib.annotation.PriorityPrecedence;
 import org.apache.isis.applib.annotation.SemanticsOf;
 import org.apache.isis.applib.services.queryresultscache.QueryResultsCache;
 import org.apache.isis.applib.services.user.UserService;
+import org.apache.isis.applib.services.userui.UserMenu;
+import org.apache.isis.core.config.IsisConfiguration;
 import org.apache.isis.extensions.secman.applib.IsisModuleExtSecmanApplib;
 import org.apache.isis.extensions.secman.applib.user.dom.ApplicationUser;
 import org.apache.isis.extensions.secman.applib.user.dom.ApplicationUserRepository;
@@ -100,6 +104,25 @@ public class MeService {
     }
 
 
+    @Component
+    @RequiredArgsConstructor(onConstructor_ = {@Inject})
+    public static class UserMenuMeActionAdvisor {
+
+        final IsisConfiguration isisConfiguration;
 
+        @EventListener(UserMenu.MeDomainEvent.class)
+        public void on(UserMenu.MeDomainEvent event) {
+            switch (isisConfiguration.getExtensions().getSecman().getUserMenuMeActionPolicy()) {
+                case HIDE:
+                    event.hide();
+                    break;
+                case DISABLE:
+                    event.disable("Use security manager's action to view the current user");
+                    break;
+                case ENABLE:
+                    break;
+            }
+        }
+    }
 
 }

[isis] 03/10: ISIS-2760: ensure that there is, though, some spacing after tabGroups.

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 46449938134957027f61d5317a33b2c2c17af1a8
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 06:05:05 2021 +0100

    ISIS-2760: ensure that there is, though, some spacing after tabGroups.
---
 .../apache/isis/viewer/wicket/ui/pages/bootstrap-overrides-all-v2.css | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides-all-v2.css b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides-all-v2.css
index 7c44728..07af137 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides-all-v2.css
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/bootstrap-overrides-all-v2.css
@@ -1205,6 +1205,6 @@ ul.navbar-wrap {
 	flex-wrap:wrap;
 }
 
-div.col > div.tabGroups {
-    margin-bottom: 10px;
+.tabGroups {
+    margin-bottom: 21px;
 }