@Override public void saveWorkspace(Map<String, Map<String, String>> data, File destination) { requireNotNull(destination, "Destination file cannot be null"); LOG.debug(DefaultI18nContext.getInstance().i18n("Saving workspace data to {0}", destination.getAbsolutePath())); try { JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT).without(JSON.Feature.WRITE_NULL_PROPERTIES) .write(data, destination); LOG.info(DefaultI18nContext.getInstance().i18n("Workspace saved")); } catch (Exception e) { // make it unchecked throw new RuntimeException(e); } }
@Override public List<PremiumModule> getPremiumModules() { try { return JSON.std.with(Feature.READ_ONLY, true).listOfFrom(PremiumModule.class, new URL(pdfsam.property(ConfigurableProperty.PREMIUM_MODULES_URL))); } catch (IOException e) { LOG.warn(DefaultI18nContext.getInstance().i18n("Unable to retrieve premium features description"), e); } return Collections.emptyList(); }
@Override public List<NewsData> getLatestNews() { try { return JSON.std.with(Feature.READ_ONLY, true).listOfFrom(NewsData.class, new URL(pdfsam.property(ConfigurableProperty.NEWS_URL))); } catch (IOException e) { LOG.warn(DefaultI18nContext.getInstance().i18n("Unable to retrieve latest news"), e); } return Collections.emptyList(); }
private static Partitions loadPartitionFromStream(File stream, String location) { try { return JSON.std.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY) .with(JSON.Feature.USE_IS_GETTERS) .beanFrom(Partitions.class, stream); } catch (IOException | RuntimeException e) { throw new RuntimeException("Error while loading partitions file from " + location, e); } } }
private static Partitions loadPartitionFromStream(File stream, String location) { try { return JSON.std.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY) .with(JSON.Feature.USE_IS_GETTERS) .beanFrom(Partitions.class, stream); } catch (IOException | RuntimeException e) { throw new RuntimeException("Error while loading partitions file from " + location, e); } } }