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
Lib
cloud
azure
OS Core Lib Azure
Commits
aa4b1e0d
Commit
aa4b1e0d
authored
Sep 08, 2020
by
Kishore Battula
Browse files
Merge branch 'haaggarw/UsingSLF4jLoggerForCosmosStore' into 'master'
Using SLF4JLogger for CosmosStore See merge request
!27
parents
19392a5e
0186f216
Pipeline
#7748
canceled with stages
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
aa4b1e0d
...
...
@@ -21,7 +21,7 @@
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
core-lib-azure
</artifactId>
<packaging>
jar
</packaging>
<version>
0.0.2
5
</version>
<version>
0.0.2
6
</version>
<name>
core-lib-azure
</name>
<properties>
...
...
src/main/java/org/opengroup/osdu/azure/CosmosStore.java
View file @
aa4b1e0d
...
...
@@ -39,8 +39,8 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* A simpler interface for interacting with CosmosDB.
...
...
@@ -82,7 +82,7 @@ import java.util.logging.Logger;
@Lazy
public
class
CosmosStore
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CosmosStore
.
class
.
getName
());
private
static
final
Logger
LOGGER
=
Logger
Factory
.
getLogger
(
CosmosStore
.
class
.
getName
());
@Autowired
private
ICosmosClientFactory
cosmosClientFactory
;
...
...
@@ -105,11 +105,11 @@ public class CosmosStore {
findItem
(
cosmosContainer
,
id
,
partitionKey
).
delete
(
new
CosmosItemRequestOptions
(
partitionKey
));
}
catch
(
NotFoundException
e
)
{
String
errorMessage
=
"Item was unexpectedly not found"
;
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
404
,
errorMessage
,
e
.
getMessage
(),
e
);
}
catch
(
CosmosClientException
e
)
{
String
errorMessage
=
"Unexpectedly failed to delete item from CosmosDB"
;
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
500
,
errorMessage
,
e
.
getMessage
(),
e
);
}
}
...
...
@@ -139,7 +139,7 @@ public class CosmosStore {
.
getObject
(
clazz
);
return
Optional
.
ofNullable
(
item
);
}
catch
(
NotFoundException
e
)
{
LOGGER
.
info
(
String
.
format
(
"Unable to find item with ID=%s and PK=%s"
,
id
,
partitionKey
));
LOGGER
.
warn
(
String
.
format
(
"Unable to find item with ID=%s and PK=%s"
,
id
,
partitionKey
));
return
Optional
.
empty
();
}
catch
(
IOException
|
CosmosClientException
e
)
{
String
errorMessage
;
...
...
@@ -148,7 +148,7 @@ public class CosmosStore {
}
else
{
errorMessage
=
"Unexpectedly encountered error calling CosmosDB"
;
}
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
500
,
errorMessage
,
e
.
getMessage
(),
e
);
}
}
...
...
@@ -195,7 +195,7 @@ public class CosmosStore {
results
.
add
(
properties
.
getObject
(
clazz
));
}
catch
(
IOException
e
)
{
String
errorMessage
=
String
.
format
(
"Malformed document for item with ID=%s"
,
properties
.
getId
());
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
500
,
errorMessage
,
e
.
getMessage
(),
e
);
}
}
...
...
@@ -318,7 +318,7 @@ public class CosmosStore {
cosmosContainer
.
upsertItem
(
item
);
}
catch
(
CosmosClientException
e
)
{
String
errorMessage
=
"Unexpectedly failed to put item into CosmosDB"
;
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
500
,
errorMessage
,
e
.
getMessage
(),
e
);
}
}
...
...
@@ -340,11 +340,11 @@ public class CosmosStore {
cosmosContainer
.
createItem
(
item
);
}
catch
(
ConflictException
e
)
{
String
errorMessage
=
"Resource with specified id or name already exists."
;
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
409
,
errorMessage
,
e
.
getMessage
(),
e
);
}
catch
(
CosmosClientException
e
)
{
String
errorMessage
=
"Unexpectedly failed to insert item into CosmosDB"
;
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
500
,
errorMessage
,
e
.
getMessage
(),
e
);
}
}
...
...
@@ -378,7 +378,7 @@ public class CosmosStore {
.
getContainer
(
collection
);
}
catch
(
Exception
e
)
{
String
errorMessage
=
"Error creating creating Cosmos Client"
;
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
LOGGER
.
warn
(
errorMessage
,
e
);
throw
new
AppException
(
500
,
errorMessage
,
e
.
getMessage
(),
e
);
}
...
...
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