Subversion Repositories eFlore/Applications.del

Rev

Rev 1049 | Rev 1661 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1049 Rev 1057
Line 20... Line 20...
20
	private $methode = null;
20
	private $methode = null;
21
	private $projetNom = array();
21
	private $projetNom = array();
22
	private $serviceNom = array();
22
	private $serviceNom = array();
23
	private $cheminCourant = null;
23
	private $cheminCourant = null;
24
	private $squelette_dossier = null;
24
	private $squelette_dossier = null;
25
	// TODO: si dans 1000 ans un nouveau format de flux apparaît, il faudra mettre ceci dans le fichier de config
-
 
26
	private $formats_autorises = array('rss1','rss2','atom');
25
	private $formats_autorises = null;
Line 27... Line 26...
27
 
26
 
Line 28... Line 27...
28
	private $conteneur;
27
	private $conteneur;
29
	
28
	
Line 38... Line 37...
38
	public function consulter($ressources, $parametres) {
37
	public function consulter($ressources, $parametres) {
39
		$this->methode = 'consulter';
38
		$this->methode = 'consulter';
40
		$resultat = '';
39
		$resultat = '';
41
		$reponseHttp = new ReponseHttp();
40
		$reponseHttp = new ReponseHttp();
42
		try {
41
		try {
-
 
42
			$this->initialiserProjet();
43
			$this->initialiserRessourcesEtParametres($ressources, $parametres);
43
			$this->initialiserRessourcesEtParametres($ressources, $parametres);
44
			$this->verifierRessourcesEtParametres();
-
 
45
			$this->conteneur = new Conteneur($this->parametres);
44
			$this->conteneur = new Conteneur($this->parametres);
-
 
45
			$this->verifierRessourcesEtParametres();
46
			$resultat = $this->traiterRessources();
46
			$resultat = $this->traiterRessources();
47
			$reponseHttp->setResultatService($this->creerResultatService($resultat));
47
			$reponseHttp->setResultatService($this->creerResultatService($resultat));
48
		} catch (Exception $e) {
48
		} catch (Exception $e) {
49
			$reponseHttp->ajouterErreur($e);
49
			$reponseHttp->ajouterErreur($e);
50
		}
50
		}
Line 57... Line 57...
57
		$this->ressources = $ressources;
57
		$this->ressources = $ressources;
58
		$this->parametres = $parametres;
58
		$this->parametres = $parametres;
59
	}
59
	}
Line 60... Line 60...
60
	
60
	
-
 
61
	private function verifierRessourcesEtParametres() {
-
 
62
		
-
 
63
		$servicesDispos = Config::get('servicesDispo');
-
 
64
		if (!isset($this->ressources[0]) || !in_array($this->ressources[0], explode(',',$servicesDispos))) {
-
 
65
			$message = "Vous devez indiquer un nom de service valide, les services disponibles sont ".$servicesDispos;
-
 
66
			$code = RestServeur::HTTP_CODE_ERREUR;
-
 
67
			throw new Exception($message, $code);
-
 
68
		}
-
 
69
		
-
 
70
		$chaineFormatsAutorises = Config::get('formatsRss');
61
	private function verifierRessourcesEtParametres() {
71
		$this->formats_autorises = explode(',', $chaineFormatsAutorises);
62
		if (!isset($this->ressources[1]) || !in_array($this->ressources[1], $this->formats_autorises)) {
72
		if (!isset($this->ressources[1]) || !in_array($this->ressources[1], $this->formats_autorises)) {
63
			$message = "Vous devez indiquer un format de flux valide, les formats acceptés sont ".implode(', ',$this->formats_autorises);
73
			$message = "Vous devez indiquer un format de flux valide, les formats acceptés sont ".$chaineFormatsAutorises;
64
			$code = RestServeur::HTTP_CODE_ERREUR;
74
			$code = RestServeur::HTTP_CODE_ERREUR;
65
			throw new Exception($message, $code);
75
			throw new Exception($message, $code);
66
		} else {
76
		} else {
67
			$this->format = $this->ressources[1];
77
			$this->format = $this->ressources[1];
68
		}
78
		}
Line 69... Line 79...
69
	}
79
	}
70
 
80
 
71
	private function traiterRessources() {
-
 
72
		$retour = '';
81
	private function traiterRessources() {
Line 73... Line 82...
73
		$this->initialiserProjet();
82
		$retour = '';
74
		$retour = $this->initialiserService();
83
		$retour = $this->initialiserService();