Skip to content

[SYNCOPE-1799] Spring Data JPA drives the persistence layer #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3a7e9c2
[SYNCOPE-1799] Spring Data JPA drives the persistence layer
ilgrosso Jan 5, 2024
7787bd6
Fixing findLastChange
ilgrosso Jan 6, 2024
6d76b6c
Fix build
ilgrosso Jan 7, 2024
0695bbe
Partial revert of findLastChange
ilgrosso Jan 7, 2024
82f6e4b
Fix build
ilgrosso Jan 7, 2024
20c225e
Several fixes and improvements, but not there yet with multi-tenancy
ilgrosso Jan 8, 2024
88c13d9
Merge branch 'master' into SYNCOPE-1799
ilgrosso Jan 10, 2024
2cc1938
Merge branch 'master' into SYNCOPE-1799
ilgrosso Jan 10, 2024
1c7a39f
From DataSource routing to EntityManagerFactory routing
ilgrosso Jan 10, 2024
5baba82
Merge branch 'master' into SYNCOPE-1799
ilgrosso Jan 11, 2024
8419a47
More integration tests
ilgrosso Jan 11, 2024
1b27c40
More RepoExt refinements
ilgrosso Jan 14, 2024
69be80c
Batch now working
ilgrosso Jan 15, 2024
1fa2d64
Merge branch 'master' into SYNCOPE-1799
ilgrosso Jan 15, 2024
65e2d30
Resolved 'Could not find Implementation...' in TaskJob
ilgrosso Jan 15, 2024
c54190e
Fix Oracle
ilgrosso Jan 15, 2024
a1b8017
Introducing Pageable
ilgrosso Jan 16, 2024
065b301
Merge remote-tracking branch 'upstream/master' into SYNCOPE-1799
ilgrosso Jan 16, 2024
fb335a2
Upgrading MySQL JDBC driver and Woodstox
ilgrosso Jan 17, 2024
6d6cc36
Merge remote-tracking branch 'upstream/master' into SYNCOPE-1799
ilgrosso Jan 17, 2024
1ccb6a5
User, Group and AnyObject repo streamline
ilgrosso Jan 17, 2024
2d14cb0
Finalize removal of unneeded RepoExt
ilgrosso Jan 18, 2024
15c903f
toList()
ilgrosso Jan 18, 2024
cba53e5
Fix ES
ilgrosso Jan 18, 2024
5811608
Temporary fix ES
ilgrosso Jan 19, 2024
03d1f21
Uniform Pageable / Page management
ilgrosso Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
toList()
  • Loading branch information
ilgrosso committed Jan 18, 2024
commit 15c903f8c8134dbb7e79a902c34da83bde79e7ad
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.Serializable;
import java.time.Duration;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public abstract class AbstractLDAPConf implements Serializable {
Expand Down Expand Up @@ -336,7 +335,7 @@ public enum LdapTrustManager {
* Indicate the collection of attributes that are to be tagged and processed as binary
* attributes by the underlying search resolver.
*/
private List<String> binaryAttributes = Stream.of("objectGUID", "objectSid").collect(Collectors.toList());
private List<String> binaryAttributes = Stream.of("objectGUID", "objectSid").toList();

public String getSearchFilter() {
return searchFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import jakarta.ws.rs.QueryParam;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.types.ConflictResolutionAction;
Expand All @@ -50,7 +49,7 @@ public Builder remediation(final boolean remediation) {
}

public Builder ignoreColumns(final String... ignoreColumns) {
instance.getIgnoreColumns().addAll(Stream.of(ignoreColumns).collect(Collectors.toList()));
instance.getIgnoreColumns().addAll(Stream.of(ignoreColumns).toList());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private static void consumeHeaders(final List<BatchPayloadLine> bodyPart, final
header = new ArrayList<>();
headers.put(headerName, header);
}
header.addAll(Stream.of(headerValue.split(",")).map(String::trim).collect(Collectors.toList()));
header.addAll(Stream.of(headerValue.split(",")).map(String::trim).toList());
} else {
isHeader = false;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ public static <T extends BatchItem> List<T> parse(
bodyPart.stream().map(BatchPayloadLine::toString).collect(Collectors.joining()));

return item;
}).collect(Collectors.toList());
}).toList();
}

private BatchPayloadParser() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.syncope.common.lib.to.AttrRepoTO;
import org.apache.syncope.common.lib.types.AMEntitlement;
Expand Down Expand Up @@ -59,7 +58,7 @@ public AttrRepoTO update(final AttrRepoTO attrRepoTO) {
@PreAuthorize("hasRole('" + AMEntitlement.ATTR_REPO_LIST + "') or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
@Transactional(readOnly = true)
public List<AttrRepoTO> list() {
return attrRepoDAO.findAll().stream().map(binder::getAttrRepoTO).collect(Collectors.toList());
return attrRepoDAO.findAll().stream().map(binder::getAttrRepoTO).toList();
}

@PreAuthorize("hasRole('" + AMEntitlement.ATTR_REPO_READ + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.syncope.common.lib.to.AuthModuleTO;
import org.apache.syncope.common.lib.types.AMEntitlement;
Expand Down Expand Up @@ -59,7 +58,7 @@ public AuthModuleTO update(final AuthModuleTO authModuleTO) {
@PreAuthorize("hasRole('" + AMEntitlement.AUTH_MODULE_LIST + "') or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
@Transactional(readOnly = true)
public List<AuthModuleTO> list() {
return authModuleDAO.findAll().stream().map(binder::getAuthModuleTO).collect(Collectors.toList());
return authModuleDAO.findAll().stream().map(binder::getAuthModuleTO).toList();
}

@PreAuthorize("hasRole('" + AMEntitlement.AUTH_MODULE_READ + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.syncope.core.logic;

import java.util.List;
import java.util.stream.Collectors;
import org.apache.syncope.common.lib.to.AuthProfileTO;
import org.apache.syncope.common.lib.types.AMEntitlement;
import org.apache.syncope.core.persistence.api.dao.AuthProfileDAO;
Expand Down Expand Up @@ -77,7 +76,7 @@ public Page<AuthProfileTO> list(final Pageable pageable) {
List<AuthProfileTO> result = authProfileDAO.findAll(pageable).
stream().
map(binder::getAuthProfileTO).
collect(Collectors.toList());
toList();

return new SyncopePage<>(result, pageable, count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.syncope.common.keymaster.client.api.ServiceOps;
Expand Down Expand Up @@ -89,7 +88,7 @@ public <T extends ClientAppTO> List<T> list(final ClientAppType type) {
stream = saml2SPClientAppDAO.findAll().stream().map(binder::getClientAppTO);
}

return stream.collect(Collectors.toList());
return stream.toList();
}

protected void checkType(final ClientAppType type, final ClientAppUtils clientAppUtils) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.syncope.common.lib.to.SAML2IdPEntityTO;
import org.apache.syncope.common.lib.types.AMEntitlement;
Expand Down Expand Up @@ -48,7 +47,7 @@ public SAML2IdPEntityLogic(final SAML2IdPEntityDataBinder binder, final SAML2IdP
public List<SAML2IdPEntityTO> list() {
return saml2IdPEntityDAO.findAll().stream().
map(binder::getSAML2IdPEntityTO).
collect(Collectors.toList());
toList();
}

@PreAuthorize("hasRole('" + AMEntitlement.SAML2_IDP_ENTITY_GET + "') "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.syncope.common.lib.to.SAML2SPEntityTO;
import org.apache.syncope.common.lib.types.AMEntitlement;
Expand Down Expand Up @@ -48,7 +47,7 @@ public SAML2SPEntityLogic(final SAML2SPEntityDataBinder binder, final SAML2SPEnt
public List<SAML2SPEntityTO> list() {
return saml2SPEntityDAO.findAll().stream().
map(binder::getSAML2SPEntityTO).
collect(Collectors.toList());
toList();
}

@PreAuthorize("hasRole('" + AMEntitlement.SAML2_SP_ENTITY_GET + "') "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.transport.http.auth.DefaultBasicAuthSupplier;
Expand Down Expand Up @@ -70,7 +69,7 @@ public SRARouteLogic(

@PreAuthorize("isAuthenticated()")
public List<SRARouteTO> list() {
return routeDAO.findAll().stream().map(binder::getSRARouteTO).collect(Collectors.toList());
return routeDAO.findAll().stream().map(binder::getSRARouteTO).toList();
}

@PreAuthorize("hasRole('" + AMEntitlement.SRA_ROUTE_CREATE + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.syncope.common.lib.types.IdRepoEntitlement;
import org.apache.syncope.common.lib.wa.GoogleMfaAuthAccount;
import org.apache.syncope.core.logic.AbstractAuthProfileLogic;
Expand Down Expand Up @@ -51,7 +50,7 @@ public List<GoogleMfaAuthAccount> list() {
map(AuthProfile::getGoogleMfaAuthAccounts).
filter(Objects::nonNull).
flatMap(List::stream).
collect(Collectors.toList());
toList();
}

@PreAuthorize("hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.time.LocalDateTime;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.syncope.common.lib.types.IdRepoEntitlement;
import org.apache.syncope.common.lib.wa.GoogleMfaAuthToken;
import org.apache.syncope.core.logic.AbstractAuthProfileLogic;
Expand Down Expand Up @@ -115,7 +114,7 @@ public List<GoogleMfaAuthToken> list() {
return authProfileDAO.findAll(Pageable.unpaged()).stream().
map(AuthProfile::getGoogleMfaAuthTokens).
flatMap(List::stream).
collect(Collectors.toList());
toList();
}

@PreAuthorize("hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.builder.CompareToBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;
Expand Down Expand Up @@ -81,7 +80,7 @@ public Page<MfaTrustedDevice> search(
return null;
}).
filter(Objects::nonNull).
collect(Collectors.toList());
toList();

List<MfaTrustedDevice> devices = (principal == null
? authProfileDAO.findAll(Pageable.unpaged()).stream().
Expand All @@ -101,7 +100,7 @@ public Page<MfaTrustedDevice> search(
return builder.build();
}).
filter(Objects::nonNull).
collect(Collectors.toList());
toList();

List<MfaTrustedDevice> result = devices.stream().
limit(pageable.getPageSize()).
Expand All @@ -116,7 +115,7 @@ public Page<MfaTrustedDevice> search(
}
return 0;
}).
collect(Collectors.toList());
toList();

return new SyncopePage<>(result, pageable, devices.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.syncope.common.lib.types.ClientAppType;
import org.apache.syncope.common.lib.types.IdRepoEntitlement;
Expand Down Expand Up @@ -64,18 +63,18 @@ public List<WAClientApp> list() {
switch (type) {
case OIDCRP:
clientApps.addAll(oidcRPClientAppDAO.findAll().stream().
map(binder::getWAClientApp).collect(Collectors.toList()));
map(binder::getWAClientApp).toList());
break;

case SAML2SP:
clientApps.addAll(saml2SPClientAppDAO.findAll().stream().
map(binder::getWAClientApp).collect(Collectors.toList()));
map(binder::getWAClientApp).toList());
break;

case CASSP:
default:
clientApps.addAll(casSPClientAppDAO.findAll().stream().
map(binder::getWAClientApp).collect(Collectors.toList()));
map(binder::getWAClientApp).toList());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.transport.http.auth.DefaultBasicAuthSupplier;
import org.apache.syncope.common.keymaster.client.api.KeymasterException;
Expand Down Expand Up @@ -71,7 +70,7 @@ public WAConfigLogic(
@PreAuthorize("hasRole('" + AMEntitlement.WA_CONFIG_LIST + "') or hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
@Transactional(readOnly = true)
public List<Attr> list() {
return waConfigDAO.findAll().stream().map(binder::get).collect(Collectors.toList());
return waConfigDAO.findAll().stream().map(binder::get).toList();
}

@PreAuthorize("hasRole('" + AMEntitlement.WA_CONFIG_GET + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.syncope.core.logic.wa;

import java.util.List;
import java.util.stream.Collectors;
import org.apache.syncope.common.lib.types.IdRepoEntitlement;
import org.apache.syncope.common.lib.wa.WebAuthnAccount;
import org.apache.syncope.common.lib.wa.WebAuthnDeviceCredential;
Expand Down Expand Up @@ -49,7 +48,7 @@ public List<WebAuthnAccount> list() {
return authProfileDAO.findAll(Pageable.unpaged()).stream().
map(profile -> new WebAuthnAccount.Builder().
credentials(profile.getWebAuthnDeviceCredentials()).build()).
collect(Collectors.toList());
toList();
}

@PreAuthorize("hasRole('" + IdRepoEntitlement.ANONYMOUS + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Locale;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -156,7 +155,7 @@ public ConnInstanceTO delete(final String key) {
public List<ConnInstanceTO> list(final String lang) {
CurrentLocale.set(StringUtils.isBlank(lang) ? Locale.ENGLISH : Locale.of(lang));

return connInstanceDAO.findAll().stream().map(binder::getConnInstanceTO).collect(Collectors.toList());
return connInstanceDAO.findAll().stream().map(binder::getConnInstanceTO).toList();
}

@PreAuthorize("hasRole('" + IdMEntitlement.CONNECTOR_READ + "')")
Expand Down Expand Up @@ -197,10 +196,10 @@ public List<ConnIdBundle> getBundles(final String lang) {
ConfigurationProperties properties = connIdBundleManager.getConfigurationProperties(bundle);
connBundleTO.getProperties().addAll(properties.getPropertyNames().stream().
map(propName -> binder.build(properties.getProperty(propName))).
collect(Collectors.toList()));
toList());

return connBundleTO;
}).collect(Collectors.toList())));
}).toList()));

return connectorBundleTOs;
}
Expand Down Expand Up @@ -233,10 +232,10 @@ public List<ConnIdObjectClass> buildObjectClassInfo(
schema.setType(AttrSchemaType.getAttrSchemaTypeByClass(attrInfo.getType()));
return schema;
}).
collect(Collectors.toList()));
toList());

return connIdObjectClassTO;
}).collect(Collectors.toList());
}).toList();
}

@PreAuthorize("hasRole('" + IdMEntitlement.CONNECTOR_READ + "')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.lang.reflect.Method;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.request.AnyCR;
Expand Down Expand Up @@ -81,7 +80,7 @@ public Page<RemediationTO> list(
long count = remediationDAO.count(before, after);

List<RemediationTO> result = remediationDAO.findAll(before, after, pageable).stream().
map(binder::getRemediationTO).collect(Collectors.toList());
map(binder::getRemediationTO).toList();

return new SyncopePage<>(result, pageable, count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -275,7 +274,7 @@ public ResourceTO read(final String key) {
@PreAuthorize("hasRole('" + IdMEntitlement.RESOURCE_LIST + "')")
@Transactional(readOnly = true)
public List<ResourceTO> list() {
return resourceDAO.findAll().stream().map(binder::getResourceTO).collect(Collectors.toList());
return resourceDAO.findAll().stream().map(binder::getResourceTO).toList();
}

protected Triple<AnyType, ExternalResource, Provision> getProvision(
Expand Down
Loading