public function save($chain_name)
 {
     $domain_name = $this->_domain_name;
     $item_name = $chain_name;
     $attributes = SimpleDbUtils::genSimpleDbAttributesArray(array("chain_name" => $chain_name));
     SimpleDbPersister::save($domain_name, $item_name, $attributes);
 }
    return;
}
//If a new business entry, check whether it exists already
if ($is_update_operation === FALSE && CoreAttributesUtils::exists($data) === TRUE) {
    $error_json = array("status" => "error", "error" => "Business already exists");
    echo json_encode($error_json);
    return;
}
//If an update operation, don't re-generate business_id and set $replace to true
if ($is_update_operation === TRUE) {
    $attributes = SimpleDbUtils::genSimpleDbAttributesArray($data, true);
} else {
    $is_busines_id_already_taken = false;
    /* Check whether the unique business id that is generated is already not
     * taken.
     */
    do {
        $business_id = BusinessIdGenerator::generate($data["pincode"]);
        $data["business_id"] = $business_id;
        $result = SimpleDbPersister::getAttributes($domain_name, $business_id, array("business_id"));
        $is_business_id_already_taken = empty($result) ? false : true;
    } while ($is_business_id_already_taken === TRUE);
    $attributes = SimpleDbUtils::genSimpleDbAttributesArray($data);
}
$message = CoreAttributesUtils::generateSMSMessage($data);
SMS::send($sms_number, $message);
$business_id = $data["business_id"];
SimpleDbPersister::save($domain_name, $business_id, $attributes);
$success_json = array("status" => "success", "business_id" => $business_id, "created_by_user" => $data["created_by_user"], "created_time" => $data["created_time"]);
echo json_encode($success_json);
return;
}
//TODO: Clean this code
if (isset($data["business_specific_attributes"]) === TRUE) {
    $keys = array_keys($data["business_specific_attributes"]);
    $business_specific_attributes = array();
    foreach ($data["business_specific_attributes"] as $key => $value) {
        $business_specific_attributes[$key] = $value;
    }
    unset($data["business_specific_attributes"]);
    $data = array_merge($data, $business_specific_attributes);
}
/* Encoding it as JSON because hours_of_operation should be saved as a JSON
 * in SimpleDb.
 */
$data["hours_of_operation"] = json_encode($data["hours_of_operation"]);
$data["status"] = "BUSINESS_VERIFIED_COMPLETE";
$attributes = SimpleDbUtils::genSimpleDbAttributesArray($data, TRUE);
SimpleDbPersister::save($domain_name, $business_id, $attributes);
$success_json = array("status" => "success", "last_updated_time" => $last_updated_time);
echo json_encode($success_json);
fastcgi_finish_request();
//Backing up old data
$attributes = SimpleDbUtils::genSimpleDbAttributesArray($business_details, TRUE);
SimpleDbPersister::save($backup_domain_name, $business_id, $attributes);
//Delete old S3 Photos
if (empty($photo_url_array) === TRUE) {
    return;
}
$new_photo_url_array = $data["photo_url"];
S3PhotoDeleter::delete($photo_url_array, $new_photo_url_array);
return;