use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project apache-kafka-on-k8s by banzaicloud.
the class VerifiableSinkTask method put.
@Override
public void put(Collection<SinkRecord> records) {
long nowMs = System.currentTimeMillis();
for (SinkRecord record : records) {
Map<String, Object> data = new HashMap<>();
data.put("name", name);
// VerifiableSourceTask's input task (source partition)
data.put("task", record.key());
data.put("sinkTask", id);
data.put("topic", record.topic());
data.put("time_ms", nowMs);
data.put("seqno", record.value());
data.put("offset", record.kafkaOffset());
String dataJson;
try {
dataJson = JSON_SERDE.writeValueAsString(data);
} catch (JsonProcessingException e) {
dataJson = "Bad data can't be written as json: " + e.getMessage();
}
System.out.println(dataJson);
unflushed.add(data);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project cytoscape-impl by cytoscape.
the class AbstractCustomGraphics2 method set.
public synchronized void set(final String key, Object value) {
if (key == null)
throw new IllegalArgumentException("'key' must not be null.");
final Class<?> type = getSettingType(key);
if (type != null) {
if (value != null) {
// It's OK; just take the value as it is.
boolean correctType = type == Array.class && value.getClass().isArray() && value.getClass().getComponentType() == getSettingElementType(key);
correctType = correctType || type.isAssignableFrom(value.getClass());
if (!correctType) {
final ObjectMapper om = getObjectMapper();
String json = value.toString();
if (type != List.class) {
try {
json = om.writeValueAsString(value);
} catch (JsonProcessingException e) {
logger.error("Cannot parse JSON field " + key, e);
}
}
value = PropertiesJsonDeserializer.readValue(key, json, om, this);
}
}
properties.put(key, value);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project cytoscape-impl by cytoscape.
the class AbstractCustomGraphics2 method toSerializableString.
@Override
public String toSerializableString() {
String output = "";
try {
final ObjectMapper om = getObjectMapper();
output = om.writeValueAsString(this.properties);
output = getId() + ":" + output;
} catch (JsonProcessingException e) {
logger.error("Cannot create JSON from custom graphics", e);
}
return output;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project metalnx-web by irods-contrib.
the class UserBookmarkController method bookmarksPaginated.
@RequestMapping(value = "/bookmarksPaginated")
@ResponseBody
public String bookmarksPaginated(final HttpServletRequest request) {
int draw = Integer.parseInt(request.getParameter("draw"));
int start = Integer.parseInt(request.getParameter("start"));
int length = Integer.parseInt(request.getParameter("length"));
String searchString = request.getParameter("search[value]");
int orderColumn = Integer.parseInt(request.getParameter("order[0][column]"));
String orderDir = request.getParameter("order[0][dir]");
boolean onlyCollections = Boolean.parseBoolean(request.getParameter("onlyCollections"));
String loggedUsername = irodsServices.getCurrentUser();
String loggedUserZoneName = irodsServices.getCurrentUserZone();
DataGridUser user = userService.findByUsernameAndAdditionalInfo(loggedUsername, loggedUserZoneName);
String[] orderBy = { "name", "path", "created_at", "is_collection" };
// checking if there is another column to order by
boolean has2ndColumnToOrderBy = request.getParameter("order[1][column]") != null;
List<DataGridUserBookmark> userBookmarks = null;
if (has2ndColumnToOrderBy) {
List<String> orderByList = new ArrayList<String>();
List<String> orderDirList = new ArrayList<String>();
int firstCol = Integer.parseInt(request.getParameter("order[0][column]"));
int secondCol = Integer.parseInt(request.getParameter("order[1][column]"));
orderByList.add(orderBy[firstCol]);
orderDirList.add(request.getParameter("order[0][dir]"));
orderByList.add(orderBy[secondCol]);
orderDirList.add(request.getParameter("order[1][dir]"));
userBookmarks = userBookmarkService.findBookmarksPaginated(user, start, length, searchString, orderByList, orderDirList, onlyCollections);
} else {
userBookmarks = userBookmarkService.findBookmarksPaginated(user, start, length, searchString, orderBy[orderColumn], orderDir, onlyCollections);
}
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> jsonResponse = new HashMap<String, Object>();
String jsonString = "";
if ("".equals(searchString)) {
totalUserBookmarks = user.getBookmarks().size();
totalUserBookmarksFiltered = user.getBookmarks().size();
} else {
totalUserBookmarksFiltered = userBookmarks.size();
}
jsonResponse.put("draw", String.valueOf(draw));
jsonResponse.put("recordsTotal", String.valueOf(totalUserBookmarks));
jsonResponse.put("recordsFiltered", String.valueOf(totalUserBookmarksFiltered));
jsonResponse.put("data", userBookmarks);
try {
jsonString = mapper.writeValueAsString(jsonResponse);
} catch (JsonProcessingException e) {
logger.error("Could not parse user bookmarks to json: {}", e.getMessage());
}
return jsonString;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project apiee by phillip-kruger.
the class SwaggerCache method generateJson.
private String generateJson(int hash, final Set<Class<?>> classes, URL url) {
log.log(Level.FINEST, "Generating {0} response from context", url);
Swagger swagger = createSwagger(classes, url);
try {
String swaggerJson = Json.pretty().writeValueAsString(swagger);
swaggerMap.put(hash, swaggerJson);
return swaggerJson;
} catch (JsonProcessingException ex) {
log.log(Level.WARNING, "Could not generate {0} - {1}", new Object[] { url.toString(), ex.getMessage() });
}
log.log(Level.WARNING, "Could not generate {0} - null", new Object[] { url.toString() });
return null;
}
Aggregations