/** * first i delete the file later i delete the record in database * * @param walletLanguage that you're trying to delete * @throws CantDeleteWalletLanguageException * @throws LanguageNotFoundException */ @Override public void deleteLanguage(WalletLanguage walletLanguage) throws CantDeleteWalletLanguageException, LanguageNotFoundException { try { String languageFileName = getLanguageFileName(walletLanguage); PluginTextFile pluginTextFile = pluginFileSystem.getTextFile( pluginId, WALLET_LANGUAGES_PATH, languageFileName, FilePrivacy.PRIVATE, FileLifeSpan.PERMANENT); pluginTextFile.delete(); try { walletLanguageMiddlewareDao.deleteLanguage(walletLanguage.getId()); } catch (CantDeleteWalletLanguageException | LanguageNotFoundException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WALLET_LANGUAGE_MIDDLEWARE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw e; } } catch (CantCreateFileException e) { throw new CantDeleteWalletLanguageException( CantDeleteWalletLanguageException.DEFAULT_MESSAGE, e, "Cant delete language file", ""); } catch (FileNotFoundException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WALLET_LANGUAGE_MIDDLEWARE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new LanguageNotFoundException( LanguageNotFoundException.DEFAULT_MESSAGE, e, "Language not found", ""); } }
private String getLanguageFileName(WalletLanguage walletLanguage) { return walletLanguage.getLanguageId() + WALLET_LANGUAGES_FILE_NAME_SEPARATOR + walletLanguage.getId() + WALLET_LANGUAGES_EXTENSION; }