@Req("REQ038a")
  private List<ConsumerInfo> getRemoteConsumersInfo() {

    ConsumerDAO consumerDAO = PeerDAOFactory.getInstance().getConsumerDAO();
    List<RemoteConsumer> remoteConsumers = consumerDAO.getRemoteConsumers();

    List<ConsumerInfo> remoteConsumersInfo = new ArrayList<ConsumerInfo>();

    for (RemoteConsumer remoteConsumer : remoteConsumers) {

      if (remoteConsumer.getConsumerAddress() == null) {
        continue;
      }

      int noOfLocalWorkers = 0;

      for (AllocableWorker allWorker : remoteConsumer.getAllocableWorkers()) {
        if (allWorker.isWorkerLocal()) {
          noOfLocalWorkers++;
        }
      }

      ConsumerInfo consumerInfo =
          new ConsumerInfo(
              noOfLocalWorkers,
              StringUtil.addressToUserAtServer(remoteConsumer.getConsumerAddress()));

      remoteConsumersInfo.add(consumerInfo);
    }

    return remoteConsumersInfo;
  }
  private CommunityInfo getCommunityInfo() {

    String dsAddress = null;
    DiscoveryServiceClientDAO dsDao = PeerDAOFactory.getInstance().getDiscoveryServiceClientDAO();
    dsAddress = dsDao.getDsAddresses().toString();

    List<String> connectedPeers = new ArrayList<String>();
    for (String peerAddress : dsDao.getRemoteWorkerProvidersAddress()) {
      connectedPeers.add(StringUtil.addressToUserAtServer(peerAddress));
    }

    return new CommunityInfo(
        dsAddress,
        dsDao.isConnected() ? DiscoveryServiceState.UP : DiscoveryServiceState.CONTACTING,
        connectedPeers);
  }
  public List<IResponseTO> execute(NotifyRemoteWorkerProviderRecoveryRequestTO request) {
    List<IResponseTO> responses = new ArrayList<IResponseTO>();

    if (CertificationUtils.getCertSubjectDN(request.getMyCertPath())
        .equals(CertificationUtils.getCertSubjectDN(request.getRwpCertPath()))) {

      LoggerResponseTO loggerResponse =
          new LoggerResponseTO(
              DiscoveryServiceClientMessages.getSameCertificateDNMessage(request.getRwpAddress()),
              LoggerResponseTO.DEBUG);
      responses.add(loggerResponse);

      ReleaseResponseTO releaseTO = new ReleaseResponseTO();
      releaseTO.setStubAddress(request.getRwpAddress());

      responses.add(releaseTO);

      return responses;
    }

    Collection<CertificateCRLPair> receivedPeersCAsData =
        PeerDAOFactory.getInstance().getPeerCertificationDAO().getReceivedPeersCAsData();

    if (receivedPeersCAsData != null && !receivedPeersCAsData.isEmpty()) {

      if (!CertificationUtils.isCertificateValid(request.getRwpCertPath())) {

        LoggerResponseTO loggerResponse =
            new LoggerResponseTO(
                DiscoveryServiceClientMessages.getInvalidCertPathMessage(request.getRwpAddress()),
                LoggerResponseTO.WARN);
        responses.add(loggerResponse);

        ReleaseResponseTO releaseTO = new ReleaseResponseTO();
        releaseTO.setStubAddress(request.getRwpAddress());

        responses.add(releaseTO);

        return responses;
      }

      if (!CertificationUtils.isCertPathIssuedByCA(
          request.getRwpCertPath(), receivedPeersCAsData)) {

        LoggerResponseTO loggerResponse =
            new LoggerResponseTO(
                DiscoveryServiceClientMessages.getNonIssuedCertPathMessage(request.getRwpAddress()),
                LoggerResponseTO.WARN);
        responses.add(loggerResponse);

        ReleaseResponseTO releaseTO = new ReleaseResponseTO();
        releaseTO.setStubAddress(request.getRwpAddress());

        responses.add(releaseTO);

        return responses;
      }
    }

    DiscoveryServiceClientDAO dao = PeerDAOFactory.getInstance().getDiscoveryServiceClientDAO();
    dao.addRemoteWorkerProviderAddress(request.getRwpAddress());

    PeerControl.getInstance()
        .insertPeer(
            responses,
            request.getRwpUserAtServer(),
            CertificationUtils.getCertSubjectDN(request.getRwpCertPath()));

    return responses;
  }