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"); } }
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."); } }
@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 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); } }
/** * 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()); } } }
@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; }
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; }
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); } }
/** * 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; } }
/* * 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(); }
@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); } } }
@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")); } }
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. } }
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(), ""); } }
@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); } }
@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; }
@Override public ActorAssetUserGroup getGroup(String groupId) throws CantGetAssetUserGroupException { try { return actorAssetUserManager.getAssetUserGroup(groupId); } catch (CantGetAssetUserGroupException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_DAP_ASSET_USER_COMMUNITY_SUB_APP_MODULE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw e; } }
/** * 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); } }
@Override public void unhold(BankMoneyTransactionRecord bankMoneyTransactionRecord) throws CantRegisterUnholdException { try { getAvailableBalance().credit(bankMoneyTransactionRecord); } catch (FermatException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_BNK_BANK_MONEY_WALLET, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); } }
@Override public List<BankAccountNumber> getAccounts() { try { return bankMoneyWalletDao.getAccounts(); } catch (CantGetAccountsException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_BNK_BANK_MONEY_WALLET, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); } return null; }
@Override public void stop() { try { removeRegisteredListeners(); this.serviceStatus = ServiceStatus.STOPPED; } catch (Exception exception) { errorManager.reportUnexpectedPluginException( Plugins.CHAT_MIDDLEWARE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, FermatException.wrapException(exception)); } }
@Override public void addActorAssetUserToGroup(ActorAssetUserGroupMember actorAssetUserGroupMember) throws CantCreateAssetUserGroupException { try { actorAssetUserManager.addAssetUserToGroup(actorAssetUserGroupMember); } catch (CantCreateAssetUserGroupException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_DAP_ASSET_USER_COMMUNITY_SUB_APP_MODULE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw e; } }
@Override public void removeActorAssetUserFromGroup(ActorAssetUserGroupMember assetUserGroupMember) throws CantDeleteAssetUserGroupException, RecordsNotFoundException { try { actorAssetUserManager.removeAssetUserFromGroup(assetUserGroupMember); } catch (CantDeleteAssetUserGroupException | RecordsNotFoundException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_DAP_ASSET_USER_COMMUNITY_SUB_APP_MODULE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw e; } }
public void Initialize() throws CantInitializeCBPAgent { try { database = this.pluginDatabaseSystem.openDatabase( pluginId, OpenContractBusinessTransactionDatabaseConstants.DATABASE_NAME); } catch (DatabaseNotFoundException databaseNotFoundException) { Logger LOG = Logger.getGlobal(); LOG.info("Database in Open Contract monitor agent doesn't exists"); OpenContractBusinessTransactionDatabaseFactory openContractBusinessTransactionDatabaseFactory = new OpenContractBusinessTransactionDatabaseFactory(this.pluginDatabaseSystem); try { database = openContractBusinessTransactionDatabaseFactory.createDatabase( pluginId, OpenContractBusinessTransactionDatabaseConstants.DATABASE_NAME); } catch (CantCreateDatabaseException cantCreateDatabaseException) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_ISSUING_TRANSACTION, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, cantCreateDatabaseException); throw new CantInitializeCBPAgent( cantCreateDatabaseException, "Initialize Monitor Agent - trying to create the plugin database", "Please, check the cause"); } } catch (CantOpenDatabaseException exception) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_ISSUING_TRANSACTION, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, exception); throw new CantInitializeCBPAgent( exception, "Initialize Monitor Agent - trying to open the plugin database", "Please, check the cause"); } }
@Override public void addNewAccount(BankAccountNumber bankAccountNumber) throws CantAddNewAccountException { System.out.println("registrando bankAccountNumber = " + bankAccountNumber.getAccount()); try { bankMoneyWalletDao.addNewAccount(bankAccountNumber); } catch (CantInsertRecordException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_BNK_BANK_MONEY_WALLET, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); throw new CantAddNewAccountException( CantInsertRecordException.DEFAULT_MESSAGE, e, null, null); } }
/** * This method initialize the database * * @throws CantInitializeNetworkServiceDatabaseException */ private void initializeCommunicationDb() throws CantInitializeNetworkServiceDatabaseException { try { this.dataBase = this.pluginDatabaseSystem.openDatabase( pluginId, CommunicationNetworkServiceDatabaseConstants.DATA_BASE_NAME); } catch (CantOpenDatabaseException cantOpenDatabaseException) { errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, cantOpenDatabaseException); throw new CantInitializeNetworkServiceDatabaseException(cantOpenDatabaseException); } catch (DatabaseNotFoundException e) { CommunicationNetworkServiceDatabaseFactory communicationLayerNetworkServiceDatabaseFactory = new CommunicationNetworkServiceDatabaseFactory(pluginDatabaseSystem); try { this.dataBase = communicationLayerNetworkServiceDatabaseFactory.createDatabase( pluginId, CommunicationNetworkServiceDatabaseConstants.DATA_BASE_NAME); } catch (CantCreateDatabaseException cantCreateDatabaseException) { errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, cantCreateDatabaseException); throw new CantInitializeNetworkServiceDatabaseException(cantCreateDatabaseException); } } }
/*Service Interface implementation.*/ @Override public void start() throws CantStartPluginException { try { this.cryptoCustomerIdentityDatabaseDao = new CryptoCustomerIdentityDatabaseDao( pluginDatabaseSystem, this.pluginFileSystem, this.pluginId); this.cryptoCustomerIdentityDatabaseDao.initialize(); } catch ( CantInitializeCryptoCustomerIdentityDatabaseException cantInitializeExtraUserRegistryException) { errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, cantInitializeExtraUserRegistryException); throw new CantStartPluginException( cantInitializeExtraUserRegistryException, this.getPluginVersionReference()); } try { exposeIdentities(); } catch (final CantExposeActorIdentitiesException e) { errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); throw new CantStartPluginException(e, this.getPluginVersionReference()); } this.serviceStatus = ServiceStatus.STARTED; }