@Override
  public void publishIdentity(String publicKey)
      throws CantPublishCryptoBrokerException, CryptoBrokerNotFoundException {

    try {

      this.identityManager.publishIdentity(publicKey);

    } catch (CantPublishIdentityException e) {

      errorManager.reportUnexpectedPluginException(
          this.getPluginVersionReference(),
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
      throw new CantPublishCryptoBrokerException(e, "", "Problem publishing the identity.");
    } catch (IdentityNotFoundException e) {

      errorManager.reportUnexpectedPluginException(
          this.getPluginVersionReference(),
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
      throw new CantPublishCryptoBrokerException(e, "", "Cannot find the identity.");
    } catch (Exception e) {

      errorManager.reportUnexpectedPluginException(
          this.getPluginVersionReference(),
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
      throw new CantPublishCryptoBrokerException(e, "", "Unhandled Exception.");
    }
  }
 public ChatMiddlewareRecorderService(
     ChatMiddlewareDatabaseDao chatMiddlewareDatabaseDao,
     EventManager eventManager,
     ErrorManager errorManager,
     ChatMiddlewareMonitorAgent chatMiddlewareMonitorAgent)
     throws CantStartServiceException {
   try {
     this.chatMiddlewareMonitorAgent = chatMiddlewareMonitorAgent;
     setDatabaseDao(chatMiddlewareDatabaseDao);
     setEventManager(eventManager);
     this.errorManager = errorManager;
   } catch (CantSetObjectException exception) {
     errorManager.reportUnexpectedPluginException(
         Plugins.CHAT_MIDDLEWARE,
         UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
         FermatException.wrapException(exception));
     throw new CantStartServiceException(
         exception,
         "Cannot set the customer ack offline merchandise database handler",
         "The database handler is null");
   } catch (Exception exception) {
     errorManager.reportUnexpectedPluginException(
         Plugins.CHAT_MIDDLEWARE,
         UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
         FermatException.wrapException(exception));
     throw new CantStartServiceException(exception, "Unexpected error", "Unexpected exception");
   }
 }
예제 #3
0
 public BankMoneyWalletImpl(
     UUID pluginId,
     PluginDatabaseSystem pluginDatabaseSystem,
     ErrorManager errorManager,
     String publicKey)
     throws CantStartPluginException {
   this.pluginId = pluginId;
   this.pluginDatabaseSystem = pluginDatabaseSystem;
   this.errorManager = errorManager;
   this.publicKey = publicKey;
   this.bankMoneyWalletDao =
       new BankMoneyWalletDao(
           this.pluginId, this.pluginDatabaseSystem, this.errorManager, publicKey);
   try {
     this.bankMoneyWalletDao.initialize();
   } catch (CantInitializeBankMoneyWalletDatabaseException e) {
     errorManager.reportUnexpectedPluginException(
         Plugins.BITDUBAI_BNK_HOLD_MONEY_TRANSACTION,
         UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
         e);
     throw new CantStartPluginException(Plugins.BITDUBAI_BNK_HOLD_MONEY_TRANSACTION);
   } catch (Exception e) {
     errorManager.reportUnexpectedPluginException(
         Plugins.BITDUBAI_BNK_BANK_MONEY_WALLET,
         UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
         e);
     throw new CantStartPluginException(
         CantStartPluginException.DEFAULT_MESSAGE, FermatException.wrapException(e), null, null);
   }
 }
  /**
   * Crea una nueva identidad para un crypto broker
   *
   * @return key con el resultado de la operacion:<br>
   *     <br>
   *     <code>CREATE_IDENTITY_SUCCESS</code>: Se creo exitosamente una identidad <br>
   *     <code>CREATE_IDENTITY_FAIL_MODULE_EXCEPTION</code>: Se genero una excepcion cuando se
   *     ejecuto el metodo para crear la identidad en el Module Manager <br>
   *     <code>CREATE_IDENTITY_FAIL_MODULE_IS_NULL</code>: No se tiene una referencia al Module
   *     Manager <br>
   *     <code>CREATE_IDENTITY_FAIL_NO_VALID_DATA</code>: Los datos ingresados para crear la
   *     identidad no son validos (faltan datos, no tiene el formato correcto, etc) <br>
   */
  private int createNewIdentity() {

    String brokerNameText = mIdentityName.getText().toString();
    boolean dataIsValid = validateIdentityData(brokerNameText, brokerImageByteArray);

    if (dataIsValid) {
      if (moduleManager != null) {
        try {
          if (!isUpdate)
            moduleManager.createNewRedeemPoint(
                brokerNameText,
                (brokerImageByteArray == null)
                    ? convertImage(R.drawable.ic_profile_male)
                    : brokerImageByteArray);
          else
            moduleManager.updateIdentityRedeemPoint(
                identitySelected.getPublicKey(), brokerNameText, brokerImageByteArray);
        } catch (CantCreateNewRedeemPointException e) {
          errorManager.reportUnexpectedUIException(
              UISource.VIEW, UnexpectedUIExceptionSeverity.UNSTABLE, e);
        } catch (CantUpdateIdentityRedeemPointException e) {
          errorManager.reportUnexpectedUIException(
              UISource.VIEW, UnexpectedUIExceptionSeverity.UNSTABLE, e);
        }
        return CREATE_IDENTITY_SUCCESS;
      }
      return CREATE_IDENTITY_FAIL_MODULE_IS_NULL;
    }
    return CREATE_IDENTITY_FAIL_NO_VALID_DATA;
  }
  private void exposeIdentities() throws CantExposeActorIdentitiesException {

    try {

      final List<CryptoCustomerExposingData> cryptoBrokerExposingDataList = new ArrayList<>();

      for (final CryptoCustomerIdentity identity : listAllCryptoCustomerFromCurrentDeviceUser()) {

        if (identity.isPublished()) {
          cryptoBrokerExposingDataList.add(
              new CryptoCustomerExposingData(
                  identity.getPublicKey(), identity.getAlias(), identity.getProfileImage()));
        }
      }

      cryptoCustomerANSManager.exposeIdentities(cryptoBrokerExposingDataList);

    } catch (final CantListCryptoCustomerIdentityException e) {

      errorManager.reportUnexpectedPluginException(
          this.getPluginVersionReference(),
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
      throw new CantExposeActorIdentitiesException(
          e, "", "Problem trying to list crypto brokers from current device user.");
    } catch (final CantExposeIdentitiesException e) {

      errorManager.reportUnexpectedPluginException(
          this.getPluginVersionReference(),
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
      throw new CantExposeActorIdentitiesException(e, "", "Problem exposing identities.");
    }
  }
  /**
   * This method initialize the database
   *
   * @throws CantInitializeDatabaseException
   */
  private void initializeDb() throws CantInitializeDatabaseException {

    try {
      /*
       * Open new database connection
       */
      this.database =
          this.pluginDatabaseSystem.openDatabase(
              pluginId, ChatMiddlewareDatabaseConstants.DATABASE_NAME);

    } catch (CantOpenDatabaseException cantOpenDatabaseException) {

      /*
       * The database exists but cannot be open. I can not handle this situation.
       */
      errorManager.reportUnexpectedPluginException(
          Plugins.CHAT_MIDDLEWARE,
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          cantOpenDatabaseException);
      throw new CantInitializeDatabaseException(cantOpenDatabaseException.getLocalizedMessage());

    } catch (DatabaseNotFoundException e) {

      /*
       * The database no exist may be the first time the plugin is running on this device,
       * We need to create the new database
       */
      ChatMiddlewareDatabaseFactory chatMiddlewareDatabaseFactory =
          new ChatMiddlewareDatabaseFactory(pluginDatabaseSystem);

      try {

        /*
         * We create the new database
         */
        this.database =
            chatMiddlewareDatabaseFactory.createDatabase(
                pluginId, ChatMiddlewareDatabaseConstants.DATABASE_NAME);

      } catch (CantCreateDatabaseException cantOpenDatabaseException) {

        /*
         * The database cannot be created. I can not handle this situation.
         */
        errorManager.reportUnexpectedPluginException(
            Plugins.CHAT_MIDDLEWARE,
            UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
            cantOpenDatabaseException);
        throw new CantInitializeDatabaseException(cantOpenDatabaseException.getLocalizedMessage());
      }
    }
  }
 /**
  * This method will be invoked when the dialog is dismissed.
  *
  * @param dialog The dialog that was dismissed will be passed into the method.
  */
 @Override
 public void onDismiss(DialogInterface dialog) {
   try {
     adapter.changeDataSet(walletManager.getListOfIdentities());
   } catch (CantGetCryptoBrokerIdentityListException e) {
     errorManager.reportUnexpectedWalletException(
         Wallets.CBP_CRYPTO_BROKER_WALLET,
         UnexpectedWalletExceptionSeverity.DISABLES_THIS_FRAGMENT,
         e);
   } catch (CantListCryptoBrokerIdentitiesException e) {
     errorManager.reportUnexpectedWalletException(
         Wallets.CBP_CRYPTO_BROKER_WALLET,
         UnexpectedWalletExceptionSeverity.DISABLES_THIS_FRAGMENT,
         e);
   }
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
      CryptoCustomerWalletModuleManager moduleManager =
          ((CryptoCustomerWalletSession) appSession).getModuleManager();
      walletManager = moduleManager.getCryptoCustomerWallet(appSession.getAppPublicKey());
      errorManager = appSession.getErrorManager();

      Object data = appSession.getData(CryptoCustomerWalletSession.LOCATION_LIST);
      if (data == null) {
        locationList = new ArrayList<>();
        appSession.setData(CryptoCustomerWalletSession.LOCATION_LIST, locationList);
      } else {
        locationList = (List<String>) data;
      }
      if (locationList.size() > 0) {
        int pos = locationList.size() - 1;
        if (locationList.get(pos).equals("settings") || locationList.get(pos).equals("wizard")) {
          locationList.remove(pos);
        }
      }
    } catch (Exception ex) {
      Log.e(TAG, ex.getMessage(), ex);
      if (errorManager != null)
        errorManager.reportUnexpectedWalletException(
            Wallets.CBP_CRYPTO_BROKER_WALLET,
            UnexpectedWalletExceptionSeverity.DISABLES_THIS_FRAGMENT,
            ex);
    }
  }
  private void saveSettingAndGoNextStep() {
    if (locationList.isEmpty()) {
      Toast.makeText(getActivity(), R.string.ccw_add_location_warning_msg, Toast.LENGTH_SHORT)
          .show();
      return;
    }

    try {
      for (String location : locationList) {
        walletManager.createNewLocation(location, appSession.getAppPublicKey());
      }

    } catch (FermatException ex) {
      Toast.makeText(getActivity(), "Oops a error occurred...", Toast.LENGTH_SHORT).show();

      Log.e(TAG, ex.getMessage(), ex);
      if (errorManager != null) {
        errorManager.reportUnexpectedWalletException(
            Wallets.CBP_CRYPTO_BROKER_WALLET,
            UnexpectedWalletExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
            ex);
      }
    }

    changeActivity(Activities.CBP_CRYPTO_CUSTOMER_WALLET_SETTINGS, appSession.getAppPublicKey());
  }
 @Override
 public List<DeveloperDatabaseTableRecord> getDatabaseTableContent(
     DeveloperObjectFactory developerObjectFactory,
     DeveloperDatabase developerDatabase,
     DeveloperDatabaseTable developerDatabaseTable) {
   UnholdCashMoneyTransactionDeveloperDatabaseFactory factory =
       new UnholdCashMoneyTransactionDeveloperDatabaseFactory(pluginDatabaseSystem, pluginId);
   List<DeveloperDatabaseTableRecord> tableRecordList = null;
   try {
     factory.initializeDatabase();
     tableRecordList =
         factory.getDatabaseTableContent(developerObjectFactory, developerDatabaseTable);
   } catch (CantInitializeUnholdCashMoneyTransactionDatabaseException cantInitializeException) {
     FermatException e =
         new CantInitializeUnholdCashMoneyTransactionDatabaseException(
             "Database cannot be initialized",
             cantInitializeException,
             "CashMoneyTransactionUnholdPluginRoot",
             "");
     errorManager.reportUnexpectedPluginException(
         Plugins.BITDUBAI_CSH_MONEY_TRANSACTION_UNHOLD,
         UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
         e);
   }
   return tableRecordList;
 }
  /*
   * Service interface implementation
   */
  @Override
  public void start() throws CantStartPluginException {
    System.out.println("CASHUNHOLD - PluginRoot START");

    try {
      unholdTransactionManager =
          new CashMoneyTransactionUnholdManager(
              cashMoneyWalletManager, pluginDatabaseSystem, pluginId, errorManager);

    } catch (Exception e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_CSH_MONEY_TRANSACTION_UNHOLD,
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          e);
      throw new CantStartPluginException(
          CantStartPluginException.DEFAULT_MESSAGE, FermatException.wrapException(e), null, null);
    }

    processorAgent =
        new CashMoneyTransactionUnholdProcessorAgent(
            errorManager, unholdTransactionManager, cashMoneyWalletManager);
    processorAgent.start();

    serviceStatus = ServiceStatus.STARTED;
    // testCreateCashUnholdTransaction();
  }
예제 #12
0
    @Override
    public void run() {

      threadWorking = true;
      logManager.log(
          OpenContractPluginRoot.getLogLevelByClass(this.getClass().getName()),
          "Open Contract Monitor Agent: running...",
          null,
          null);
      while (threadWorking) {
        /** Increase the iteration counter */
        iterationNumber++;
        try {
          Thread.sleep(SLEEP_TIME);
        } catch (InterruptedException interruptedException) {
          return;
        }

        /** now I will check if there are pending transactions to raise the event */
        try {

          logManager.log(
              OpenContractPluginRoot.getLogLevelByClass(this.getClass().getName()),
              "Iteration number " + iterationNumber,
              null,
              null);
          doTheMainTask();
        } catch (CannotSendContractHashException | CantUpdateRecordException e) {
          errorManager.reportUnexpectedPluginException(
              Plugins.BITDUBAI_ASSET_ISSUING_TRANSACTION,
              UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
              e);
        }
      }
    }
예제 #13
0
  public BigDecimal getWalletBalance(String walletPublicKey, BalanceType balanceType)
      throws CantGetCashMoneyWalletBalanceException {
    BigDecimal balance;
    try {
      DatabaseTableRecord record = this.getWalletRecordByPublicKey(walletPublicKey);
      if (balanceType == BalanceType.AVAILABLE)
        balance =
            new BigDecimal(
                record.getStringValue(
                    CashMoneyWalletDatabaseConstants.WALLETS_AVAILABLE_BALANCE_COLUMN_NAME));
      else if (balanceType == BalanceType.BOOK)
        balance =
            new BigDecimal(
                record.getStringValue(
                    CashMoneyWalletDatabaseConstants.WALLETS_BOOK_BALANCE_COLUMN_NAME));
      else throw new InvalidParameterException();
    } catch (Exception e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY,
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          e);
      throw new CantGetCashMoneyWalletBalanceException(
          CantGetCashMoneyWalletBalanceException.DEFAULT_MESSAGE,
          e,
          "Cant get wallet balance",
          null);
    }

    return balance;
  }
예제 #14
0
  public CashMoneyWalletImpl(
      final PluginDatabaseSystem pluginDatabaseSystem,
      final UUID pluginId,
      final ErrorManager errorManager,
      String walletPublicKey)
      throws CantGetCashMoneyWalletException {
    this.pluginDatabaseSystem = pluginDatabaseSystem;
    this.pluginId = pluginId;
    this.errorManager = errorManager;
    this.walletPublicKey = walletPublicKey;

    try {
      this.dao = new CashMoneyWalletDao(pluginDatabaseSystem, pluginId, errorManager);
      dao.initialize();

      if (dao.walletExists(walletPublicKey)) this.walletPublicKey = walletPublicKey;
      else throw new CashMoneyWalletDoesNotExistException();

    } catch (Exception e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY,
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          e);
      throw new CantGetCashMoneyWalletException(
          CantGetCashMoneyWalletException.DEFAULT_MESSAGE, e, null, null);
    }
  }
예제 #15
0
 public ContactListAdapter(
     Context context,
     ArrayList contactinfo,
     ArrayList contacticon,
     ArrayList contactid,
     ChatManager chatManager,
     ChatModuleManager moduleManager,
     ErrorManager errorManager,
     ChatSession chatSession,
     FermatSession appSession,
     AdapterCallback mAdapterCallback) {
   super(context, R.layout.contact_list_item, contactinfo);
   // tf = Typeface.createFromAsset(context.getAssets(), "fonts/HelveticaNeue Medium.ttf");
   this.contactinfo = contactinfo;
   this.contacticon = contacticon;
   this.contactid = contactid;
   this.chatManager = chatManager;
   this.moduleManager = moduleManager;
   this.errorManager = errorManager;
   this.chatSession = chatSession;
   this.appSession = appSession;
   this.mContext = context;
   try {
     this.mAdapterCallback = mAdapterCallback;
   } catch (Exception e) {
     errorManager.reportUnexpectedSubAppException(
         SubApps.CHT_CHAT,
         UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
         e);
   }
 }
  @Override
  public List<CryptoBrokerIdentity> getMoreDataAsync(FermatRefreshTypes refreshType, int pos) {
    List<CryptoBrokerIdentity> data = new ArrayList<>();

    try {
      data.addAll(walletManager.getListOfIdentities());
      if (walletManager.getListOfIdentities().isEmpty()) {
        PresentationDialog presentationDialog =
            new PresentationDialog.Builder(getActivity(), appSession)
                .setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION)
                .setBannerRes(R.drawable.banner_crypto_broker)
                .setIconRes(R.drawable.crypto_broker)
                .setBody("Custom text support for dialog in the wizard identities help 2")
                .setSubTitle("This is a simple wallet for exchange Merchandise. " + identities)
                .setTextFooter(
                    "To begin, choose an avatar below. You might change it later with any picture and your alias")
                .build();
        presentationDialog.setOnDismissListener(this);
        presentationDialog.show();
      }

    } catch (FermatException ex) {

      Log.e(TAG, ex.getMessage(), ex);
      if (errorManager != null) {
        errorManager.reportUnexpectedWalletException(
            Wallets.CBP_CRYPTO_BROKER_WALLET,
            UnexpectedWalletExceptionSeverity.DISABLES_THIS_FRAGMENT,
            ex);
      }
    }

    return data;
  }
예제 #17
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    txt_title = (TextView) this.findViewById(R.id.cht_alert_txt_title);
    txt_body = (TextView) this.findViewById(R.id.cht_alert_txt_body);
    btn_yes = (Button) this.findViewById(R.id.cht_alert_btn_yes);
    btn_no = (Button) this.findViewById(R.id.cht_alert_btn_no);
    try {
      chatSession = ((ChatSession) getSession());
      moduleManager = chatSession.getModuleManager();
      chatManager = moduleManager.getChatManager();
      errorManager = getSession().getErrorManager();

    } catch (Exception e) {
      if (errorManager != null)
        errorManager.reportUnexpectedSubAppException(
            SubApps.CHT_CHAT,
            UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
            e);
    }
    txt_title.setText(title);
    txt_body.setText(body);

    setUpListeners();
  }
예제 #18
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {

      setHasOptionsMenu(true);
      // setting up  module
      moduleManager = appSession.getModuleManager();
      errorManager = appSession.getErrorManager();

      mNotificationsCount =
          moduleManager
              .listCryptoBrokersPendingLocalAction(
                  moduleManager.getSelectedActorIdentity(), MAX, offset)
              .size();

      // TODO: display unread notifications.
      new FetchCountTask().execute();

    } catch (Exception ex) {
      CommonLogger.exception(TAG, ex.getMessage(), ex);
      errorManager.reportUnexpectedUIException(
          UISource.ACTIVITY, UnexpectedUIExceptionSeverity.CRASH, ex);
    }
  }
예제 #19
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    try {
      int id = item.getItemId();

      if (id == SessionConstantsAssetUser.IC_ACTION_USER_HELP_REDEEM) {
        setUpHelpAssetRedeem(
            settingsManager
                .loadAndGetSettings(appSession.getAppPublicKey())
                .isPresentationHelpEnabled());
        return true;
      }

    } catch (Exception e) {
      errorManager.reportUnexpectedUIException(
          UISource.ACTIVITY,
          UnexpectedUIExceptionSeverity.UNSTABLE,
          FermatException.wrapException(e));
      makeText(
              getActivity(),
              getResources().getString(R.string.dap_user_wallet_system_error),
              Toast.LENGTH_SHORT)
          .show();
    }
    return super.onOptionsItemSelected(item);
  }
  /**
   * This method validate is all required resource are injected into the plugin root by the platform
   *
   * @throws CantStartPluginException
   */
  private void validateInjectedResources() throws CantStartPluginException {

    /*
     * If all resources are inject
     */
    if (eventManager == null || logManager == null || errorManager == null) {

      StringBuffer contextBuffer = new StringBuffer();
      contextBuffer.append("Plugin ID: " + pluginId);
      contextBuffer.append(CantStartPluginException.CONTEXT_CONTENT_SEPARATOR);
      contextBuffer.append("eventManager: " + eventManager);
      contextBuffer.append(CantStartPluginException.CONTEXT_CONTENT_SEPARATOR);
      contextBuffer.append("logManager: " + logManager);
      contextBuffer.append(CantStartPluginException.CONTEXT_CONTENT_SEPARATOR);
      contextBuffer.append("errorManager: " + errorManager);

      System.out.println(
          "WsCommunicationsServerCloudPluginRoot - contextBuffer = " + contextBuffer);

      String context = contextBuffer.toString();
      String possibleCause = "No all required resource are injected";
      CantStartPluginException pluginStartException =
          new CantStartPluginException(
              CantStartPluginException.DEFAULT_MESSAGE, null, context, possibleCause);

      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_WS_COMMUNICATION_CLIENT_CHANNEL,
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          pluginStartException);
      throw pluginStartException;
    }
  }
예제 #21
0
 @Override
 public void createBankName(String bankName) {
   try {
     bankMoneyWalletDao.createBankName(bankName);
   } catch (FermatException e) {
     errorManager.reportUnexpectedPluginException(Plugins.BITDUBAI_BNK_BANK_MONEY_WALLET, null, e);
   }
 }
  private void processMetadata() {

    try {

      listRecorMessageToSend =
          outgoingMessageDao.findAll(
              CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_STATUS_COLUMN_NAME,
              FermatMessagesStatus.PENDING_TO_SEND.getCode());

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

        for (FermatMessage fm : listRecorMessageToSend) {

          if (!poolConnectionsWaitingForResponse.containsKey(fm.getReceiver())) {

            /*
             * Create the sender basic profile
             */
            PlatformComponentProfile sender =
                wsCommunicationsCloudClientManager
                    .getCommunicationsCloudClientConnection()
                    .constructBasicPlatformComponentProfileFactory(
                        fm.getSender(),
                        NetworkServiceType.UNDEFINED,
                        PlatformComponentType.ACTOR_ASSET_REDEEM_POINT);

            /*
             * Create the receiver basic profile
             */
            PlatformComponentProfile receiver =
                wsCommunicationsCloudClientManager
                    .getCommunicationsCloudClientConnection()
                    .constructBasicPlatformComponentProfileFactory(
                        fm.getReceiver(),
                        NetworkServiceType.UNDEFINED,
                        PlatformComponentType.ACTOR_ASSET_ISSUER);

            try {
              communicationNetworkServiceConnectionManager.connectTo(
                  sender, platformComponentProfile, receiver);
            } catch (Exception e) {
              e.printStackTrace();
            }

            // pass the metada to a pool wainting for the response of the other peer or server
            // failure
            poolConnectionsWaitingForResponse.put(fm.getReceiver(), fm);
          }
        }
      }

    } catch (CantReadRecordDataBaseException e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_DAP_ASSET_ISSUER_ACTOR_NETWORK_SERVICE,
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          new Exception("Can not send Message PENDING_TO_SEND"));
    }
  }
예제 #23
0
 public void initialize() throws CantInitializeCashMoneyWalletDatabaseException {
   try {
     database = this.pluginDatabaseSystem.openDatabase(pluginId, pluginId.toString());
   } catch (DatabaseNotFoundException e) {
     CashMoneyWalletDatabaseFactory databaseFactory =
         new CashMoneyWalletDatabaseFactory(pluginDatabaseSystem);
     try {
       database = databaseFactory.createDatabase(pluginId, pluginId.toString());
     } catch (CantCreateDatabaseException cantCreateDatabaseException) {
       errorManager.reportUnexpectedPluginException(
           Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY,
           UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
           cantCreateDatabaseException);
       errorManager.reportUnexpectedPluginException(
           Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY,
           UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
           cantCreateDatabaseException);
       throw new CantInitializeCashMoneyWalletDatabaseException(
           "Database could not be opened",
           cantCreateDatabaseException,
           "Database Name: " + pluginId.toString(),
           "");
     }
   } catch (CantOpenDatabaseException cantOpenDatabaseException) {
     errorManager.reportUnexpectedPluginException(
         Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY,
         UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
         cantOpenDatabaseException);
     throw new CantInitializeCashMoneyWalletDatabaseException(
         "Database could not be opened",
         cantOpenDatabaseException,
         "Database Name: " + pluginId.toString(),
         "");
   } catch (Exception e) {
     errorManager.reportUnexpectedPluginException(
         Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY,
         UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
         e);
     throw new CantInitializeCashMoneyWalletDatabaseException(
         "Database could not be opened",
         FermatException.wrapException(e),
         "Database Name: " + pluginId.toString(),
         "");
   }
 }
  private void doTheMainTask() {
    // System.out.println("CASHUNHOLD - Agent LOOP");

    List<CashUnholdTransaction> transactionList;

    try {
      transactionList = unholdTransactionManager.getAcknowledgedTransactionList();
    } catch (CantGetUnholdTransactionException e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_CSH_MONEY_TRANSACTION_UNHOLD,
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          e);
      return;
    }

    /*
     * For each new (acknowledged) transaction, this thread:
     * Changes its status to Pending
     * Tries to unhold funds in wallet
     * If successfull, changes transaction status to Confirmed
     * If not, changes transaction status to Rejected.
     */

    for (CashUnholdTransaction transaction : transactionList) {

      try {
        // TODO: cashMoneyWalletManager.loadCashMoneyWallet.unhold(cashMoneyWalletTransaction);
        unholdTransactionManager.setTransactionStatusToConfirmed(transaction.getTransactionId());
        /*} catch (CantCreateUnholdTransactionException e) {
        try {
            unholdTransactionManager.setTransactionStatusToRejected(transaction.getTransactionId());
        } catch (CantUpdateUnholdTransactionException ex) {
            errorManager.reportUnexpectedPluginException(Plugins.BITDUBAI_CSH_MONEY_TRANSACTION_UNHOLD, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, ex);
        }*/
      } catch (CantUpdateUnholdTransactionException e) {
        errorManager.reportUnexpectedPluginException(
            Plugins.BITDUBAI_CSH_MONEY_TRANSACTION_UNHOLD,
            UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
            e);
      }

      // TODO: Lanzar un evento al plugin que envio la transaccion para avisarle que se updateo el
      // status de su transaccion.
    }
  }
예제 #25
0
 @Override
 public String getBankName() {
   try {
     return bankMoneyWalletDao.getBankName();
   } catch (FermatException e) {
     errorManager.reportUnexpectedPluginException(Plugins.BITDUBAI_BNK_BANK_MONEY_WALLET, null, e);
   }
   return null;
 }
  @Override
  public void start() throws CantStartPluginException {

    try {

      FermatEventListener fermatEventListener;
      FermatEventHandler fermatEventHandler;

      this.cryptoCustomerActorDao =
          new CryptoCustomerActorDao(pluginDatabaseSystem, pluginFileSystem, pluginId);
      this.cryptoCustomerActorDao.initializeDatabase();

      fermatManager =
          new CustomerActorManager(
              this.cryptoCustomerActorDao,
              cryptoBrokerANSManager,
              errorManager,
              getPluginVersionReference());

      ActorCustomerExtraDataEventActions handlerAction =
          new ActorCustomerExtraDataEventActions(
              cryptoBrokerANSManager, cryptoCustomerActorDao, cryptoBrokerActorConnectionManager);

      fermatEventListener =
          eventManager.getNewListener(EventType.CRYPTO_BROKER_QUOTES_REQUEST_UPDATES);
      fermatEventHandler = new CryptoCustomerExtraDataEventHandler(handlerAction, this);
      fermatEventListener.setEventHandler(fermatEventHandler);
      eventManager.addListener(fermatEventListener);
      listenersAdded.add(fermatEventListener);

      fermatEventListener =
          eventManager.getNewListener(EventType.CRYPTO_BROKER_ACTOR_CONNECTION_NEW_CONNECTION);
      fermatEventHandler = new CryptoBrokerNewConnectionEventHandler(handlerAction, this);
      fermatEventListener.setEventHandler(fermatEventHandler);
      eventManager.addListener(fermatEventListener);
      listenersAdded.add(fermatEventListener);

      agente =
          new CryptoBrokerExtraDataUpdateAgent(
              cryptoBrokerANSManager,
              cryptoCustomerActorDao,
              errorManager,
              getPluginVersionReference());
      agente.start();
      this.serviceStatus = ServiceStatus.STARTED;

    } catch (CantStartAgentException | CantInitializeCryptoCustomerActorDatabaseException e) {
      errorManager.reportUnexpectedPluginException(
          this.getPluginVersionReference(),
          UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN,
          e);
      throw new CantStartPluginException(e, this.getPluginVersionReference());
    }
  }
 public IdentityAssetUser getActiveAssetUserIdentity() throws CantGetIdentityAssetUserException {
   try {
     return identityAssetUserManager.getIdentityAssetUser();
   } catch (CantGetAssetUserIdentitiesException e) {
     errorManager.reportUnexpectedPluginException(
         Plugins.BITDUBAI_DAP_ASSET_USER_COMMUNITY_SUB_APP_MODULE,
         UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
         e);
     throw new CantGetIdentityAssetUserException(e);
   }
 }
예제 #28
0
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View item = inflater.inflate(R.layout.contact_list_item, null, true);
    try {
      imagen =
          (ImageView)
              item.findViewById(
                  R.id
                      .icon); // imagen.setImageResource(contacticon.get(position));//contacticon[position]);
      imagen.setImageBitmap(
          getRoundedShape(
              contacticon.get(position),
              400)); // imagen.setImageBitmap(getRoundedShape(decodeFile(getContext(),
                     // contacticon.get(position)), 300));

      contactname = (TextView) item.findViewById(R.id.text1);
      contactname.setText(contactinfo.get(position));
      // contactname.setTypeface(tf, Typeface.NORMAL);

      final int pos = position;
      imagen.setOnClickListener(
          new View.OnClickListener() {
            // int pos = position;
            @Override
            public void onClick(View v) {
              try {

                // TODO:Cardozo revisar esta logica ya no aplica, esto viene de un metodo nuevo que
                // lo buscara del module del actor connections//chatManager.getChatUserIdentities();
                appSession.setData(
                    ChatSession.CONTACT_DATA,
                    null); // chatManager.getContactByContactId(contactid.get(pos)));
                mAdapterCallback.onMethodCallback(); // solution to access to changeactivity. j
                // } catch (CantGetContactException e) {
                //    errorManager.reportUnexpectedSubAppException(SubApps.CHT_CHAT,
                // UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, e);
              } catch (Exception e) {
                errorManager.reportUnexpectedSubAppException(
                    SubApps.CHT_CHAT,
                    UnexpectedSubAppExceptionSeverity
                        .DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
                    e);
              }
            }
          });

    } catch (Exception e) {
      errorManager.reportUnexpectedSubAppException(
          SubApps.CHT_CHAT,
          UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
          e);
    }
    return item;
  }
  @Override
  public List<AssetUserActorRecord> getAllActorAssetUserRegistered()
      throws CantGetAssetUserActorsException {
    List<ActorAssetUser> list = null;
    List<AssetUserActorRecord> assetUserActorRecords = null;

    try {
      list = assetUserActorNetworkServiceManager.getListActorAssetUserRegistered();
      actorAssetUserManager.createActorAssetUserRegisterInNetworkService(list);
    } catch (CantRequestListActorAssetUserRegisteredException e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_DAP_ASSET_USER_COMMUNITY_SUB_APP_MODULE,
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
    } catch (CantCreateAssetUserActorException e) {
      errorManager.reportUnexpectedPluginException(
          Plugins.BITDUBAI_DAP_ASSET_USER_COMMUNITY_SUB_APP_MODULE,
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
    }

    if (list != null) {
      assetUserActorRecords = new ArrayList<>();

      try {
        for (ActorAssetUser actorAssetUser :
            actorAssetUserManager.getAllAssetUserActorInTableRegistered()) {
          AssetUserActorRecord assetUserActorRecord = (AssetUserActorRecord) actorAssetUser;
          assetUserActorRecords.add(assetUserActorRecord);
        }

      } catch (CantGetAssetUserActorsException e) {
        errorManager.reportUnexpectedPluginException(
            Plugins.BITDUBAI_DAP_ASSET_USER_COMMUNITY_SUB_APP_MODULE,
            UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
            e);
        e.printStackTrace();
      }
    }
    return assetUserActorRecords;
  }
  /**
   * Handles events that indicate a connection to been established between two network services and
   * prepares all objects to work with this new connection
   *
   * @param remoteComponentProfile
   */
  public final void handleEstablishedRequestedNetworkServiceConnection(
      PlatformComponentProfile remoteComponentProfile) {

    try {

      /*
       * Get the active connection
       */
      CommunicationsVPNConnection communicationsVPNConnection =
          communicationsClientConnection.getCommunicationsVPNConnectionStablished(
              platformComponentProfile.getNetworkServiceType(), remoteComponentProfile);

      // Validate the connection
      if (communicationsVPNConnection != null && communicationsVPNConnection.isActive()) {

        /*
         * Instantiate the local reference
         */
        CommunicationNetworkServiceLocal communicationNetworkServiceLocal =
            buildCommunicationNetworkServiceLocal(remoteComponentProfile);

        /*
         * Instantiate the remote reference
         */
        CommunicationNetworkServiceRemoteAgent communicationNetworkServiceRemoteAgent =
            buildCommunicationNetworkServiceRemoteAgent(communicationsVPNConnection);

        /*
         * Register the observer to the observable agent
         */
        communicationNetworkServiceRemoteAgent.addObserver(communicationNetworkServiceLocal);

        /*
         * Start the service thread
         */
        communicationNetworkServiceRemoteAgent.start();

        /*
         * Add to the cache
         */
        communicationNetworkServiceLocalsCache.put(
            remoteComponentProfile.getIdentityPublicKey(), communicationNetworkServiceLocal);
        communicationNetworkServiceRemoteAgentsCache.put(
            remoteComponentProfile.getIdentityPublicKey(), communicationNetworkServiceRemoteAgent);
      }

    } catch (final Exception e) {
      errorManager.reportUnexpectedPluginException(
          pluginVersionReference,
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
    }
  }