package org.gcube.data.publishing.ckan2zenodo; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.gcube.common.resources.gcore.GenericResource; import org.gcube.data.publishing.ckan2zenodo.commons.IS; import lombok.Synchronized; public class TransformerManager { private static DocumentBuilder builder=null; @Synchronized private static DocumentBuilder getBuilder() throws ParserConfigurationException { if(builder==null) { DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance(); builder = factory.newDocumentBuilder(); } return builder; } public Translator getByProfile(String profile) throws Exception { for(GenericResource r: IS.queryForGenericResources("Ckan-Zenodo-Mappings")){ if (r.profile().name().equals(profile)) return new Translator(IS.readMappings(r),IS.readResourceFilters(r)); } throw new Exception("No transformer found for profile "+profile); } }