Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Jan 21, 2025
1 parent 66bc5ce commit a4e463c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;

import static org.apache.syncope.core.persistence.jpa.dao.AbstractDAO.LOG;

import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -299,7 +297,7 @@ protected String buildFrom(
final Set<String> plainSchemas,
final OrderBySupport obs) {

StringBuilder prefix = new StringBuilder(super.buildFrom(from, plainSchemas, obs));
StringBuilder clause = new StringBuilder(super.buildFrom(from, plainSchemas, obs));

Set<String> schemas = new HashSet<>(plainSchemas);

Expand All @@ -313,13 +311,13 @@ protected String buildFrom(
}

schemas.forEach(schema -> Optional.ofNullable(plainSchemaDAO.find(schema)).ifPresentOrElse(
pschema -> prefix.append(',').
pschema -> clause.append(',').
append("jsonb_path_query_array(plainattrs, '$[*] ? (@.schema==\"").
append(schema).append("\").").
append("\"").append(pschema.isUniqueConstraint() ? "uniqueValue" : "values").append("\"')").
append(" AS ").append(schema),
() -> LOG.warn("Ignoring invalid schema '{}'", schema)));

return prefix.toString();
return clause.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@

# See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
# Possible values: "trace", "debug", "info", "warn", or "error"
org.slf4j.simpleLogger.showDateTime=true
org.slf4j.simpleLogger.dateTimeFormat=YYYY-mm-dd HH:mm:ss.SSS
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.log.org.springframework.jdbc.core.JdbcTemplate=error
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
# Possible values: "trace", "debug", "info", "warn", or "error"
org.slf4j.simpleLogger.showDateTime=true
org.slf4j.simpleLogger.dateTimeFormat=YYYY-mm-dd HH:mm:ss.SSS
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.log.org.springframework.jdbc.core.JdbcTemplate=error

Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@

# See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
# Possible values: "trace", "debug", "info", "warn", or "error"
org.slf4j.simpleLogger.showDateTime=true
org.slf4j.simpleLogger.dateTimeFormat=YYYY-mm-dd HH:mm:ss.SSS
org.slf4j.simpleLogger.defaultLogLevel=debug

Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,11 @@ protected static void populateTransitiveResources(
PropagationByResource<String> propByRes = new PropagationByResource<>();
group.getResources().forEach(resource -> {
// exclude from propagation those objects that have that resource assigned by some other membership(s)
if (!any.getResources().contains(resource) && any.getMemberships().stream()
.filter(otherGrpMemb -> !otherGrpMemb.getRightEnd().equals(group))
.noneMatch(otherGrpMemb -> otherGrpMemb.getRightEnd().getResources().stream()
.anyMatch(r -> resource.getKey().equals(r.getKey())))) {
if (!any.getResources().contains(resource)
&& any.getMemberships().stream().
filter(m -> !m.getRightEnd().equals(group)).
noneMatch(m -> m.getRightEnd().getResources().contains(resource))) {

propByRes.add(ResourceOperation.DELETE, resource.getKey());
}

Expand Down
3 changes: 2 additions & 1 deletion ext/scimv2/logic/src/test/resources/simplelogger.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@

# See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
# Possible values: "trace", "debug", "info", "warn", or "error"
org.slf4j.simpleLogger.showDateTime=true
org.slf4j.simpleLogger.dateTimeFormat=YYYY-mm-dd HH:mm:ss.SSS
org.slf4j.simpleLogger.defaultLogLevel=debug

Original file line number Diff line number Diff line change
Expand Up @@ -1831,51 +1831,54 @@ void issueSYNCOPE1818() {
void issueSYNCOPE1853() {
GroupTO cGroupForPropagation = createGroup(
new GroupCR.Builder(SyncopeConstants.ROOT_REALM, "cGroupForPropagation")
.resource(RESOURCE_NAME_LDAP)
.build()).getEntity();
.resource(RESOURCE_NAME_LDAP).build()).getEntity();
GroupTO dGroupForPropagation = createGroup(
new GroupCR.Builder(SyncopeConstants.ROOT_REALM, "dGroupForPropagation")
.resource(RESOURCE_NAME_LDAP)
.build()).getEntity();
.resource(RESOURCE_NAME_LDAP).build()).getEntity();

// 1. assign both groups cGroupForPropagation and dGroupForPropagation with resource-csv to bellini
updateUser(new UserUR.Builder("c9b2dec2-00a7-4855-97c0-d854842b4b24").memberships(
new MembershipUR.Builder(cGroupForPropagation.getKey()).build(),
new MembershipUR.Builder(dGroupForPropagation.getKey()).build()).build());
// 2. assign cGroupForPropagation also to vivaldi
updateUser(new UserUR.Builder("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee").membership(
new MembershipUR.Builder(dGroupForPropagation.getKey()).build()).build());

// 3. propagation tasks cleanup
TASK_SERVICE.search(
new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("c9b2dec2-00a7-4855-97c0-d854842b4b24")
.build()).getResult()
new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("c9b2dec2-00a7-4855-97c0-d854842b4b24")
.build()).getResult()
.forEach(pt -> TASK_SERVICE.delete(TaskType.PROPAGATION, pt.getKey()));
TASK_SERVICE.search(
new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee")
.build()).getResult()
new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee")
.build()).getResult()
.forEach(pt -> TASK_SERVICE.delete(TaskType.PROPAGATION, pt.getKey()));

// 4. delete group cGroupForPropagation: no deprovision should be fired on bellini, since there is already
// bGroupForPropagation, deprovision instead must be fired for vivaldi
GROUP_SERVICE.delete(cGroupForPropagation.getKey());
await().during(5, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS).until(() -> TASK_SERVICE.search(
new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("c9b2dec2-00a7-4855-97c0-d854842b4b24").build())
await().during(MAX_WAIT_SECONDS, TimeUnit.SECONDS).atMost(MAX_WAIT_SECONDS, TimeUnit.SECONDS)
.until(() -> TASK_SERVICE.search(new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("c9b2dec2-00a7-4855-97c0-d854842b4b24").build())
.getResult().stream().map(PropagationTaskTO.class::cast)
.collect(Collectors.toList()).stream().noneMatch(pt -> ResourceOperation.DELETE == pt.getOperation()));
.collect(Collectors.toList()).stream()
.noneMatch(pt -> ResourceOperation.DELETE == pt.getOperation()));
GROUP_SERVICE.delete(dGroupForPropagation.getKey());
await().atMost(10, TimeUnit.SECONDS).until(() -> TASK_SERVICE.search(
new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee").build())
await().atMost(MAX_WAIT_SECONDS, TimeUnit.SECONDS)
.until(() -> TASK_SERVICE.search(new TaskQuery.Builder(TaskType.PROPAGATION)
.anyTypeKind(AnyTypeKind.USER)
.resource(RESOURCE_NAME_LDAP)
.entityKey("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee").build())
.getResult().stream().map(PropagationTaskTO.class::cast)
.collect(Collectors.toList()).stream().anyMatch(pt -> ResourceOperation.DELETE == pt.getOperation()));
.collect(Collectors.toList()).stream()
.anyMatch(pt -> ResourceOperation.DELETE == pt.getOperation()));
}
}

0 comments on commit a4e463c

Please sign in to comment.