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


The following commit(s) were added to refs/heads/master by this push:
     new 9c58b2c  ISIS-2223: even more mitigations
9c58b2c is described below

commit 9c58b2c368f256aada3f4a757fa47ce2349c58af
Author: Andi Huber <ahu...@apache.org>
AuthorDate: Fri Feb 14 14:17:24 2020 +0100

    ISIS-2223: even more mitigations
---
 .../core/commons/internal/primitives/_Ints.java    |  6 ++-
 .../components/actions/ActionParametersForm.java   | 62 ++++++++++++----------
 .../wicket/ui/components/layout/bs3/col/Col.java   | 24 ++++-----
 .../scalars/ScalarPanelTextFieldAbstract.java      |  5 +-
 .../datepicker/js/bootstrap-datetimepicker.js      |  5 +-
 .../ui/components/scalars/datepicker/js/moment.js  |  2 +-
 .../jdkmath/BigDecimalConverterWithScale.java      |  2 +-
 .../ui/components/tree/themes/bootstrap/theme.css  |  4 +-
 .../widgets/breadcrumbs/BreadcrumbPanel.java       |  5 +-
 9 files changed, 63 insertions(+), 52 deletions(-)

diff --git 
a/core/commons/src/main/java/org/apache/isis/core/commons/internal/primitives/_Ints.java
 
b/core/commons/src/main/java/org/apache/isis/core/commons/internal/primitives/_Ints.java
index 972667e..82a219f 100644
--- 
a/core/commons/src/main/java/org/apache/isis/core/commons/internal/primitives/_Ints.java
+++ 
b/core/commons/src/main/java/org/apache/isis/core/commons/internal/primitives/_Ints.java
@@ -5,6 +5,8 @@ import java.util.function.Consumer;
 
 import javax.annotation.Nullable;
 
+import static org.apache.isis.core.commons.internal.base._With.requires;
+
 import lombok.val;
 import lombok.experimental.UtilityClass;
 
@@ -92,7 +94,9 @@ public class _Ints {
     private static long parseIntElseLongMaxValue(
             @Nullable final String s, 
             final int radix, 
-            @Nullable final Consumer<String> onFailure) {
+            final Consumer<String> onFailure) {
+        
+        requires(onFailure, "onFailure");
         
         if (s == null) {
             onFailure.accept("null");
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersForm.java
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersForm.java
index 3cd4bc7..7d9e683 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersForm.java
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionParametersForm.java
@@ -19,7 +19,7 @@
 package org.apache.isis.viewer.wicket.ui.components.actions;
 
 import java.util.Collections;
-import java.util.List;
+import java.util.Optional;
 
 import org.apache.wicket.Component;
 import org.apache.wicket.MarkupContainer;
@@ -31,13 +31,11 @@ import org.apache.wicket.markup.repeater.RepeatingView;
 
 import org.apache.isis.applib.annotation.SemanticsOf;
 import org.apache.isis.core.commons.internal.exceptions._Exceptions;
-import org.apache.isis.core.metamodel.consent.Consent;
 import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
 import org.apache.isis.viewer.wicket.model.hints.IsisActionCompletedEvent;
 import org.apache.isis.viewer.wicket.model.isis.WicketViewerSettings;
-import org.apache.isis.viewer.wicket.model.mementos.ActionParameterMemento;
 import org.apache.isis.viewer.wicket.model.models.ActionArgumentModel;
 import org.apache.isis.viewer.wicket.model.models.ActionModel;
 import org.apache.isis.viewer.wicket.ui.ComponentType;
@@ -69,30 +67,35 @@ class ActionParametersForm extends 
PromptFormAbstract<ActionModel> {
 
     @Override
     protected void addParameters() {
-        final ActionModel actionModel = getActionModel();
-
-        final RepeatingView rv = new 
RepeatingView(ActionParametersFormPanel.ID_ACTION_PARAMETERS);
-        add(rv);
+        val actionModel = getActionModel();
+        
+        val repeatingView = new 
RepeatingView(ActionParametersFormPanel.ID_ACTION_PARAMETERS);
+        add(repeatingView);
 
         paramPanels.clear();
-        List<ActionParameterMemento> parameterMementos = 
actionModel.primeArgumentModels();
-        for (final ActionParameterMemento apm : parameterMementos) {
-            final WebMarkupContainer container = new 
WebMarkupContainer(rv.newChildId());
-            rv.add(container);
+        val parameterMementos = actionModel.primeArgumentModels();
+        for (val actionParameterMemento : parameterMementos) {
+            val container = new WebMarkupContainer(repeatingView.newChildId());
+            repeatingView.add(container);
 
-            final ActionArgumentModel actionArgumentModel = 
actionModel.getArgumentModel(apm);
+            val actionArgumentModel = 
actionModel.getArgumentModel(actionParameterMemento);
             
actionArgumentModel.setActionArgsHint(actionModel.getArgumentsAsImmutable());
-            final ScalarPanelAbstract2 paramPanel = newParamPanel(container, 
actionArgumentModel);
-            paramPanels.add(paramPanel);
-
-            // TODO: maybe this logic should move instead to 
ScalarModel.Kind#whether{Hidden/Disabled}
-            val targetAdapter = actionModel.getTargetAdapter();
-            val realTargetAdapter = 
actionModel.getActionMemento().getAction(getSpecificationLoader())
-                    .realTargetAdapter(targetAdapter);
-            final Consent consent = 
apm.getActionParameter(getSpecificationLoader())
-                    .isVisible(realTargetAdapter, Collections.emptyList(), 
InteractionInitiatedBy.USER);
-            final boolean allowed = consent.isAllowed();
-            paramPanel.setVisible(allowed);
+            newParamPanel(container, actionArgumentModel)
+            .ifPresent(paramPanel->{
+            
+                paramPanels.add(paramPanel);
+
+                // TODO: maybe this logic should move instead to 
ScalarModel.Kind#whether{Hidden/Disabled}
+                val targetAdapter = actionModel.getTargetAdapter();
+                val realTargetAdapter = 
actionModel.getActionMemento().getAction(getSpecificationLoader())
+                        .realTargetAdapter(targetAdapter);
+                val consent = 
actionParameterMemento.getActionParameter(getSpecificationLoader())
+                        .isVisible(realTargetAdapter, Collections.emptyList(), 
InteractionInitiatedBy.USER);
+                val allowed = consent.isAllowed();
+                paramPanel.setVisible(allowed);
+                
+            });
+            
         }
 
         setOutputMarkupId(true);
@@ -100,7 +103,7 @@ class ActionParametersForm extends 
PromptFormAbstract<ActionModel> {
 
     }
 
-    private ScalarPanelAbstract2 newParamPanel(final WebMarkupContainer 
container, final ActionArgumentModel model) {
+    private Optional<ScalarPanelAbstract2> newParamPanel(final 
WebMarkupContainer container, final ActionArgumentModel model) {
         final Component component = getComponentFactoryRegistry()
                 .addOrReplaceComponent(container, 
ComponentType.SCALAR_NAME_AND_VALUE, model);
 
@@ -123,11 +126,12 @@ class ActionParametersForm extends 
PromptFormAbstract<ActionModel> {
                 component instanceof ScalarPanelAbstract2
                 ? (ScalarPanelAbstract2) component
                         : null;
-                if (paramPanel != null) {
-                    paramPanel.setOutputMarkupId(true);
-                    paramPanel.notifyOnChange(this);
-                }
-                return paramPanel;
+                
+        if (paramPanel != null) {
+            paramPanel.setOutputMarkupId(true);
+            paramPanel.notifyOnChange(this);
+        }
+        return Optional.of(paramPanel);
     }
 
     @Override
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
index 121943f..bc814d2 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
@@ -22,8 +22,6 @@ import java.util.List;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
-import javax.annotation.Nullable;
-
 import org.apache.wicket.Component;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 
@@ -170,15 +168,13 @@ public class Col extends PanelAbstract<EntityModel> 
implements HasDynamicallyVis
         // tab groups
         final List<BS3TabGroup> tabGroupsWithNonEmptyTabs =
                 _NullSafe.stream(bs3Col.getTabGroups())
-                .filter(new Predicate<BS3TabGroup>() {
-                    @Override public boolean test(@Nullable final BS3TabGroup 
bs3TabGroup) {
-                        final List<BS3Tab> bs3TabsWithRows = 
_NullSafe.stream(bs3TabGroup.getTabs())
-                                .filter(BS3Tab.Predicates.notEmpty())
-                                .collect(Collectors.toList());
-                        return !bs3TabsWithRows.isEmpty();
-                    }
-                })
+                .filter(_NullSafe::isPresent)
+                .filter(bs3TabGroup -> 
+                        _NullSafe.stream(bs3TabGroup.getTabs())
+                                .anyMatch(BS3Tab.Predicates.notEmpty())
+                )
                 .collect(Collectors.toList());
+        
         if(!tabGroupsWithNonEmptyTabs.isEmpty()) {
             final RepeatingViewWithDynamicallyVisibleContent tabGroupRv =
                     new 
RepeatingViewWithDynamicallyVisibleContent(ID_TAB_GROUPS);
@@ -223,12 +219,10 @@ public class Col extends PanelAbstract<EntityModel> 
implements HasDynamicallyVis
         // fieldsets
         final List<FieldSet> fieldSetsWithProperties = 
                 _NullSafe.stream(bs3Col.getFieldSets())
-                .filter(new Predicate<FieldSet>() {
-                    @Override public boolean test(@Nullable final FieldSet 
fieldSet) {
-                        return !fieldSet.getProperties().isEmpty();
-                    }
-                })
+                .filter(_NullSafe::isPresent)
+                .filter(fieldSet -> ! 
_NullSafe.isEmpty(fieldSet.getProperties()))
                 .collect(Collectors.toList());
+        
         if(!fieldSetsWithProperties.isEmpty()) {
             final RepeatingViewWithDynamicallyVisibleContent fieldSetRv =
                     new 
RepeatingViewWithDynamicallyVisibleContent(ID_FIELD_SETS);
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
index eaa2c2f..bd188cc 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
@@ -38,6 +38,7 @@ import org.apache.wicket.validation.IValidator;
 import org.apache.wicket.validation.ValidationError;
 
 import org.apache.isis.core.commons.internal.base._Casts;
+import org.apache.isis.core.commons.internal.exceptions._Exceptions;
 import org.apache.isis.core.metamodel.facets.SingleIntValueFacet;
 import org.apache.isis.core.metamodel.facets.objectvalue.maxlen.MaxLengthFacet;
 import 
org.apache.isis.core.metamodel.facets.objectvalue.typicallen.TypicalLengthFacet;
@@ -233,7 +234,9 @@ implements TextFieldValueModel.ScalarModelProvider {
             }
             
             private ObjectManager objectManager() {
-                return IsisSession.current().get().getMetaModelContext()
+                return IsisSession.current()
+                        .orElseThrow(()->_Exceptions.unrecoverable("no current 
IsisSession"))
+                        .getMetaModelContext()
                         .getObjectManager();
             }
             
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/bootstrap-datetimepicker.js
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/bootstrap-datetimepicker.js
index b912fa8..edd9c53 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/bootstrap-datetimepicker.js
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/bootstrap-datetimepicker.js
@@ -555,7 +555,10 @@
                     if (currentDate.day() === 0 || currentDate.day() === 6) {
                         clsName += ' weekend';
                     }
-                    row.append('<td data-action="selectDay" class="day' + 
clsName + '">' + currentDate.date() + '</td>');
+                    if (row) {
+                       row.append('<td data-action="selectDay" class="day' + 
clsName + '">' + currentDate.date() + '</td>');   
+                    }
+                    
                     currentDate.add(1, 'd');
                 }
 
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/moment.js
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/moment.js
index c635ec0..7a181c6 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/moment.js
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/datepicker/js/moment.js
@@ -4,7 +4,7 @@
 //! license : MIT
 //! momentjs.com
 
-(function (undefined) {
+(function () {
     /************************************
         Constants
     ************************************/
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/BigDecimalConverterWithScale.java
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/BigDecimalConverterWithScale.java
index 597da54..6356739 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/BigDecimalConverterWithScale.java
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/BigDecimalConverterWithScale.java
@@ -101,7 +101,7 @@ public class BigDecimalConverterWithScale extends 
BigDecimalConverter {
                 throw new ConversionException("No more than " + this.scale + " 
digits can be entered after the decimal place");
             }
             try {
-                return bd != null ? bd.setScale(this.scale) : null;
+                return bd.setScale(this.scale);
             } catch(Exception ex) {
                 // TODO: this is not actually shown; we see a generic error
                 // need to configure the ConversionException somehow
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/themes/bootstrap/theme.css
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/themes/bootstrap/theme.css
index bf4bffb..8f1a184 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/themes/bootstrap/theme.css
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/tree/themes/bootstrap/theme.css
@@ -47,7 +47,7 @@
 }
 
 .tree-theme-bootstrap .tree-junction-expanded:before {
-  font-family: "Glyphicons Halflings";
+  font-family: "Glyphicons Halflings", sans-serif;
   content: "\e114";
 }
 
@@ -63,7 +63,7 @@
 }
 
 .tree-theme-bootstrap .tree-junction-collapsed:before {
-  font-family: "Glyphicons Halflings";
+  font-family: "Glyphicons Halflings", sans-serif;
   content: "\e080";
 }
 
diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/breadcrumbs/BreadcrumbPanel.java
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/breadcrumbs/BreadcrumbPanel.java
index f9c0b3c..189090a 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/breadcrumbs/BreadcrumbPanel.java
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/breadcrumbs/BreadcrumbPanel.java
@@ -33,6 +33,7 @@ import org.wicketstuff.select2.Select2Choice;
 import org.wicketstuff.select2.Settings;
 
 import org.apache.isis.core.commons.internal.collections._Lists;
+import org.apache.isis.core.commons.internal.exceptions._Exceptions;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.core.runtime.session.IsisSession;
@@ -136,7 +137,9 @@ public class BreadcrumbPanel extends 
PanelAbstract<IModel<Void>> {
                     }
 
                     private AuthenticationSession getAuthenticationSession() {
-                        return 
IsisSession.current().get().getAuthenticationSession();
+                        return IsisSession.current()
+                                .orElseThrow(()->_Exceptions.unrecoverable("no 
current IsisSession"))
+                                .getAuthenticationSession();
                     }
                 });
 

Reply via email to