public void write(JsonWriter w, Map<String, AttributeValue> map) throws IOException { if (map == null) { w.nullValue(); } else { // Uses the outer class's gson instance String json = gson.toJson(attributeValueMapToItem(map).asMap()); w.jsonValue(json); } }
public void write(JsonWriter w, Map<String, AttributeValue> map) throws IOException { if (map == null) { w.nullValue(); } else { // Uses the outer class's gson instance String json = gson.toJson(attributeValueMapToItem(map).asMap()); w.jsonValue(json); } }
/** * Sanitises the specified item. * * @param item The item. Must not be {@code null}. * * @return The sanitised item. */ static Item sanitize(final Item item) { return Item.fromMap(sanitize(item.asMap())); }
/** * Reads a page from a "shared" DynamoDB table. Shared tables are tables that have global secondary indexes * and can contain the objects of multiple apps. * @param <P> type of object * @param appid the app identifier (name) * @param pager a {@link Pager} * @return the id of the last object on the page, or null. */ public static <P extends ParaObject> List<P> readPageFromSharedTable(String appid, Pager pager) { LinkedList<P> results = new LinkedList<>(); if (StringUtils.isBlank(appid)) { return results; } PageIterable<Item, QueryOutcome> pages = queryGSI(appid, pager); if (pages != null) { for (Page<Item, QueryOutcome> page : pages) { for (Item item : page) { P obj = ParaObjectUtils.setAnnotatedFields(item.asMap()); if (obj != null) { results.add(obj); } } } } if (!results.isEmpty() && pager != null) { pager.setLastKey(results.peekLast().getId()); } return results; }
/** * Reads a page from a "shared" DynamoDB table. Shared tables are tables that have global secondary indexes * and can contain the objects of multiple apps. * @param <P> type of object * @param appid the app identifier (name) * @param pager a {@link Pager} * @return the id of the last object on the page, or null. */ public static <P extends ParaObject> List<P> readPageFromSharedTable(String appid, Pager pager) { LinkedList<P> results = new LinkedList<>(); if (StringUtils.isBlank(appid)) { return results; } PageIterable<Item, QueryOutcome> pages = queryGSI(appid, pager); if (pages != null) { for (Page<Item, QueryOutcome> page : pages) { for (Item item : page) { P obj = ParaObjectUtils.setAnnotatedFields(item.asMap()); if (obj != null) { results.add(obj); } } } } if (!results.isEmpty() && pager != null) { pager.setLastKey(results.peekLast().getId()); } return results; }