Fixes bug on configuration setting and refactors logic on file parsing due to that fix.

This commit is contained in:
gkolokythas 2019-11-08 15:53:46 +02:00
parent 28a2326743
commit e81ffa2825
14 changed files with 21 additions and 34 deletions

View File

@ -40,7 +40,7 @@ public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfigu
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///"+current + "/web/src/main/resources/FunderConfiguration.xml").openStream();
is = new URL("file:///"+ current + "/web/src/main/resources/FunderConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -41,7 +41,7 @@ public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfigur
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///" + this.environment.getProperty("configuration.resources.path") + "FunderConfiguration.xml").openStream();
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -48,7 +48,7 @@ public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfigura
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///"+current + "/web/src/main/resources/GrantConfiguration.xml").openStream();
is = new URL("file:///"+ current + "/web/src/main/resources/GrantConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -48,7 +48,7 @@ public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfigurat
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///" + this.environment.getProperty("configuration.resources.path") + "GrantConfiguration.xml").openStream();
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -42,7 +42,7 @@ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfi
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///"+current + "/web/src/main/resources/ProjectConfiguration.xml").openStream();
is = new URL("file:///"+ current + "/web/src/main/resources/ProjectConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -45,7 +45,7 @@ public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfig
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///" + this.environment.getProperty("configuration.resources.path") + "ProjectConfiguration.xml").openStream();
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -52,11 +52,6 @@ public class TagController extends BaseController {
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(externalUrlCriteria, type);
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);
// ObjectMapper mapper = new ObjectMapper();
// String fileUrl = this.environment.getProperty("configuration.resources.path") + this.environment.getProperty("dataset.tags.mock");
// List<Map<String, String>> data = mapper.readValue(new File(fileUrl), new TypeReference<List<Map<String, String>>>(){});
// TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(data);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<TagExternalSourcesModel>().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
}
}

View File

@ -192,7 +192,7 @@ public class DatasetProfileManager {
}
public List<String> getRDACommonStandards(Environment environment) {
String filePath = environment.getProperty("configuration.resources.path") + "RDACommonStandards.txt";
String filePath = environment.getProperty("configuration.rda");
BufferedReader reader;
List<String> rdaList = new LinkedList<>();
try {

View File

@ -31,7 +31,7 @@ public class DevelConfigLoader implements ConfigLoader {
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///"+current+"/web/src/main/resources/ExternalUrls.xml").openStream();
is = new URL("file:///"+ current +"/web/src/main/resources/ExternalUrls.xml").openStream();
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {

View File

@ -9,7 +9,6 @@ import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@ -20,6 +19,7 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
@ -28,9 +28,6 @@ public class RemoteFetcher {
private ConfigLoader configLoader;
@Value("${configuration.resources.path}")
private String resourcesPath;
@Autowired
public RemoteFetcher(ConfigLoader configLoader) {
this.configLoader = configLoader;
@ -268,9 +265,9 @@ public class RemoteFetcher {
}
private List<Map<String, String>> getAllResultsFromMockUpJson(String path, String query) {
String filePath = this.resourcesPath + path;
List<Map<String, String>> internalResults;
try {
String filePath = Paths.get(path).toUri().toURL().toString();
ObjectMapper mapper = new ObjectMapper();
internalResults = mapper.readValue(new File(filePath), new TypeReference<List<Map<String, Object>>>(){});
searchListMap(internalResults, query);

View File

@ -16,14 +16,10 @@ pdf.converter.url=http://localhost:88/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=/tmp/ExternalUrls.xml
configuration.dynamicGrantUrl=/tmp/GrantConfiguration.xml
configuration.dynamicProjectUrl=/tmp/ProjectConfiguration.xml
configuration.dynamicFunderUrl=/tmp/FunderConfiguration.xml
configuration.h2020template=C:\\Users\\gkolokythas\\Documents\\openDmp\\dmp-backend\\web\\src\\main\\resources\\documents\\h2020.docx
configuration.resources.path =
configuration.rda=C:/Users/gkolokythas/Documents/openDmp/dmp-backend/web/src/main/resources/RDACommonStandards.txt
configuration.loginProviders=C:/Users/gkolokythas/Documents/openDmp/dmp-backend/web/src/main/resources/LoginProviders.xml
configuration.h2020template=C:/Users/gkolokythas/Documents/openDmp/dmp-backend/web/src/main/resources/documents/h2020.docx
####################MOCK FILES CONFIGURATIONS##########
dataset.tags.mock=/mockupTags.json
#############TWITTER LOGIN CONFIGURATIONS#########
twitter.login.redirect_uri=http://127.0.0.1:4200/login/twitter

View File

@ -17,11 +17,8 @@ pdf.converter.url=http://docsbox-web/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=/tmp/ExternalUrls.xml
configuration.rda=/tmp/RDACommonStandards.txt
configuration.h2020template=/tmp/h2020.docx
configuration.resources.path=/tmp
####################MOCK FILES CONFIGURATIONS##########
dataset.tags.mock=/mockupTags.json
####################SPRING MAIL CONFIGURATIONS#################
spring.mail.default-encoding=UTF-8

View File

@ -17,11 +17,8 @@ pdf.converter.url=http://docsbox-web/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=/tmp/ExternalUrls.xml
configuration.h2020template=/tmp/h2020.docx
configuration.resources.path=/tmp/
####################MOCK FILES CONFIGURATIONS##########
dataset.tags.mock=mockupTags.json
configuration.rda=/tmp/RDACommonStandards.txt
configuration.h2020template=tmp/h2020.docx
####################INVITATION MAIL CONFIGURATIONS##############
####################GENERIC MAIL CONFIGURATIONS#################

View File

@ -19,6 +19,11 @@ spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=
configuration.rda=
configuration.h2020template=
#############LOGIN CONFIGURATIONS#########
#############GENERIC LOGIN CONFIGURATIONS#########
autouser.root.email=