Skip to content
Snippets Groups Projects
Commit 054dfa3c authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Merge branch 'master' into 'integration-master'

Master

See merge request go3-nrg/platform/security-and-compliance/legal!6
parents 07e5a9ec 45ae6724
No related branches found
No related tags found
6 merge requests!68Integration tests for Google Cloud Run (GONRG-1016),!57Wip unique backed name across gcp mykola zamkovyi,!56Readme for gcp (GONRG-838),!51Publish CICD Community for Legal GONRG-636,!50Wip unique backed name across gcp mykola zamkovyi,!42Unify logic for credentials (GONRG-539)
Pipeline #6461 failed
......@@ -49,7 +49,7 @@ public class LegalFilterTest {
Mockito.verify(httpServletResponse).addHeader("Access-Control-Allow-Origin", Collections.singletonList("*").toString());
Mockito.verify(httpServletResponse).addHeader("Access-Control-Allow-Headers", Collections.singletonList("origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey").toString());
Mockito.verify(httpServletResponse).addHeader("Access-Control-Allow-Methods", Collections.singletonList("GET, POST, PUT, DELETE, OPTIONS, HEAD").toString());
Mockito.verify(httpServletResponse).addHeader("Access-Control-Allow-Methods", Collections.singletonList("GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH").toString());
Mockito.verify(httpServletResponse).addHeader("Access-Control-Allow-Credentials", Collections.singletonList("true").toString());
Mockito.verify(httpServletResponse).addHeader("X-Frame-Options", Collections.singletonList("DENY").toString());
Mockito.verify(httpServletResponse).addHeader("X-XSS-Protection", Collections.singletonList("1; mode=block").toString());
......
......@@ -9,7 +9,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<docker.image.prefix>opendes</docker.image.prefix>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<os-core-common.version>0.3.3</os-core-common.version>
<os-core-common.version>0.3.6</os-core-common.version>
</properties>
<licenses>
......
......@@ -40,7 +40,6 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.3.4</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu.legal</groupId>
......
......@@ -14,11 +14,8 @@
package org.opengroup.osdu.legal.azure.di;
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosContainer;
import com.azure.security.keyvault.secrets.SecretClient;
import org.opengroup.osdu.azure.KeyVaultFacade;
import org.opengroup.osdu.common.Validators;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
......@@ -95,16 +92,17 @@ public class AzureBootstrapConfig {
}
@Bean
@Named("LEGAL_TAGS_CONTAINER")
CosmosContainer legalTagsContainer(final CosmosClient cosmosClient) {
Validators.checkNotNull(cosmosClient, "Cosmos client cannot be null");
return cosmosClient.getDatabase(cosmosDBName).getContainer(legalCollectionName);
public String cosmosDBName() {
return cosmosDBName;
}
@Bean
@Named("TENANT_INFO_CONTAINER")
CosmosContainer tenantInfoContainer(final CosmosClient cosmosClient) {
Validators.checkNotNull(cosmosClient, "Cosmos client cannot be null");
return cosmosClient.getDatabase(cosmosDBName).getContainer(tenantCollectionName);
public String legalTagsContainer(){
return legalCollectionName;
}
@Bean
public String tenantInfoContainer(){
return tenantCollectionName;
}
}
\ No newline at end of file
......@@ -14,14 +14,12 @@
package org.opengroup.osdu.legal.azure.di;
import javax.inject.Inject;
import javax.inject.Named;
import com.azure.cosmos.CosmosContainer;
import org.opengroup.osdu.azure.CosmosFacade;
import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collection;
......@@ -30,9 +28,18 @@ import java.util.Map;
@Component
public class TenantFactoryImpl implements ITenantFactory {
@Inject
@Named("TENANT_INFO_CONTAINER")
private CosmosContainer container;
@Autowired
private CosmosStore cosmosStore;
@Autowired
private String tenantInfoContainer;
@Autowired
private String cosmosDBName;
@Autowired
private DpsHeaders headers;
private Map<String, TenantInfo> tenants;
......@@ -64,7 +71,7 @@ public class TenantFactoryImpl implements ITenantFactory {
private void initTenants() {
this.tenants = new HashMap<>();
CosmosFacade.findAllItems(container, TenantInfoDoc.class).forEach(doc -> {
cosmosStore.findAllItems(headers.getPartitionId(), cosmosDBName, tenantInfoContainer, TenantInfoDoc.class).forEach(doc -> {
TenantInfo ti = new TenantInfo();
String tenantName = doc.getId();
ti.setName(tenantName);
......
......@@ -14,13 +14,18 @@
package org.opengroup.osdu.legal.azure.tags.dataaccess;
import com.azure.cosmos.*;
import org.opengroup.osdu.azure.CosmosFacade;
import com.azure.cosmos.FeedOptions;
import com.azure.cosmos.SqlParameter;
import com.azure.cosmos.SqlParameterList;
import com.azure.cosmos.SqlQuerySpec;
import org.opengroup.osdu.azure.CosmosStore;
import org.opengroup.osdu.common.Validators;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.legal.ListLegalTagArgs;
import org.opengroup.osdu.core.common.model.legal.LegalTag;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.legal.provider.interfaces.ILegalTagRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
......@@ -30,17 +35,22 @@ import java.util.Optional;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Named;
@Repository
public class LegalTagRepositoryImpl implements ILegalTagRepository {
private ReentrantLock mutex = new ReentrantLock();
@Inject
@Named("LEGAL_TAGS_CONTAINER")
private CosmosContainer container;
@Autowired
private CosmosStore cosmosStore;
@Autowired
private String legalTagsContainer;
@Autowired
private String cosmosDBName;
@Autowired
private DpsHeaders headers;
@Override
public Long create(LegalTag legalTag) {
......@@ -51,11 +61,11 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository {
LegalTagDoc legalTagDoc = new LegalTagDoc(strId, legalTag);
try {
mutex.lock();
Optional<LegalTagDoc> existingDoc = CosmosFacade.findItem(container, strId, strId, LegalTagDoc.class);
Optional<LegalTagDoc> existingDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class);
if (existingDoc.isPresent()) {
throw AppException.legalTagAlreadyExistsError(legalTag.getName());
}
CosmosFacade.upsertItem(container, legalTagDoc);
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, legalTagDoc);
} finally {
mutex.unlock();
}
......@@ -70,7 +80,7 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository {
for(long id : ids)
{
String strId = String.valueOf(id);
CosmosFacade.findItem(container, strId, strId, LegalTagDoc.class)
cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class)
.ifPresent(tagDoc -> output.add(tagDoc.getLegalTag()));
}
}
......@@ -81,11 +91,11 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository {
public Boolean delete(LegalTag legalTag) {
Long id = legalTag.getId();
String strId = String.valueOf(id);
boolean exists = CosmosFacade.findItem(container, strId, strId, LegalTagDoc.class).isPresent();
boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class).isPresent();
if (!exists)
return false;
CosmosFacade.deleteItem(container, strId, strId);
cosmosStore.deleteItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId);
return true;
}
......@@ -96,11 +106,11 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository {
Long id = newLegalTag.getId();
String strId = String.valueOf(id);
boolean exists = CosmosFacade.findItem(container, strId, strId, LegalTagDoc.class).isPresent();
boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class).isPresent();
if (!exists)
throw AppException.legalTagDoesNotExistError(newLegalTag.getName());
CosmosFacade.upsertItem(container, new LegalTagDoc(strId, newLegalTag));
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, new LegalTagDoc(strId, newLegalTag));
return newLegalTag;
}
......@@ -112,7 +122,7 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository {
.setParameters(new SqlParameterList(new SqlParameter("@isValid", args.getIsValid())));
FeedOptions options = new FeedOptions().setEnableCrossPartitionQuery(true);
return CosmosFacade.queryItems(container, query, options, LegalTagDoc.class)
return cosmosStore.queryItems(headers.getPartitionId(), cosmosDBName, legalTagsContainer, query, options, LegalTagDoc.class)
.stream()
.map(LegalTagDoc::getLegalTag)
.collect(Collectors.toList());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment