diff --git a/MaarchREST.class.php b/MaarchREST.class.php index 22daeea0d045fd8b8f03ce569eb7c40714c457e3..77f3dc620c1fb09d79e5a1fe4989bbd51b5395d8 100644 --- a/MaarchREST.class.php +++ b/MaarchREST.class.php @@ -104,8 +104,7 @@ class MaarchREST extends SAEConnecteur { * @throws Exception */ public function getAcuseReception($id_transfert) { - - if (! $id_transfert){ + if (!$id_transfert){ throw new UnrecoverableException("L'identifiant du transfert n'a pas été trouvé"); } @@ -118,7 +117,7 @@ class MaarchREST extends SAEConnecteur { if ($messageInformations) { $zipMessage = $this->getZipMessage($messageInformations['messageId']); } else { - throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageInformations['messageId']." n'a pas pu êtr récuperé."); + throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageInformations['messageId']." n'a pas pu être récuperé."); } return $this->getXmlFromZipMessage($zipMessage, $messageInformations['messageId']); @@ -147,7 +146,7 @@ class MaarchREST extends SAEConnecteur { if ($messageInformations) { $zipMessage = $this->getZipMessage($messageInformations['replyMessage']['messageId']); } else { - throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageInformations['messageId']." n'a pas pu êtr récuperé."); + throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageInformations['messageId']." n'a pas pu être récuperé."); } return $this->getXmlFromZipMessage($zipMessage, $messageInformations['replyMessage']['messageId']); @@ -178,7 +177,6 @@ class MaarchREST extends SAEConnecteur { if (!file_exists($fullFilePath)) { throw new UnrecoverableException("Problème lors de la lecture du fichier $fullFilePath."); } - $xmlContent = file_get_contents($fullFilePath); unlink($zipTempFile); @@ -194,7 +192,7 @@ class MaarchREST extends SAEConnecteur { */ public function getZipMessage($messageId) { if (!$messageId) { - throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageId." n'a pas pu êtr récuperé."); + throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageId." n'a pas pu être récuperé."); } $zipMessage = $this->getWS( @@ -205,7 +203,7 @@ class MaarchREST extends SAEConnecteur { if ($zipMessage) { return $zipMessage; } else { - throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageId." n'a pas pu êtr récuperé."); + throw new UnrecoverableException("Le paquet du bordereau identifié par ".$messageId." n'a pas pu être récuperé."); } } @@ -238,7 +236,12 @@ class MaarchREST extends SAEConnecteur { throw new Exception($curlWrapper->getLastError()); } $http_code = $curlWrapper->getHTTPCode(); - if ($http_code != 200){ + if ($http_code == 401) { + throw new Exception("Jeton d'authentification invalide. <BR> Veuillez vérifier votre configuration du connecteur en fonction du compte de service dans l'applciation Maarch RM."); + } else if ($http_code == 403) { + throw new Exception("Le compte de service ne possède pas les droits suffisants pour effectuer cette action. <BR> URL : $this->url.$url."); + } + else if ($http_code != 200){ throw new Exception("$result - code d'erreur HTTP : $http_code"); } $old_result = $result; @@ -259,7 +262,14 @@ class MaarchREST extends SAEConnecteur { * @throws Exception */ public function getVersion(){ - return $this->getWS('/versions'); + $orgId = $this->connecteur_config->get('originating_agency'); + + $orgs = $this->getWS('/organization/organization/Search?term='.$orgId); + foreach ($orgs as $org) { + if ($org["registrationNumber"] == $orgId) { + return "Nom de l'organisation du compte de service : ".$org["displayName"]; + } + } } } \ No newline at end of file diff --git a/entite-properties.yml b/entite-properties.yml index 973f56bf12af2476c0b611ad680c461fc95c39a7..e863066f6c9b2a8447921f1138a5cfe6d074734b 100644 --- a/entite-properties.yml +++ b/entite-properties.yml @@ -14,6 +14,6 @@ formulaire: action: version: - name: Tester la connexion (NON FONCTIONNEL POUR LE MOMENT) + name: Tester la connexion au SAE action-class: MaarchRestVersion - + \ No newline at end of file