@Override public A apply(EntityManager em) { return persistOrUpdate(em, a); } };
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))); } } } }