package org.gcube.application.geoportalcommon; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import org.gcube.application.geoportalcommon.geoportalconfig.DocumentConfig; import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigDV; import com.fasterxml.jackson.core.JsonProcessingException; public class MockDocumentConfigurationReader { private List listDocumentConfigsDV = new ArrayList(); public MockDocumentConfigurationReader() { try { loadDocumentConfiguration(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } //THIS IS A MOCK private void loadDocumentConfiguration() throws Exception { System.out.println("loadDocumentConfiguration called"); String filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config.json"; DocumentConfigDV dc = getDocumentConfigVO(filePath); listDocumentConfigsDV.add(dc); filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config2.json"; dc = getDocumentConfigVO(filePath); listDocumentConfigsDV.add(dc); filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config3.json"; dc = getDocumentConfigVO(filePath); listDocumentConfigsDV.add(dc); filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config4.json"; dc = getDocumentConfigVO(filePath); listDocumentConfigsDV.add(dc); } private DocumentConfigDV getDocumentConfigVO(String filePath) throws JsonProcessingException, IOException { String theFile = readFile(filePath); System.out.println("the file is: " + theFile); DocumentConfig dc = org.gcube.application.geoportal.client.utils.Serialization.read(theFile, DocumentConfig.class); System.out.println(dc); return ConvertToDataValueObjectModel.toDocumentConfigDV(dc); } private static String readFile(String filePath) { String content = ""; try { content = new String(Files.readAllBytes(Paths.get(filePath))); } catch (IOException e) { e.printStackTrace(); } return content; } public List getListDocumentConfig() { return listDocumentConfigsDV; } }