use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class ClientEndPointDTO method toJson.
@Override
public JsonObject toJson() {
final JsonObject root = Json.object();
root.add("uuid", uuid.toString());
root.add("address", address);
root.add("clientType", clientType);
root.add("name", name);
JsonArray labelsObject = Json.array();
for (String label : labels) {
labelsObject.add(label);
}
root.add("labels", labelsObject);
root.add("ipAddress", ipAddress);
root.add("canonicalHostName", canonicalHostName);
return root;
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class ClientEndPointDTO method fromJson.
@Override
public void fromJson(JsonObject json) {
uuid = UUID.fromString(getString(json, "uuid"));
address = getString(json, "address");
clientType = getString(json, "clientType");
name = getString(json, "name");
JsonArray labelsArray = getArray(json, "labels");
labels = new HashSet<>();
for (JsonValue labelValue : labelsArray) {
labels.add(labelValue.asString());
}
ipAddress = getString(json, "ipAddress", null);
canonicalHostName = getString(json, "canonicalHostName", null);
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class WanReplicationConfigDTO method toJson.
@Override
public JsonObject toJson() {
JsonObject root = new JsonObject();
if (config.getName() != null) {
root.add("name", config.getName());
}
JsonArray batchPublishers = new JsonArray();
JsonArray customPublishers = new JsonArray();
for (WanBatchPublisherConfig publisherConfig : config.getBatchPublisherConfigs()) {
batchPublishers.add(new WanBatchPublisherConfigDTO(publisherConfig).toJson());
}
for (WanCustomPublisherConfig publisherConfig : config.getCustomPublisherConfigs()) {
customPublishers.add(new CustomWanPublisherConfigDTO(publisherConfig).toJson());
}
root.add("batchPublishers", batchPublishers);
root.add("customPublishers", customPublishers);
WanConsumerConfig consumerConfig = config.getConsumerConfig();
if (consumerConfig != null) {
root.add("consumer", new WanConsumerConfigDTO(consumerConfig).toJson());
}
return root;
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class EventBatch method toJson.
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.add("cluster", cluster);
json.add("address", address);
JsonArray eventJsonArray = new JsonArray();
for (Event event : events) {
JsonObject metadataJson = new JsonObject();
metadataJson.add("type", event.getType().getCode());
metadataJson.add("timestamp", event.getTimestamp());
JsonObject eventJson = new JsonObject();
eventJson.add("metadata", metadataJson);
eventJson.add("data", event.toJson());
eventJsonArray.add(eventJson);
}
json.add("events", eventJsonArray);
return json;
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class PermissionConfigDTO method toJson.
@Override
public JsonObject toJson() {
JsonObject object = new JsonObject();
object.add("permissionType", permissionConfig.getType().getNodeName());
object.add("name", permissionConfig.getName());
if (StringUtil.isNullOrEmptyAfterTrim(permissionConfig.getPrincipal())) {
object.add("principal", "*");
} else {
object.add("principal", permissionConfig.getPrincipal());
}
Set<String> endpoints = permissionConfig.getEndpoints();
if (endpoints != null) {
JsonArray endpointsArray = new JsonArray();
for (String endpoint : endpoints) {
endpointsArray.add(endpoint);
}
object.add("endpoints", endpointsArray);
}
Set<String> actions = permissionConfig.getActions();
if (actions != null) {
JsonArray actionsArray = new JsonArray();
for (String action : actions) {
actionsArray.add(action);
}
object.add("actions", actionsArray);
}
return object;
}
Aggregations