diff --git a/provider/legal-azure/pom.xml b/provider/legal-azure/pom.xml index 8487918e7fa5b02f908eab75f22bbce2d2544d13..4ce85e34a07db2cf545faf83d351452654f12ee9 100644 --- a/provider/legal-azure/pom.xml +++ b/provider/legal-azure/pom.xml @@ -109,12 +109,6 @@ <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> - <dependency> - <groupId>org.opengroup.osdu.legal</groupId> - <artifactId>legal-core</artifactId> - <version>0.0.5-SNAPSHOT</version> - <scope>compile</scope> - </dependency> <!-- test --> <dependency> diff --git a/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImpl.java b/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImpl.java index f27dc1bcca0ef9060316f8a69fe9e254d2bc5f42..bc88dc043541cf22ae1143702b04301284aa1fdd 100644 --- a/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImpl.java +++ b/provider/legal-azure/src/main/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImpl.java @@ -32,14 +32,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; -import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; @Repository public class LegalTagRepositoryImpl implements ILegalTagRepository { - private ReentrantLock mutex = new ReentrantLock(); - @Autowired private CosmosStore cosmosStore; @@ -59,16 +56,11 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository { String strId = String.valueOf(id); LegalTagDoc legalTagDoc = new LegalTagDoc(strId, legalTag); - try { - mutex.lock(); - Optional<LegalTagDoc> existingDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class); - if (existingDoc.isPresent()) { - throw AppException.legalTagAlreadyExistsError(legalTag.getName()); - } - cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, legalTagDoc); - } finally { - mutex.unlock(); + Optional<LegalTagDoc> existingDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class); + if (existingDoc.isPresent()) { + throw AppException.legalTagAlreadyExistsError(legalTag.getName()); } + cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, legalTagDoc); return id; } diff --git a/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java b/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java index 70cfae98617e6ab1127bb8abdd190902a6bd864f..8162d1f5f481e853427501914ad1df798b92d444 100644 --- a/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java +++ b/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java @@ -86,7 +86,7 @@ public class LegalTagRepositoryImplTest { long obtainedId = sut.create(legalTag); ArgumentCaptor<LegalTagDoc> arg = ArgumentCaptor.forClass(LegalTagDoc.class); - verify(cosmosStore).upsertItem(eq(dataPartitionId), any(), any(), arg.capture()); + verify(cosmosStore).createItem(eq(dataPartitionId), any(), any(), arg.capture()); assertEquals(arg.getValue().getId(), strId); assertEquals(obtainedId, id);