/**
  * Checks if the passed value is valid.
  *
  * @param \Akeneo\Bundle\BatchBundle\Item\AbstractConfigurableStepElement $protocol   Value to validate
  * @param Constraint                                                      $constraint Constraint for validation
  *
  * @api
  */
 public function validate($protocol, Constraint $constraint)
 {
     if (!$protocol instanceof PrestashopItemStep) {
         return null;
     }
     $clientParameters = $this->clientParametersRegistry->getInstance($protocol->getRestApiKey(), $protocol->getPrestashopUrl(), $protocol->getDefaultStoreView(), $protocol->getHttpLogin(), $protocol->getHttpPassword());
     if (null === $clientParameters->isValid() || false === $clientParameters->isValid()) {
         try {
             $xml = $this->urlExplorer->getUrlContent($clientParameters);
             $this->xmlChecker->checkXml($xml);
             $webservice = $this->webserviceGuesser->getWebservice($clientParameters);
             $webservice->getStoreViewsList();
             $clientParameters->setValidation(true);
         } catch (NotReachableUrlException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('prestashopUrl', $constraint->messageUrlNotReachable . ' "' . $e->getMessage() . '"');
         } catch (InvalidRestUrlException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('prestashopUrl', $constraint->messageRestNotValid . ' "' . $e->getMessage() . '"');
         } catch (InvalidXmlException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('prestashopUrl', $constraint->messageXmlNotValid);
         } catch (InvalidCredentialException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('restApiKey', $constraint->messageApiKey);
         } catch (RestCallException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('restApiKey', $e->getMessage());
         } catch (\Exception $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('restApiKey', $e->getMessage());
         }
     }
 }
 /**
  * Get the prestashop soap client parameters.
  *
  * @return PrestashopRestClientParameters
  */
 protected function getClientParameters()
 {
     $this->clientParameters = $this->clientParametersRegistry->getInstance($this->restApiKey, $this->prestashopUrl, $this->defaultStoreView, $this->httpLogin, $this->httpPassword);
     return $this->clientParameters;
 }