Kenmegne
7 days ago 23a46b4be35277e06ec89f48730eeb694e686be8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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);
    }
 
}