Commit e3e35387 authored by Anastasiia Gelmut's avatar Anastasiia Gelmut
Browse files

GONRG-1537 Finalize Partition Service

-SonarLint comments are fixed.
parent 1da279d0
......@@ -36,12 +36,12 @@ public class AuthorizationService implements IAuthorizationService {
private final DpsHeaders headers;
private final org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService authorizationService;
private final org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService authorizationServiceImpl;
@Override
public boolean isDomainAdminServiceAccount() {
try {
authorizationService.authorizeAny(headers, PARTITION_ADMIN_ROLE);
authorizationServiceImpl.authorizeAny(headers, PARTITION_ADMIN_ROLE);
} catch (AppException e) {
throw e;
} catch (Exception e) {
......
......@@ -98,10 +98,10 @@ public class PartitionServiceImpl implements IPartitionService {
@Transactional
@Override
public PartitionInfo updatePartition(String partitionId, PartitionInfo partitionInfo) {
this.partitionPropertyEntityRepository.findByPartitionId(partitionId)
.orElseThrow(
() -> new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON,
"An attempt to update not existing partition."));
if (!this.partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) {
throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON,
"An attempt to update not existing partition.");
}
List<PartitionPropertyEntity> partitionProperties = new ArrayList<>();
for (Map.Entry<String, Property> entry : partitionInfo.getProperties().entrySet()) {
PartitionPropertyEntity entity = this.partitionPropertyEntityRepository
......@@ -144,10 +144,10 @@ public class PartitionServiceImpl implements IPartitionService {
@Transactional
@Override
public boolean deletePartition(String partitionId) {
this.partitionPropertyEntityRepository.findByPartitionId(partitionId)
.orElseThrow(
() -> new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON,
"An attempt to delete not existing partition."));
if (!this.partitionPropertyEntityRepository.findByPartitionId(partitionId).isPresent()) {
throw new AppException(HttpStatus.SC_NOT_FOUND, UNKNOWN_ERROR_REASON,
"An attempt to delete not existing partition.");
}
this.partitionPropertyEntityRepository.deleteByPartitionId(partitionId);
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment