@Override
  protected void action() {
    if (step == 0) {
      getAgent().send(createRequest(request));

      conversationIdTemplate = MessageTemplate.matchConversationId(request.getId());

      step = 1;
    } else {
      AclMessage message = getAgent().receive(conversationIdTemplate);

      if (message == null) {
        block();
        return;
      }

      if (AclMessage.Performative.INFORM == message.getPerformative()
          && JobProtocol.ID.equals(message.getProtocol())) {
        JobAudit audit = (JobAudit) message.getContentObject();
        if (JobAudit.Type.PRE == audit.getType() && audit.hasError()) {
          stopProtocol();
        } else if (JobAudit.Type.POST == audit.getType()) {
          stopProtocol();
        }
        handleInform(message);
      } else if (AclMessage.Performative.FAILURE == message.getPerformative()) {
        stopProtocol();
        handleFailure(message);
      } else {
        handleOutOfSequence(message);
      }
    }
  }
    public AclMessage executeRequest(AclMessage request, AclMessage agreement)
        throws FailureException {
      try {
        ExportManager exportManager = new ExportManager();
        exportManager.doExport(getConnection(request), request.getContent());

        AclMessage reply = request.createReply(AclMessage.Performative.INFORM);
        reply.setContent("Export terminé");
        return reply;
      } catch (SQLException exception) {
        LOG.error(exception.getLocalizedMessage(), exception);
        throw new FailureException(exception.getLocalizedMessage());
      } catch (IOException exception) {
        LOG.error("Impossible d'écrire le fichier d'export.", exception);
        throw new FailureException("Impossible d'écrire le fichier d'export.");
      } catch (Exception exception) {
        LOG.error("Exception inattendue.", exception);
        throw new FailureException(exception.getLocalizedMessage());
      }
    }
 protected AclMessage createRequest(JobRequest requestToSend) {
   AclMessage message = new AclMessage(AclMessage.Performative.REQUEST);
   message.addReceiver(participantAID);
   message.setConversationId(requestToSend.getId());
   message.setProtocol(JobProtocol.ID);
   message.setContentObject(requestToSend);
   message.setReplyByDate(new Date(System.currentTimeMillis() + replyTimeout));
   if (userId != null) {
     message.encodeUserId(userId);
   }
   return message;
 }
    @Override
    public void parseMessage(AclMessage request)
        throws NotUnderstoodException, IOException, ParseException, SQLException {
      String message = request.getContent();
      if (message == null || message.length() == 0) {
        throw new NotUnderstoodException("Message vide.");
      }

      String[] args = message.split(";");
      if (args.length != 2) {
        throw new NotUnderstoodException("Message incorrect.");
      }

      String exportType = args[0];
      if (exportType == null || exportType.length() == 0) {
        throw new ParseException("Le type d'export est incorrect.");
      }

      String exportFilePath = args[1];
      if (exportFilePath == null || exportFilePath.length() == 0) {
        throw new ParseException("Le chemin du fichier d'export est incorrect.");
      }
    }