private void storeIncidentTexts(Bundle bundle) { logger.debug("Scanning bundle {}, (ID {}) for incident localizations", bundle.getSymbolicName(), bundle.getBundleId()); final Enumeration<?> l10n = bundle.findEntries(INCIDENT_L10N_DIR, PROPERTIES_GLOB, false); while (l10n != null && l10n.hasMoreElements()) { final URL resourceUrl = (URL) l10n.nextElement(); final String resourceFileName = resourceUrl.getPath(); // e.g. org.opencastproject.composer.properties or org.opencastproject.composer_de.properties final String fullResourceName = FilenameUtils.getBaseName(resourceFileName); final String[] fullResourceNameParts = fullResourceName.split("_"); // part 0 contains the key base, e.g. org.opencastproject.composer final String keyBase = fullResourceNameParts[0]; final List<String> locale = mlist(fullResourceNameParts).drop(1).value(); final Properties texts = loadPropertiesFromUrl(resourceUrl); for (String key : texts.stringPropertyNames()) { final String text = texts.getProperty(key); final String dbKey = mlist(keyBase, key).concat(locale).mkString("."); logger.debug("Storing text {}={}", dbKey, text); penv.tx(Queries.persistOrUpdate(IncidentTextDto.mk(dbKey, text))); } } } }
public static HttpGet get(String path, Tuple<String, String>... queryParams) { final String url = mlist(path, mlist(queryParams).map(new Function<Tuple<String, String>, String>() { @Override public String apply(Tuple<String, String> a) { try { return a.getA() + "=" + URLEncoder.encode(a.getB(), "UTF-8"); } catch (UnsupportedEncodingException e) { return chuck(e); } } }).mkString("&")).mkString("?"); return new HttpGet(url); }