Example usage for com.fasterxml.jackson.databind JsonNode toString

List of usage examples for com.fasterxml.jackson.databind JsonNode toString

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JsonNode toString.

Prototype

public abstract String toString();

Source Link

Usage

From source file:controllers.AnyplaceMapping.java

/**
 * Inserts a new Point of Interest at the coordinates passed in
 *
 * @return the newly created POIS ID is included in the response if success
 *///from   ww w  .j  av  a2s  .c o m
public static Result poisAdd() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::poisAdd(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "is_published", "buid", "floor_name",
            "floor_number", "name", "pois_type", "is_door", "is_building_entrance", "coordinates_lat",
            "coordinates_lon", "access_token");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }
    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.path("buid").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id) && !isBuildingCoOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    try {
        Poi poi = new Poi(json);
        //System.out.println(poi.toValidCouchJson());
        if (!ProxyDataSource.getIDatasource().addJsonDocument(poi.getId(), 0, poi.toCouchGeoJSON())) {
            return AnyResponseHelper.bad_request("Poi already exists or could not be added!");
        }
        ObjectNode res = JsonUtils.createObjectNode();
        res.put("puid", poi.getId());
        return AnyResponseHelper.ok(res, "Successfully added poi!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}

From source file:controllers.AnyplaceMapping.java

/**
 * Adds a floor to the building denoted by buid
 *
 * @return/*ww w.  ja  v a2 s .c  o m*/
 */
public static Result floorAdd() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::floorAdd(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "is_published", "buid", "floor_name",
            "description", "floor_number", "access_token");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }

    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.path("buid").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    String floor_number = json.path("floor_number").textValue();

    if (!Floor.checkFloorNumberFormat(floor_number)) {
        return AnyResponseHelper.bad_request("Floor number cannot contain whitespace!");
    }

    try {
        Floor floor = new Floor(json);
        //System.out.println(floor.toValidCouchJson());
        if (!ProxyDataSource.getIDatasource().addJsonDocument(floor.getId(), 0, floor.toValidCouchJson())) {
            return AnyResponseHelper.bad_request("Floor already exists or could not be added!");
        }
        return AnyResponseHelper.ok("Successfully added floor " + floor_number + "!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}

From source file:controllers.AnyplaceMapping.java

public static Result buildingUpdateCoOwners() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }//from   ww  w  . j  a  v a  2  s . c o m
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::buildingUpdateCoOwners(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "buid", "access_token", "co_owners");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }
    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.path("buid").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

        Building building = new Building(stored_building);
        if (!ProxyDataSource.getIDatasource().replaceJsonDocument(building.getId(), 0,
                building.appendCoOwners(json))) {
            return AnyResponseHelper.bad_request("Building could not be updated!");
        }

        return AnyResponseHelper.ok("Successfully updated building!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}

From source file:controllers.AnyplaceMapping.java

/**
 * Delete the Point of Interest denoted by the requested POIS id
 *
 * @return//ww w.  ja  va 2s  . com
 */
public static Result poisDelete() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::poiDelete(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "puid", "buid", "access_token");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }
    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.findPath("buid").textValue();
    String puid = json.findPath("puid").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id) && !isBuildingCoOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    try {
        // we need to download the pois/floors/connections and all its connections and delete them all
        List<String> all_items_failed = ProxyDataSource.getIDatasource().deleteAllByPoi(puid);
        if (all_items_failed.size() > 0) {
            // TODO - THINK WHAT TO DO WHEN DELETION FAILS ON SOME ITEMS

            // TODO - MARKING THEM INSIDE THE DB APPENDING A FLAG IN ORDER A TO MAKE THEM
            // TODO - ELIGIBLE FOR ANOTHER SERVICE THAT RUNS EVERY HOUR AND DELETES EVERYTHING

            ObjectNode obj = JsonUtils.createObjectNode();
            obj.put("ids", JsonUtils.getJsonFromList(all_items_failed));
            return AnyResponseHelper.bad_request(obj,
                    "Some items related to the deleted poi could not be deleted: " + all_items_failed.size()
                            + " items.");
        }
        return AnyResponseHelper.ok("Successfully deleted everything related to the poi!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}

From source file:controllers.AnyplaceMapping.java

public static Result buildingUpdateOwner() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }/*from   w  w w . j av  a  2  s  .  co m*/
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::buildingUpdateCoOwners(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "buid", "access_token", "new_owner");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }
    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.path("buid").textValue();

    String newOwner = json.path("new_owner").textValue();
    newOwner = appendToOwnerId(newOwner);

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

        Building building = new Building(stored_building);
        if (!ProxyDataSource.getIDatasource().replaceJsonDocument(building.getId(), 0,
                building.changeOwner(newOwner))) {
            return AnyResponseHelper.bad_request("Building could not be updated!");
        }

        return AnyResponseHelper.ok("Successfully updated building!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}

From source file:com.delphix.delphix.DelphixEngine.java

/**
 * Send GET to Delphix Engine and return the result
 *///from ww  w .  j  av  a  2s  . c  o  m
private JsonNode engineGET(final String path) throws IOException, DelphixEngineException {
    // Log requests
    LOGGER.log(Level.WARNING, path);

    // Build and send request
    HttpGet request = new HttpGet(PROTOCOL + engineAddress + path);
    request.setHeader(HttpHeaders.CONTENT_TYPE, CONTENT_TYPE);
    HttpResponse response = client.execute(request);

    // Get result of request
    String result = EntityUtils.toString(response.getEntity());
    JsonNode jsonResult = MAPPER.readTree(result);
    EntityUtils.consume(response.getEntity());
    if (!jsonResult.get(FIELD_STATUS).asText().equals(OK_STATUS)) {
        throw new DelphixEngineException(jsonResult.get("error").get("details").asText());
    }

    // Log result
    LOGGER.log(Level.WARNING, jsonResult.toString());
    return jsonResult;
}

From source file:controllers.AnyplaceMapping.java

/**
 * Delete the floor specified by buid and floor_number.
 *
 * @return/*from ww  w  .  ja va  2 s. c  o m*/
 */
public static Result floorDelete() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::floorDelete(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "buid", "floor_number",
            "access_token");

    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }

    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.findPath("buid").textValue();
    String floor_number = json.findPath("floor_number").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    try {
        // we need to download the pois/connections and all its connections and delete them all
        List<String> all_items_failed = ProxyDataSource.getIDatasource().deleteAllByFloor(buid, floor_number);
        if (all_items_failed.size() > 0) {
            // TODO - THINK WHAT TO DO WHEN DELETION FAILS ON SOME ITEMS

            // TODO - MARKING THEM INSIDE THE DB APPENDING A FLAG IN ORDER A TO MAKE THEM
            // TODO - ELIGIBLE FOR ANOTHER SERVICE THAT RUNS EVERY HOUR AND DELETES EVERYTHING

            ObjectNode obj = JsonUtils.createObjectNode();
            obj.put("ids", JsonUtils.getJsonFromList(all_items_failed));
            return AnyResponseHelper.bad_request(obj,
                    "Some items related to the deleted floor could not be deleted: " + all_items_failed.size()
                            + " items.");
        }
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    // delete the floor plan
    String filePath = AnyPlaceTilerHelper.getFloorPlanFor(buid, floor_number);
    try {
        File floorfile = new File(filePath);
        if (floorfile.exists())
            HelperMethods.recDeleteDirFile(floorfile);
    } catch (IOException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage()
                + "] while deleting floor plan." + "\nAll related information is deleted from the database!");
    }
    return AnyResponseHelper.ok("Successfully deleted everything related to the floor!");
}

From source file:controllers.AnyplaceMapping.java

/**
 * Delete the building specified by buid.
 *
 * @return/*w  w  w  .ja  v  a  2s .c  om*/
 */
public static Result buildingDelete() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::buildingDelete(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "buid", "access_token");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }

    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.findPath("buid").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    try {
        // we need to download the pois/floors/connections and all its connections and delete them all
        List<String> all_items_failed = ProxyDataSource.getIDatasource().deleteAllByBuilding(buid);
        if (all_items_failed.size() > 0) {
            // TODO - THINK WHAT TO DO WHEN DELETION FAILS ON SOME ITEMS

            // TODO - MARKING THEM INSIDE THE DB APPENDING A FLAG IN ORDER A TO MAKE THEM
            // TODO - ELIGIBLE FOR ANOTHER SERVICE THAT RUNS EVERY HOUR AND DELETES EVERYTHING

            ObjectNode obj = JsonUtils.createObjectNode();
            obj.put("ids", JsonUtils.getJsonFromList(all_items_failed));
            return AnyResponseHelper.bad_request(obj,
                    "Some items related to the deleted building could not be deleted: "
                            + all_items_failed.size() + " items.");
        }
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    // delete all the floor plans
    String filePath = AnyPlaceTilerHelper.getRootFloorPlansDirFor(buid);
    try {
        File buidfile = new File(filePath);
        if (buidfile.exists())
            HelperMethods.recDeleteDirFile(buidfile);
    } catch (IOException e) {
        // TODO - what to do on failure
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage()
                + "] while deleting floor plans." + "\nAll related information is deleted from the database!");
    }
    return AnyResponseHelper.ok("Successfully deleted everything related to building!");
}

From source file:controllers.AnyplaceMapping.java

/**
 * Update floor information ( floor name, description, is_published )
 *
 * @return/*w  ww  .  j  ava  2 s. co  m*/
 */
public static Result floorUpdate() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::floorUpdate(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "buid", "floor_number",
            "access_token");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }

    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid = json.path("buid").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }

        if (!isBuildingOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    String floor_number = json.path("floor_number").textValue();

    if (!Floor.checkFloorNumberFormat(floor_number)) {
        return AnyResponseHelper.bad_request("Floor number cannot contain whitespace!");
    }

    try {
        String fuid = Floor.getId(buid, floor_number);
        ObjectNode stored_floor = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(fuid);
        if (stored_floor == null) {
            return AnyResponseHelper.bad_request("Floor does not exist or could not be retrieved!");
        }

        // check for values to update
        if (json.findValue("is_published") != null) {
            stored_floor.put("is_published", json.path("is_published").textValue());
        }
        if (json.findValue("floor_name") != null) {
            stored_floor.put("floor_name", json.path("floor_name").textValue());
        }
        if (json.findValue("description") != null) {
            stored_floor.put("description", json.path("description").textValue());
        }

        AbstractModel floor = new Floor(stored_floor);
        if (!ProxyDataSource.getIDatasource().replaceJsonDocument(floor.getId(), 0, floor.toValidCouchJson())) {
            return AnyResponseHelper.bad_request("Floor could not be updated!");
        }

        return AnyResponseHelper.ok("Successfully updated floor!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}

From source file:controllers.AnyplaceMapping.java

/**
 * Deletes the connection between two Points of Interest - denoted by pois_a and pois_b -
 *
 * @return//w ww .j av  a  2s  .  co m
 */
public static Result connectionDelete() {
    OAuth2Request anyReq = new OAuth2Request(request(), response());
    if (!anyReq.assertJsonBody()) {
        return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON);
    }
    JsonNode json = anyReq.getJsonBody();
    LPLogger.info("AnyplaceMapping::poiDelete(): " + json.toString());

    List<String> requiredMissing = JsonUtils.requirePropertiesInJson(json, "pois_a", "pois_b", "buid_a",
            "buid_b", "access_token");
    if (!requiredMissing.isEmpty()) {
        return AnyResponseHelper.requiredFieldsMissing(requiredMissing);
    }
    // get access token from url and check it against google's service
    if (json.findValue("access_token") == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    String owner_id = verifyOwnerId(json.findValue("access_token").textValue());
    if (owner_id == null) {
        return AnyResponseHelper.forbidden("Unauthorized");
    }
    owner_id = appendToOwnerId(owner_id);
    ((ObjectNode) json).put("owner_id", owner_id);

    String buid1 = json.path("buid_a").textValue();
    String buid2 = json.path("buid_b").textValue();

    try {
        ObjectNode stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid1);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }
        if (!isBuildingOwner(stored_building, owner_id) && !isBuildingCoOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

        stored_building = (ObjectNode) ProxyDataSource.getIDatasource().getFromKeyAsJson(buid2);
        if (stored_building == null) {
            return AnyResponseHelper.bad_request("Building does not exist or could not be retrieved!");
        }
        if (!isBuildingOwner(stored_building, owner_id) && !isBuildingCoOwner(stored_building, owner_id)) {
            return AnyResponseHelper.unauthorized("Unauthorized");
        }

    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }

    String pois_a = json.path("pois_a").textValue();
    String pois_b = json.path("pois_b").textValue();
    try {
        String cuid = Connection.getId(pois_a, pois_b);
        // we need to download the pois/floors/connections and all its connections and delete them all
        List<String> all_items_failed = ProxyDataSource.getIDatasource().deleteAllByConnection(cuid);

        if (all_items_failed == null) {
            LPLogger.info("AnyplaceMapping::connectionDelete(): " + cuid + " not found.");
            return AnyResponseHelper.bad_request("POI Connection not found");
        }

        if (all_items_failed.size() > 0) {
            // TODO - THINK WHAT TO DO WHEN DELETION FAILS ON SOME ITEMS

            // TODO - MARKING THEM INSIDE THE DB APPENDING A FLAG IN ORDER A TO MAKE THEM
            // TODO - ELIGIBLE FOR ANOTHER SERVICE THAT RUNS EVERY HOUR AND DELETES EVERYTHING

            ObjectNode obj = JsonUtils.createObjectNode();
            obj.put("ids", JsonUtils.getJsonFromList(all_items_failed));
            return AnyResponseHelper.bad_request(obj,
                    "Some items related to the deleted connection could not be deleted: "
                            + all_items_failed.size() + " items.");
        }
        return AnyResponseHelper.ok("Successfully deleted everything related to the connection!");
    } catch (DatasourceException e) {
        return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage() + "]");
    }
}