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 2017/11/14 22:45:23 UTC

[isis] branch ISIS-1759 created (now 003f830)

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

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


      at 003f830  ISIS-1759: suppresses superfluous calls to obtain value of property if the property is hidden anyway

This branch includes the following new commits:

     new 7c95d76  ISIS-1714: default implementation of UserProfileService.
     new 6292890  ISIS-1710: fixes NPE if no prior list of services
     new 003f830  ISIS-1759: suppresses superfluous calls to obtain value of property if the property is hidden anyway

The 3 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.


-- 
To stop receiving notification emails like this one, please contact
['"commits@isis.apache.org" <co...@isis.apache.org>'].

[isis] 02/03: ISIS-1710: fixes NPE if no prior list of services

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

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

commit 629289008ec55a5b56895a7ddde1903fd2a70e39
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Nov 14 18:19:15 2017 +0000

    ISIS-1710: fixes NPE if no prior list of services
---
 .../systemusinginstallers/IsisComponentProvider.java    | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
index f6e61a8..ec66347 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
@@ -174,14 +174,21 @@ public abstract class IsisComponentProvider {
 
         final List<Class<?>> additionalServices = appManifest.getAdditionalServices();
         if(additionalServices != null) {
-            String existingServicesCsv = configuration.getString(ServicesInstallerFromConfiguration.SERVICES_KEY);
-            String additionalServicesCsv = classNamesFrom(additionalServices);
-            String servicesCsv = Joiner.on(",").join(existingServicesCsv, additionalServicesCsv);
-            putConfigurationProperty(
-                    ServicesInstallerFromConfiguration.SERVICES_KEY, servicesCsv);
+            final String additionalServicesCsv = classNamesFrom(additionalServices);
+            appendToPropertyCsvValue(ServicesInstallerFromConfiguration.SERVICES_KEY, additionalServicesCsv);
         }
     }
 
+    private void appendToPropertyCsvValue(final String servicesKey, final String additionalServicesCsv) {
+        final String existingServicesCsv = configuration.getString(servicesKey);
+        final String servicesCsv = join(existingServicesCsv, additionalServicesCsv);
+        putConfigurationProperty(servicesKey, servicesCsv);
+    }
+
+    private static String join(final String csv1, final String csv2) {
+        return csv1 != null ? Joiner.on(",").join(csv1, csv2) : null;
+    }
+
     private Iterable<String> modulePackageNamesFrom(final AppManifest appManifest) {
         List<Class<?>> modules = appManifest.getModules();
         if (modules == null || modules.isEmpty()) {

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.

[isis] 01/03: ISIS-1714: default implementation of UserProfileService.

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

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

commit 7c95d76c72d1243999277fff85e330889ee13f23
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Nov 14 17:59:37 2017 +0000

    ISIS-1714: default implementation of UserProfileService.
---
 ..._presentation-layer-spi_UserProfileService.adoc |  7 ++++---
 .../userprof/UserProfileServiceDefault.java        | 22 ++++++++++++++++++++++
 .../wicket/ui/components/header/HeaderPanel.java   |  6 ++----
 3 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_UserProfileService.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_UserProfileService.adoc
index 0c22838..b361cd6 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_UserProfileService.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_presentation-layer-spi_UserProfileService.adoc
@@ -33,9 +33,10 @@ In the future this API may be expanded; one obvious possibility is to return a p
 
 == Implementation
 
-There is no default implementation of this service provided by the core Apache Isis framework.
+(As of `1.16.0-SNAPSHOT`) the framework provides a default implementation of this service, `o.a.i.core.runtime.services.UserProfileServiceDefault`.
+This simply returns the user's name as the user's profile name.
 
-An example implementation can be found in the (non-ASF)
+An example implementation can also be found in the (non-ASF)
 http://github.com/isisaddons/isis-app-todoapp[Isis addons' todoapp]:
 
 image::{_imagesdir}reference-services-spi/UserProfileService/todoapp.png[width="800px",link="{_imagesdir}reference-services-spi/UserProfileService/todoapp.png"]
@@ -43,5 +44,5 @@ image::{_imagesdir}reference-services-spi/UserProfileService/todoapp.png[width="
 
 [NOTE]
 ====
-Currently this feature is not integrated with Apache Isis' authentication mechanisms; the information provided is purely metadata provided for presentation purposes only.
+This feature does not integrate with Apache Isis' authentication mechanisms; the information returned is used purely for presentation purposes.
 ====
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/userprof/UserProfileServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/userprof/UserProfileServiceDefault.java
new file mode 100644
index 0000000..e10be0f
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/userprof/UserProfileServiceDefault.java
@@ -0,0 +1,22 @@
+package org.apache.isis.core.runtime.services.userprof;
+
+import javax.inject.Inject;
+
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.services.userprof.UserProfileService;
+import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
+
+@DomainService(nature = NatureOfService.DOMAIN)
+public class UserProfileServiceDefault implements UserProfileService {
+
+    @Programmatic
+    @Override
+    public String userProfileName() {
+        return authenticationSessionProvider.getAuthenticationSession().getUserName();
+    }
+
+    @Inject
+    AuthenticationSessionProvider authenticationSessionProvider;
+}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/header/HeaderPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/header/HeaderPanel.java
index bd38ff1..4e3a00c 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/header/HeaderPanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/header/HeaderPanel.java
@@ -20,8 +20,6 @@ package org.apache.isis.viewer.wicket.ui.components.header;
 
 import java.util.Locale;
 
-import com.google.inject.name.Named;
-
 import org.apache.wicket.Component;
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.Page;
@@ -107,8 +105,7 @@ public class HeaderPanel extends PanelAbstract<Model<String>> {
                 }
                 try {
                     final UserProfileService userProfileService = lookupService(UserProfileService.class);
-                    final String userProfileName = userProfileService != null ? userProfileService.userProfileName() : null;
-                    return userProfileName != null? userProfileName: getAuthenticationSession().getUserName();
+                    return userProfileService.userProfileName();
                 } catch (final Exception e) {
                     return getAuthenticationSession().getUserName();
                 }
@@ -135,4 +132,5 @@ public class HeaderPanel extends PanelAbstract<Model<String>> {
         container.add(menuBarComponent);
 
     }
+
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.

[isis] 03/03: ISIS-1759: suppresses superfluous calls to obtain value of property if the property is hidden anyway

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

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

commit 003f830d53c96d5b4405641bc47b38298868e665
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Nov 14 22:44:53 2017 +0000

    ISIS-1759: suppresses superfluous calls to obtain value of property if the property is hidden anyway
---
 .../viewer/wicket/model/models/ScalarModel.java    | 26 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
index 7feeb06..315c126 100644
--- a/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
+++ b/core/viewer-wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
@@ -288,10 +288,8 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
                 final OneToOneAssociation property = scalarModel.propertyMemento.getProperty(scalarModel.getSpecificationLoader());
 
                 final ObjectAdapter parentAdapter = scalarModel.getParentEntityModel().load();
+                setObjectFromPropertyIfVisible(scalarModel, property, parentAdapter);
 
-                final ObjectAdapter associatedAdapter =
-                        property.get(parentAdapter, InteractionInitiatedBy.USER);
-                scalarModel.setObject(associatedAdapter);
             }
 
             @Override
@@ -625,6 +623,24 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
         public abstract String toStringOf(final ScalarModel scalarModel);
     }
 
+    private static void setObjectFromPropertyIfVisible(
+            final ScalarModel scalarModel,
+            final OneToOneAssociation property,
+            final ObjectAdapter parentAdapter) {
+
+        // optimisation... no need to sync ScalarModel with property value if not visible anyway
+
+        // TODO: shouldn't assume OBJECT_FORMS ... need to pass in somehow
+        final Consent visibility =
+                property.isVisible(parentAdapter, InteractionInitiatedBy.FRAMEWORK, Where.OBJECT_FORMS);
+
+        final ObjectAdapter associatedAdapter =
+                visibility.isAllowed()
+                        ? property.get(parentAdapter, InteractionInitiatedBy.USER)
+                        : null;
+
+        scalarModel.setObject(associatedAdapter);
+    }
 
     private final Kind kind;
     
@@ -696,8 +712,8 @@ public class ScalarModel extends EntityModel implements LinksProvider,FormExecut
         final OneToOneAssociation property = propertyMemento.getProperty(getSpecificationLoader());
         final ObjectAdapter parentAdapter = parentAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK,
                 getPersistenceSession(), getSpecificationLoader());
-        final ObjectAdapter associatedAdapter = property.get(parentAdapter, InteractionInitiatedBy.USER);
-        setObject(associatedAdapter);
+
+        setObjectFromPropertyIfVisible(ScalarModel.this, property, parentAdapter);
     }
 
     public boolean isCollection() {

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.