You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by GitBox <gi...@apache.org> on 2022/10/27 07:42:56 UTC

[GitHub] [syncope] ilgrosso opened a new pull request, #383: [SYNCOPE-1705] Encapsulating each object processing into an inner transaction

ilgrosso opened a new pull request, #383:
URL: https://github.com/apache/syncope/pull/383

   …nsaction


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] github-code-scanning[bot] commented on a diff in pull request #383: [SYNCOPE-1705] Encapsulating each object processing into an inner transaction

Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #383:
URL: https://github.com/apache/syncope/pull/383#discussion_r1006548975


##########
core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/LDAPMembershipPullActions.java:
##########
@@ -190,15 +212,49 @@
         });
     }
 
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
     @Override
     public void afterAll(final ProvisioningProfile<?, ?> profile) throws JobExecutionException {
-        Map<String, Object> jobMap = new HashMap<>();
-        jobMap.put(SetUMembershipsJob.MEMBERSHIPS_BEFORE_KEY, membershipsBefore);
-        jobMap.put(SetUMembershipsJob.MEMBERSHIPS_AFTER_KEY, membershipsAfter);
-        jobMap.put(JobManager.EXECUTOR_KEY, profile.getExecutor());
-        jobMap.put(
-                SetUMembershipsJob.CONTEXT,
-                "PullTask " + profile.getTask().getKey() + " '" + profile.getTask().getName() + "'");
-        schedule(SetUMembershipsJob.class, jobMap);
+        List<UserUR> updateReqs = new ArrayList<>();
+
+        membershipsAfter.forEach((user, groups) -> {
+            UserUR userUR = new UserUR();
+            userUR.setKey(user);
+            updateReqs.add(userUR);
+
+            groups.stream().forEach(group -> {
+                Set<String> before = membershipsBefore.get(user);
+                if (before == null || !before.contains(group)) {
+                    userUR.getMemberships().add(new MembershipUR.Builder(group).
+                            operation(PatchOperation.ADD_REPLACE).
+                            build());
+                }
+            });
+        });
+
+        membershipsBefore.forEach((user, groups) -> {
+            UserUR userUR = updateReqs.stream().
+                    filter(req -> user.equals(req.getKey())).findFirst().
+                    orElseGet(() -> {
+                        UserUR req = new UserUR.Builder(user).build();
+                        updateReqs.add(req);
+                        return req;
+                    });
+
+            groups.forEach(group -> {
+                Set<String> after = membershipsAfter.get(user);
+                if (after == null || !after.contains(group)) {
+                    userUR.getMemberships().add(new MembershipUR.Builder(group).
+                            operation(PatchOperation.DELETE).
+                            build());
+                }
+            });
+        });
+
+        String context = "PullTask " + profile.getTask().getKey() + " '" + profile.getTask().getName() + "'";
+        updateReqs.stream().filter(req -> !req.isEmpty()).forEach(req -> {
+            LOG.debug("About to update User {}", req);

Review Comment:
   ## Use of default toString()
   
   Default toString(): UserUR inherits toString() from Object, and so is not suitable for printing.
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1188)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] github-code-scanning[bot] commented on a diff in pull request #383: [SYNCOPE-1705] Encapsulating each object processing into an inner transaction

Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #383:
URL: https://github.com/apache/syncope/pull/383#discussion_r1006691739


##########
core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningActions.java:
##########
@@ -28,7 +28,7 @@
      * @param profile provisioning profile
      * @throws JobExecutionException in case of generic failure
      */
-    default void beforeAll(final ProvisioningProfile<?, ?> profile) throws JobExecutionException {
+    default void beforeAll(ProvisioningProfile<?, ?> profile) throws JobExecutionException {

Review Comment:
   ## Useless parameter
   
   The parameter 'profile' is never used.
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1189)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] ilgrosso merged pull request #383: [SYNCOPE-1705] Encapsulating each object processing into an inner transaction

Posted by GitBox <gi...@apache.org>.
ilgrosso merged PR #383:
URL: https://github.com/apache/syncope/pull/383


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org