Commit 0d222104 authored by Maxym Borodenko's avatar Maxym Borodenko

Upgrade to Spring Data JPA 2.2.5 and Hibernate 5.4

parent c83715cf
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId> <artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version> <version>${hibernate.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
......
...@@ -22,7 +22,7 @@ import org.genesys.blocks.auditlog.model.AuditLog; ...@@ -22,7 +22,7 @@ import org.genesys.blocks.auditlog.model.AuditLog;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
...@@ -31,7 +31,7 @@ import org.springframework.stereotype.Repository; ...@@ -31,7 +31,7 @@ import org.springframework.stereotype.Repository;
* @author Matija Obreza * @author Matija Obreza
*/ */
@Repository @Repository
public interface AuditLogRepository extends AuditLogCustomRepository, JpaRepository<AuditLog, Long>, QueryDslPredicateExecutor<AuditLog> { public interface AuditLogRepository extends AuditLogCustomRepository, JpaRepository<AuditLog, Long>, QuerydslPredicateExecutor<AuditLog> {
/** /**
* List audit log entries in descending order (most recent first). * List audit log entries in descending order (most recent first).
......
...@@ -69,7 +69,7 @@ public class AuditLogRepositoryCustomImpl implements AuditLogCustomRepository { ...@@ -69,7 +69,7 @@ public class AuditLogRepositoryCustomImpl implements AuditLogCustomRepository {
*/ */
@Override @Override
public AuditLog getLastAuditLog(final EntityId entity) { public AuditLog getLastAuditLog(final EntityId entity) {
final List<AuditLog> l = repository.listAuditLogs(entity.getClass().getName(), entity.getId(), new PageRequest(0, 1)); final List<AuditLog> l = repository.listAuditLogs(entity.getClass().getName(), entity.getId(), PageRequest.of(0, 1));
return (l == null) || l.isEmpty() ? null : l.get(0); return (l == null) || l.isEmpty() ? null : l.get(0);
} }
...@@ -80,7 +80,7 @@ public class AuditLogRepositoryCustomImpl implements AuditLogCustomRepository { ...@@ -80,7 +80,7 @@ public class AuditLogRepositoryCustomImpl implements AuditLogCustomRepository {
*/ */
@Override @Override
public AuditLog getLastAuditLog(final EntityId entity, final String propertyName) { public AuditLog getLastAuditLog(final EntityId entity, final String propertyName) {
final List<AuditLog> l = repository.listAuditLogs(entity.getClass().getName(), entity.getId(), propertyName, new PageRequest(0, 1)); final List<AuditLog> l = repository.listAuditLogs(entity.getClass().getName(), entity.getId(), propertyName, PageRequest.of(0, 1));
return (l == null) || l.isEmpty() ? null : l.get(0); return (l == null) || l.isEmpty() ? null : l.get(0);
} }
......
...@@ -72,7 +72,7 @@ public class AuditTrailServiceImpl implements AuditTrailService { ...@@ -72,7 +72,7 @@ public class AuditTrailServiceImpl implements AuditTrailService {
@Override @Override
@Transactional(isolation = Isolation.READ_UNCOMMITTED, propagation = Propagation.REQUIRED) @Transactional(isolation = Isolation.READ_UNCOMMITTED, propagation = Propagation.REQUIRED)
public List<AuditLog> addAuditLogs(final Set<TransactionAuditLog> auditLogs) { public List<AuditLog> addAuditLogs(final Set<TransactionAuditLog> auditLogs) {
return auditLogRepository.save(auditLogs.stream().map(tlog -> toAuditLog(tlog)).collect(Collectors.toList())); return auditLogRepository.saveAll(auditLogs.stream().map(tlog -> toAuditLog(tlog)).collect(Collectors.toList()));
} }
/* /*
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package org.genesys.blocks.auditlog.service.impl; package org.genesys.blocks.auditlog.service.impl;
import java.util.Optional;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import org.genesys.blocks.auditlog.service.ClassPKService; import org.genesys.blocks.auditlog.service.ClassPKService;
...@@ -96,8 +98,8 @@ public class ClassPKServiceImpl implements ClassPKService { ...@@ -96,8 +98,8 @@ public class ClassPKServiceImpl implements ClassPKService {
@Override @Override
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRES_NEW) @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRES_NEW)
public String getClassName(final Long id) { public String getClassName(final Long id) {
final ClassPK classPK = classPkRepository.findOne(id); Optional<ClassPK> classPK = classPkRepository.findById(id);
return classPK.getClassname(); return classPK.map(ClassPK::getClassname).orElse(null);
} }
/* /*
......
...@@ -71,7 +71,7 @@ public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository> ...@@ -71,7 +71,7 @@ public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository>
repository.save(log); repository.save(log);
assertThat(log.getId(), not(nullValue())); assertThat(log.getId(), not(nullValue()));
final AuditLog l = repository.findOne(log.getId()); final AuditLog l = repository.findById(log.getId()).orElse(null);
assertThat(l, not(nullValue())); assertThat(l, not(nullValue()));
assertThat(l.getId(), equalTo(log.getId())); assertThat(l.getId(), equalTo(log.getId()));
assertThat(l.getClassPk(), not(nullValue())); assertThat(l.getClassPk(), not(nullValue()));
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.genesys.blocks.auditlog.model; package org.genesys.blocks.auditlog.model;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import org.genesys.blocks.auditlog.test.EntityTest; import org.genesys.blocks.auditlog.test.EntityTest;
...@@ -60,7 +61,8 @@ public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> { ...@@ -60,7 +61,8 @@ public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> {
public void successfulPersist() { public void successfulPersist() {
final ClassPK cpk = repository.save(makeClassPK(Long.class)); final ClassPK cpk = repository.save(makeClassPK(Long.class));
final ClassPK l = repository.findOne(cpk.getId()); final ClassPK l = repository.findById(cpk.getId()).orElse(null);
assertThat(l, notNullValue());
assertThat(l.getId(), equalTo(cpk.getId())); assertThat(l.getId(), equalTo(cpk.getId()));
assertThat(l.getClassname(), equalTo(cpk.getClassname())); assertThat(l.getClassname(), equalTo(cpk.getClassname()));
} }
......
...@@ -64,7 +64,7 @@ public class ExampleAuditedEntityServiceImpl implements ExampleAuditedEntityServ ...@@ -64,7 +64,7 @@ public class ExampleAuditedEntityServiceImpl implements ExampleAuditedEntityServ
@Override @Override
public ExampleAuditedEntity get(Long id) { public ExampleAuditedEntity get(Long id) {
return exampleAuditedEntityRepository.findOne(id); return exampleAuditedEntityRepository.findById(id).orElse(null);
} }
} }
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId> <artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version> <version>${hibernate.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
......
...@@ -40,14 +40,15 @@ ...@@ -40,14 +40,15 @@
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version> <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<jackson.version>2.9.8</jackson.version> <jackson.version>2.10.1</jackson.version>
<spring.version>4.3.22.RELEASE</spring.version> <spring.version>5.2.4.RELEASE</spring.version>
<spring.data.version>1.11.18.RELEASE</spring.data.version> <spring.data.version>2.2.5.RELEASE</spring.data.version>
<spring.security.oauth2.version>2.3.3.RELEASE</spring.security.oauth2.version> <spring.security.oauth2.version>2.3.4.RELEASE</spring.security.oauth2.version>
<querydsl.version>4.1.4</querydsl.version> <querydsl.version>4.2.1</querydsl.version>
<spring.security.version>4.2.11.RELEASE</spring.security.version> <spring.security.version>5.2.2.RELEASE</spring.security.version>
<hibernate.version>5.2.17.Final</hibernate.version> <!--<hibernate.version>5.3.15.Final</hibernate.version>-->
<hsqldb.version>2.4.1</hsqldb.version> <hibernate.version>5.4.12.Final</hibernate.version>
<hsqldb.version>2.5.0</hsqldb.version>
<tomcat-jdbc.version>8.5.8</tomcat-jdbc.version> <tomcat-jdbc.version>8.5.8</tomcat-jdbc.version>
</properties> </properties>
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId> <artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version> <version>${hibernate.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
...@@ -104,6 +104,13 @@ ...@@ -104,6 +104,13 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
...@@ -139,6 +146,13 @@ ...@@ -139,6 +146,13 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId> <artifactId>spring-aspects</artifactId>
......
...@@ -19,14 +19,14 @@ import org.genesys.blocks.oauth.model.OAuthClient; ...@@ -19,14 +19,14 @@ import org.genesys.blocks.oauth.model.OAuthClient;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
* The Interface OAuthClientRepository. * The Interface OAuthClientRepository.
*/ */
@Repository @Repository
public interface OAuthClientRepository extends JpaRepository<OAuthClient, Long>, QueryDslPredicateExecutor<OAuthClient> { public interface OAuthClientRepository extends JpaRepository<OAuthClient, Long>, QuerydslPredicateExecutor<OAuthClient> {
/** /**
* Find by client id. * Find by client id.
......
...@@ -97,7 +97,7 @@ public class OAuthServiceImpl implements OAuthClientDetailsService { ...@@ -97,7 +97,7 @@ public class OAuthServiceImpl implements OAuthClientDetailsService {
*/ */
@Override @Override
public List<OAuthClient> listClientDetails() { public List<OAuthClient> listClientDetails() {
return oauthClientRepository.findAll(new Sort("clientId")); return oauthClientRepository.findAll(Sort.by("clientId"));
} }
@Override @Override
...@@ -212,14 +212,14 @@ public class OAuthServiceImpl implements OAuthClientDetailsService { ...@@ -212,14 +212,14 @@ public class OAuthServiceImpl implements OAuthClientDetailsService {
// description contains // description contains
.or(QOAuthClient.oAuthClient.description.contains(term)); .or(QOAuthClient.oAuthClient.description.contains(term));
return oauthClientRepository.findAll(predicate, new PageRequest(0, Math.min(100, limit), new Sort("title"))).getContent(); return oauthClientRepository.findAll(predicate, PageRequest.of(0, Math.min(100, limit), Sort.by("title"))).getContent();
} }
@Override @Override
@Transactional @Transactional
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#oauthClient, 'ADMINISTRATION')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#oauthClient, 'ADMINISTRATION')")
public final String resetSecret(OAuthClient oauthClient) { public final String resetSecret(OAuthClient oauthClient) {
oauthClient = oauthClientRepository.findOne(oauthClient.getId()); oauthClient = oauthClientRepository.findById(oauthClient.getId()).orElse(oauthClient);
String oldHash = oauthClient.getClientSecret(); String oldHash = oauthClient.getClientSecret();
String newHash = null; String newHash = null;
...@@ -238,7 +238,7 @@ public class OAuthServiceImpl implements OAuthClientDetailsService { ...@@ -238,7 +238,7 @@ public class OAuthServiceImpl implements OAuthClientDetailsService {
@Transactional @Transactional
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#oauthClient, 'ADMINISTRATION')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#oauthClient, 'ADMINISTRATION')")
public final OAuthClient removeSecret(OAuthClient oauthClient) { public final OAuthClient removeSecret(OAuthClient oauthClient) {
oauthClient = oauthClientRepository.findOne(oauthClient.getId()); oauthClient = oauthClientRepository.findById(oauthClient.getId()).orElse(oauthClient);
if (oauthClient.getAuthorizedGrantTypes().contains("client_credentials")) { if (oauthClient.getAuthorizedGrantTypes().contains("client_credentials")) {
throw new RuntimeException("OAuth Client with client_credentials grant must have a secret"); throw new RuntimeException("OAuth Client with client_credentials grant must have a secret");
} }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package org.genesys.blocks.security; package org.genesys.blocks.security;
import java.util.Optional;
import org.genesys.blocks.security.model.AclSid; import org.genesys.blocks.security.model.AclSid;
import org.genesys.blocks.security.service.CustomAclService; import org.genesys.blocks.security.service.CustomAclService;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -42,22 +44,22 @@ public class SpringSecurityAuditorAware implements AuditorAware<Long> { ...@@ -42,22 +44,22 @@ public class SpringSecurityAuditorAware implements AuditorAware<Long> {
* @see org.springframework.data.domain.AuditorAware#getCurrentAuditor() * @see org.springframework.data.domain.AuditorAware#getCurrentAuditor()
*/ */
@Override @Override
public Long getCurrentAuditor() { public Optional<Long> getCurrentAuditor() {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) { if (authentication != null) {
Object principal = authentication.getPrincipal(); Object principal = authentication.getPrincipal();
if (principal instanceof AclSid) { if (principal instanceof AclSid) {
return ((AclSid) principal).getId(); return Optional.of(((AclSid) principal).getId());
} else if (principal instanceof String) { } else if (principal instanceof String) {
return aclService.getSidId((String) principal); return Optional.of(aclService.getSidId((String) principal));
} else { } else {
LOG.warn("Principal {} is not AclSid, but type {}. Auth of type {}", principal, principal.getClass(), authentication.getClass()); LOG.warn("Principal {} is not AclSid, but type {}. Auth of type {}", principal, principal.getClass(), authentication.getClass());
} }
} }
LOG.info("No security principal available."); LOG.info("No security principal available.");
return null; return Optional.empty();
} }
} }
...@@ -60,7 +60,7 @@ public class AclAssignerAspect { ...@@ -60,7 +60,7 @@ public class AclAssignerAspect {
* @param result the result * @param result the result
* @return the object * @return the object
*/ */
@AfterReturning(pointcut = "execution(* org.springframework.data.repository.*.save(..)) || execution(* org.springframework.data.jpa.repository.*.save(..)) || execution(* org.springframework.data.jpa.repository.*.saveAndFlush(..))", returning = "result") @AfterReturning(pointcut = "execution(* org.springframework.data.repository.*.save(..)) || execution(* org.springframework.data.repository.*.saveAll(..)) || execution(* org.springframework.data.jpa.repository.*.save(..)) || execution(* org.springframework.data.jpa.repository.*.saveAndFlush(..))", returning = "result")
public Object afterSaveAclObject(final Object result) { public Object afterSaveAclObject(final Object result) {
final Authentication auth = SecurityContextHolder.getContext().getAuthentication(); final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
...@@ -99,8 +99,11 @@ public class AclAssignerAspect { ...@@ -99,8 +99,11 @@ public class AclAssignerAspect {
* *
* @param joinPoint the join point * @param joinPoint the join point
*/ */
@Before("execution(* org.springframework.data.repository.*.delete(..)) || execution(* org.springframework.data.jpa.repository.*.deleteInBatch(..))") @Before("execution(* org.springframework.data.repository.*.delete(..)) || execution(* org.springframework.data.repository.*.deleteAll(..)) || execution(* org.springframework.data.jpa.repository.*.deleteInBatch(..))")
public void afterDeleteAclObject(final JoinPoint joinPoint) { public void afterDeleteAclObject(final JoinPoint joinPoint) {
if (joinPoint.getArgs().length == 0) {
return;
}
final Object arg0 = joinPoint.getArgs()[0]; final Object arg0 = joinPoint.getArgs()[0];
try { try {
......
...@@ -21,13 +21,13 @@ import org.genesys.blocks.security.model.AclObjectIdentity; ...@@ -21,13 +21,13 @@ import org.genesys.blocks.security.model.AclObjectIdentity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
/** /**
* The Interface AclObjectIdentityPersistence. * The Interface AclObjectIdentityPersistence.
*/ */
public interface AclObjectIdentityPersistence extends JpaRepository<AclObjectIdentity, Long>, QueryDslPredicateExecutor<AclObjectIdentity> { public interface AclObjectIdentityPersistence extends JpaRepository<AclObjectIdentity, Long>, QuerydslPredicateExecutor<AclObjectIdentity> {
/** /**
* Find by object id identity and class name. * Find by object id identity and class name.
......
...@@ -174,7 +174,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends ...@@ -174,7 +174,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends
*/ */
@Override @Override
public T getUser(final long id) { public T getUser(final long id) {
final T user = _repository.findOne(id); final T user = _repository.findById(id).orElse(null);
return deepLoad(user); return deepLoad(user);
} }
...@@ -203,7 +203,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends ...@@ -203,7 +203,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends
@PreAuthorize("hasRole('ADMINISTRATOR') || principal.id == #user.id") @PreAuthorize("hasRole('ADMINISTRATOR') || principal.id == #user.id")
public T updateUser(T user, final String email, final String fullName) throws NotUniqueUserException, UserException { public T updateUser(T user, final String email, final String fullName) throws NotUniqueUserException, UserException {
// reload // reload
user = _repository.findOne(user.getId()); user = _repository.findById(user.getId()).orElse(user);
if (!StringUtils.equals(email, user.getEmail()) && getUserByEmail(email) != null) { if (!StringUtils.equals(email, user.getEmail()) && getUserByEmail(email) != null) {
throw new NotUniqueUserException("Email address already registered"); throw new NotUniqueUserException("Email address already registered");
...@@ -237,7 +237,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends ...@@ -237,7 +237,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends
@Override @Override
@Transactional @Transactional
public T setRoles(T user, final Set<R> newRoles) { public T setRoles(T user, final Set<R> newRoles) {
user = _repository.findOne(user.getId()); user = _repository.findById(user.getId()).orElse(user);
// Remove transient roles // Remove transient roles
newRoles.removeAll(getDefaultUserRoles()); newRoles.removeAll(getDefaultUserRoles());
...@@ -345,7 +345,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends ...@@ -345,7 +345,7 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends
@Override @Override
@Transactional @Transactional
public T setAccountType(T user, AccountType accountType) { public T setAccountType(T user, AccountType accountType) {
T u = _repository.findOne(user.getId()); T u = _repository.findById(user.getId()).orElse(user);
u.setAccountType(accountType); u.setAccountType(accountType);
if (accountType != AccountType.LOCAL) { if (accountType != AccountType.LOCAL) {
......
...@@ -96,7 +96,7 @@ public class CustomAclServiceImpl implements CustomAclService { ...@@ -96,7 +96,7 @@ public class CustomAclServiceImpl implements CustomAclService {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public AclSid getSid(Long id) { public AclSid getSid(Long id) {
return aclSidPersistence.findOne(id); return aclSidPersistence.findById(id).orElse(null);
} }
...@@ -104,7 +104,7 @@ public class CustomAclServiceImpl implements CustomAclService { ...@@ -104,7 +104,7 @@ public class CustomAclServiceImpl implements CustomAclService {
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Cacheable(cacheNames = { "aclSidNames" }, key = "#id", unless = "#result == null") @Cacheable(cacheNames = { "aclSidNames" }, key = "#id", unless = "#result == null")
public String getSidName(long id) { public String getSidName(long id) {
AclSid sid = aclSidPersistence.findOne(id); AclSid sid = aclSidPersistence.findById(id).orElse(null);
return sid == null ? null : sid.getSid(); return sid == null ? null : sid.getSid();
} }
...@@ -238,7 +238,7 @@ public class CustomAclServiceImpl implements CustomAclService { ...@@ -238,7 +238,7 @@ public class CustomAclServiceImpl implements CustomAclService {
@Override @Override
@PreAuthorize("hasRole('ADMINISTRATOR')") @PreAuthorize("hasRole('ADMINISTRATOR')")
public AclObjectIdentity updateInheriting(final long objectIdIdentity, final boolean entriesInheriting) { public AclObjectIdentity updateInheriting(final long objectIdIdentity, final boolean entriesInheriting) {
final AclObjectIdentity objectIdentity = aclObjectIdentityPersistence.findOne(objectIdIdentity); final AclObjectIdentity objectIdentity = aclObjectIdentityPersistence.findById(objectIdIdentity).orElse(null);
if (objectIdentity == null) { if (objectIdentity == null) {
LOG.warn("ACL object identity not found by id={}", objectIdIdentity); LOG.warn("ACL object identity not found by id={}", objectIdIdentity);
return null; return null;
...@@ -269,13 +269,13 @@ public class CustomAclServiceImpl implements CustomAclService { ...@@ -269,13 +269,13 @@ public class CustomAclServiceImpl implements CustomAclService {
@Override @Override
@PreAuthorize("hasRole('ADMINISTRATOR')") @PreAuthorize("hasRole('ADMINISTRATOR')")
public AclObjectIdentity updateParentObject(final long objectIdIdentity, final long parentObjectId) { public AclObjectIdentity updateParentObject(final long objectIdIdentity, final long parentObjectId) {
final AclObjectIdentity objectIdentity = aclObjectIdentityPersistence.findOne(objectIdIdentity); final AclObjectIdentity objectIdentity = aclObjectIdentityPersistence.findById(objectIdIdentity).orElse(null);
if (objectIdentity == null) { if (objectIdentity == null) {
LOG.warn("ACL object identity not found by id={}", objectIdIdentity); LOG.warn("ACL object identity not found by id={}", objectIdIdentity);
return null; return null;
} }
final AclObjectIdentity parentIdentity = aclObjectIdentityPersistence.findOne(parentObjectId); final AclObjectIdentity parentIdentity = aclObjectIdentityPersistence.findById(parentObjectId).orElse(null);
if (parentIdentity == null) { if (parentIdentity == null) {
LOG.warn("ACL object identity not found by id={}", objectIdIdentity); LOG.warn("ACL object identity not found by id={}", objectIdIdentity);
return null; return null;
...@@ -321,7 +321,7 @@ public class CustomAclServiceImpl implements CustomAclService { ...@@ -321,7 +321,7 @@ public class CustomAclServiceImpl implements CustomAclService {
LOG.info("Deleting ACL data of {}", target); LOG.info("Deleting ACL data of {}", target);
final List<AclEntry> aclEntries = aclEntryPersistence.findByObjectIdentity(aclObjectIdentity); final List<AclEntry> aclEntries = aclEntryPersistence.findByObjectIdentity(aclObjectIdentity);
if (aclEntries != null) { if (aclEntries != null) {
aclEntryPersistence.delete(aclEntries); aclEntryPersistence.deleteAll(aclEntries);
} }
aclObjectIdentityPersistence.delete(aclObjectIdentity); aclObjectIdentityPersistence.delete(aclObjectIdentity);
} }