public void initializeDatabase() throws CantInitializeWalletContactsMiddlewareDatabaseException { try { database = this.pluginDatabaseSystem.openDatabase(pluginId, pluginId.toString()); } catch (CantOpenDatabaseException cantOpenDatabaseException) { throw new CantInitializeWalletContactsMiddlewareDatabaseException( cantOpenDatabaseException.getMessage()); } catch (DatabaseNotFoundException e) { WalletContactsMiddlewareDatabaseFactory walletContactsMiddlewareDatabaseFactory = new WalletContactsMiddlewareDatabaseFactory(pluginDatabaseSystem); try { database = walletContactsMiddlewareDatabaseFactory.createDatabase(pluginId, pluginId.toString()); } catch (CantCreateDatabaseException cantCreateDatabaseException) { throw new CantInitializeWalletContactsMiddlewareDatabaseException( cantCreateDatabaseException.getMessage()); } } catch (Exception e) { throw new CantInitializeWalletContactsMiddlewareDatabaseException(e.getMessage()); } }
/** * 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()); } } }
public void initializeDatabase() throws CantInitializeCashMoneyDestockDatabaseException { try { /* * Open new database connection */ database = this.pluginDatabaseSystem.openDatabase( pluginId, StockTransactionsCashMoneyDestockDatabaseConstants.CASH_MONEY_DESTOCK_DATABASE_NAME); database.closeDatabase(); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /* * The database exists but cannot be open. I can not handle this situation. */ throw new CantInitializeCashMoneyDestockDatabaseException( cantOpenDatabaseException.getMessage()); } 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 */ StockTransactionsCashMoneyDestockDatabaseFactory stockTransactionsCashMoneyDestockDatabaseFactory = new StockTransactionsCashMoneyDestockDatabaseFactory(this.pluginDatabaseSystem); try { /* * We create the new database */ database = stockTransactionsCashMoneyDestockDatabaseFactory.createDatabase( pluginId, StockTransactionsCashMoneyDestockDatabaseConstants .CASH_MONEY_DESTOCK_DATABASE_NAME); database.closeDatabase(); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /* * The database cannot be created. I can not handle this situation. */ throw new CantInitializeCashMoneyDestockDatabaseException( cantCreateDatabaseException.getMessage()); } } }
/** * This method open or creates the database i'll be working with * * @throws CantInitializeAssetRedeemPointIdentityDatabaseException */ private void initializeDatabase() throws CantInitializeAssetRedeemPointIdentityDatabaseException { try { /* * Open new database connection */ database = this.pluginDatabaseSystem.openDatabase( this.pluginId, AssetRedeemPointIdentityDatabaseConstants.ASSET_REDEEM_POINT_IDENTITY_DB_NAME); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /* * The database exists but cannot be open. I can not handle this situation. */ throw new CantInitializeAssetRedeemPointIdentityDatabaseException( cantOpenDatabaseException.getMessage()); } 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 */ AssetRedeemPointIdentityDatabaseFactory assetRedeemPointIdentityDatabaseFactory = new AssetRedeemPointIdentityDatabaseFactory(pluginDatabaseSystem); try { /* * We create the new database */ database = assetRedeemPointIdentityDatabaseFactory.createDatabase(pluginId); database.closeDatabase(); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /* * The database cannot be created. I can not handle this situation. */ throw new CantInitializeAssetRedeemPointIdentityDatabaseException( cantCreateDatabaseException.getMessage()); } } catch (Exception e) { throw new CantInitializeAssetRedeemPointIdentityDatabaseException(e.getMessage()); } }
/** * This method open or creates the database i'll be working with * * @throws CantInitializeCustomerBrokerSaleNegotiationDatabaseException */ public void initializeDatabase() throws CantInitializeCustomerBrokerSaleNegotiationDatabaseException { try { /* * Open new database connection */ database = this.pluginDatabaseSystem.openDatabase( pluginId, CustomerBrokerSaleNegotiationDatabaseConstants.DATABASE_NAME); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /* * The database exists but cannot be open. I can not handle this situation. */ throw new CantInitializeCustomerBrokerSaleNegotiationDatabaseException( cantOpenDatabaseException.getMessage()); } 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 */ CustomerBrokerSaleNegotiationDatabaseFactory customerBrokerSaleNegotiationDatabaseFactory = new CustomerBrokerSaleNegotiationDatabaseFactory(pluginDatabaseSystem); try { /* * We create the new database */ database = customerBrokerSaleNegotiationDatabaseFactory.createDatabase( pluginId, CustomerBrokerSaleNegotiationDatabaseConstants.DATABASE_NAME); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /* * The database cannot be created. I can not handle this situation. */ throw new CantInitializeCustomerBrokerSaleNegotiationDatabaseException( cantCreateDatabaseException.getMessage()); } } }
/** * This method initialize the database * * @throws CantInitializeDatabaseException */ private void initializeDb() throws CantInitializeDatabaseException { try { /* * Open new database connection */ this.database = this.pluginDatabaseSystem.openDatabase( pluginId, BrokerSubmitOnlineMerchandiseBusinessTransactionDatabaseConstants.DATABASE_NAME); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /* * The database exists but cannot be open. I can not handle this situation. */ reportError(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 */ BrokerSubmitOnlineMerchandiseBusinessTransactionDatabaseFactory factory = new BrokerSubmitOnlineMerchandiseBusinessTransactionDatabaseFactory(pluginDatabaseSystem); try { /* * We create the new database */ this.database = factory.createDatabase( pluginId, BrokerSubmitOnlineMerchandiseBusinessTransactionDatabaseConstants.DATABASE_NAME); } catch (CantCreateDatabaseException cantOpenDatabaseException) { reportError(DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, cantOpenDatabaseException); throw new CantInitializeDatabaseException(cantOpenDatabaseException.getLocalizedMessage()); } } }
/** * This method open or creates the database i'll be working with * * @throws CantInitializeAssetsOverBitcoinCryptoVaultDatabaseException */ public void initializeDatabase() throws CantInitializeAssetsOverBitcoinCryptoVaultDatabaseException { try { /* * Open new database connection */ database = this.pluginDatabaseSystem.openDatabase(pluginId, pluginId.toString()); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /* * The database exists but cannot be open. I can not handle this situation. */ throw new CantInitializeAssetsOverBitcoinCryptoVaultDatabaseException( cantOpenDatabaseException.getMessage()); } 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 */ AssetsOverBitcoinCryptoVaultDatabaseFactory assetsOverBitcoinCryptoVaultDatabaseFactory = new AssetsOverBitcoinCryptoVaultDatabaseFactory(pluginDatabaseSystem); try { /* * We create the new database */ database = assetsOverBitcoinCryptoVaultDatabaseFactory.createDatabase( pluginId, pluginId.toString()); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /* * The database cannot be created. I can not handle this situation. */ throw new CantInitializeAssetsOverBitcoinCryptoVaultDatabaseException( cantCreateDatabaseException.getMessage()); } } }
/** * This method open or creates the database i'll be working with * * @throws CantInitializeTimeOutNotifierAgentDatabaseException */ public void initializeDatabase() throws CantInitializeTimeOutNotifierAgentDatabaseException { try { /* * Open new database connection */ database = this.pluginDatabaseSystem.openDatabase(pluginId, "TimeOut Notifier"); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /* * The database exists but cannot be open. I can not handle this situation. */ throw new CantInitializeTimeOutNotifierAgentDatabaseException( cantOpenDatabaseException.getMessage()); } 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 */ TimeOutNotifierAgentDatabaseFactory timeOutNotifierAgentDatabaseFactory = new TimeOutNotifierAgentDatabaseFactory(pluginDatabaseSystem); try { /* * We create the new database */ database = timeOutNotifierAgentDatabaseFactory.createDatabase(pluginId, "TimeOut Notifier"); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /* * The database cannot be created. I can not handle this situation. */ throw new CantInitializeTimeOutNotifierAgentDatabaseException( cantCreateDatabaseException.getMessage()); } } }
/** * Method that create a new database and her tables. * * @return Object database. * @throws CantCreateDatabaseException */ public Database createDatabase(UUID pluginId) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this User. */ try { database = this.pluginDatabaseSystem.createDatabase( pluginId, RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_DB_NAME); /** Next, I will add the needed tables. */ DatabaseTableFactory table; /** Asset Issuer Identity table. */ DatabaseFactory databaseFactory = database.getDatabaseFactory(); table = databaseFactory.newTableFactory( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_TABLE_NAME); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, true); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_PRIVATE_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, false); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_ALIAS_COLUMN_NAME, DatabaseDataType.STRING, 36, false); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 130, false); table.addColumn( RedeemPointIdentityDatabaseConstants .REDEEM_POINT_IDENTITY_DEVICE_USER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, false); table.addIndex(RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_FIRST_KEY_COLUMN); databaseFactory.createTable(table); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ String message = CantCreateDatabaseException.DEFAULT_MESSAGE; FermatException cause = cantCreateDatabaseException.getCause(); String context = "Asset Issuer Identity DataBase_Factory: " + cantCreateDatabaseException.getContext(); String possibleReason = "The exception is thrown the Create Database Asset Issuer Identity 'this.platformDatabaseSystem.createDatabase(\"AssetIssuerIdentity\")'" + cantCreateDatabaseException.getPossibleReason(); throw new CantCreateDatabaseException(message, cause, context, possibleReason); } catch (CantCreateTableException cantCreateTableException) { String message = CantCreateTableException.DEFAULT_MESSAGE; FermatException cause = cantCreateTableException.getCause(); String context = "Create Table Asset Issuer Identity" + cantCreateTableException.getContext(); String possibleReason = "The exception is generated when creating the table Asset Issuer Identity - DatabaseFactory.createTable(table) " + cantCreateTableException.getPossibleReason(); throw new CantCreateDatabaseException(message, cause, context, possibleReason); } catch (Exception exception) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } return database; }