diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/AbstractLDAPConf.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/AbstractLDAPConf.java index f462dd199b..8b6c8f2fec 100644 --- a/common/am/lib/src/main/java/org/apache/syncope/common/lib/AbstractLDAPConf.java +++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/AbstractLDAPConf.java @@ -21,6 +21,7 @@ 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 { @@ -335,7 +336,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 binaryAttributes = Stream.of("objectGUID", "objectSid").toList(); + private List binaryAttributes = Stream.of("objectGUID", "objectSid").collect(Collectors.toList()); public String getSearchFilter() { return searchFilter; diff --git a/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java b/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java index fb2963a1bf..224e33fd64 100644 --- a/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java +++ b/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java @@ -638,24 +638,24 @@ public List push( } }); spec.getPlainAttrs().forEach(item -> { - if (plainSchemaDAO.findById(item) == null) { - LOG.warn("Ignoring invalid plain schema {}", item); - } else { + if (plainSchemaDAO.existsById(item)) { columns.add(item); + } else { + LOG.warn("Ignoring invalid plain schema {}", item); } }); spec.getDerAttrs().forEach(item -> { - if (derSchemaDAO.findById(item) == null) { - LOG.warn("Ignoring invalid derived schema {}", item); - } else { + if (derSchemaDAO.existsById(item)) { columns.add(item); + } else { + LOG.warn("Ignoring invalid derived schema {}", item); } }); - spec.getVirAttrs().forEach(item -> { - if (virSchemaDAO.findById(item) == null) { - LOG.warn("Ignoring invalid virtual schema {}", item); - } else { + spec.getDerAttrs().forEach(item -> { + if (virSchemaDAO.existsById(item)) { columns.add(item); + } else { + LOG.warn("Ignoring invalid virtual schema {}", item); } }); diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractJobLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractJobLogic.java index 2f3c1e7f61..dbf699c289 100644 --- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractJobLogic.java +++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractJobLogic.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Optional; import org.apache.commons.lang3.tuple.Triple; import org.apache.syncope.common.lib.to.EntityTO; import org.apache.syncope.common.lib.to.JobTO; @@ -101,8 +100,7 @@ protected JobTO getJobTO(final JobKey jobKey, final boolean includeCustom) throw jobTO.setStatus("UNKNOWN"); if (jobTO.isRunning()) { try { - jobTO.setStatus(Optional.ofNullable(jobStatusDAO.findById(jobTO.getRefDesc())). - filter(Optional::isPresent).map(Optional::get). + jobTO.setStatus(jobStatusDAO.findById(jobTO.getRefDesc()). map(JobStatus::getStatus). orElse(jobTO.getStatus())); } catch (NoSuchBeanDefinitionException e) { diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java index 3fef491872..162ba001b9 100644 --- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java +++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java @@ -216,11 +216,11 @@ public ProvisioningResult delete(final String key, final boolean nu before.getLeft().getKey(), nullPriorityAsync, AuthContextUtils.getUsername(), REST_CONTEXT); AnyObjectTO deletedTO; - if (anyObjectDAO.findById(before.getLeft().getKey()).isEmpty()) { + if (anyObjectDAO.existsById(before.getLeft().getKey())) { + deletedTO = binder.getAnyObjectTO(before.getLeft().getKey()); + } else { deletedTO = new AnyObjectTO(); deletedTO.setKey(before.getLeft().getKey()); - } else { - deletedTO = binder.getAnyObjectTO(before.getLeft().getKey()); } return afterDelete(deletedTO, statuses, before.getRight()); diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java index 90cc07fddc..03e7f3e302 100644 --- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java +++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java @@ -67,7 +67,7 @@ public AnyTypeClassTO create(final AnyTypeClassTO anyTypeClassTO) { sce.getElements().add(AnyTypeClass.class.getSimpleName() + " name"); throw sce; } - if (anyTypeClassDAO.findById(anyTypeClassTO.getKey()).isPresent()) { + if (anyTypeClassDAO.existsById(anyTypeClassTO.getKey())) { throw new DuplicateException(anyTypeClassTO.getKey()); } return binder.getAnyTypeClassTO(anyTypeClassDAO.save(binder.create(anyTypeClassTO))); diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java index d7da3bfa4a..8592dbaa52 100644 --- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java +++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java @@ -76,7 +76,7 @@ public AnyTypeTO create(final AnyTypeTO anyTypeTO) { sce.getElements().add(AnyType.class.getSimpleName() + " key"); throw sce; } - if (anyTypeDAO.findById(anyTypeTO.getKey()).isPresent()) { + if (anyTypeDAO.existsById(anyTypeTO.getKey())) { throw new DuplicateException(anyTypeTO.getKey()); } diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/ImplementationLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/ImplementationLogic.java index 27358b52ea..db2d83a518 100644 --- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/ImplementationLogic.java +++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/ImplementationLogic.java @@ -130,7 +130,7 @@ public ImplementationTO create(final ImplementationTO implementationTO) { checkType(implementationTO.getType()); - if (implementationDAO.findById(implementationTO.getKey()).isPresent()) { + if (implementationDAO.existsById(implementationTO.getKey())) { throw new DuplicateException(implementationTO.getKey()); } diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/MailTemplateLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/MailTemplateLogic.java index 918a53b9db..61f309b139 100644 --- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/MailTemplateLogic.java +++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/MailTemplateLogic.java @@ -79,7 +79,7 @@ public List list() { @PreAuthorize("hasRole('" + IdRepoEntitlement.MAIL_TEMPLATE_CREATE + "')") public MailTemplateTO create(final String key) { - if (mailTemplateDAO.findById(key).isPresent()) { + if (mailTemplateDAO.existsById(key)) { throw new DuplicateException(key); } diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java index d7d22e2682..131bc93851 100644 --- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java +++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java @@ -499,11 +499,11 @@ protected ProvisioningResult doDelete( before.getLeft().getKey(), nullPriorityAsync, AuthContextUtils.getUsername(), REST_CONTEXT); UserTO deletedTO; - if (userDAO.findById(before.getLeft().getKey()).isEmpty()) { + if (userDAO.existsById(before.getLeft().getKey())) { + deletedTO = binder.getUserTO(before.getLeft().getKey()); + } else { deletedTO = new UserTO(); deletedTO.setKey(before.getLeft().getKey()); - } else { - deletedTO = binder.getUserTO(before.getLeft().getKey()); } return afterDelete(deletedTO, statuses, before.getRight()); diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java index 9a10a50227..44f38f43f6 100644 --- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java +++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java @@ -127,7 +127,8 @@ public PagedResult search(final AnyQuery anyQuery) { : getSearchCond(anyQuery.getFiql(), realm); try { Page result = getAnyLogic().search( - searchCond, pageable(anyQuery), + searchCond, + pageable(anyQuery), realm, anyQuery.getRecursive(), anyQuery.getDetails()); diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SyncopeServiceImpl.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SyncopeServiceImpl.java index d275f07919..3a3af2b3ac 100644 --- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SyncopeServiceImpl.java +++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SyncopeServiceImpl.java @@ -118,7 +118,7 @@ public Response batch(final InputStream input) { MediaType mediaType = MediaType.valueOf(messageContext.getHttpServletRequest().getContentType()); String boundary = mediaType.getParameters().get(RESTHeaders.BOUNDARY_PARAMETER); - if (batchDAO.findById(boundary).isPresent()) { + if (batchDAO.existsById(boundary)) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.EntityExists); sce.getElements().add("Batch with boundary " + boundary + " already processing"); throw sce; diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DAO.java index 3096d5b6ef..61b48c6d9b 100644 --- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DAO.java +++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DAO.java @@ -27,6 +27,8 @@ public interface DAO { Sort DEFAULT_SORT = Sort.by("id"); + boolean existsById(String key); + Optional findById(String key); long count(); diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPABatchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPABatchDAO.java index 2cdfcf9217..42e902da0d 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPABatchDAO.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPABatchDAO.java @@ -38,6 +38,12 @@ public JPABatchDAO(final EntityManager entityManager) { this.entityManager = entityManager; } + @Transactional(readOnly = true) + @Override + public boolean existsById(final String key) { + return findById(key).isPresent(); + } + @Transactional(readOnly = true) @Override public Optional findById(final String key) { diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAJobStatusDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAJobStatusDAO.java index ec9e4bd288..f9a7b70795 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAJobStatusDAO.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAJobStatusDAO.java @@ -37,6 +37,11 @@ public JPAJobStatusDAO(final EntityManager entityManager) { this.entityManager = entityManager; } + @Override + public boolean existsById(final String key) { + return findById(key).isPresent(); + } + @Transactional(readOnly = true) @Override public Optional findById(final String key) { diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java index c8ad23bbac..dbc0c5b389 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java @@ -115,6 +115,11 @@ public JPAPolicyDAO( this.entityManager = entityManager; } + @Override + public boolean existsById(final String key) { + return findById(key).isPresent(); + } + @Override public Optional findById(final String key) { return Optional.ofNullable(entityManager.find(AbstractPolicy.class, key)); diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java index 0a43101e4b..c5fb007e3e 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java @@ -98,6 +98,11 @@ public JPATaskDAO( this.entityManager = entityManager; } + @Override + public boolean existsById(final String key) { + return findById(key).isPresent(); + } + @Transactional(readOnly = true) @Override @SuppressWarnings("unchecked") diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java index a5b8aff1b3..214f7fb207 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java @@ -58,6 +58,11 @@ public JPATaskExecDAO( this.entityManager = entityManager; } + @Override + public boolean existsById(final String key) { + return findById(key).isPresent(); + } + @Override @SuppressWarnings("unchecked") public > Optional> findById(final TaskType type, final String key) { diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java index 2b7aade383..bc1a8744fc 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/PolicyDataBinderImpl.java @@ -98,7 +98,7 @@ protected T getPolicy(final T policy, final PolicyTO policyTO passwordPolicyTO.getRules().forEach(ruleKey -> implementationDAO.findById(ruleKey).ifPresentOrElse( passwordPolicy::add, - () -> LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", ruleKey))); + () -> LOG.debug("Invalid {} {}, ignoring...", Implementation.class.getSimpleName(), ruleKey))); // remove all implementations not contained in the TO passwordPolicy.getRules(). removeIf(implementation -> !passwordPolicyTO.getRules().contains(implementation.getKey())); diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java index 58fdc23560..fba2654b40 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java @@ -119,7 +119,7 @@ private Provision provision( columns.stream(). filter(column -> anyUtils.getField(column) != null - || plainSchemaDAO.findById(column).isPresent() || virSchemaDAO.findById(column).isPresent()). + || plainSchemaDAO.existsById(column) || virSchemaDAO.existsById(column)). map(column -> { Item item = new Item(); item.setExtAttrName(column); diff --git a/core/self-keymaster-starter/src/main/java/org/apache/syncope/core/logic/DomainLogic.java b/core/self-keymaster-starter/src/main/java/org/apache/syncope/core/logic/DomainLogic.java index 87d9beb836..fc1ff5ca0c 100644 --- a/core/self-keymaster-starter/src/main/java/org/apache/syncope/core/logic/DomainLogic.java +++ b/core/self-keymaster-starter/src/main/java/org/apache/syncope/core/logic/DomainLogic.java @@ -71,7 +71,7 @@ public Domain create(final Domain domain) { throw new KeymasterException("Cannot create domain " + SyncopeConstants.MASTER_DOMAIN); } - if (domainDAO.findById(domain.getKey()).isPresent()) { + if (domainDAO.existsById(domain.getKey())) { throw new DuplicateException("Domain " + domain.getKey() + " already existing"); } diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java index 83cd1c9376..ae56ebb639 100644 --- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java +++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java @@ -124,8 +124,8 @@ protected StringBuilder createProcessInstanceQuery(final String userKey) { return query; } - protected int countProcessInstances(final StringBuilder processInstanceQuery) { - return (int) engine.getRuntimeService().createNativeProcessInstanceQuery(). + protected long countProcessInstances(final StringBuilder processInstanceQuery) { + return engine.getRuntimeService().createNativeProcessInstanceQuery(). sql("SELECT COUNT(ID_) FROM " + StringUtils.substringAfter(processInstanceQuery.toString(), " FROM ")). count(); @@ -151,7 +151,7 @@ protected UserRequest getUserRequest(final ProcessInstance procInst) { @Override public Page getUserRequests(final String userKey, final Pageable pageable) { StringBuilder query = createProcessInstanceQuery(userKey); - Integer count = countProcessInstances(query); + long count = countProcessInstances(query); if (!pageable.getSort().isEmpty()) { query.append(" ORDER BY"); diff --git a/pom.xml b/pom.xml index 5ae7de58b2..88c081078a 100644 --- a/pom.xml +++ b/pom.xml @@ -413,14 +413,14 @@ under the License. 1.77 9.37.3 - 3.2.1 + 3.2.2 4.1.0 4.0.0-SNAPSHOT 1.9.3 - 5.0.0-alpha-4 + 5.0.0-alpha-5 7.0.1 6.8.0 @@ -1159,7 +1159,7 @@ under the License. commons-logging commons-logging - 1.2 + 1.3.0 provided