chg: [sighting/api] improved comments

pull/3789/head
Sami Mokaddem 2018-10-23 13:39:29 +02:00
parent d5be7e8ad9
commit 5763a74b96
3 changed files with 6 additions and 10 deletions

View File

@ -183,7 +183,7 @@ class RestResponseComponent extends Component
),
'restSearch' => array(
'description' => "Search MISP using a list of filter parameters and return the data in the JSON format.
The search is available on an event, attribute or instace level,
The search is available on an event, attribute or instance level,
just select the scope via the URL (/sighting/get/event vs /sighting/get/attribute vs /sighting/get/).
id MUST be provided if context is set.",
'mandatory' => array('returnFormat'),

View File

@ -232,10 +232,11 @@ class SightingsController extends AppController
);
$filters = $this->_harvestParameters($filterData, $exception);
// ensure that an id is provided if context is set
// validate context
if (!in_array($context, $allowedContext, true)) {
throw new MethodNotAllowedException(_('Invalid context.'));
}
// ensure that an id is provided if context is set
if ($context !== false && !isset($filters['id'])) {
throw new MethodNotAllowedException(_('An id must be provided if the context is set.'));
}

View File

@ -463,7 +463,7 @@ class Sighting extends AppModel
App::uses($this->validFormats[$returnFormat][1], 'Export');
$exportTool = new $this->validFormats[$returnFormat][1]();
// fetch sightings matching the query
// construct filtering conditions
if (isset($filters['from']) && isset($filters['to'])) {
$timeCondition = array($filters['from'], $filters['to']);
unset($filters['from']);
@ -494,6 +494,7 @@ class Sighting extends AppModel
$conditions['Sighting.event_id'] = $filters['id'];
}
// fetch sightings matching the query
$sightings = $this->find('list', array(
'recursive' => -1,
'conditions' => $conditions,
@ -503,7 +504,7 @@ class Sighting extends AppModel
$filters['requested_attributes'] = array('id', 'attribute_id', 'event_id', 'org_id', 'date_sighting', 'uuid', 'source', 'type');
// apply ACL and sightings policies
// apply ACL and sighting policies
$allowedSightings = array();
$additional_attribute_added = false;
$additional_event_added = false;
@ -537,9 +538,6 @@ class Sighting extends AppModel
// this is where the new code path for the export modules will go
throw new MethodNotFoundException('Invalid export format.');
}
if (method_exists($exportTool, 'modify_params')) {
//$params = $exportTool->modify_params($user, $params);
}
$exportToolParams = array(
'user' => $user,
@ -548,9 +546,6 @@ class Sighting extends AppModel
'scope' => 'Sighting',
'filters' => $filters
);
if (!empty($exportTool->additional_params)) {
//$params = array_merge($params, $exportTool->additional_params);
}
$tmpfile = tmpfile();
fwrite($tmpfile, $exportTool->header($exportToolParams));