/** * Simplified method form for invoking the PutItem operation with an AsyncHandler. * * @see #putItemAsync(PutItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item, com.amazonaws.handlers.AsyncHandler<PutItemRequest, PutItemResult> asyncHandler) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item), asyncHandler); }
/** * Simplified method form for invoking the PutItem operation. * * @see #putItemAsync(PutItemRequest) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item)); }
/** * Simplified method form for invoking the PutItem operation with an AsyncHandler. * * @see #putItemAsync(PutItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item, com.amazonaws.handlers.AsyncHandler<PutItemRequest, PutItemResult> asyncHandler) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item), asyncHandler); }
/** * Simplified method form for invoking the PutItem operation. * * @see #putItemAsync(PutItemRequest) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item)); }
@Override public PutItemResult putItem(String tableName, java.util.Map<String, AttributeValue> item) { return putItem(new PutItemRequest().withTableName(tableName).withItem(item)); }
@Override public PutItemResult putItem(String tableName, java.util.Map<String, AttributeValue> item) { return putItem(new PutItemRequest().withTableName(tableName).withItem(item)); }
/** * Simplified method form for invoking the PutItem operation. * * @see #putItemAsync(PutItemRequest) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item, String returnValues) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item).withReturnValues(returnValues)); }
/** * Simplified method form for invoking the PutItem operation. * * @see #putItemAsync(PutItemRequest) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item, String returnValues) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item).withReturnValues(returnValues)); }
/** * Simplified method form for invoking the PutItem operation with an AsyncHandler. * * @see #putItemAsync(PutItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item, String returnValues, com.amazonaws.handlers.AsyncHandler<PutItemRequest, PutItemResult> asyncHandler) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item).withReturnValues(returnValues), asyncHandler); }
/** * Simplified method form for invoking the PutItem operation with an AsyncHandler. * * @see #putItemAsync(PutItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<PutItemResult> putItemAsync(String tableName, java.util.Map<String, AttributeValue> item, String returnValues, com.amazonaws.handlers.AsyncHandler<PutItemRequest, PutItemResult> asyncHandler) { return putItemAsync(new PutItemRequest().withTableName(tableName).withItem(item).withReturnValues(returnValues), asyncHandler); }
@Override public PutItemResult putItem(String tableName, java.util.Map<String, AttributeValue> item, String returnValues) { return putItem(new PutItemRequest().withTableName(tableName).withItem(item).withReturnValues(returnValues)); }
@Override public PutItemResult putItem(String tableName, java.util.Map<String, AttributeValue> item, String returnValues) { return putItem(new PutItemRequest().withTableName(tableName).withItem(item).withReturnValues(returnValues)); }
/** * Save the item using a PutItem request. The handler will call this * method if * <ul> * <li> CLOBBER configuration is being used; * <li> OR the item contains auto-generated key value; * <li> OR an UpdateItem request has silently failed (200 response with * no affected attribute), which indicates the key-only-put scenario * that we used to handle by the keyOnlyPut(...) hack. * </ul> */ protected PutItemResult doPutItem() { Map<String, AttributeValue> attributeValues = convertToItem(getAttributeValueUpdates()); attributeValues = transformAttributes( toParameters(attributeValues, this.clazz, getTableName(), saveConfig)); PutItemRequest req = new PutItemRequest() .withTableName(getTableName()) .withItem(attributeValues) .withExpected(mergeExpectedAttributeValueConditions()) .withConditionalOperator(userProvidedConditionOperator) .withRequestMetricCollector(saveConfig.getRequestMetricCollector()); return db.putItem(applyUserAgent(req)); }
private PutItemOutcome doPutItem(PutItemSpec spec) { // set the table name String tableName = getTable().getTableName(); PutItemRequest req = spec.getRequest().withTableName(tableName); // set up the item Item item = spec.getItem(); final Map<String,AttributeValue> attributes = InternalUtils.toAttributeValues(item); // set up the expected attribute map, if any final Map<String, ExpectedAttributeValue> expectedMap = InternalUtils.toExpectedAttributeValueMap(spec.getExpected()); // set up the value map, if any (when expression API is used) final Map<String,AttributeValue> attrValMap = InternalUtils.fromSimpleMap(spec.getValueMap()); // set up the request req.withItem(attributes) .withExpected(expectedMap) .withExpressionAttributeNames(spec.getNameMap()) .withExpressionAttributeValues(attrValMap) ; PutItemResult result = getClient().putItem(req); return new PutItemOutcome(result); } }
@Override public void saveAttributes(RequestEnvelope envelope, Map<String, Object> attributes) throws PersistenceException { String partitionKey = partitionKeyGenerator.apply(envelope); PutItemRequest request = new PutItemRequest() .withTableName(tableName) .withItem(getItem(partitionKey, attributes)); try { dynamoDb.putItem(request); } catch (ResourceNotFoundException e) { throw new PersistenceException(String.format("Table %s does not exist or is in the process of being created", tableName), e); } catch (AmazonDynamoDBException e) { throw new PersistenceException("Failed to save attributes to DynamoDB", e); } }
@Override public void createProject(String project) { try { dynamoDBClient.putItem(new PutItemRequest() .withTableName(tableConfig.getTableName()) .addExpectedEntry("id", new ExpectedAttributeValue().withExists(false)) .withItem(ImmutableMap.<String, AttributeValue>builder() .put("project", new AttributeValue(project)) .put("id", new AttributeValue("|")).build() )); } catch (ConditionalCheckFailedException e) { throw new AlreadyExistsException("Project", HttpResponseStatus.BAD_REQUEST); } }
@Override public <T> void setConfig(String project, String configName, @NotNull T value) { dynamoDBClient.putItem(new PutItemRequest() .withTableName(tableConfig.getTableName()) .withItem(of( "project", new AttributeValue(project), "id", new AttributeValue(configName), "value", new AttributeValue(JsonHelper.encode(value))))); }
@Override public Object create(String project, Object id, ObjectNode properties) { dynamoDBClient.putItem(new PutItemRequest().withTableName(tableConfig.getTableName()) .withItem(generatePutRequest(project, id, properties))); return id; }
@Override public <T> T setConfigOnce(String project, String configName, @NotNull T value) { try { dynamoDBClient.putItem(new PutItemRequest() .withTableName(tableConfig.getTableName()) .withExpected(of("id", new ExpectedAttributeValue(false), "project", new ExpectedAttributeValue(false))) .withItem(of( "project", new AttributeValue(project), "id", new AttributeValue(configName), "value", new AttributeValue(JsonHelper.encode(value))))); return value; } catch (Exception e) { return getConfig(project, configName, (Class<T>) value.getClass()); } }
@Override public void createMaterializedView(String project, MaterializedView materializedView) { dynamoDBClient.putItem(new PutItemRequest().withTableName(tableConfig.getTableName()) .withItem(of( "project", new AttributeValue(project), "type_table_name", new AttributeValue("materialized_" + materializedView.tableName), "value", new AttributeValue(JsonHelper.encode(materializedView))))); }