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 package fr.paris.lutece.plugins.ctv.handler;
35
36 import java.util.Date;
37 import java.util.List;
38 import java.util.Map;
39 import java.util.concurrent.ConcurrentHashMap;
40
41 import javax.servlet.http.HttpSession;
42
43 import org.apache.commons.fileupload.FileItem;
44 import org.springframework.stereotype.Component;
45
46 import fr.paris.lutece.plugins.ctv.bo.Emprise;
47 import fr.paris.lutece.plugins.ctv.business.IEmpriseService;
48 import fr.paris.lutece.plugins.ctv.constants.CtvConstants;
49 import fr.paris.lutece.portal.service.spring.SpringContextService;
50
51 @Component
52 public class CtvUploadEmpriseDocumentHandler extends AbstractCtvUploadHandler
53 {
54
55 private static Map<String, Map<String, List<FileItem>>> _mapAsynchronousUpload = new ConcurrentHashMap<>( );
56
57 public static final String CTV_EMPRISE_UPLOAD_HANDLER = "ctvEmpriseUploadHandler";
58
59 public String getUploadDirectory( )
60 {
61 return uploadDirectory + "/emprises";
62 }
63
64 @Override
65 public String getHandlerName( )
66 {
67 return CTV_EMPRISE_UPLOAD_HANDLER;
68 }
69
70 @Override
71 Map<String, Map<String, List<FileItem>>> getMapAsynchronousUpload( )
72 {
73 return _mapAsynchronousUpload;
74 }
75
76 @Override
77 public String getFileIdNameInSession( )
78 {
79 return CtvConstants.EMPRISE_ID;
80 }
81
82 @Override
83 public Date getDateCreationDossier( HttpSession session )
84 {
85 Date dateCreation = null;
86 String idInSession = getIdInSession( session );
87 if ( idInSession != null )
88 {
89 int numEmprise = Integer.parseInt( idInSession );
90 IEmpriseService empriseService = SpringContextService.getBean( "empriseService" );
91 Emprise emprise = empriseService.findEmpriseById( numEmprise );
92 if ( emprise != null )
93 {
94 dateCreation = emprise.getEmpriseDateCreation( );
95 }
96 }
97 return dateCreation;
98 }
99
100 }