/**
  * 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 MagentoItemStep) {
         return null;
     }
     $clientParameters = $this->clientParametersRegistry->getInstance($protocol->getSoapUsername(), $protocol->getSoapApiKey(), $protocol->getMagentoUrl(), $protocol->getWsdlUrl(), $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('wsdlUrl', $constraint->messageUrlNotReachable . ' "' . $e->getMessage() . '"');
         } catch (InvalidSoapUrlException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('wsdlUrl', $constraint->messageSoapNotValid . ' "' . $e->getMessage() . '"');
         } catch (InvalidXmlException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('wsdlUrl', $constraint->messageXmlNotValid);
         } catch (InvalidCredentialException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('soapUsername', $constraint->messageUsername);
         } catch (SoapCallException $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('soapUsername', $e->getMessage());
         } catch (\Exception $e) {
             $clientParameters->setValidation(false);
             $this->context->addViolationAt('soapUsername', $e->getMessage());
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function setConfiguration(array $config)
 {
     parent::setConfiguration($config);
     if (!$this->afterConfiguration) {
         $this->afterConfigurationSet();
         $this->afterConfiguration = true;
     }
 }
 /**
  * Handle step execution warning
  *
  * @param StepExecution                   $stepExecution
  * @param AbstractConfigurableStepElement $element
  * @param InvalidItemException            $e
  */
 protected function handleStepExecutionWarning(StepExecution $stepExecution, AbstractConfigurableStepElement $element, InvalidItemException $e)
 {
     if ($element instanceof AbstractConfigurableStepElement) {
         $warningName = $element->getName();
     } else {
         $warningName = get_class($element);
     }
     $stepExecution->addWarning($warningName, $e->getMessage(), $e->getMessageParameters(), $e->getItem());
     $this->dispatchInvalidItemEvent(get_class($element), $e->getMessage(), $e->getMessageParameters(), $e->getItem());
 }