Commit 74484b34 authored by Aman Verma's avatar Aman Verma
Browse files

fixing indentation

parent 04829f9d
Pipeline #4081 passed with stage
in 3 minutes and 8 seconds
...@@ -17,7 +17,6 @@ package org.opengroup.osdu.schema.azure.definitions; ...@@ -17,7 +17,6 @@ package org.opengroup.osdu.schema.azure.definitions;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.opengroup.osdu.schema.azure.definitions.FlattenedSchemaInfo;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
......
...@@ -22,7 +22,6 @@ import com.azure.security.keyvault.secrets.models.KeyVaultSecret; ...@@ -22,7 +22,6 @@ import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
import javax.inject.Named; import javax.inject.Named;
@Component @Component
public class AzureBootstrapConfig { public class AzureBootstrapConfig {
......
...@@ -73,15 +73,14 @@ public class TenantFactoryImpl implements ITenantFactory { ...@@ -73,15 +73,14 @@ public class TenantFactoryImpl implements ITenantFactory {
this.tenants = new HashMap<>(); this.tenants = new HashMap<>();
cosmosStore.findAllItems( headers.getPartitionId(), cosmosDBName, tenantInfoContainer, TenantInfoDoc.class) cosmosStore.findAllItems( headers.getPartitionId(), cosmosDBName, tenantInfoContainer, TenantInfoDoc.class)
.forEach(doc -> { .forEach(doc -> {
TenantInfo ti = new TenantInfo(); TenantInfo ti = new TenantInfo();
String tenantName = doc.getId(); String tenantName = doc.getId();
ti.setName(tenantName); ti.setName(tenantName);
String complianceRuleSet = doc.getComplianceRuleSet(); String complianceRuleSet = doc.getComplianceRuleSet();
ti.setComplianceRuleSet(complianceRuleSet); ti.setComplianceRuleSet(complianceRuleSet);
this.tenants.put(tenantName, ti) ; this.tenants.put(tenantName, ti) ;
}); });
} }
} }
...@@ -62,7 +62,7 @@ public class AzureAuthorityStore implements IAuthorityStore { ...@@ -62,7 +62,7 @@ public class AzureAuthorityStore implements IAuthorityStore {
@Override @Override
public Authority get(String authorityId) throws NotFoundException, ApplicationException { public Authority get(String authorityId) throws NotFoundException, ApplicationException {
String id = headers.getPartitionId().toString() + ":" + authorityId; String id = headers.getPartitionId() + ":" + authorityId;
AuthorityDoc authorityDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, headers.getPartitionId(), AuthorityDoc.class) AuthorityDoc authorityDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, headers.getPartitionId(), AuthorityDoc.class)
.orElseThrow(() -> new NotFoundException("bad input parameter")); .orElseThrow(() -> new NotFoundException("bad input parameter"));
...@@ -80,7 +80,7 @@ public class AzureAuthorityStore implements IAuthorityStore { ...@@ -80,7 +80,7 @@ public class AzureAuthorityStore implements IAuthorityStore {
@Override @Override
public Authority create(Authority authority) throws ApplicationException, BadRequestException { public Authority create(Authority authority) throws ApplicationException, BadRequestException {
String id = headers.getPartitionId().toString() + ":" + authority.getAuthorityId(); String id = headers.getPartitionId() + ":" + authority.getAuthorityId();
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, headers.getPartitionId(), AuthorityDoc.class).isPresent(); Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, headers.getPartitionId(), AuthorityDoc.class).isPresent();
if (exists) { if (exists) {
......
...@@ -64,7 +64,7 @@ public class AzureEntityTypeStore implements IEntityTypeStore { ...@@ -64,7 +64,7 @@ public class AzureEntityTypeStore implements IEntityTypeStore {
@Override @Override
public EntityType get(String entityTypeId) throws NotFoundException, ApplicationException { public EntityType get(String entityTypeId) throws NotFoundException, ApplicationException {
String id = headers.getPartitionId().toString() + ":" + entityTypeId; String id = headers.getPartitionId() + ":" + entityTypeId;
EntityTypeDoc entityTypeDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, headers.getPartitionId(), EntityTypeDoc.class) EntityTypeDoc entityTypeDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, headers.getPartitionId(), EntityTypeDoc.class)
.orElseThrow(() -> new NotFoundException("bad input parameter")); .orElseThrow(() -> new NotFoundException("bad input parameter"));
...@@ -82,7 +82,7 @@ public class AzureEntityTypeStore implements IEntityTypeStore { ...@@ -82,7 +82,7 @@ public class AzureEntityTypeStore implements IEntityTypeStore {
@Override @Override
public EntityType create(EntityType entityType) throws BadRequestException, ApplicationException { public EntityType create(EntityType entityType) throws BadRequestException, ApplicationException {
String id = headers.getPartitionId().toString() + ":" + entityType.getEntityTypeId(); String id = headers.getPartitionId() + ":" + entityType.getEntityTypeId();
// Check whether EntityType already exists and throw required exception. // Check whether EntityType already exists and throw required exception.
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, headers.getPartitionId(), EntityTypeDoc.class).isPresent(); Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, headers.getPartitionId(), EntityTypeDoc.class).isPresent();
......
...@@ -85,7 +85,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ...@@ -85,7 +85,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
@Override @Override
public SchemaInfo getSchemaInfo(String schemaId) throws ApplicationException, NotFoundException { public SchemaInfo getSchemaInfo(String schemaId) throws ApplicationException, NotFoundException {
String id = headers.getPartitionId().toString() + ":" + schemaId; String id = headers.getPartitionId() + ":" + schemaId;
SchemaInfoDoc schemaInfoDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class) SchemaInfoDoc schemaInfoDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class)
.orElseThrow(() -> new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT)); .orElseThrow(() -> new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT));
...@@ -103,7 +103,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ...@@ -103,7 +103,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
*/ */
@Override @Override
public SchemaInfo createSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException { public SchemaInfo createSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException {
String id = headers.getPartitionId().toString() + ":" + schema.getSchemaInfo().getSchemaIdentity().getId(); String id = headers.getPartitionId() + ":" + schema.getSchemaInfo().getSchemaIdentity().getId();
// Check whether SchemaInfo already exists and throw required exception. // Check whether SchemaInfo already exists and throw required exception.
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class).isPresent(); Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class).isPresent();
...@@ -135,7 +135,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ...@@ -135,7 +135,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
*/ */
@Override @Override
public SchemaInfo updateSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException { public SchemaInfo updateSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException {
String id = headers.getPartitionId().toString() + ":" + schema.getSchemaInfo().getSchemaIdentity().getId(); String id = headers.getPartitionId() + ":" + schema.getSchemaInfo().getSchemaIdentity().getId();
FlattenedSchemaInfo flattenedSchemaInfo = populateSchemaInfo(schema.getSchemaInfo()); FlattenedSchemaInfo flattenedSchemaInfo = populateSchemaInfo(schema.getSchemaInfo());
SchemaInfoDoc schemaInfoDoc = new SchemaInfoDoc(id, headers.getPartitionId(), flattenedSchemaInfo); SchemaInfoDoc schemaInfoDoc = new SchemaInfoDoc(id, headers.getPartitionId(), flattenedSchemaInfo);
try { try {
...@@ -158,7 +158,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ...@@ -158,7 +158,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
*/ */
@Override @Override
public boolean cleanSchema(String schemaId) throws ApplicationException { public boolean cleanSchema(String schemaId) throws ApplicationException {
String id = headers.getPartitionId().toString() + ":" + schemaId; String id = headers.getPartitionId() + ":" + schemaId;
// Check whether SchemaInfo already exists // Check whether SchemaInfo already exists
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class).isPresent(); Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class).isPresent();
...@@ -219,7 +219,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ...@@ -219,7 +219,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
// check for super-seeding schemas // check for super-seeding schemas
String supersededById = ""; String supersededById = "";
if (schemaInfo.getSupersededBy() != null) { if (schemaInfo.getSupersededBy() != null) {
String id = headers.getPartitionId().toString() + ":" + schemaInfo.getSupersededBy().getId(); String id = headers.getPartitionId() + ":" + schemaInfo.getSupersededBy().getId();
if (schemaInfo.getSupersededBy().getId() == null if (schemaInfo.getSupersededBy().getId() == null
|| !cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), FlattenedSchemaInfo.class).isPresent()) { || !cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), FlattenedSchemaInfo.class).isPresent()) {
...@@ -228,6 +228,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ...@@ -228,6 +228,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
} }
supersededById = schemaInfo.getSupersededBy().getId(); supersededById = schemaInfo.getSupersededBy().getId();
} }
return FlattenedSchemaInfo.builder().id(schemaInfo.getSchemaIdentity().getId()) return FlattenedSchemaInfo.builder().id(schemaInfo.getSchemaIdentity().getId())
.supersededBy(supersededById) .supersededBy(supersededById)
.dateCreated(new Date()) .dateCreated(new Date())
...@@ -241,14 +242,12 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ...@@ -241,14 +242,12 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
.scope(schemaInfo.getScope().name()) .scope(schemaInfo.getScope().name())
.status(schemaInfo.getStatus().name()) .status(schemaInfo.getStatus().name())
.build(); .build();
//return new FlattenedSchemaInfo();
} }
private SchemaInfo getSchemaInfoObject(FlattenedSchemaInfo flattenedSchemaInfo) { private SchemaInfo getSchemaInfoObject(FlattenedSchemaInfo flattenedSchemaInfo) {
SchemaIdentity superSededBy = null; SchemaIdentity superSededBy = null;
if (!flattenedSchemaInfo.getSupersededBy().isEmpty()) { if (!flattenedSchemaInfo.getSupersededBy().isEmpty()) {
String id = headers.getPartitionId().toString() + ":" + flattenedSchemaInfo.getSupersededBy(); String id = headers.getPartitionId() + ":" + flattenedSchemaInfo.getSupersededBy();
SchemaInfoDoc doc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class).get(); SchemaInfoDoc doc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class).get();
superSededBy = getSchemaIdentity(doc.getFlattenedSchemaInfo()); superSededBy = getSchemaIdentity(doc.getFlattenedSchemaInfo());
} }
......
...@@ -79,16 +79,16 @@ public class AzureSourceStore implements ISourceStore { ...@@ -79,16 +79,16 @@ public class AzureSourceStore implements ISourceStore {
@Override @Override
public Source create(Source source) throws BadRequestException, ApplicationException { public Source create(Source source) throws BadRequestException, ApplicationException {
String id = headers.getPartitionId().toString() + ":" + source.getSourceId(); String id = headers.getPartitionId() + ":" + source.getSourceId();
// Check whether Source already exists and throw required exception. // Check whether Source already exists and throw required exception.
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, sourceContainer, id, headers.getPartitionId(), SourceDoc.class).isPresent(); Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, sourceContainer, id, headers.getPartitionId(), SourceDoc.class).isPresent();
if (exists) { if (exists) {
log.warning(SchemaConstants.SOURCE_EXISTS); log.warning(SchemaConstants.SOURCE_EXISTS);
throw new BadRequestException(MessageFormat.format(SchemaConstants.SOURCE_EXISTS_EXCEPTION, throw new BadRequestException(MessageFormat.format(SchemaConstants.SOURCE_EXISTS_EXCEPTION,
source.getSourceId())); source.getSourceId()));
} }
try { try {
SourceDoc sourceDoc = new SourceDoc(id, headers.getPartitionId(), source); SourceDoc sourceDoc = new SourceDoc(id, headers.getPartitionId(), source);
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, sourceContainer, sourceDoc); cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, sourceContainer, sourceDoc);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
package org.opengroup.osdu.schema.azure.impl.schemastore; package org.opengroup.osdu.schema.azure.impl.schemastore;
import com.azure.storage.blob.BlobContainerClient; import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.specialized.BlockBlobClient;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.schema.azure.utils.OSDUAzureBlobStorageImpl; import org.opengroup.osdu.schema.azure.utils.OSDUAzureBlobStorageImpl;
...@@ -26,10 +25,6 @@ import org.opengroup.osdu.schema.provider.interfaces.schemastore.ISchemaStore; ...@@ -26,10 +25,6 @@ import org.opengroup.osdu.schema.provider.interfaces.schemastore.ISchemaStore;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
/** /**
* Repository class to to register resolved Schema in Azure storage. * Repository class to to register resolved Schema in Azure storage.
* *
......
...@@ -72,7 +72,6 @@ public class AzureEntityTypeStoreTest { ...@@ -72,7 +72,6 @@ public class AzureEntityTypeStoreTest {
Optional<EntityTypeDoc> cosmosItem = Optional.of(entityTypeDoc); Optional<EntityTypeDoc> cosmosItem = Optional.of(entityTypeDoc);
doReturn(cosmosItem).when(cosmosStore).findItem(anyString(), any(), any(), anyString(), anyString(), any()); doReturn(cosmosItem).when(cosmosStore).findItem(anyString(), any(), any(), anyString(), anyString(), any());
assertNotNull(store.get(EntityTypeId)); assertNotNull(store.get(EntityTypeId));
assertEquals(EntityTypeId, store.get(EntityTypeId).getEntityTypeId()); assertEquals(EntityTypeId, store.get(EntityTypeId).getEntityTypeId());
} }
......
...@@ -92,9 +92,8 @@ public class AzureSchemaInfoStoreTest { ...@@ -92,9 +92,8 @@ public class AzureSchemaInfoStoreTest {
@Rule @Rule
public ExpectedException expectedException = ExpectedException.none(); public ExpectedException expectedException = ExpectedException.none();
@Before @Before
public void init() throws CosmosClientException { public void init() {
initMocks(this); initMocks(this);
doReturn(dataPartitionId).when(headers).getPartitionId(); doReturn(dataPartitionId).when(headers).getPartitionId();
} }
...@@ -129,7 +128,6 @@ public class AzureSchemaInfoStoreTest { ...@@ -129,7 +128,6 @@ public class AzureSchemaInfoStoreTest {
@Test @Test
public void testGetSchemaInfo_Empty() throws NotFoundException, ApplicationException { public void testGetSchemaInfo_Empty() throws NotFoundException, ApplicationException {
expectedException.expect(NotFoundException.class); expectedException.expect(NotFoundException.class);
expectedException.expectMessage(SchemaConstants.SCHEMA_NOT_PRESENT); expectedException.expectMessage(SchemaConstants.SCHEMA_NOT_PRESENT);
......
...@@ -49,7 +49,6 @@ public class AzureSchemaStoreTest { ...@@ -49,7 +49,6 @@ public class AzureSchemaStoreTest {
@Rule @Rule
public ExpectedException expectedException = ExpectedException.none(); public ExpectedException expectedException = ExpectedException.none();
private static final String BUCKET = "test-schema";
private static final String dataPartitionId = "dataPartitionId"; private static final String dataPartitionId = "dataPartitionId";
private static final String FILE_PATH = "/test-folder/test-file"; private static final String FILE_PATH = "/test-folder/test-file";
private static final String CONTENT = "Hello World"; private static final String CONTENT = "Hello World";
......
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