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"); } }
@Override public void setTransactionDescription(UUID transactionID, String description) throws CantFindTransactionException, CantStoreMemoException { try { assetIssuerWalletDao = new AssetIssuerWalletDao(database); assetIssuerWalletDao.setPluginFileSystem(pluginFileSystem); assetIssuerWalletDao.setPlugin(pluginId); assetIssuerWalletDao.updateMemoField(transactionID, description); } catch (CantStoreMemoException exception) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_WALLET_ISSUER, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, FermatException.wrapException(exception)); throw exception; } catch (Exception exception) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_WALLET_ISSUER, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, FermatException.wrapException(exception)); throw new CantStoreMemoException( CantStoreMemoException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
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<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; }
@Override public List<AssetIssuerWalletTransaction> gettLastActorTransactionsByTransactionType( BalanceType balanceType, TransactionType transactionType, int max, int offset) throws CantGetTransactionsException { try { assetIssuerWalletDao = new AssetIssuerWalletDao(database); assetIssuerWalletDao.setPluginFileSystem(pluginFileSystem); assetIssuerWalletDao.setPlugin(pluginId); return assetIssuerWalletDao.getTransactionsByTransactionType(transactionType, max, offset); } catch (CantGetTransactionsException exception) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_WALLET_ISSUER, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, FermatException.wrapException(exception)); throw exception; } catch (Exception exception) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_WALLET_ISSUER, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, FermatException.wrapException(exception)); throw new CantGetTransactionsException( CantGetTransactionsException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
/* * 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(); }
public String getAssetIssuerIdentityPrivateKey(String publicKey) throws CantGetAssetRedeemPointIdentityPrivateKeyException { String privateKey = ""; try { PluginTextFile file = this.pluginFileSystem.getTextFile( pluginId, DeviceDirectory.LOCAL_USERS.getName(), ReedemPointIdentityPluginRoot.ASSET_REDEEM_POINT_PRIVATE_KEYS_FILE_NAME + "_" + publicKey, FilePrivacy.PRIVATE, FileLifeSpan.PERMANENT); file.loadFromMedia(); privateKey = file.getContent(); } catch (CantLoadFileException e) { throw new CantGetAssetRedeemPointIdentityPrivateKeyException( "CAN'T GET PRIVATE KEY ", e, "Error loaded file.", null); } catch (FileNotFoundException | CantCreateFileException e) { throw new CantGetAssetRedeemPointIdentityPrivateKeyException( "CAN'T GET PRIVATE KEY ", e, "Error getting developer identity private keys file.", null); } catch (Exception e) { throw new CantGetAssetRedeemPointIdentityPrivateKeyException( "CAN'T GET PRIVATE KEY ", FermatException.wrapException(e), "", ""); } return privateKey; }
public byte[] getAssetIssuerProfileImagePrivateKey(String publicKey) throws CantGetAssetRedeemPointIdentityProfileImageException { byte[] profileImage; try { PluginBinaryFile file = this.pluginFileSystem.getBinaryFile( pluginId, DeviceDirectory.LOCAL_USERS.getName(), ReedemPointIdentityPluginRoot.ASSET_REDEEM_POINT_PROFILE_IMAGE_FILE_NAME + "_" + publicKey, FilePrivacy.PRIVATE, FileLifeSpan.PERMANENT); file.loadFromMedia(); profileImage = file.getContent(); } catch (CantLoadFileException e) { throw new CantGetAssetRedeemPointIdentityProfileImageException( "CAN'T GET IMAGE PROFILE ", e, "Error loaded file.", null); } catch (FileNotFoundException | CantCreateFileException e) { // Not image found return byte null profileImage = new byte[0]; // throw new CantGetIntraWalletUserIdentityProfileImageException("CAN'T GET IMAGE PROFILE ", // e, "Error getting developer identity private keys file.", null); } catch (Exception e) { throw new CantGetAssetRedeemPointIdentityProfileImageException( "CAN'T GET IMAGE PROFILE ", FermatException.wrapException(e), "", ""); } return profileImage; }
@Override public void handleEvent(FermatEvent fermatEvent) throws FermatException { if (this.customerAckOnlineMerchandiseRecorderService.getStatus() == ServiceStatus.STARTED) { try { this.customerAckOnlineMerchandiseRecorderService .BrokerSubmitMerchandiseConfirmedEventHandler( (BrokerSubmitMerchandiseConfirmed) fermatEvent); } catch (CantSaveEventException exception) { throw new CantSaveEventException( exception, "Handling the BrokerSubmitMerchandiseConfirmed", "Check the cause"); } catch (ClassCastException exception) { // Logger LOG = Logger.getGlobal(); // LOG.info("EXCEPTION DETECTOR----------------------------------"); // exception.printStackTrace(); throw new CantSaveEventException( FermatException.wrapException(exception), "Handling the BrokerSubmitMerchandiseConfirmed", "Cannot cast this event"); } catch (Exception exception) { throw new CantSaveEventException( exception, "Handling the BrokerSubmitMerchandiseConfirmed", "Unexpected exception"); } } else { throw new TransactionServiceNotStartedException(); } }
@Override public void handleEvent(FermatEvent fermatEvent) throws FermatException { if (this.assetDistributionRecorderService.getStatus() == ServiceStatus.STARTED) { try { this.assetDistributionRecorderService .incomingAssetReversedOnCryptoNetworkWaitingTransferenceAssetUserEvent( (IncomingAssetReversedOnCryptoNetworkNetworkWaitingTransferenceAssetUserEvent) fermatEvent); } catch (CantSaveEventException exception) { throw new CantSaveEventException( exception, "Handling the IncomingAssetReversedOnCryptoNetworkNetworkWaitingTransferenceAssetUserEvent", "Check the cause"); } catch (ClassCastException exception) { // Logger LOG = Logger.getGlobal(); // LOG.info("EXCEPTION DETECTOR----------------------------------"); // exception.printStackTrace(); throw new CantSaveEventException( FermatException.wrapException(exception), "Handling the IncomingAssetReversedOnCryptoNetworkNetworkWaitingTransferenceAssetUserEvent", "Cannot cast this event"); } catch (Exception exception) { throw new CantSaveEventException( exception, "Handling the IncomingAssetReversedOnCryptoNetworkNetworkWaitingTransferenceAssetUserEvent", "Unexpected exception"); } } else { throw new TransactionServiceNotStartedException(); } }
/** Private Methods */ private void persistNewUserPrivateKeysFile(String publicKey, String privateKey) throws CantPersistPrivateKeyException { try { PluginTextFile file = this.pluginFileSystem.createTextFile( pluginId, DeviceDirectory.LOCAL_USERS.getName(), ArtistIdentityPluginRoot.ARTIST_PRIVATE_KEYS_FILE_NAME + "_" + publicKey, FilePrivacy.PRIVATE, FileLifeSpan.PERMANENT); file.setContent(privateKey); file.persistToMedia(); } catch (CantPersistFileException e) { throw new CantPersistPrivateKeyException( "CAN'T PERSIST PRIVATE KEY ", e, "Error persist file.", null); } catch (CantCreateFileException e) { throw new CantPersistPrivateKeyException( "CAN'T PERSIST PRIVATE KEY ", e, "Error creating file.", null); } catch (Exception e) { throw new CantPersistPrivateKeyException( "CAN'T PERSIST PRIVATE KEY ", FermatException.wrapException(e), "", ""); } }
public boolean isPendingTransactions(CryptoStatus cryptoStatus) throws CantExecuteQueryException { try { this.database = openDatabase(); DatabaseTable databaseTable; databaseTable = database.getTable(AssetReceptionDatabaseConstants.ASSET_RECEPTION_TABLE_NAME); databaseTable.addStringFilter( AssetReceptionDatabaseConstants.ASSET_RECEPTION_PROTOCOL_STATUS_COLUMN_NAME, ProtocolStatus.TO_BE_NOTIFIED.getCode(), DatabaseFilterType.EQUAL); databaseTable.addStringFilter( AssetReceptionDatabaseConstants.ASSET_RECEPTION_CRYPTO_STATUS_COLUMN_NAME, cryptoStatus.getCode(), DatabaseFilterType.EQUAL); databaseTable.loadToMemory(); return !databaseTable.getRecords().isEmpty(); } catch (CantLoadTableToMemoryException exception) { throw new CantExecuteQueryException( "Error executing query in DB.", exception, "Getting pending transactions.", "Cannot load table to memory."); } catch (Exception exception) { throw new CantExecuteQueryException( CantExecuteQueryException.DEFAULT_MESSAGE, FermatException.wrapException(exception), "Getting pending transactions.", "Unexpected exception"); } }
private boolean isPendingEventsBySource(EventSource eventSource) throws CantExecuteQueryException { try { this.database = openDatabase(); DatabaseTable databaseTable; databaseTable = database.getTable( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_TABLE_NAME); databaseTable.addStringFilter( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_STATUS_COLUMN_NAME, EventStatus.PENDING.getCode(), DatabaseFilterType.EQUAL); databaseTable.addStringFilter( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_SOURCE_COLUMN_NAME, eventSource.getCode(), DatabaseFilterType.EQUAL); databaseTable.loadToMemory(); return !databaseTable.getRecords().isEmpty(); } catch (CantLoadTableToMemoryException exception) { throw new CantExecuteQueryException( "Error executing query in DB.", exception, "Getting pending events.", "Cannot load table to memory."); } catch (Exception exception) { throw new CantExecuteQueryException( CantExecuteQueryException.DEFAULT_MESSAGE, FermatException.wrapException(exception), "Getting pending events.", "Unexpected exception"); } }
private List<String> getValueListFromTableByColumn( String referenceValue, String table, String referenceColumn, String returningColumn) throws CantCheckAssetReceptionProgressException { try { this.database = openDatabase(); DatabaseTable databaseTable; List<String> returningList = new ArrayList<>(); databaseTable = database.getTable(table); databaseTable.addStringFilter(referenceColumn, referenceValue, DatabaseFilterType.EQUAL); databaseTable.loadToMemory(); for (DatabaseTableRecord record : databaseTable.getRecords()) { returningList.add(record.getStringValue(returningColumn)); } return returningList; } catch (CantLoadTableToMemoryException exception) { throw new CantCheckAssetReceptionProgressException( exception, "Getting " + referenceColumn + " list", "Cannot load table to memory"); } catch (CantExecuteDatabaseOperationException exception) { throw new CantCheckAssetReceptionProgressException( exception, "Getting " + referenceColumn + " list", "Cannot open or find the Asset Reception database"); } catch (Exception exception) { throw new CantCheckAssetReceptionProgressException( FermatException.wrapException(exception), "Getting " + referenceColumn + " list", "Unexpected exception"); } }
private boolean isAssetsByReceptionStatus(ReceptionStatus receptionStatus) throws CantExecuteQueryException { try { this.database = openDatabase(); DatabaseTable databaseTable; databaseTable = database.getTable(AssetReceptionDatabaseConstants.ASSET_RECEPTION_TABLE_NAME); databaseTable.addStringFilter( AssetReceptionDatabaseConstants.ASSET_RECEPTION_RECEPTION_STATUS_COLUMN_NAME, receptionStatus.getCode(), DatabaseFilterType.EQUAL); databaseTable.addStringFilter( AssetReceptionDatabaseConstants.ASSET_RECEPTION_CRYPTO_STATUS_COLUMN_NAME, CryptoStatus.PENDING_SUBMIT.getCode(), DatabaseFilterType.EQUAL); databaseTable.loadToMemory(); return !databaseTable.getRecords().isEmpty(); } catch (CantLoadTableToMemoryException exception) { throw new CantExecuteQueryException( "Error executing query in DB.", exception, "Getting assets by reception status.", "Cannot load table to memory."); } catch (Exception exception) { throw new CantExecuteQueryException( CantExecuteQueryException.DEFAULT_MESSAGE, FermatException.wrapException(exception), "Getting assets by reception status.", "Unexpected exception"); } }
/* * Service Interface implementation */ @Override public void start() { try { this.outgoingIntraActorDao = new OutgoingIntraActorDao(getErrorManager(), this.pluginDatabaseSystem); this.outgoingIntraActorDao.initialize(this.pluginId); this.transactionHandlerFactory = new OutgoingIntraActorTransactionHandlerFactory( this.eventManager, this.cryptoWalletManager, this.outgoingIntraActorDao, this.lossProtectedWalletManager); this.transactionProcessorAgent = new OutgoingIntraActorTransactionProcessorAgent( getErrorManager(), this.cryptoVaultManager, this.cryptoFermatVaultManager, this.bitcoinNetworkManager, this.cryptoWalletManager, this.outgoingIntraActorDao, this.transactionHandlerFactory, this.cryptoTransmissionNetworkServiceManager, this.eventManager, this.broadcaster, this.lossProtectedWalletManager); this.transactionProcessorAgent.start(); this.serviceStatus = ServiceStatus.STARTED; } catch (CantInitializeOutgoingIntraActorDaoException e) { reportUnexpectedException(e); } catch (Exception e) { reportUnexpectedException(FermatException.wrapException(e)); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { CryptoBrokerWalletModuleManager moduleManager = ((CryptoBrokerWalletSession) appSession).getModuleManager(); walletManager = moduleManager.getCryptoBrokerWallet(appSession.getAppPublicKey()); errorManager = appSession.getErrorManager(); identities = getMoreDataAsync(FermatRefreshTypes.NEW, 0); } catch (FermatException ex) { Log.e(TAG, ex.getMessage(), ex); } }
public boolean isGenesisTransactionRegistered(String genesisTransaction) throws CantExecuteQueryException { try { this.database = openDatabase(); DatabaseTable databaseTable; databaseTable = database.getTable(AssetReceptionDatabaseConstants.ASSET_RECEPTION_TABLE_NAME); databaseTable.addStringFilter( AssetReceptionDatabaseConstants.ASSET_RECEPTION_GENESIS_TRANSACTION_COLUMN_NAME, genesisTransaction, DatabaseFilterType.EQUAL); databaseTable.loadToMemory(); return !databaseTable.getRecords().isEmpty(); } catch (CantLoadTableToMemoryException exception) { throw new CantExecuteQueryException( "Error executing query in DB.", exception, "Checking if genesis transaction exists in database.", "Cannot load table to memory."); } catch (Exception exception) { throw new CantExecuteQueryException( CantExecuteQueryException.DEFAULT_MESSAGE, FermatException.wrapException(exception), "Checking if genesis transaction exits in database.", "Unexpected exception"); } }
public Database createDatabase(UUID ownerId, UUID walletId) throws CantCreateDatabaseException { Database database = null; try { database = this.pluginDatabaseSystem.createDatabase(ownerId, walletId.toString()); createLossProtetedWalletTable(ownerId, database.getDatabaseFactory()); createLossProtectedWalletBalancesTable(ownerId, database.getDatabaseFactory()); createLossProtectedWalletSpentTableFactory(ownerId, database.getDatabaseFactory()); insertInitialBalancesRecord(database); database.closeDatabase(); return database; } catch (CantCreateTableException | CantInsertRecordException exception) { if (database != null) database.closeDatabase(); throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, exception, null, "Check the cause"); } catch (CantCreateDatabaseException exception) { throw exception; } catch (Exception exception) { if (database != null) database.closeDatabase(); throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
@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); }
// DELETE METHOD FOR TEST public void deleteAllForTest() throws CantRegisterCustomerBrokerNewNegotiationTransactionException { try { DatabaseTable table = this.database.getTable( CustomerBrokerNewNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_NEW_TABLE_NAME); DatabaseTableRecord record = table.getEmptyRecord(); table.deleteRecord(record); } catch (CantDeleteRecordException e) { throw new CantRegisterCustomerBrokerNewNegotiationTransactionException( e.getMessage(), e, "Negotiation Transaction, Customer Broker New", "Cant delete Register, delete database problems."); } catch (Exception e) { throw new CantRegisterCustomerBrokerNewNegotiationTransactionException( e.getMessage(), FermatException.wrapException(e), "Negotiation Transaction, Customer Broker New", "Cant delete Register, unknown failure."); } }
public void updateTxHash(UUID transactionId, String newHash) throws OutgoingIntraActorCantInsertRecordException { try { DatabaseTable transactionTable = this.database.getTable( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TABLE_NAME); transactionTable.addStringFilter( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_ID_COLUMN_NAME, transactionId.toString(), DatabaseFilterType.EQUAL); transactionTable.loadToMemory(); if (transactionTable.getRecords().isEmpty()) throw new RecordsNotFoundException(); DatabaseTableRecord record = transactionTable.getRecords().get(0); record.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_HASH_COLUMN_NAME, newHash); transactionTable.updateRecord(record); } catch (Exception exception) { throw new com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer .bitdubai.version_1.exceptions.OutgoingIntraActorCantInsertRecordException( com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai .version_1.exceptions.OutgoingIntraActorCantInsertRecordException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
public void setToCryptoStatus( OutgoingDraftTransactionWrapper transactionWrapper, CryptoStatus cryptoStatus) throws CantUpdateRecordException, CantLoadTableToMemoryException, com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai .version_1.exceptions.OutgoingIntraActorInconsistentTableStateException { try { DatabaseTable transactionTable = this.database.getTable( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TABLE_NAME); DatabaseTableRecord recordToUpdate = getByPrimaryKey(transactionWrapper.getRequestId()); recordToUpdate.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_STATUS_COLUMN_NAME, cryptoStatus.getCode()); transactionTable.addStringFilter( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_ID_COLUMN_NAME, transactionWrapper.getRequestId().toString(), DatabaseFilterType.EQUAL); transactionTable.updateRecord(recordToUpdate); } catch (CantUpdateRecordException | com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai .version_1.exceptions.OutgoingIntraActorInconsistentTableStateException | CantLoadTableToMemoryException exception) { throw exception; } catch (Exception exception) { throw new CantLoadTableToMemoryException( CantLoadTableToMemoryException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
public CryptoStatus getCryptoStatus(String transactionHash) throws OutgoingIntraActorCantGetCryptoStatusException { try { DatabaseTable transactionTable = this.database.getTable( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TABLE_NAME); transactionTable.addStringFilter( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_HASH_COLUMN_NAME, transactionHash, DatabaseFilterType.EQUAL); transactionTable.loadToMemory(); List<DatabaseTableRecord> records = transactionTable.getRecords(); transactionTable.clearAllFilters(); return CryptoStatus.getByCode( records .get(0) .getStringValue( OutgoingDraftTransactionDatabaseConstants .OUTGOING_DRAFT_CRYPTO_STATUS_COLUMN_NAME)); } catch (InvalidParameterException | CantLoadTableToMemoryException e) { throw new OutgoingIntraActorCantGetCryptoStatusException("An exception happened", e, "", ""); } catch (Exception e) { throw new OutgoingIntraActorCantGetCryptoStatusException( "An unexpected exception happened", FermatException.wrapException(e), "", ""); } }
public void initialize(UUID walletId) throws CantInitializeAssetIssuerWalletException { if (walletId == null) throw new CantInitializeAssetIssuerWalletException( "InternalId is null", null, "Parameter walletId is null", "loadWallet didn't find the asociated id"); try { database = this.pluginDatabaseSystem.openDatabase(this.pluginId, walletId.toString()); } catch (CantOpenDatabaseException cantOpenDatabaseException) { throw new CantInitializeAssetIssuerWalletException( "I can't open database", cantOpenDatabaseException, "WalletId: " + walletId.toString(), ""); } catch (DatabaseNotFoundException databaseNotFoundException) { throw new CantInitializeAssetIssuerWalletException( "Database does not exists", databaseNotFoundException, "WalletId: " + walletId.toString(), ""); } catch (Exception exception) { throw new CantInitializeAssetIssuerWalletException( CantInitializeAssetIssuerWalletException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
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); } }
private void persistNewUserProfileImage(String publicKey, byte[] profileImage) throws CantPersistProfileImageException { try { PluginBinaryFile file = this.pluginFileSystem.createBinaryFile( pluginId, DeviceDirectory.LOCAL_USERS.getName(), ReedemPointIdentityPluginRoot.ASSET_REDEEM_POINT_PROFILE_IMAGE_FILE_NAME + "_" + publicKey, FilePrivacy.PRIVATE, FileLifeSpan.PERMANENT); file.setContent(profileImage); file.persistToMedia(); } catch (CantPersistFileException e) { throw new CantPersistProfileImageException( "CAN'T PERSIST PROFILE IMAGE ", e, "Error persist file.", null); } catch (CantCreateFileException e) { throw new CantPersistProfileImageException( "CAN'T PERSIST PROFILE IMAGE ", e, "Error creating file.", null); } catch (Exception e) { throw new CantPersistProfileImageException( "CAN'T PERSIST PROFILE IMAGE ", FermatException.wrapException(e), "", ""); } }
private void launchPresentationDialog() { try { DialogInterface.OnDismissListener onDismissListener = new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { try { identity = moduleManager.getSelectedActorIdentity(); loadSelectedActorIdentityInBackground(); if (identity == null) getActivity().onBackPressed(); else { invalidate(); onRefresh(); } } catch (Exception e) { e.printStackTrace(); } } }; if (launchActorCreationDialog) { PresentationDialog presentationDialog = new PresentationDialog.Builder(getActivity(), appSession) .setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION) .setBannerRes(R.drawable.ccc_banner) .setIconRes(R.drawable.crypto_customer) .setSubTitle(R.string.cbp_ccc_launch_action_creation_dialog_sub_title) .setBody(R.string.cbp_ccc_launch_action_creation_dialog_body) .setTextFooter(R.string.cbp_ccc_launch_action_creation_dialog_footer) .setTextNameLeft(R.string.cbp_ccc_launch_action_creation_name_left) .setTextNameRight(R.string.cbp_ccc_launch_action_creation_name_right) .setIsCheckEnabled(false) .build(); presentationDialog.setOnDismissListener(onDismissListener); presentationDialog.show(); } else if (launchListIdentitiesDialog) { ListIdentitiesDialog listIdentitiesDialog = new ListIdentitiesDialog(getActivity(), appSession, appResourcesProviderManager); listIdentitiesDialog.setOnDismissListener(onDismissListener); listIdentitiesDialog.show(); } else { onRefresh(); } } catch (Exception ex) { errorManager.reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.CRASH, FermatException.wrapException(ex)); Toast.makeText( getActivity().getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_SHORT) .show(); } }
public CryptoCustomerIdentity createCryptoCustomerIdentity(String alias, byte[] profileImage) throws CantCreateCryptoCustomerIdentityException { try { DeviceUser loggedUser = deviceUserManager.getLoggedInDeviceUser(); KeyPair keyPair = AsymmetricCryptography.generateECCKeyPair(); // TODO BY DEFAULT THE CUSTOMER IS PUBLISHED CryptoCustomerIdentity cryptoCustomer = new CryptoCustomerIdentityImpl( alias, keyPair.getPrivateKey(), keyPair.getPublicKey(), profileImage, true); cryptoCustomerIdentityDatabaseDao.createNewCryptoCustomerIdentity( cryptoCustomer, keyPair.getPrivateKey(), loggedUser); return cryptoCustomer; } catch (CantGetLoggedInDeviceUserException e) { throw new CantCreateCryptoCustomerIdentityException( "CAN'T CREATE NEW CRYPTO CUSTOMER IDENTITY", e, "Error getting current logged in device user", ""); } catch (CantCreateNewDeveloperException e) { throw new CantCreateCryptoCustomerIdentityException( "CAN'T CREATE NEW CRYPTO CUSTOMER IDENTITY", e, "Error save user on database", ""); } catch (Exception e) { throw new CantCreateCryptoCustomerIdentityException( "CAN'T CREATE NEW CRYPTO CUSTOMER IDENTITY", FermatException.wrapException(e), "", ""); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { try { int id = item.getItemId(); CharSequence itemTitle = item.getTitle(); // Esto podria ser un enum de item menu que correspondan a otro menu if (itemTitle.equals("New Identity")) { changeActivity(Activities.CWP_INTRA_USER_CREATE_ACTIVITY.getCode()); } // if(id == R.id.action_connection_request){ // Toast.makeText(getActivity(),"Intra user // request",Toast.LENGTH_SHORT).show(); // } if (item.getItemId() == R.id.action_notifications) { changeActivity(Activities.CCP_SUB_APP_INTRA_USER_COMMUNITY_REQUEST.getCode()); return true; } } catch (Exception e) { errorManager.reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, FermatException.wrapException(e)); makeText(getActivity(), "Oooops! recovering from system error", LENGTH_LONG).show(); } return super.onOptionsItemSelected(item); }