Commit 35cee8b5 authored by François Agneray's avatar François Agneray
Browse files

Update data management system

parent 07ea9148
Pipeline #4870 passed with stages
in 2 minutes and 31 seconds
......@@ -22,7 +22,7 @@ $app->group('', function (RouteCollectorProxy $group) {
$group->map([OPTIONS, GET, POST], '/database', App\Action\DatabaseListAction::class);
$group->map([OPTIONS, GET, PUT, DELETE], '/database/{id}', App\Action\DatabaseAction::class);
$group->map([OPTIONS, GET], '/database/{id}/table', App\Action\TableListAction::class);
$group->map([OPTIONS, GET], '/file-explorer/[{fpath:.*}]', App\Action\AdminFileExplorerAction::class);
$group->map([OPTIONS, GET], '/file-explorer[{fpath:.*}]', App\Action\AdminFileExplorerAction::class);
})->add(new App\Middleware\RouteGuardMiddleware(
boolval($container->get(SETTINGS)['token']['enabled']),
array(GET, POST, PUT, DELETE),
......@@ -66,5 +66,5 @@ $app->group('', function (RouteCollectorProxy $group) {
));
$app->get('/search/{dname}', App\Action\SearchAction::class);
$app->get('/dataset-file-explorer/{dname}/[{fpath:.*}]', App\Action\DatasetFileExplorerAction::class);
$app->get('/dataset-file-explorer/{dname}[{fpath:.*}]', App\Action\DatasetFileExplorerAction::class);
$app->get('/download-file/{dname}/[{fpath:.*}]', App\Action\DownloadFileAction::class);
......@@ -70,7 +70,7 @@ curl -d '{"name":"colibri","label":"Colibri Project Test","description":"Project
curl -d '{"label":"Default dataset family","display":10}' --header 'Content-Type: application/json' -X POST http://localhost/instance/default/dataset-family
curl -d '{"name":"obs_cat","table_ref":"obs_cat","label":"ObsCat dataset","description":"ObsCat","display":10,"count":10000,"vo":false,"data_path":"/mnt/mount","config":{"cone_search":{"enabled":true,"column_ra":2,"column_dec":3},"selectable_row":true},"public":true,"project_name":"anis_project"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset
curl -d '{"name":"observations","table_ref":"observations_info","label":"Observations dataset","description":"Observations","display":20,"count":177454,"vo":false,"data_path":"/mnt/mount","config":{"selectable_row":false},"public":true,"project_name":"anis_project"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset
curl -d '{"name":"vipers_dr2_w1","table_ref":"aspic_vipers_dr2_w1","label":"VIPERS-W1 (DR2)","description":"VIPERS W1 dataset","display":30,"count":1000,"vo":false,"data_path":"ASPIC/VIPERS_DR2","config":{"selectable_row":false},"public":true,"project_name":"anis_project"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset
curl -d '{"name":"vipers_dr2_w1","table_ref":"aspic_vipers_dr2_w1","label":"VIPERS-W1 (DR2)","description":"VIPERS W1 dataset","display":30,"count":1000,"vo":false,"data_path":"/ASPIC/VIPERS_DR2","config":{"selectable_row":false},"public":true,"project_name":"anis_project"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset
curl -d '{"name":"gama_g02_dr3","table_ref":"aspic_gama_g02","label":"GAMA G02 (DR3)","description":"GAMA G02 dataset","display":40,"count":8,"vo":false,"data_path":"/mnt/mount","config":{"selectable_row":false},"public":true,"project_name":"anis_project"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset
# Add ANIS obs_cat default criteria family, default output family and default output category
......
......@@ -15,6 +15,7 @@ namespace App\Action;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Doctrine\ORM\EntityManagerInterface;
use Slim\Exception\HttpNotFoundException;
use Slim\Exception\HttpBadRequestException;
use Nyholm\Psr7\Factory\Psr17Factory;
......@@ -52,7 +53,7 @@ final class AdminFileExplorerAction
return $response->withHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
}
$path = realpath($this->dataPath);
$path = $this->dataPath;
if (array_key_exists('fpath', $args)) {
$path .= DIRECTORY_SEPARATOR . $args['fpath'];
......@@ -65,6 +66,13 @@ final class AdminFileExplorerAction
);
}
if (!file_exists($path)) {
throw new HttpNotFoundException(
$request,
'Directory ' . $args['fpath'] . ' is not found'
);
}
$files = array();
foreach (scandir($path) as $file) {
......
......@@ -16,6 +16,7 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Doctrine\ORM\EntityManagerInterface;
use Slim\Exception\HttpNotFoundException;
use Slim\Exception\HttpBadRequestException;
use Nyholm\Psr7\Factory\Psr17Factory;
final class DatasetFileExplorerAction extends AbstractAction
......@@ -79,7 +80,7 @@ final class DatasetFileExplorerAction extends AbstractAction
$this->verifyDatasetAuthorization($request, $dataset->getName(), $this->settings['admin_role']);
}
$path = realpath($this->dataPath) . DIRECTORY_SEPARATOR . $dataset->getDataPath();
$path = $this->dataPath . $dataset->getDataPath();
if (array_key_exists('fpath', $args)) {
$path .= DIRECTORY_SEPARATOR . $args['fpath'];
......@@ -92,6 +93,13 @@ final class DatasetFileExplorerAction extends AbstractAction
);
}
if (!file_exists($path)) {
throw new HttpNotFoundException(
$request,
'Directory ' . $args['fpath'] . ' is not found'
);
}
$files = array();
foreach (scandir($path) as $file) {
......
......@@ -80,9 +80,7 @@ final class DownloadFileAction extends AbstractAction
}
// Search the file
$filePath = $this->dataPath
. DIRECTORY_SEPARATOR . $dataset->getDataPath()
. DIRECTORY_SEPARATOR . $args['fpath'];
$filePath = $this->dataPath . $dataset->getDataPath() . DIRECTORY_SEPARATOR . $args['fpath'];
// If the file not found 404
if (!file_exists($filePath)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment