You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2020/05/19 14:27:20 UTC

[syncope] branch 2_0_X updated: [SYNCOPE-1560] Possibly the last tweaks

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

ilgrosso pushed a commit to branch 2_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_0_X by this push:
     new 1645d2a  [SYNCOPE-1560] Possibly the last tweaks
1645d2a is described below

commit 1645d2adfbd2b35085cc78028d4b98a3f1e8f1c6
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue May 19 16:05:45 2020 +0200

    [SYNCOPE-1560] Possibly the last tweaks
---
 .../client/console/wicket/markup/html/form/BinaryFieldPanel.java  | 8 +++-----
 .../org/apache/syncope/client/console/panels/ImportMetadata.java  | 8 ++++----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
index 3ed178a..2079292 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
@@ -176,23 +176,21 @@ public class BinaryFieldPanel extends FieldPanel<String> {
         downloadLink.setOutputMarkupId(true);
         uploadForm.add(downloadLink);
 
-        final ListModel<FileUpload> fileUploadModel = new ListModel<>(new ArrayList<FileUpload>());
         FileInputConfig config = new FileInputConfig().
                 showUpload(false).showRemove(false).showPreview(false);
         String language = SyncopeConsoleSession.get().getLocale().getLanguage();
         if (!Locale.ENGLISH.getLanguage().equals(language)) {
             config.withLocale(language);
         }
-        fileUpload = new BootstrapFileInputField("fileUpload", fileUploadModel, config);
+        fileUpload = new BootstrapFileInputField("fileUpload", new ListModel<>(new ArrayList<FileUpload>()), config);
         fileUpload.add(new AjaxFormSubmitBehavior(Constants.ON_CHANGE) {
 
             private static final long serialVersionUID = -1107858522700306810L;
 
             @Override
             protected void onSubmit(final AjaxRequestTarget target) {
-                if (!fileUploadModel.getObject().isEmpty()) {
-                    FileUpload uploaded = fileUploadModel.getObject().get(0);
-
+                FileUpload uploaded = fileUpload.getFileUpload();
+                if (uploaded != null) {
                     if (maxUploadSize != null && uploaded.getSize() > maxUploadSize.bytes()) {
                         // SYNCOPE-1213 manage directly max upload file size (if set in properties file)
                         SyncopeConsoleSession.get().error(getString("tooLargeFile").
diff --git a/ext/saml2sp/client-console/src/main/java/org/apache/syncope/client/console/panels/ImportMetadata.java b/ext/saml2sp/client-console/src/main/java/org/apache/syncope/client/console/panels/ImportMetadata.java
index 373bfc2..8d32a74 100644
--- a/ext/saml2sp/client-console/src/main/java/org/apache/syncope/client/console/panels/ImportMetadata.java
+++ b/ext/saml2sp/client-console/src/main/java/org/apache/syncope/client/console/panels/ImportMetadata.java
@@ -48,14 +48,14 @@ public class ImportMetadata extends TogglePanel<Serializable> {
         Form<?> form = new Form<>("metadataForm");
         addInnerObject(form);
 
-        final ListModel<FileUpload> fileUploadModel = new ListModel<>(new ArrayList<FileUpload>());
         FileInputConfig config = new FileInputConfig().
                 showUpload(false).showRemove(false).showPreview(false);
         String language = SyncopeConsoleSession.get().getLocale().getLanguage();
         if (!Locale.ENGLISH.getLanguage().equals(language)) {
             config.withLocale(language);
         }
-        BootstrapFileInputField fileUpload = new BootstrapFileInputField("fileUpload", fileUploadModel, config);
+        final BootstrapFileInputField fileUpload =
+                new BootstrapFileInputField("fileUpload", new ListModel<>(new ArrayList<FileUpload>()), config);
         form.add(fileUpload.setOutputMarkupId(true));
 
         form.add(new AjaxSubmitLink("doUpload", form) {
@@ -64,8 +64,8 @@ public class ImportMetadata extends TogglePanel<Serializable> {
 
             @Override
             protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
-                if (!fileUploadModel.getObject().isEmpty()) {
-                    FileUpload uploaded = fileUploadModel.getObject().get(0);
+                FileUpload uploaded = fileUpload.getFileUpload();
+                if (uploaded != null) {
                     try {
                         restClient.importIdPs(uploaded.getInputStream());