25,6 → 25,7 |
|
private $parametres = array(); |
private $ressources = array(); |
private $methode = null; |
private $projetNom = array(); |
private $serviceNom = array(); |
private $cheminCourant = null; |
39,7 → 40,7 |
} |
|
public function consulter($ressources, $parametres) { |
|
$this->methode = 'consulter'; |
$resultat = ''; |
$reponseHttp = new ReponseHttp(); |
try { |
54,6 → 55,18 |
$corps = $reponseHttp->getCorps(); |
return $corps; |
} |
|
public function ajouter($ressources, $requeteDonnees) { |
$this->methode = 'ajouter'; |
$resultat = ''; |
try { |
$this->initialiserRessourcesEtParametres($ressources, $requeteDonnees); |
$this->conteneur = new Conteneur($this->parametres); |
$resultat = $this->traiterRessources(); |
} catch (Exception $e) { |
$reponseHttp->ajouterErreur($e); |
} |
} |
|
private function initialiserRessourcesEtParametres($ressources, $parametres) { |
$this->ressources = $ressources; |
69,9 → 82,9 |
return $retour; |
} |
|
private function avoirRessourceIdentifiant() { |
private function avoirRessourceIdentifiant($num) { |
$presenceId = false; |
if (is_numeric($this->ressources[0])) { |
if (is_numeric($this->ressources[$num])) { |
$presenceId = true; |
} else { |
$message = "Le service demandé '$service' nécessite d'avoir un identifiant d'image valide"; |
110,7 → 123,7 |
* */ |
$presenceRessourceService = false; |
if (isset($this->ressources[0])) { |
if ($this->avoirRessourceIdentifiant()) { |
if ($this->avoirRessourceIdentifiant(0)) { |
if (sizeof($this->ressources) == 1) { |
$presenceRessourceService = true; |
$this->serviceNom = 'observation'; |
130,15 → 143,17 |
private function avoirRessourceSousService() { |
$presenceRessourceService = false; |
$servicesDispo = Outils::recupererTableauConfig('servicesDispo'); |
$service = $this->ressources[1]; |
if (in_array($service, $servicesDispo)) { |
$presenceRessourceService = true; |
$this->serviceNom = 'votes-image'; |
} else { |
$message = "Le service demandé '$service' n'est pas disponible pour le projet {$this->projetNom} !\n". |
"Les services disponibles sont : ".implode(', ', $servicesDispo); |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; |
throw new Exception($message, $code); |
if ($this->avoirRessourceIdentifiant(1)) { |
$service = $this->ressources[2]; |
if (in_array($service, $servicesDispo)) { |
$presenceRessourceService = true; |
$this->serviceNom = 'vote-observation'; |
} else { |
$message = "Le service demandé '$service' n'est pas disponible pour le projet {$this->projetNom} !\n". |
"Les services disponibles sont : ".implode(', ', $servicesDispo); |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; |
throw new Exception($message, $code); |
} |
} |
return $presenceRessourceService; |
} |
157,7 → 172,11 |
$this->conteneur->chargerConfiguration('config_'.$this->projetNom.'.ini'); |
require_once $chemin; |
$service = new $classe($this->conteneur); |
$retour = $service->consulter($this->ressources, $this->parametres); |
if ($this->methode == 'consulter') { |
$retour = $service->consulter($this->ressources, $this->parametres); |
} elseif ($this->methode == 'ajouter') { |
$retour = $service->ajouter($this->ressources, $this->parametres); |
} |
} |
} |
|