com.amazonaws.services.dynamodbv2.document.PutItemOutcome Java Examples
The following examples show how to use
com.amazonaws.services.dynamodbv2.document.PutItemOutcome.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamoDBInstalledAppContextStore.java From smartapp-sdk-java with Apache License 2.0 | 6 votes |
@Override public void add(DefaultInstalledAppContext context) { Table table = dynamoDB.getTable(tableName); InstalledApp installedApp = context.getInstalledApp(); Token token = context.getToken(); String configJson; try { configJson = mapper.writeValueAsString(installedApp.getConfig()); } catch (JsonProcessingException e) { log.error("problem mapping config as JSON", e); configJson = null; } Item item = new Item().withPrimaryKey("installedAppId", context.getInstalledAppId()) .with("authToken", token.getAccessToken()) // named to match NodeSDK version .with("authTokenExpiration", token.getAccessTokenExpiration().toEpochMilli()) .with("refreshToken", token.getRefreshToken()) .with("refreshTokenExpiration", token.getRefreshTokenExpiration().toEpochMilli()) .with("locationId", installedApp.getLocationId()).with("config", configJson) .with("permissions", installedApp.getPermissions()); PutItemOutcome outcome = table.putItem(item); if (log.isDebugEnabled()) { log.debug("put item outcome = " + outcome); log.debug("put item outcome.getItem() = " + outcome.getItem()); log.debug("put item outcome.getPutItemResult() = " + outcome.getPutItemResult()); } }
Example #2
Source File: MoviesItemOps01.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard() .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2")) .build(); DynamoDB dynamoDB = new DynamoDB(client); Table table = dynamoDB.getTable("Movies"); int year = 2015; String title = "The Big New Movie"; final Map<String, Object> infoMap = new HashMap<String, Object>(); infoMap.put("plot", "Nothing happens at all."); infoMap.put("rating", 0); try { System.out.println("Adding a new item..."); PutItemOutcome outcome = table .putItem(new Item().withPrimaryKey("year", year, "title", title).withMap("info", infoMap)); System.out.println("PutItem succeeded:\n" + outcome.getPutItemResult()); } catch (Exception e) { System.err.println("Unable to add item: " + year + " " + title); System.err.println(e.getMessage()); } }
Example #3
Source File: SavePersonHandler.java From tutorials with MIT License | 5 votes |
private PutItemOutcome persistData(PersonRequest personRequest) throws ConditionalCheckFailedException { return this.dynamoDb.getTable(DYNAMODB_TABLE_NAME) .putItem( new PutItemSpec().withItem(new Item() .withNumber("id", personRequest.getId()) .withString("firstName", personRequest.getFirstName()) .withString("lastName", personRequest.getLastName()) .withNumber("age", personRequest.getAge()) .withString("address", personRequest.getAddress()))); }