-
Leonardo Passig Horstmann authored
on mu_put.php and mv_put.php we changed instantiation of Backend to support requests with certificate. on put.php the extra newline that php was complaining about was removed. on Backend.php was changed to adjust create series (fix algorithm that merge series), and some bug fixes on multi SmartData insertion. on Series.php throw exception if invalid values of t0, t1 and r was changed to include the values of these parameters. on MultiSmartData.php: bug fix on verifying existance of ->uncertainty and adding a parseJson method. Also, files Backend.php and SmartAPI.php were changed to support get_activity.
Leonardo Passig Horstmann authoredon mu_put.php and mv_put.php we changed instantiation of Backend to support requests with certificate. on put.php the extra newline that php was complaining about was removed. on Backend.php was changed to adjust create series (fix algorithm that merge series), and some bug fixes on multi SmartData insertion. on Series.php throw exception if invalid values of t0, t1 and r was changed to include the values of these parameters. on MultiSmartData.php: bug fix on verifying existance of ->uncertainty and adding a parseJson method. Also, files Backend.php and SmartAPI.php were changed to support get_activity.
mu_put.php 1.78 KiB
<?php
namespace SmartData;
require_once('../bin/smartdata/SmartAPI.php');
require_once('../bin/smartdata/Logger.php');
require_once('../bin/smartdata/MultiSmartData.php');
http_response_code(HttpStatusCode::BAD_REQUEST);
try {
$content = file_get_contents('php://input');
//if(!REQUEST_CERT){
// throw new Exception\BadRequestException("!CERT > For batch import, the user must use a valid certificate");
//}
$values = json_decode($content, false, 512, JSON_BIGINT_AS_STRING);
if (json_last_error() === JSON_ERROR_NONE) {
if (property_exists( $values, "credentials") ) {
$credentials = Credentials::fromJson( $values->credentials );
$backend = new Backend($credentials);
} else {
$backend = new Backend();
}
$data = MultiSmartData::multi_units($values);
$keys = array_keys($data);
foreach ($keys as $k) {
$lst = $data[$k];
if (!$backend->insert_multiple(...$lst)) {
throw new Exception\InsertionFailedException("MultiValue SmartData Insertion Failed");
}
}
} else {
// Is Binary
$data = MultiSmartData::unpackMultiUnit($content);
$db = new Backend();
$keys = array_keys($data);
foreach ($keys as $k) {
$lst = $data[$k];
if (!$db->insert_multiple(...$lst)) {
throw new Exception\InsertionFailedException("MultiValue SmartData Insertion Failed");
}
}
}
}catch(Exception\CustomException $e){
http_response_code($e->getHTTPCodeError());
Logger::exception($e);
return false;
}catch(\Exception $e){
http_response_code(HttpStatusCode::BAD_REQUEST);
Logger::exception($e);
return false;
}
http_response_code(HttpStatusCode::NO_CONTENT);