Java Json Get getSitesFromDb(String replicationSitesInDB)

Here you can find the source of getSitesFromDb(String replicationSitesInDB)

Description

The reason this in JSON is that it probably makes sense to someday query RSAL or some other "big data" component live for a list of remotes sites to which a particular dataset is replicated to.

License

GNU General Public License

Declaration

public static JsonArray getSitesFromDb(String replicationSitesInDB) 

Method Source Code

//package com.java2s;

import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;

public class Main {
    /**//from  w w  w  .j  ava  2 s  .c o  m
     * The reason this in JSON is that it probably makes sense to someday query
     * RSAL or some other "big data" component live for a list of remotes sites
     * to which a particular dataset is replicated to.
     */
    public static JsonArray getSitesFromDb(String replicationSitesInDB) {
        JsonArrayBuilder arraybuilder = Json.createArrayBuilder();
        if (replicationSitesInDB == null || replicationSitesInDB.isEmpty()) {
            return arraybuilder.build();
        }
        // Right now we have all the data right in the database setting but we should probably query RSAL to get the list.
        String[] sites = replicationSitesInDB.split(",");
        for (String site : sites) {
            String[] parts = site.split(":");
            arraybuilder.add(Json.createObjectBuilder().add("fqdn", parts[0]).add("name", parts[1]).add("country",
                    parts[2]));
        }
        return arraybuilder.build();
    }
}

Related

  1. getJsonObject(JsonObject object, String name)
  2. getJsonValue(String json_path, JsonObject response)
  3. getKeyAsString(JsonObject obj, String key, String defaultValue)
  4. getLongProperty(JsonObject object, String property)
  5. getPrettyJsonWriterFactory()
  6. getString(JsonObject jso, String name)
  7. getValueFromJson(JsonObject currentJsonObject, String key)