@Override public WalletLanguage createNewVersion(WalletLanguage walletLanguage) throws CantCopyWalletLanguageException { UUID id = UUID.randomUUID(); LanguageState state = LanguageState.DRAFT; WalletLanguage newWalletLanguage = new WalletLanguageMiddlewareWalletLanguage( id, walletLanguage.getLanguageId(), walletLanguage.getName(), walletLanguage.getType(), state, walletLanguage.getTranslatorPublicKey(), walletLanguage.getVersion()); try { Language language = getLanguage(walletLanguage); saveLanguage(language, newWalletLanguage); try { walletLanguageMiddlewareDao.createLanguage(newWalletLanguage); return newWalletLanguage; } catch (CantCreateEmptyWalletLanguageException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WALLET_LANGUAGE_MIDDLEWARE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantCopyWalletLanguageException( CantCopyWalletLanguageException.DEFAULT_MESSAGE, e, "Cant insert new wallet language", ""); } } catch (CantSaveLanguageException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WALLET_LANGUAGE_MIDDLEWARE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantCopyWalletLanguageException( CantCopyWalletLanguageException.DEFAULT_MESSAGE, e, "Cant create language", ""); } catch (CantGetLanguageException | LanguageNotFoundException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WALLET_LANGUAGE_MIDDLEWARE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantCopyWalletLanguageException( CantCopyWalletLanguageException.DEFAULT_MESSAGE, e, "Language not found", ""); } }
private String getLanguageFileName(WalletLanguage walletLanguage) { return walletLanguage.getLanguageId() + WALLET_LANGUAGES_FILE_NAME_SEPARATOR + walletLanguage.getId() + WALLET_LANGUAGES_EXTENSION; }