You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2020/12/22 15:56:07 UTC

[syncope] branch 2_1_X updated: [SYNCOPE-1606] Fix user toggle panel

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

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


The following commit(s) were added to refs/heads/2_1_X by this push:
     new d99f242  [SYNCOPE-1606] Fix user toggle panel
d99f242 is described below

commit d99f24226bb7027b851c666d63fb4fb81b81ee2f
Author: Marco Di Sabatino Di Diodoro <ma...@tirasa.net>
AuthorDate: Tue Dec 22 16:55:08 2020 +0100

    [SYNCOPE-1606] Fix user toggle panel
---
 .../client/console/panels/UserDirectoryPanel.java  | 118 +++++++++++----------
 1 file changed, 60 insertions(+), 58 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/UserDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/UserDirectoryPanel.java
index 8c30d8a..41657ec 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/UserDirectoryPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/UserDirectoryPanel.java
@@ -182,6 +182,7 @@ public class UserDirectoryPanel extends AnyDirectoryPanel<UserTO, UserRestClient
             @Override
             public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
                 try {
+                    model.setObject(restClient.read(model.getObject().getKey()));
                     restClient.mustChangePassword(
                             model.getObject().getETagValue(),
                             !model.getObject().isMustChangePassword(),
@@ -205,6 +206,7 @@ public class UserDirectoryPanel extends AnyDirectoryPanel<UserTO, UserRestClient
 
                 @Override
                 public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
+                    model.setObject(restClient.read(model.getObject().getKey()));
                     IModel<AnyWrapper<UserTO>> formModel = new CompoundPropertyModel<>(
                             new AnyWrapper<>(model.getObject()));
                     displayAttributeModal.setFormModel(formModel);
@@ -347,78 +349,78 @@ public class UserDirectoryPanel extends AnyDirectoryPanel<UserTO, UserRestClient
             if (wizardInModal) {
                 panel.add(new ActionLink<UserTO>() {
                     private static final long serialVersionUID = 8011039414597736111L;
-                    
+
                     @Override
                     public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
                         model.setObject(UserRestClient.class.cast(restClient).read(model.getObject().getKey()));
                         MergeLinkedAccountsWizardBuilder builder =
-                          new MergeLinkedAccountsWizardBuilder(model, pageRef, UserDirectoryPanel.this, modal);
+                                new MergeLinkedAccountsWizardBuilder(model, pageRef, UserDirectoryPanel.this, modal);
                         builder.setEventSink(builder);
                         target.add(modal.setContent(builder.build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
                         modal.header(new StringResourceModel("mergeLinkedAccounts.title", model));
                         modal.show(true);
                     }
-                    }, ActionType.MERGE_ACCOUNTS,
-                    String.format("%s,%s,%s,%s", StandardEntitlement.USER_READ, StandardEntitlement.USER_UPDATE,
-                        StandardEntitlement.USER_DELETE, StandardEntitlement.RESOURCE_GET_CONNOBJECT));
+                }, ActionType.MERGE_ACCOUNTS,
+                        String.format("%s,%s,%s,%s", StandardEntitlement.USER_READ, StandardEntitlement.USER_UPDATE,
+                                StandardEntitlement.USER_DELETE, StandardEntitlement.RESOURCE_GET_CONNOBJECT));
             }
         }
 
         if (wizardInModal) {
             panel.add(new ActionLink<UserTO>() {
-                  private static final long serialVersionUID = -1978723352517770644L;
-
-                  @Override
-                  public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
-                      model.setObject(restClient.read(model.getObject().getKey()));
-                      target.add(altDefaultModal.setContent(new AuditHistoryModal<UserTO>(
-                          altDefaultModal,
-                          AuditElements.EventCategoryType.LOGIC,
-                          "UserLogic",
-                          model.getObject(),
-                          StandardEntitlement.USER_UPDATE,
-                          pageRef) {
-
-                          private static final long serialVersionUID = 959378158400669867L;
-
-                          @Override
-                          protected void restore(final String json, final AjaxRequestTarget target) {
-                              // The original audit record masks the password and the security
-                              // answer; so we cannot use the audit record to resurrect the entry
-                              // based on mask data.
-                              //
-                              // The method behavior below will reset the audit record such
-                              // that the current security answer and the password for the object
-                              // are always maintained, and such properties for the
-                              // user cannot be restored using audit records.
-                              UserTO original = model.getObject();
-                              try {
-                                  UserTO updated = MAPPER.readValue(json, UserTO.class);
-                                  UserPatch userPatch = AnyOperations.diff(updated, original, false);
-                                  userPatch.setPassword(null);
-                                  userPatch.setSecurityAnswer(null);
-                                  ProvisioningResult<UserTO> result =
-                                      restClient.update(original.getETagValue(), userPatch);
-                                  model.getObject().setLastChangeDate(result.getEntity().getLastChangeDate());
-
-                                  SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
-                                  target.add(container);
-                              } catch (Exception e) {
-                                  LOG.error("While restoring user {}", model.getObject().getKey(), e);
-                                  SyncopeConsoleSession.get().onException(e);
-                              }
-                              ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
-                          }
-                      }));
-
-                      altDefaultModal.header(new Model<>(
-                          getString("auditHistory.title", new Model<>(new AnyWrapper<>(model.getObject())))));
-
-                      altDefaultModal.show(true);
-                  }
-              }, ActionType.VIEW_AUDIT_HISTORY,
-            String.format("%s,%s", StandardEntitlement.USER_READ, StandardEntitlement.AUDIT_LIST)).
-            setRealms(realm, model.getObject().getDynRealms());
+                private static final long serialVersionUID = -1978723352517770644L;
+
+                @Override
+                public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
+                    model.setObject(restClient.read(model.getObject().getKey()));
+                    target.add(altDefaultModal.setContent(new AuditHistoryModal<UserTO>(
+                            altDefaultModal,
+                            AuditElements.EventCategoryType.LOGIC,
+                            "UserLogic",
+                            model.getObject(),
+                            StandardEntitlement.USER_UPDATE,
+                            pageRef) {
+
+                        private static final long serialVersionUID = 959378158400669867L;
+
+                        @Override
+                        protected void restore(final String json, final AjaxRequestTarget target) {
+                            // The original audit record masks the password and the security
+                            // answer; so we cannot use the audit record to resurrect the entry
+                            // based on mask data.
+                            //
+                            // The method behavior below will reset the audit record such
+                            // that the current security answer and the password for the object
+                            // are always maintained, and such properties for the
+                            // user cannot be restored using audit records.
+                            UserTO original = model.getObject();
+                            try {
+                                UserTO updated = MAPPER.readValue(json, UserTO.class);
+                                UserPatch userPatch = AnyOperations.diff(updated, original, false);
+                                userPatch.setPassword(null);
+                                userPatch.setSecurityAnswer(null);
+                                ProvisioningResult<UserTO> result =
+                                        restClient.update(original.getETagValue(), userPatch);
+                                model.getObject().setLastChangeDate(result.getEntity().getLastChangeDate());
+
+                                SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
+                                target.add(container);
+                            } catch (Exception e) {
+                                LOG.error("While restoring user {}", model.getObject().getKey(), e);
+                                SyncopeConsoleSession.get().onException(e);
+                            }
+                            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
+                        }
+                    }));
+
+                    altDefaultModal.header(new Model<>(
+                            getString("auditHistory.title", new Model<>(new AnyWrapper<>(model.getObject())))));
+
+                    altDefaultModal.show(true);
+                }
+            }, ActionType.VIEW_AUDIT_HISTORY,
+                    String.format("%s,%s", StandardEntitlement.USER_READ, StandardEntitlement.AUDIT_LIST)).
+                    setRealms(realm, model.getObject().getDynRealms());
         }
 
         panel.add(new ActionLink<UserTO>() {