package com.megatim.fdxcommons.model.camel;
|
|
import java.io.IOException;
|
|
/**
|
*
|
* @author Gabuntu
|
*/
|
public class LocalConfiguration {
|
|
private final FileProperties fileProperties;
|
|
public LocalConfiguration(FileProperties fileProperties) {
|
this.fileProperties = fileProperties;
|
}
|
|
public String referentielRouteURI() throws IOException {
|
return "file:" + referentielLocalPath() + "?include=.*.zip" + routeParameters();
|
}
|
|
public String fichierRouteURI() throws IOException {
|
return "file:" + fichierLocalPath() + "?include=.*\\.(csv|txt)$" + routeParameters();
|
}
|
|
public String standaloneTmpRouteURI() throws IOException {
|
return "file:" + standaloneTmpDir() + "?include=.*\\.(csv|txt)$&delete=true" + routeParameters();
|
}
|
|
public String standaloneRouteURI() throws IOException {
|
return "file:" + standaloneDestinationDir() + "?include=.*\\.(csv|txt)$" + routeParameters();
|
}
|
|
public String standaloneTmpDir() throws IOException {
|
return fileProperties.properties().getProperty(CamelProperties.STANDALONE_TMP_DIR_PROPERTY);
|
}
|
|
public String consultationTmpRouteURI() throws IOException {
|
return "file:" + consultationTmpDir() + "?include=.*\\.(csv|txt)$&delete=true" + routeParameters();
|
}
|
|
public String consultationRouteURI() throws IOException {
|
return "file:" + consultationDestinationDir() + "?include=.*\\.(csv|txt)$" + routeParameters();
|
}
|
|
public String consultationTmpDir() throws IOException {
|
return fileProperties.properties().getProperty(CamelProperties.CONSULTATION_TMP_DIR);
|
}
|
|
public boolean isStandaloneCorrect() throws IOException {
|
return referentielLocalPath() != null
|
&& fichierLocalPath() != null
|
&& standaloneTmpDir() != null
|
&& standaloneDestinationDir() != null;
|
}
|
|
public boolean isConsultationCorrect() throws IOException {
|
return consultationTmpDir() != null && consultationDestinationDir() != null;
|
}
|
|
private String routeParameters() {
|
return "&moveFailed=" + CamelProperties.ERROR_DIR + "&noop=true&readLock=rename";
|
}
|
|
public String referentielLocalPath() throws IOException {
|
return fileProperties.properties().getProperty(CamelProperties.REFERENTIEL_LOCAL_PATH_PROPERTY);
|
}
|
|
public String fichierLocalPath() throws IOException {
|
return fileProperties.properties().getProperty(CamelProperties.FICHIER_LOCAL_PATH_PROPERTY);
|
}
|
|
private String standaloneDestinationDir() throws IOException {
|
return fileProperties.properties().getProperty(CamelProperties.STANDALONE_DESTINATION_DIR_PROPERTY);
|
}
|
|
public String consultationDestinationDir() throws IOException {
|
return fileProperties.properties().getProperty(CamelProperties.CONSULTATION_DESTINATION_DIR_PROPERTY);
|
}
|
|
}
|