@Test(expected = ClientException.class) public void testUpdateContentPropsEmptyPropertyNameToSave() { String identifier = "test_content"; String body = "test_content_body"; Map<String, Object> map = new HashMap<>(); map.put("", body); contentStore.updateContentProperties(identifier, map); }
public void updateContentProperties(String contentId, Map<String, Object> map) { TelemetryManager.log("UpdateContentProperties | Content: " + contentId + " | Properties: " + map); Session session = CassandraConnector.getSession(); if (null == map || map.isEmpty()) throw new ClientException(ContentStoreParams.ERR_INVALID_PROPERTY_VALUES.name(), "Invalid property values. Please specify valid property values"); String query = getUpdateQuery(map.keySet()); PreparedStatement ps = session.prepare(query); Object[] values = new Object[map.size() + 1]; try { int i = 0; for (Entry<String, Object> entry : map.entrySet()) { String value = ""; if (null == entry.getValue()) { value = ""; } else if (entry.getValue() instanceof String) { value = (String) entry.getValue(); } else { value = mapper.writeValueAsString(entry.getValue()); } values[i] = value; i += 1; } values[i] = contentId; BoundStatement bound = ps.bind(values); session.execute(bound); logTransactionEvent("UPDATE", contentId, map); } catch (Exception e) { TelemetryManager.error("Error! Executing update content property: " + e.getMessage(), e); throw new ServerException(ContentStoreParams.ERR_SERVER_ERROR.name(), "Error updating property in Content Store."); } }
ContentStore extends CassandraStore { public void updateContentProperties(String contentId, Map<String, Object> map) { TelemetryManager.log("UpdateContentProperties | Content: " + contentId + " | Properties: " + map); Session session = CassandraConnector.getSession(); if (null == map || map.isEmpty()) throw new ClientException(ContentStoreParams.ERR_INVALID_PROPERTY_VALUES.name(), "Invalid property values. Please specify valid property values"); String query = getUpdateQuery(map.keySet()); PreparedStatement ps = session.prepare(query); Object[] values = new Object[map.size() + 1]; try { int i = 0; for (Entry<String, Object> entry : map.entrySet()) { String value = ""; if (null == entry.getValue()) { value = ""; } else if (entry.getValue() instanceof String) { value = (String) entry.getValue(); } else { value = mapper.writeValueAsString(entry.getValue()); } values[i] = value; i += 1; } values[i] = contentId; BoundStatement bound = ps.bind(values); session.execute(bound); logTransactionEvent("UPDATE", contentId, map); } catch (Exception e) { TelemetryManager.error("Error! Executing update content property: " + e.getMessage(), e); throw new ServerException(ContentStoreParams.ERR_SERVER_ERROR.name(), "Error updating property in Content Store."); } } }
ContentStore extends CassandraStore { public void updateContentProperties(String contentId, Map<String, Object> map) { TelemetryManager.log("UpdateContentProperties | Content: " + contentId + " | Properties: " + map); Session session = CassandraConnector.getSession(); if (null == map || map.isEmpty()) throw new ClientException(ContentStoreParams.ERR_INVALID_PROPERTY_VALUES.name(), "Invalid property values. Please specify valid property values"); String query = getUpdateQuery(map.keySet()); PreparedStatement ps = session.prepare(query); Object[] values = new Object[map.size() + 1]; try { int i = 0; for (Entry<String, Object> entry : map.entrySet()) { String value = ""; if (null == entry.getValue()) { value = ""; } else if (entry.getValue() instanceof String) { value = (String) entry.getValue(); } else { value = mapper.writeValueAsString(entry.getValue()); } values[i] = value; i += 1; } values[i] = contentId; BoundStatement bound = ps.bind(values); session.execute(bound); logTransactionEvent("UPDATE", contentId, map); } catch (Exception e) { TelemetryManager.error("Error! Executing update content property: " + e.getMessage(), e); throw new ServerException(ContentStoreParams.ERR_SERVER_ERROR.name(), "Error updating property in Content Store."); } } ContentStore(); }
ContentStore extends CassandraStore { public void updateContentProperties(String contentId, Map<String, Object> map) { TelemetryManager.log("UpdateContentProperties | Content: " + contentId + " | Properties: " + map); Session session = CassandraConnector.getSession(); if (null == map || map.isEmpty()) throw new ClientException(ContentStoreParams.ERR_INVALID_PROPERTY_VALUES.name(), "Invalid property values. Please specify valid property values"); String query = getUpdateQuery(map.keySet()); PreparedStatement ps = session.prepare(query); Object[] values = new Object[map.size() + 1]; try { int i = 0; for (Entry<String, Object> entry : map.entrySet()) { String value = ""; if (null == entry.getValue()) { value = ""; } else if (entry.getValue() instanceof String) { value = (String) entry.getValue(); } else { value = mapper.writeValueAsString(entry.getValue()); } values[i] = value; i += 1; } values[i] = contentId; BoundStatement bound = ps.bind(values); session.execute(bound); logTransactionEvent("UPDATE", contentId, map); } catch (Exception e) { TelemetryManager.error("Error! Executing update content property: " + e.getMessage(), e); throw new ServerException(ContentStoreParams.ERR_SERVER_ERROR.name(), "Error updating property in Content Store."); } } ContentStore(); void updateContentBody(String contentId, String body); void updateContentOldBody(String contentId, String body); String getContentBody(String contentId); String getContentProperty(String contentId, String property); Map<String, Object> getContentProperties(String contentId, List<String> properties); void updateContentProperty(String contentId, String property, String value); void updateContentProperties(String contentId, Map<String, Object> map); }
ContentStore extends CassandraStore { public void updateContentProperties(String contentId, Map<String, Object> map) { TelemetryManager.log("UpdateContentProperties | Content: " + contentId + " | Properties: " + map); Session session = CassandraConnector.getSession(); if (null == map || map.isEmpty()) throw new ClientException(ContentStoreParams.ERR_INVALID_PROPERTY_VALUES.name(), "Invalid property values. Please specify valid property values"); String query = getUpdateQuery(map.keySet()); PreparedStatement ps = session.prepare(query); Object[] values = new Object[map.size() + 1]; try { int i = 0; for (Entry<String, Object> entry : map.entrySet()) { String value = ""; if (null == entry.getValue()) { value = ""; } else if (entry.getValue() instanceof String) { value = (String) entry.getValue(); } else { value = mapper.writeValueAsString(entry.getValue()); } values[i] = value; i += 1; } values[i] = contentId; BoundStatement bound = ps.bind(values); session.execute(bound); logTransactionEvent("UPDATE", contentId, map); } catch (Exception e) { TelemetryManager.error("Error! Executing update content property: " + e.getMessage(), e); throw new ServerException(ContentStoreParams.ERR_SERVER_ERROR.name(), "Error updating property in Content Store."); } } ContentStore(); void updateContentBody(String contentId, String body); void updateContentOldBody(String contentId, String body); String getContentBody(String contentId); String getContentProperty(String contentId, String property); Map<String, Object> getContentProperties(String contentId, List<String> properties); void updateContentProperty(String contentId, String property, String value); void updateContentProperties(String contentId, Map<String, Object> map);  }