Skip to content

Commit

Permalink
Upgrading Spring Boot, Groovy and commons-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Jan 20, 2024
1 parent 682d7d1 commit 4a9cfb1
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<String> binaryAttributes = Stream.of("objectGUID", "objectSid").toList();
private List<String> binaryAttributes = Stream.of("objectGUID", "objectSid").collect(Collectors.toList());

public String getSearchFilter() {
return searchFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,24 +638,24 @@ public List<ProvisioningReport> 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);
}
});

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.Optional;
import org.apache.commons.lang3.tuple.Triple;
import org.apache.syncope.common.lib.to.EntityTO;
import org.apache.syncope.common.lib.to.JobTO;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ public ProvisioningResult<AnyObjectTO> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public List<MailTemplateTO> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,11 @@ protected ProvisioningResult<UserTO> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public PagedResult<TO> search(final AnyQuery anyQuery) {
: getSearchCond(anyQuery.getFiql(), realm);
try {
Page<TO> result = getAnyLogic().search(
searchCond, pageable(anyQuery),
searchCond,
pageable(anyQuery),
realm,
anyQuery.getRecursive(),
anyQuery.getDetails());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public interface DAO<E extends Entity> {

Sort DEFAULT_SORT = Sort.by("id");

boolean existsById(String key);

Optional<? extends E> findById(String key);

long count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Batch> findById(final String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends JobStatus> findById(final String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public JPAPolicyDAO(
this.entityManager = entityManager;
}

@Override
public boolean existsById(final String key) {
return findById(key).isPresent();
}

@Override
public Optional<? extends Policy> findById(final String key) {
return Optional.ofNullable(entityManager.find(AbstractPolicy.class, key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public JPATaskExecDAO(
this.entityManager = entityManager;
}

@Override
public boolean existsById(final String key) {
return findById(key).isPresent();
}

@Override
@SuppressWarnings("unchecked")
public <T extends Task<T>> Optional<TaskExec<T>> findById(final TaskType type, final String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected <T extends Policy> 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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -151,7 +151,7 @@ protected UserRequest getUserRequest(final ProcessInstance procInst) {
@Override
public Page<UserRequest> 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");
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,14 @@ under the License.
<bouncycastle.version>1.77</bouncycastle.version>
<nimbus-jose-jwt.version>9.37.3</nimbus-jose-jwt.version>

<spring-boot.version>3.2.1</spring-boot.version>
<spring-boot.version>3.2.2</spring-boot.version>
<spring-cloud-gateway.version>4.1.0</spring-cloud-gateway.version>

<openjpa.version>4.0.0-SNAPSHOT</openjpa.version>

<jasypt.version>1.9.3</jasypt.version>

<groovy.version>5.0.0-alpha-4</groovy.version>
<groovy.version>5.0.0-alpha-5</groovy.version>

<flowable.version>7.0.1</flowable.version>
<flowable-old.version>6.8.0</flowable-old.version>
Expand Down Expand Up @@ -1159,7 +1159,7 @@ under the License.
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<version>1.3.0</version>
<scope>provided</scope>
</dependency>

Expand Down

0 comments on commit 4a9cfb1

Please sign in to comment.