@Override public void validate(ShallowConnectAddonBean addonBean) throws InvalidDescriptorException { if (!TranslationsBean.empty().equals(addonBean.getTranslations()) && !i18nSupportIsEnabled()) { throw new InvalidDescriptorException( "i18n support is not enabled, hence the 'translations' property is not allowed!", "connect.install.error.i18n.disabled"); } }
public static TranslationsBean empty() { return new TranslationsBean(new TranslationPathsBean()); }
public ShallowConnectAddonBean() { this.key = ""; this.name = ""; this.version = "1.0"; this.description = ""; this.vendor = VendorBean.newVendorBean().build(); this.links = newHashMap(); this.lifecycle = LifecycleBean.newLifecycleBean().build(); this.scopes = new HashSet<>(); this.baseUrl = ""; this.authentication = newAuthenticationBean().build(); this.enableLicensing = false; this.translations = TranslationsBean.empty(); this.dependencies = new DependenciesBean(); }
}); addonBuilder.withTranslations(new TranslationsBean(paths)); addonBuilder.withBaseurl(addonBaseUrl); addonBuilder.withScopes(scopes);
@Override public int hashCode() { return Objects.hash(getPaths()); }
@Override public String toString() { return com.google.common.base.Objects.toStringHelper(this) .add("paths", getPaths()) .toString(); } }
public Translations download(ConnectAddonBean addonBean) throws TranslationsDownloadException { List<DownloadResult<ResponsePromise>> downloadsInProgress = Stream.of(Language.values()) .map(lang -> pair(lang, lang.getPath(addonBean.getTranslations().getPaths()))) .filter(langAndPath -> langAndPath.right().isPresent()) .map(langAndPath -> scheduleDownload(langAndPath.left(), addonBean.getBaseUrl(), langAndPath.right().get())) .collect(toList()); final Map<Language, I18nKeysMapping> translations = downloadsInProgress.stream() .map(this::download) .collect(Collectors.toMap(DownloadResult::getLanguage, DownloadResult::getResult)); return Translations.from(translations); }