public static void main(String[] args) throws Exception { IJarDigester digester = IJarDigester.Utils.digester(); IArc4EclipseRepository repository = IArc4EclipseRepository.Utils.repository(); repository.addStatusListener(IStatusChangedListener.Utils.sysout()); // Rewrite System.out.println("Jar Data"); for (JarDataAndPath dataAndPath : AllTestFixtures.allJarDataConstants()) { Map<String, Object> jarData = dataAndPath.data; for (String key : jarData.keySet()) { String digest = digester.apply(dataAndPath.jar); Object value = jarData.get(key); repository.modifyJarData(digest, key, value, Collections.<String, Object>emptyMap()).get(); } } putData( repository, AllTestFixtures.allOrganisationDataConstants(), Arc4EclipseRepositoryConstants.organisationUrlKey, repository.generator().forOrganisation()); putData( repository, AllTestFixtures.allProjectDataConstants(), Arc4EclipseRepositoryConstants.projectUrlKey, repository.generator().forProject()); repository.shutdown(); }
private static void putData( IArc4EclipseRepository repository, Iterable<Map<String, Object>> maps, String urlKey, IFunction1<String, String> urlMapper) throws IllegalAccessException { try { System.out.println("Data for " + urlKey); for (Map<String, Object> item : maps) { String rawUrl = (String) item.get(urlKey); if (rawUrl == null) throw new NullPointerException( MessageFormat.format(Arc4EclipseRepositoryConstants.cannotFindDataFor, urlKey, item)); String url = urlMapper.apply(rawUrl); for (String key : item.keySet()) { Object value = item.get(key); repository.modifyData(url, key, value, Collections.<String, Object>emptyMap()).get(); } } } catch (Exception e) { throw WrappedException.wrap(e); } }