in src/main/java/org/apache/sling/distribution/queue/impl/simple/QueueItemMapper.java [44:81]
DistributionQueueItem readQueueItem(String line) {
String[] split = line.split(" ", 2);
if (split.length != 2) {
throw new IllegalArgumentException("Invalid item found " + line);
}
String packageId = split[0];
String infoString = split[1];
Map<String, Object> info = new HashMap<String, Object>();
JsonReader reader = Json.createReader(new StringReader(infoString));
JsonObject jsonObject = reader.readObject();
NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
for (Map.Entry<String, JsonValue> entry : jsonObject.entrySet()) {
if (entry.getValue().getValueType().equals(JsonValue.ValueType.ARRAY)) {
JsonArray value = jsonObject.getJsonArray(entry.getKey());
String[] a = new String[value.size()];
for (int i = 0; i < a.length; i++) {
a[i] = value.getString(i);
}
info.put(entry.getKey(), a);
} else if (JsonValue.NULL.equals(entry.getValue())) {
info.put(entry.getKey(), null);
} else if (entry.getValue().getValueType().equals(JsonValue.ValueType.NUMBER)) {
try {
Number n = numberFormat.parse(entry.getValue().toString());
info.put(entry.getKey(), n);
} catch (ParseException e) {
throw new IllegalStateException("Failed to read queue item", e);
}
} else {
info.put(entry.getKey(), ((JsonString) entry.getValue()).getString());
}
}
return new DistributionQueueItem(packageId, info);
}