Bonjour,

je suis entrain de développer un service rest et je reçois cette erreur quand je run mon application :

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataFlowController': Unsatisfied dependency expressed through field 'pamdaImportDirectStarter'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pamdaImportDirect': Unsatisfied dependency expressed through field 'catalogueImportDirectStarter'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catalogueImportDirectStarter' is expected to be of type 'com.orange.pamda.worker.starter.CatalogueImportDirectStarter' but was actually of type 'com.sun.proxy.$Proxy129'
Apr 08, 2020 12:58:35 PM org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean destroy
INFO: Closing JPA EntityManagerFactory for persistence unit 'pamdaPersistenceUnit'
Apr 08, 2020 12:58:35 PM org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor shutdown
INFO: Shutting down ExecutorService
Apr 08, 2020 12:58:35 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataFlowController': Unsatisfied dependency expressed through field 'pamdaImportDirectStarter'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pamdaImportDirect': Unsatisfied dependency expressed through field 'catalogueImportDirectStarter'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catalogueImportDirectStarter' is expected to be of type 'com.orange.pamda.worker.starter.CatalogueImportDirectStarter' but was actually of type 'com.sun.proxy.$Proxy129'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4685)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pamdaImportDirect': Unsatisfied dependency expressed through field 'catalogueImportDirectStarter'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catalogueImportDirectStarter' is expected to be of type 'com.orange.pamda.worker.starter.CatalogueImportDirectStarter' but was actually of type 'com.sun.proxy.$Proxy129'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 45 more
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catalogueImportDirectStarter' is expected to be of type 'com.orange.pamda.worker.starter.CatalogueImportDirectStarter' but was actually of type 'com.sun.proxy.$Proxy129'
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:378)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 58 more

Apr 08, 2020 12:58:35 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataFlowController': Unsatisfied dependency expressed through field 'pamdaImportDirectStarter'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pamdaImportDirect': Unsatisfied dependency expressed through field 'catalogueImportDirectStarter'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catalogueImportDirectStarter' is expected to be of type 'com.orange.pamda.worker.starter.CatalogueImportDirectStarter' but was actually of type 'com.sun.proxy.$Proxy129'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4685)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pamdaImportDirect': Unsatisfied dependency expressed through field 'catalogueImportDirectStarter'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catalogueImportDirectStarter' is expected to be of type 'com.orange.pamda.worker.starter.CatalogueImportDirectStarter' but was actually of type 'com.sun.proxy.$Proxy129'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 45 more
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catalogueImportDirectStarter' is expected to be of type 'com.orange.pamda.worker.starter.CatalogueImportDirectStarter' but was actually of type 'com.sun.proxy.$Proxy129'
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:378)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 58 more

voici le code de mon servie rest "dataFlowController" :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
 
package com.orange.pamda.controller;
 
import java.io.File;
import java.io.IOException;
import java.util.List;
 
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import com.orange.pamda.config.PamdaServerProperty;
import com.orange.pamda.dao.ProfileDao;
import com.orange.pamda.dao.ScopeDao;
import com.orange.pamda.interfaces.v11.CatalogueSystem;
import com.orange.pamda.worker.service.WorkerService;
import com.orange.pamda.worker.starter.CatalogueImportDirectStarter;
import com.orange.pamda.worker.starter.MappingExportStarter;
import com.orange.pamda.worker.starter.MappingImportStarter;
import com.orange.pamda.worker.starter.CatalogueExportDirectStarter;
import com.orange.pamda.worker.starter.PamdaImportDirectStarter;
import com.orange.pamda.worker.utils.DataFlowParameterInfo;
import com.orange.pamda.worker.utils.Worker;
import com.orange.pamda.worker.utils.WorkerExecutionStatus;
import com.orange.pamda.worker.utils.WorkerParameterInfo;
 
@RestController
@RequestMapping("dataFlow")
@Transactional
@CrossOrigin
public class DataFlowController {
 
	private static final Logger LOGGER = LoggerFactory.getLogger(DataFlowController.class);
 
	@Autowired
	//@Qualifier("catalogueImportDirectStarter")
	CatalogueImportDirectStarter catalogueImportDirectStarter;
 
	@Autowired
	CatalogueExportDirectStarter catalogueExportDirectStarter;
 
	@Autowired
	MappingImportStarter mappingImportStarter;
 
	@Autowired
	MappingExportStarter mappingExportStarter; 
 
	@Autowired
	PamdaImportDirectStarter pamdaImportDirectStarter;
 
 
	@Autowired
	WorkerService workerService;
 
	@Autowired
	AuthenticationManager authenticationManager;
 
	@Autowired
	DaoAuthenticationProvider authenticationProvider;
 
	@Autowired
	PamdaServerProperty pamdaProperty;
 
	@Autowired
	ScopeDao scopeDao;
 
 
	 @RequestMapping(value = "/directExportCatalogue", method = RequestMethod.POST)
	public ResponseEntity<WorkerExecutionStatus> directExportCatalogue(@RequestBody DataFlowParameterInfo dataFlowParameterInfo) {
 
	 WorkerExecutionStatus workerExecutionStatus = new WorkerExecutionStatus();
 
	 try {
		 	long startTime = System.nanoTime();
 
		 	dataFlowParameterInfo.setDataFlowName(com.orange.pamda.worker.utils.Worker.catalogueImport.name().toString());
		 	catalogueExportDirectStarter.start(dataFlowParameterInfo);
			long endTime = (System.nanoTime() - startTime) / 1000000000;
			LOGGER.trace("[TIMER] Pamda import direct : {}", endTime);
			System.out.println("[TIMER] Pamda import direct : {}"+ endTime);
		} catch (IOException e) {
			// TODO Auto-generated catch block
 
			workerExecutionStatus.setOnError(true);	
 
		}
		return new ResponseEntity<>(workerExecutionStatus, HttpStatus.OK);
	}
 
 
	@RequestMapping(value = "/directImportCatalogue", method = RequestMethod.POST)
	public ResponseEntity<WorkerExecutionStatus> directImportCatalogue(@RequestBody DataFlowParameterInfo dataFlowParameterInfo) {
	 dataFlowParameterInfo.setDataFlowName(com.orange.pamda.worker.utils.Worker.catalogueImport.name().toString());
	 WorkerExecutionStatus workerExecutionStatus = new WorkerExecutionStatus();
 
	 try {
		 	long startTime = System.nanoTime();
 
 
			catalogueImportDirectStarter.start(dataFlowParameterInfo);
			long endTime = (System.nanoTime() - startTime) / 1000000000;
			LOGGER.trace("[TIMER] directImportCatalogue : {}", endTime);
			System.out.println("[TIMER] directImportCatalogue : {}"+ endTime);
		} catch (IOException e) {
			// TODO Auto-generated catch block
 
			workerExecutionStatus.setOnError(true);	
 
		} 
		return new ResponseEntity<>(workerExecutionStatus, HttpStatus.OK);
	}
 
 
	@PostMapping(value = "/directImportPamda")
	public ResponseEntity<WorkerExecutionStatus> directImportPamda(@RequestBody DataFlowParameterInfo dataFlowParameterInfo) {
 
	 WorkerExecutionStatus workerExecutionStatus = new WorkerExecutionStatus();
 
	 try {
		 	long startTime = System.nanoTime();
 
		 	dataFlowParameterInfo.setDataFlowName(com.orange.pamda.worker.utils.Worker.catalogueImport.name().toString());
		 	pamdaImportDirectStarter.start(dataFlowParameterInfo);
			long endTime = (System.nanoTime() - startTime) / 1000000000;
			LOGGER.trace("[TIMER] Pamda import direct : {}", endTime);
			System.out.println("[TIMER] Pamda import direct : {}"+ endTime);
		} catch (IOException e) {
			// TODO Auto-generated catch block
 
			workerExecutionStatus.setOnError(true);	
 
		}
		return new ResponseEntity<>(workerExecutionStatus, HttpStatus.OK);
	}
 
 
	/* @RequestMapping(value = "/directExportMapping", method = RequestMethod.POST)
	public ResponseEntity<Void> directExportMapping(@RequestBody WorkerParameterInfo workerParameterInfo) {
		workerParameterInfo.setWorker(Worker.valueOf(com.orange.pamda.worker.utils.Worker.mappingExport.name()));
		workerService.launch(workerParameterInfo);
		return new ResponseEntity<>(HttpStatus.OK);
	}
 
 
 
	@RequestMapping(value = "/directImportMapping", method = RequestMethod.POST)
	public ResponseEntity<WorkerExecutionStatus> directImportMapping(@RequestBody WorkerParameterInfo workerParameterInfo) {
		workerParameterInfo.setWorker(Worker.valueOf(com.orange.pamda.worker.utils.Worker.mappingImport.name()));
		List<WorkerExecutionStatus> workerExecutionStatuss = workerService.launch(workerParameterInfo);
		return new ResponseEntity<>(workerExecutionStatuss.get(0), HttpStatus.OK);
	}
	*/
}
et voici la classe appelée par ma méthode directImportPamda pour le traitement:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
 
package com.orange.pamda.worker.starter;
 
import java.io.File;
import java.io.IOException;
import java.util.List;
 
import javax.inject.Inject;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import com.google.common.collect.Lists;
import com.orange.pamda.config.PamdaServerProperty;
import com.orange.pamda.dao.MappingContextDAO;
import com.orange.pamda.entity.jpa.MappingContext;
import com.orange.pamda.service.MappingContextService;
import com.orange.pamda.util.DataFlowParametersBuilder;
import com.orange.pamda.util.DateHelper;
import com.orange.pamda.util.FileFormatter;
import com.orange.pamda.util.FileHelper;
import com.orange.pamda.util.PamdaDataFlowStarter;
import com.orange.pamda.worker.distributon.ArchiveService;
import com.orange.pamda.worker.eraser.DataEraser;
import com.orange.pamda.worker.utils.DataFlowParameterInfo;
 
 
@Component("pamdaImportDirect")
public class PamdaImportDirectStarter implements PamdaDataFlowStarter {
 
	@Inject
	private ArchiveService archiveService;
 
	@Inject
	private DataEraser dataEraser;
 
	@Autowired
	CatalogueImportDirectStarter catalogueImportDirectStarter;
 
	@Autowired
	CatalogueExportDirectStarter catalogueExportDirectStarter;
 
	@Autowired
	MappingImportStarter mappingImportStarter;
 
	@Autowired
	MappingExportStarter mappingExportStarter;
 
	@Inject
	private PamdaServerProperty pamdaProperty;
 
	@Autowired
	private MappingContextDAO mappingContextDAO;
 
	@Autowired
	private MappingContextService mappingContextService;
 
	protected static Logger logger = LoggerFactory.getLogger(PamdaImportDirectStarter.class);
 
 
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public void start(DataFlowParameterInfo dataFlowParameterInfo)
			throws  IOException {
 
		System.out.println("START launching Pamda Import");
 
 
	    startImport(dataFlowParameterInfo);
		System.out.println("End launching Pamda Import JOB");
 
	}
 
	private void startImport(DataFlowParameterInfo dataFlowParameterInfo) {
		try {
			catalogueExportDirectStarter.start(dataFlowParameterInfo);
		} catch (IOException e3) {
			// TODO Auto-generated catch block
			e3.printStackTrace();
		}
 
		try {
			mappingExportStarter.start(dataFlowParameterInfo);
		} catch (IOException e2) {
			// TODO Auto-generated catch block
			e2.printStackTrace();
		}
 
		archive(dataFlowParameterInfo);
 
		unZipArchive(dataFlowParameterInfo);
 
		dataEraser(dataFlowParameterInfo);
 
		try {
			catalogueImportDirectStarter.start(dataFlowParameterInfo);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
 
		try {
			mappingImportStarter.start(dataFlowParameterInfo);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
		deleteUnZipFiles();
	}
 
	public void archive(DataFlowParameterInfo dataFlowParameterInfo) {
 
		DataFlowParametersBuilder builder = new DataFlowParametersBuilder();
 
		String pamdaImportPath = pamdaProperty.getPamdaImportPath();
 
		File[] filesList = null;
		try {
			filesList =		FileHelper.getFilesFromDirectoryMatchingPattern(pamdaImportPath, pamdaProperty.getPamdaFilename());
		} catch(Exception ex) {
			//throw new JobParametersInvalidException(dataFlowParameterInfo.NO_FILE);
		} 
 
		if (filesList != null && filesList.length > 1) 
			//throw new JobParametersInvalidException(dataFlowParameterInfo.TOO_MANY_FILES);
 
		if (filesList != null && filesList.length == 1) {
			MappingContext selectedMappingContext = mappingContextDAO.findMappingContext(Long.parseLong(dataFlowParameterInfo.getCurrentMappingContext()));
 
			//if(!filesList[0].getName().contains(selectedMappingContext.getCode()))
				//throw new JobParametersInvalidException(dataFlowParameterInfo.DIFFERENT_CONTEXT_FILE + "." + filesList[0].getName());
		}
 
 
 
		String parameterPaths = FileHelper.buildSplitFilenameParameter(filesList);
 
 
		String pamdaFilename = pamdaProperty.getPamdaFilename();
		long startTime = System.currentTimeMillis();
		String exportDateString = DateHelper.FILE_DATE_TIME_FORMATTER.print(startTime);
 
		MappingContext mappCntxt = mappingContextService
				.findById(Long.valueOf(dataFlowParameterInfo.getCurrentMappingContext()));
 
		List<String> pathList = FileHelper.splitFilesParameter(cataloguePath, catalogueFilename);
		pathList.addAll(FileHelper.splitFilesParameter(mappingPath, mappingFilename));
 
		String pamdaExportPath = pamdaProperty.getPamdaExportPath();
		File pamdaExportResult;
 
		try {
			pamdaExportResult = FileFormatter.getFormattedFileWithDate(mappCntxt.getCode(), pamdaFilename, ".zip",
					pamdaExportPath, exportDateString);
			archiveService.archiveFiles(pamdaExportPath, pamdaExportResult.getName(), pathList, currentContext , dataFlowParameterInfo.getPamdaVersion().getVersion() , dataFlowParameterInfo.getPamdaVersion().getCommentaire(), dataFlowParameterInfo.getUser(), dataFlowParameterInfo.getPamdaVersion().getFlag());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	}
 
 
 
 
	private void unZipArchive (DataFlowParameterInfo dataFlowParameterInfo) {
 
 
		String pamdaImportPath = pamdaProperty.getPamdaImportPath();
		File[] filesList = null;
		try {
			filesList =		FileHelper.getFilesFromDirectoryMatchingPattern(pamdaImportPath, pamdaProperty.getPamdaFilename());
		} catch(Exception ex) {
			//throw new JobParametersInvalidException(dataFlowParameterInfo.NO_FILE);
		} 
		String importFilename = FileHelper.buildSplitFilenameParameter(filesList);
		List<String> files = FileHelper.splitFilesParameter(pamdaImportPath, importFilename);
		try {
			archiveService.unZipArchiveFile( files );
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	}
 
	public void dataEraser(DataFlowParameterInfo dataFlowParameterInfo) {
 
		dataEraser.eraseData(Long.parseLong(dataFlowParameterInfo.getCurrentMappingContext()));
 
	}
 
public void deleteUnZipFiles() {
 
		List<File> folderList = Lists.newArrayList();
		folderList.add(FileHelper.getFileFromResource(pamdaProperty.getMappingImportPamdaPath()));
		folderList.add(FileHelper.getFileFromResource(pamdaProperty.getCatalogueImportPamdaPath()));
 
		try {
			archiveService.deleteArchiveFiles(folderList);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	}
 
}
et voici le code de ma classe CatalogExportDirectStarter qui est appelé par la classe PamdaImportDirect:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
 
package com.orange.pamda.worker.starter;
 
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import javax.inject.Inject;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import com.orange.pamda.config.PamdaServerProperty;
import com.orange.pamda.dao.MappingContextDAO;
import com.orange.pamda.entity.jpa.MappingContext;
import com.orange.pamda.service.MappingContextService;
import com.orange.pamda.util.DataFlowParameters;
import com.orange.pamda.util.DataFlowParametersBuilder;
import com.orange.pamda.util.DateHelper;
import com.orange.pamda.util.FileFormatter;
import com.orange.pamda.util.FileHelper;
import com.orange.pamda.util.PamdaDataFlowStarter;
import com.orange.pamda.worker.catalogue.exporter.CatalogueExporter;
import com.orange.pamda.worker.catalogue.importer.CatalogueImporter;
import com.orange.pamda.worker.service.XMLValidationService;
import com.orange.pamda.worker.utils.DataFlowParameterInfo;
 
 
@Component("catalogueExportDirectStarter")
public class CatalogueExportDirectStarter implements PamdaDataFlowStarter {
 
	@Inject
	@Qualifier("catalogueImporter")
	private CatalogueExporter catalogueExporter;
 
	@Inject
	private XMLValidationService xmlValidationService;
	@Inject
	private PamdaServerProperty pamdaProperty;
 
	@Autowired
	private MappingContextDAO mappingContextDAO;
 
	@Autowired
	private MappingContextService mappingContextService;
 
	protected static Logger logger = LoggerFactory.getLogger(PamdaImportDirectStarter.class);
 
 
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public void start(DataFlowParameterInfo dataFlowParameterInfo)
			throws  IOException {
 
		String pamdaExportPath = pamdaProperty.getPamdaExportPath();
		String pamdaFilename = pamdaProperty.getPamdaFilename();
 
 
 
		DataFlowParametersBuilder builder = new DataFlowParametersBuilder();
		long startTime = System.currentTimeMillis();
 
		MappingContext mappCntxt = mappingContextService
				.findById(Long.valueOf(dataFlowParameterInfo.getCurrentMappingContext()));
 
		String exportDateString = DateHelper.FILE_DATE_TIME_FORMATTER.print(startTime);
 
		File pamdaCatalogueExportResult = FileFormatter.getFormattedFileWithDate(mappCntxt.getCode(),
				pamdaProperty.getCatalogueFilename(), ".xml", pamdaExportPath, exportDateString);
		builder.addString(cataloguePath, pamdaExportPath);
		builder.addString(catalogueFilename, pamdaCatalogueExportResult.getName());
		builder.addString("catalogueCode", dataFlowParameterInfo.ALL);
 
		File pamdaMappingExportResult = FileFormatter.getFormattedFileWithDate(mappCntxt.getCode(),
				pamdaProperty.getMappingFilename(), ".xml", pamdaExportPath, exportDateString);
		builder.addString(mappingPath, pamdaExportPath);
		builder.addString(mappingFilename, pamdaMappingExportResult.getName());
 
		File pamdaExportResult = FileFormatter.getFormattedFileWithDate(mappCntxt.getCode(), pamdaFilename, ".zip",
				pamdaExportPath, exportDateString);
		builder.addString("archiveTargetName", pamdaExportResult.getName());
		builder.addString("archiveTargetDirectory", pamdaExportPath);
		builder.addString(targetFilePathParameterName, "archiveTargetName");
		builder.addLong(datetime, startTime);
 
		builder.addString(currentContext, dataFlowParameterInfo.getCurrentMappingContext());
		builder.addString(disabledByUser, String.valueOf(dataFlowParameterInfo.isDisabledByUser()));
		if(dataFlowParameterInfo.getPamdaVersion() != null) {
			builder.addString("pamdaVersion", dataFlowParameterInfo.getPamdaVersion().getVersion());
			builder.addString("comVersion", dataFlowParameterInfo.getPamdaVersion().getCommentaire());
			builder.addString("login", dataFlowParameterInfo.getUser());
			builder.addDate("flag", dataFlowParameterInfo.getPamdaVersion().getFlag());
		}
 
		startExport(builder.toDataFlowParameters() );
	}
		public void startExport(DataFlowParameters dataFlowParameters ) { 
 
 
 
			//catalogueExport 
 
			Long mappingSystemId = Long.parseLong(dataFlowParameters.getString(PamdaDataFlowStarter.currentContext));
			List<String> inputFilePaths = new ArrayList<String>();
			inputFilePaths.add(dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename));
 
			catalogueExporter.export(dataFlowParameters.getString(PamdaDataFlowStarter.cataloguePath) + File.separator + dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename), dataFlowParameters.getString(PamdaDataFlowStarter.catalogueCode), dataFlowParameters.getString(PamdaDataFlowStarter.currentContext));
 
			//catalogueValidation
			catalogueValidation(dataFlowParameters);			
		}
 
 
		public void catalogueValidation(DataFlowParameters dataFlowParameters) {
			String catalogueFilename = dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename);
			String filePath = dataFlowParameters.getString(PamdaDataFlowStarter.cataloguePath);
 
			List<String> files = FileHelper.splitFilesParameter(filePath, catalogueFilename);
			xmlValidationService.validate( files, pamdaProperty.getCatalogueXSDfile());
 
 
		}
 
 
}
et voici le code de ma class "mappingExportStarter" qui est appellé par la class pamdaImportDirectStarter" :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
81
82
83
84
85
86
87
88
89
90
91
92
 
 
package com.orange.pamda.worker.starter;
 
import java.io.File;
import java.io.IOException;
import java.util.List;
 
import javax.inject.Inject;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import com.orange.pamda.config.PamdaServerProperty;
import com.orange.pamda.entity.jpa.MappingContext;
import com.orange.pamda.service.MappingContextService;
import com.orange.pamda.util.DataFlowParameters;
import com.orange.pamda.util.DataFlowParametersBuilder;
import com.orange.pamda.util.DateHelper;
import com.orange.pamda.util.FileFormatter;
import com.orange.pamda.util.FileHelper;
import com.orange.pamda.util.PamdaDataFlowStarter;
import com.orange.pamda.worker.mapping.exporter.MappingExporter;
import com.orange.pamda.worker.service.XMLValidationService;
import com.orange.pamda.worker.utils.DataFlowParameterInfo;
 
@Component("mappingExportStarter")
public class MappingExportStarter implements PamdaDataFlowStarter {
 
 
	@Inject
	private XMLValidationService xmlValidationService;
 
	@Autowired
	protected MappingExporter mappingExporter;
 
	@Inject
	private PamdaServerProperty pamdaProperty;
 
	@Autowired
	private MappingContextService mappingContextService;
 
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public void start(DataFlowParameterInfo dataFlowParameterInfo)
			throws  IOException {
 
		//List<JobExecution> listJobExecution = Lists.newArrayList();
		long startTime = System.currentTimeMillis();
		String exportDateString = DateHelper.FILE_DATE_TIME_FORMATTER.print(startTime);
 
		MappingContext mappCntxt = mappingContextService
				.findById(Long.valueOf(dataFlowParameterInfo.getCurrentMappingContext()));
 
		String rootPath = pamdaProperty.getMappingExportPath();
 
		File mappingExportResult = FileFormatter.getFormattedFileWithDate(mappCntxt.getCode(),
				pamdaProperty.getMappingFilename(), ".xml", rootPath, exportDateString);
		DataFlowParametersBuilder builder = new DataFlowParametersBuilder();
		builder.addString(mappingPath, rootPath);
		builder.addString(mappingFilename, mappingExportResult.getName());
		builder.addString(targetFilePathParameterName, mappingPath);
		builder.addString(targetFilenameParameterName, mappingFilename);
		builder.addLong(datetime, startTime);
 
		builder.addString(currentContext, dataFlowParameterInfo.getCurrentMappingContext());
		builder.addString(disabledByUser, String.valueOf(dataFlowParameterInfo.isDisabledByUser()));
 
 
		startExport(builder.toDataFlowParameters() );
 
	}
 
	public void startExport(DataFlowParameters dataFlowParameters ) { 
 
		mappingExporter.export(dataFlowParameters.getString(PamdaDataFlowStarter.cataloguePath) + File.separator + dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename), dataFlowParameters.getString(PamdaDataFlowStarter.currentContext) );
		catalogueValidation(dataFlowParameters);
 
	}
 
	public void catalogueValidation(DataFlowParameters dataFlowParameters) {
		String catalogueFilename = dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename);
		String filePath = dataFlowParameters.getString(PamdaDataFlowStarter.cataloguePath);
 
		List<String> files = FileHelper.splitFilesParameter(filePath, catalogueFilename);
		xmlValidationService.validate( files, pamdaProperty.getCatalogueXSDfile());
 
 
	}
 
	}
et voici la class "catalogueImportDirectStarter" qui est elle aussi appellé par la class "pamdaImportDirectStarter" :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 
package com.orange.pamda.worker.starter;
 
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import javax.inject.Inject;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.Job;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import com.orange.pamda.config.PamdaServerProperty;
import com.orange.pamda.config.batch.listener.RenameFileAfterImportListener;
import com.orange.pamda.dao.MappingContextDAO;
import com.orange.pamda.entity.jpa.MappingContext;
import com.orange.pamda.util.DataFlowParameters;
import com.orange.pamda.util.DataFlowParametersBuilder;
import com.orange.pamda.util.FileHelper;
import com.orange.pamda.util.PamdaDataFlowStarter;
import com.orange.pamda.worker.catalogue.importer.CatalogueImporter;
import com.orange.pamda.worker.service.XMLValidationService;
import com.orange.pamda.worker.utils.DataFlowParameterInfo;
 
@Component("catalogueImportDirectStarter")
public class CatalogueImportDirectStarter implements PamdaDataFlowStarter {
 
 
	@Inject
	@Qualifier("catalogueImporter")
	private CatalogueImporter catalogueImporter;
 
	@Inject
	private XMLValidationService xmlValidationService;
 
	@Inject
	private PamdaServerProperty pamdaProperty;
 
 
	@Autowired
	private MappingContextDAO mappingContextDAO;
 
	protected static Logger logger = LoggerFactory.getLogger(CatalogueImportDirectStarter.class);
 
 
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public void start(DataFlowParameterInfo dataFlowParameterInfo)
			throws  IOException {
 
		//List<JobExecution> listJobExecution = new ArrayList<JobExecution>();
 
		String rootPath = pamdaProperty.getCatalogueImportPath();
 
		System.out.println("--------------- Import Catalogue Directory ----" + rootPath);	
 
		File[] filesList = null;
		try {
			filesList =	FileHelper.getFilesFromDirectoryMatchingPattern(rootPath, pamdaProperty.getCatalogueFilename());
		} catch(Exception ex) {
			//throw new JobParametersInvalidException(WorkerParameterInfo.NO_FILE);
		} 
 
		if (filesList != null && filesList.length > 1) 
		//	throw new JobParametersInvalidException(WorkerParameterInfo.TOO_MANY_FILES);
 
		if (filesList != null && filesList.length == 1) {
			MappingContext selectedMappingContext = mappingContextDAO.findMappingContext(Long.parseLong(dataFlowParameterInfo.getCurrentMappingContext()));
 
			//if(!filesList[0].getName().contains(selectedMappingContext.getCode()))
			//	throw new JobParametersInvalidException(WorkerParameterInfo.DIFFERENT_CONTEXT_FILE + "." + filesList[0].getName());
		}
 
		String parameterPaths = FileHelper.buildSplitFilenameParameter(filesList);
		DataFlowParametersBuilder builder = new DataFlowParametersBuilder();
		builder.addLong(datetime, System.nanoTime());
 
		builder.addString(currentContext, dataFlowParameterInfo.getCurrentMappingContext());
		builder.addString(cataloguePath, rootPath);
		builder.addString(catalogueFilename, parameterPaths);
		builder.addString(sourceFilePathParameterName, "cataloguePath");
		builder.addString(sourceFilenameParameterName, "catalogueFilename");
 
 
		Long mappingSystemId = Long.parseLong(dataFlowParameterInfo.getCurrentMappingContext());
		List<String> inputFilePaths = new ArrayList<String>();
		inputFilePaths.add(parameterPaths);
 
		// catalogueImport:
		startImport(builder.toDataFlowParameters() );
 
	}
 
	private void startImport(DataFlowParameters dataFlowParameters ) { 
		//catalogueValidation
		catalogueValidation(dataFlowParameters);
 
 
		//catalogueImport 
 
		Long mappingSystemId = Long.parseLong(dataFlowParameters.getString(PamdaDataFlowStarter.currentContext));
		List<String> inputFilePaths = new ArrayList<String>();
		inputFilePaths.add(dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename));
		catalogueImporter.importCatalogue(inputFilePaths,mappingSystemId );
 
 
	}
 
	public void catalogueValidation(DataFlowParameters dataFlowParameters) {
		String catalogueFilename = dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename);
		String filePath = dataFlowParameters.getString(PamdaDataFlowStarter.cataloguePath);
 
		List<String> files = FileHelper.splitFilesParameter(filePath, catalogueFilename);
		xmlValidationService.validate( files, pamdaProperty.getCatalogueXSDfile());
 
 
	}
}

et enfin voici la class "mappingImportStarter" qui est elle aussi appellé par la class "pamdaImportDirectStarter" :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
 
package com.orange.pamda.worker.starter;
 
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
 
import javax.inject.Inject;
 
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import com.google.common.collect.Lists;
import com.orange.pamda.config.PamdaServerProperty;
import com.orange.pamda.entity.jpa.MappingContext;
import com.orange.pamda.service.MappingContextService;
import com.orange.pamda.util.DataFlowParameters;
import com.orange.pamda.util.DataFlowParametersBuilder;
import com.orange.pamda.util.DateHelper;
import com.orange.pamda.util.FileFormatter;
import com.orange.pamda.util.FileHelper;
import com.orange.pamda.util.PamdaDataFlowStarter;
import com.orange.pamda.worker.mapping.exporter.MappingExporter;
import com.orange.pamda.worker.mapping.importer.MappingImporter;
import com.orange.pamda.worker.service.XMLValidationService;
import com.orange.pamda.worker.utils.DataFlowParameterInfo;
import com.orange.pamda.worker.utils.WorkerParameterInfo;
 
@Component("mappingImportStarter")
public class MappingImportStarter implements PamdaDataFlowStarter {
 
	@Autowired
	protected MappingImporter mappingImporter;
 
	@Inject
	private XMLValidationService xmlValidationService;
 
	@Inject
	private PamdaServerProperty pamdaProperty;
 
	@Autowired
	private MappingContextService mappingContextService;
 
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public void start(DataFlowParameterInfo dataFlowParameterInfo)
			throws  IOException {
 
 
		long startTime = System.currentTimeMillis();
		String exportDateString = DateHelper.FILE_DATE_TIME_FORMATTER.print(startTime);
 
		MappingContext mappCntxt = mappingContextService
				.findById(Long.valueOf(dataFlowParameterInfo.getCurrentMappingContext()));
 
		String rootPath = pamdaProperty.getMappingExportPath();
 
		File mappingExportResult = FileFormatter.getFormattedFileWithDate(mappCntxt.getCode(),
				pamdaProperty.getMappingFilename(), ".xml", rootPath, exportDateString);
		DataFlowParametersBuilder builder = new DataFlowParametersBuilder();
		builder.addString(mappingPath, rootPath);
		builder.addString(mappingFilename, mappingExportResult.getName());
		builder.addString(targetFilePathParameterName, mappingPath);
		builder.addString(targetFilenameParameterName, mappingFilename);
		builder.addLong(datetime, startTime);
 
		builder.addString(currentContext, dataFlowParameterInfo.getCurrentMappingContext());
		builder.addString(disabledByUser, String.valueOf(dataFlowParameterInfo.isDisabledByUser()));
 
 
		startImport(builder.toDataFlowParameters() );
 
	}
 
	public void startImport(DataFlowParameters dataFlowParameters ) { 
 
		mappingValidation(dataFlowParameters);
 
		List<String> inputFilePaths = new ArrayList<String>();
		inputFilePaths.add(dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename));
		try {
			mappingImporter.importMappingSystem(inputFilePaths, dataFlowParameters.getString(PamdaDataFlowStarter.currentContext));
		} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
 
	}
 
	public void mappingValidation(DataFlowParameters dataFlowParameters) {
		String catalogueFilename = dataFlowParameters.getString(PamdaDataFlowStarter.catalogueFilename);
		String filePath = dataFlowParameters.getString(PamdaDataFlowStarter.cataloguePath);
 
		List<String> files = FileHelper.splitFilesParameter(filePath, catalogueFilename);
		xmlValidationService.validate( files, pamdaProperty.getCatalogueXSDfile());
 
 
	}
 
 
 
}
Quelqu'un peut m'aider s'il vous plait a résoudre ce problème ?