コード例 #1
0
  @Override
  public void handleEvent(FermatEvent fermatEvent) throws FermatException {

    // TODO USABA LA WALLETID DE LA REQUESTED CREADA PARA CARGAR LAS BILLETERAS DEL USUARIO?
    UUID walletId = ((WalletCreatedEvent) fermatEvent).getWalletId();
    EventSource eventSource = fermatEvent.getSource();
    if (eventSource == EventSource.MIDDLEWARE_WALLET_PLUGIN) {

      if (((Service) this.walletManager).getStatus() == ServiceStatus.STARTED) {

        try {
          // TODO USABA LA WALLETID DE LA REQUESTED CREADA PARA CARGAR LAS BILLETERAS DEL USUARIO?
          this.walletManager.loadUserWallets("");
        } catch (CantLoadWalletsException cantLoadWalletsException) {
          /** The main module could not handle this exception. Me neither. Will throw it again. */
          System.err.println(
              "CantCreateCryptoWalletException: " + cantLoadWalletsException.getMessage());
          cantLoadWalletsException.printStackTrace();

          throw cantLoadWalletsException;
        }
      } else {
        throw new ModuleNotRunningException();
      }
    }
  }
  @Override
  public void handleEvent(FermatEvent fermatEvent) throws FermatException {
    String context =
        "Event Type: " + fermatEvent.getEventType() + "Event Source: " + fermatEvent.getSource();

    if (assetDistributionRecorderService.getStatus() != ServiceStatus.STARTED) {
      throw new TransactionServiceNotStartedException();
    }

    if (!(fermatEvent instanceof ReceivedNewTransactionStatusNotificationEvent)) {
      // You're using the wrong handler..
      throw new CantSaveEventException(
          null,
          context,
          "The event received event is not an instance of ReceivedNewTransactionStatusNotificationEvent, use the right handler.");
    }

    ReceivedNewTransactionStatusNotificationEvent metadataNotificationEvent =
        (ReceivedNewTransactionStatusNotificationEvent) fermatEvent;

    try {
      assetDistributionRecorderService.receivedTransactionStatusNotificationrEvent(
          metadataNotificationEvent);
    } catch (Exception exception) {
      throw new CantSaveEventException(
          exception,
          "Handling the ReceivedNewTransactionStatusNotificationEvent",
          "Unexpected exception");
    }
  }
コード例 #3
0
  /**
   * (non-Javadoc)
   *
   * @see FermatEventHandler#handleEvent(FermatEvent)
   * @param platformEvent
   * @throws Exception
   */
  @Override
  public void handleEvent(FermatEvent platformEvent) throws FermatException {

    if (platformEvent.getSource() == NetworkServiceChatNetworkServicePluginRoot.EVENT_SOURCE) {

      // System.out.println("CompleteComponentConnectionRequestNotificationEventHandler -
      // handleEvent platformEvent =" + platformEvent.toString());
      //  System.out.println("NetworkServiceChatNetworkServicePluginRoot  - NOTIFICACION EVENTO
      // MENSAJE RECIBIDO!!!!");

      /*
       * Get the message receive
       */
      NewNetworkServiceMessageReceivedNotificationEvent
          newNetworkServiceMessageReceivedNotificationEvent =
              (NewNetworkServiceMessageReceivedNotificationEvent) platformEvent;
      FermatMessage fermatMessageReceive =
          (FermatMessage) newNetworkServiceMessageReceivedNotificationEvent.getData();

      /*
       * Get the content of the message like a JsonObject
       */
      JsonObject jsonMsjContent = parser.parse(fermatMessageReceive.getContent()).getAsJsonObject();

      /*
       * Extract the type of content of the message
       */
      ChatMessageTransactionType chatMessageTransactionType =
          gson.fromJson(
              jsonMsjContent.get(ChatTransmissionJsonAttNames.MSJ_CONTENT_TYPE),
              ChatMessageTransactionType.class);

      /*
       * Process the messages for his type
       */
      if (messagesProcessorsRegistered.containsKey(chatMessageTransactionType)) {
        messagesProcessorsRegistered
            .get(chatMessageTransactionType)
            .processingMessage(fermatMessageReceive, jsonMsjContent);
      } else {
        System.out.println(
            "NetworkServiceChatNetworkServicePluginRoot - CompleteComponentConnectionRequestNotificationEventHandler - message type no supported = "
                + chatMessageTransactionType);
      }
    }
  }