Commit 174fbff9 authored by Aman Verma's avatar Aman Verma
Browse files

adding new method

parent d5161b67
......@@ -14,6 +14,7 @@
......@@ -316,6 +317,32 @@ public class CosmosStore {
* @param dataPartitionId Data partition id to fetch appropriate cosmos client for each partition
* @param cosmosDBName Database to be used
* @param collection Collection to be used
* @param item Data object to store
* @param <T> Type of response
public <T> void createItem(
final String dataPartitionId,
final String cosmosDBName,
final String collection,
final T item) {
try {
CosmosContainer cosmosContainer = getCosmosContainer(dataPartitionId, cosmosDBName, collection);
} catch (ConflictException e) {
String errorMessage = "Resource with specified id or name already exists.";
LOGGER.log(Level.WARNING, 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);
throw new AppException(500, errorMessage, e.getMessage(), e);
* @param cosmos Container to query
* @param id ID of item
Supports Markdown
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