Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Schema
Commits
2a80c27a
Commit
2a80c27a
authored
Apr 11, 2022
by
Artem Dobrynin (EPAM)
Browse files
Bugfix: Storage Exception is not being processed by Schema
* Added Storage Exception
parent
cd922bee
Pipeline
#103721
passed with stages
in 64 minutes and 24 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemastore/ObmSchemaStore.java
View file @
2a80c27a
...
...
@@ -17,6 +17,7 @@
package
org.opengroup.osdu.schema.impl.schemastore
;
import
com.google.cloud.storage.StorageException
;
import
org.opengroup.osdu.core.common.logging.JaxRsDpsLog
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory
;
...
...
@@ -33,6 +34,7 @@ import org.opengroup.osdu.schema.exceptions.NotFoundException;
import
org.opengroup.osdu.schema.impl.mapper.AbstractMapperRepository
;
import
org.opengroup.osdu.schema.provider.interfaces.schemastore.ISchemaStore
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Repository
;
import
java.nio.charset.StandardCharsets
;
...
...
@@ -77,8 +79,8 @@ public class ObmSchemaStore extends AbstractMapperRepository<String, ObmDestinat
try
{
blob
=
driver
.
getBlobContent
(
bucketName
,
filePath
,
getDestination
());
}
catch
(
ObmDriverRuntimeException
|
NullPointerException
ex
){
if
(
ex
instanceof
NullPointer
Exception
||
NO_SUCH_KEY
.
equals
(((
ObmDriverRuntimeException
)
ex
.
getCause
()).
getError
())
){
if
(
isNotFound
Exception
(
ex
)){
log
.
warning
(
ex
.
getMessage
())
;
throw
new
NotFoundException
(
SchemaConstants
.
SCHEMA_NOT_PRESENT
);
}
else
{
...
...
@@ -92,6 +94,25 @@ public class ObmSchemaStore extends AbstractMapperRepository<String, ObmDestinat
throw
new
NotFoundException
(
SchemaConstants
.
SCHEMA_NOT_PRESENT
);
}
private
boolean
isNotFoundException
(
RuntimeException
ex
)
{
if
(
ex
instanceof
NullPointerException
){
return
true
;
}
ObmDriverRuntimeException
obmException
=
(
ObmDriverRuntimeException
)
ex
;
if
(
obmException
.
getCause
()
instanceof
ObmDriverRuntimeException
){
ObmDriverRuntimeException
cause
=
(
ObmDriverRuntimeException
)
obmException
.
getCause
();
return
NO_SUCH_KEY
.
equals
(
cause
.
getError
());
}
if
(
obmException
.
getCause
()
instanceof
StorageException
){
return
HttpStatus
.
NOT_FOUND
.
value
()
==
(((
StorageException
)
obmException
.
getCause
()).
getCode
());
}
return
false
;
}
/**
* Method to get System schema from Blob Storage
* @param filePath
...
...
provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemastore/ObmSchemaStoreTest.java
View file @
2a80c27a
package
org.opengroup.osdu.schema.impl.schemastore
;
import
com.google.cloud.storage.StorageException
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Rule
;
...
...
@@ -163,6 +164,20 @@ public class ObmSchemaStoreTest {
schemaStore
.
getSchema
(
dataPartitionId
,
FILE_PATH
);
}
@Test
public
void
testGetSchema_NotFound_StorageException
()
throws
ApplicationException
,
NotFoundException
{
expectedException
.
expect
(
NotFoundException
.
class
);
expectedException
.
expectMessage
(
SchemaConstants
.
SCHEMA_NOT_PRESENT
);
String
filePath
=
FILE_PATH
+
SchemaConstants
.
JSON_EXTENSION
;
ObmDriverRuntimeException
obmDriverRuntimeException
=
new
ObmDriverRuntimeException
(
new
StorageException
(
404
,
"test"
));
when
(
tenantFactory
.
getTenantInfo
(
dataPartitionId
)).
thenReturn
(
TenantInfo
);
when
(
TenantInfo
.
getProjectId
()).
thenReturn
(
"test"
);
when
(
driver
.
getBlobContent
(
BUCKET
,
filePath
,
DESTINATION
)).
thenThrow
(
obmDriverRuntimeException
);
schemaStore
.
getSchema
(
dataPartitionId
,
FILE_PATH
);
}
@Test
public
void
testGetSchema_NotFound_SystemSchemas
()
throws
ApplicationException
,
NotFoundException
{
expectedException
.
expect
(
NotFoundException
.
class
);
...
...
Riabokon Stanislav(EPAM)[GCP]
@Stanislav_Riabokon
mentioned in commit
3cb8de34
·
Apr 12, 2022
mentioned in commit
3cb8de34
mentioned in commit 3cb8de341abb3eeda2845034a79c45cfcb98c2dd
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment