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.formengine.web;
35
36 import java.io.StringWriter;
37 import java.net.URL;
38 import java.sql.Date;
39 import java.sql.Time;
40 import java.util.ArrayList;
41 import java.util.Collection;
42 import java.util.Collections;
43 import java.util.Enumeration;
44 import java.util.HashMap;
45 import java.util.List;
46 import java.util.Locale;
47 import java.util.Map;
48
49 import javax.servlet.http.HttpServletRequest;
50 import javax.servlet.http.HttpSession;
51 import javax.xml.bind.JAXBContext;
52 import javax.xml.bind.JAXBException;
53 import javax.xml.bind.Marshaller;
54 import javax.xml.bind.Validator;
55 import javax.xml.validation.Schema;
56 import javax.xml.validation.SchemaFactory;
57
58 import org.apache.commons.fileupload.FileItem;
59 import org.xml.sax.SAXException;
60
61 import fr.paris.lutece.plugins.formengine.business.jaxb.formdefinition.Output;
62 import fr.paris.lutece.plugins.formengine.business.jaxb.formdefinition.OutputSet;
63 import fr.paris.lutece.plugins.formengine.business.jaxb.formdefinition.Outputs;
64 import fr.paris.lutece.plugins.formengine.business.jaxb.transaction.ObjectFactory;
65 import fr.paris.lutece.plugins.formengine.business.jaxb.transaction.SenderInfo;
66 import fr.paris.lutece.plugins.formengine.business.jaxb.transaction.ServerInfo;
67 import fr.paris.lutece.plugins.formengine.business.jaxb.transaction.Transaction;
68 import fr.paris.lutece.plugins.formengine.business.jaxb.transaction.TransactionData;
69 import fr.paris.lutece.plugins.formengine.business.jaxb.transaction.TransactionInfo;
70 import fr.paris.lutece.plugins.formengine.service.draft.DraftBackupService;
71 import fr.paris.lutece.plugins.formengine.service.output.GeneratorFactory;
72 import fr.paris.lutece.plugins.formengine.service.output.IdGenerator;
73 import fr.paris.lutece.plugins.formengine.service.output.OutputFactory;
74 import fr.paris.lutece.plugins.formengine.service.output.OutputProcessor;
75 import fr.paris.lutece.plugins.formengine.service.output.TransactionFileIdGenerator;
76 import fr.paris.lutece.plugins.formengine.service.parameter.FormEngineParameterService;
77 import fr.paris.lutece.plugins.formengine.util.JSONUtils;
78 import fr.paris.lutece.portal.service.message.SiteMessageException;
79 import fr.paris.lutece.portal.service.security.UserNotSignedException;
80 import fr.paris.lutece.portal.service.util.AppException;
81 import fr.paris.lutece.portal.service.util.AppLogService;
82 import fr.paris.lutece.portal.service.util.AppPropertiesService;
83 import fr.paris.lutece.util.ReferenceItem;
84 import fr.paris.lutece.util.date.DateUtil;
85
86
87
88
89
90 public abstract class Form
91 {
92 public static final String RESOURCE_TYPE = "FORMENGINE";
93 private static final String SESSION_ATTRIBUTE_FORM_DOCUMENT = "FORM_DOCUMENT";
94 private static final String SESSION_ATTRIBUTE_TRANSACTION_ID = "TRANSACTION_ID";
95 private static final String SESSION_ATTRIBUTE_FORM_ERRORS = "ERRORS";
96 private static final String SESSION_ATTRIBUTE_BLOCK_PROCESSING = "BLOCK_PROCESS";
97 private static final String PROPERTY_FORMDEFINITION_PACKAGE_NAME = "formengine.jaxb.packagename.formdefinition";
98 private static final String PROPERTY_TRANSACTION_PACKAGE_NAME = "formengine.jaxb.packagename.transaction";
99 private static final String SEPARATOR_PACKAGE = ":";
100 private static final String PARAMETER_DATE_BEGIN = "_date_begin";
101 private static final String PARAMETER_DATE_END = "_date_end";
102
103
104
105
106
107
108
109
110
111
112
113 private static final String W3C_XML_SCHEMA_NS_URI = "http://www.w3.org/2001/XMLSchema";
114 private String _strTitle;
115 private String _strName;
116 private SubForm _subformFirst;
117 private Map<String, SubForm> _subForms;
118
119
120 private Map<String, Map<String, Map<String, List<FileItem>>>> _mapAsynchronousUploads = new HashMap<String, Map<String, Map<String, List<FileItem>>>>( );
121 private Outputs _outputs;
122 private JAXBContext _jaxbSpecificContext;
123 private JAXBContext _jaxbContextFormElements;
124 private Schema _javaxXsdSchema;
125 private DraftBackupService _draftBackupService;
126
127
128
129
130
131 public Form( String strFormName )
132 {
133 this.setName( strFormName );
134
135 try
136 {
137 String strTransactionPackageName = AppPropertiesService.getProperty( PROPERTY_TRANSACTION_PACKAGE_NAME );
138 String strContext = this.getGeneratedPackageName( ) + SEPARATOR_PACKAGE + strTransactionPackageName;
139
140 _jaxbSpecificContext = JAXBContext.newInstance( strContext );
141
142
143 String strFormElementsPackageName = AppPropertiesService.getProperty( PROPERTY_FORMDEFINITION_PACKAGE_NAME );
144 _jaxbContextFormElements = JAXBContext.newInstance( strFormElementsPackageName );
145 }
146 catch ( JAXBException ex )
147 {
148 throw new AppException( "Formengine : an error occurred while instancing the form : " + strFormName, ex );
149 }
150
151 _subForms = new HashMap( );
152 }
153
154
155
156
157
158 public void setXSDSchema( String strSchemaPath )
159 {
160 if ( strSchemaPath != null )
161 {
162 try
163 {
164
165
166
167 SchemaFactory sf = SchemaFactory.newInstance( W3C_XML_SCHEMA_NS_URI );
168
169 URL xsdUrl = this.getClass( ).getClassLoader( ).getResource( strSchemaPath );
170 _javaxXsdSchema = sf.newSchema( xsdUrl );
171 }
172 catch ( SAXException ex )
173 {
174 AppLogService.info( "Schema not loaded : '" + strSchemaPath + "', cause :" + ex.getLocalizedMessage( ) );
175 }
176 }
177 }
178
179
180
181
182
183
184
185
186
187 public abstract String getXslDirectoryPath( );
188
189
190
191
192
193
194
195
196 protected abstract String getGeneratedPackageName( );
197
198
199
200
201
202 public abstract String getTransactionCode( );
203
204
205
206
207
208 public abstract String getInstanceName( );
209
210
211
212
213
214 public abstract String getTransactionName( );
215
216
217
218
219
220
221
222 public String getName( )
223 {
224 return _strName;
225 }
226
227
228
229
230
231 public final void setName( String strName )
232 {
233 _strName = strName;
234 }
235
236
237
238
239
240 public String getTitle( )
241 {
242 return _strTitle;
243 }
244
245
246
247
248
249 public void setTitle( String strTitle )
250 {
251 _strTitle = strTitle;
252 }
253
254
255
256
257
258 public Outputs getOutputs( )
259 {
260 return _outputs;
261 }
262
263
264
265
266
267 public void setOutputs( Outputs outputs )
268 {
269 _outputs = outputs;
270 }
271
272
273
274
275
276
277 public String getTransactionId( HttpServletRequest request )
278 {
279 return (String) this.getSessionAttribute( request, SESSION_ATTRIBUTE_TRANSACTION_ID );
280 }
281
282
283
284
285
286
287 public void setTransactionId( HttpServletRequest request, String strTransactionId )
288 {
289 setSessionAttribute( request, SESSION_ATTRIBUTE_TRANSACTION_ID, strTransactionId );
290 }
291
292
293
294
295
296
297 public SubForm getSubForm( String strName )
298 {
299 return (SubForm) _subForms.get( strName );
300 }
301
302
303
304
305
306 public Map getSubForm( )
307 {
308 return _subForms;
309 }
310
311
312
313
314
315
316 public void addSubForm( String strName, SubForm subForm )
317 {
318 _subForms.put( strName, subForm );
319 }
320
321
322
323
324
325
326
327 public void setFirstSubForm( SubForm subform )
328 {
329 _subformFirst = subform;
330 }
331
332
333
334
335
336
337
338 public SubForm getFirstSubForm( )
339 {
340 return _subformFirst;
341 }
342
343
344
345
346
347
348
349
350 public String getXml( Object object )
351 {
352 String strXml = "";
353
354 if ( object == null )
355 {
356 return strXml;
357 }
358
359 try
360 {
361 StringWriter writer = new StringWriter( );
362 Marshaller marshaller = _jaxbSpecificContext.createMarshaller( );
363 marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
364 marshaller.marshal( object, writer );
365 strXml = writer.toString( );
366 }
367 catch ( JAXBException e )
368 {
369 throw new AppException( "Formengine : an error occurred during marshalling for the form : "
370 + this.getName( ), e );
371 }
372
373 return strXml;
374 }
375
376
377
378
379
380
381 public Object getFormDocument( HttpServletRequest request )
382 {
383
384 Object object = this.getSessionAttribute( request, SESSION_ATTRIBUTE_FORM_DOCUMENT );
385
386 if ( object == null )
387 {
388 AppLogService.info( "FORMENGINE : FormDocument retrieved is null" );
389 }
390
391 return object;
392 }
393
394
395
396
397
398
399
400
401 public void setIsAccessToSubFormAllowed( HttpServletRequest request, String strSubFormName,
402 boolean bIsSubFormAllowed )
403 {
404 SubForm subform = this.getSubForm( strSubFormName );
405
406 if ( subform != null )
407 {
408 subform.setIsSubFormAllowed( request, bIsSubFormAllowed );
409 }
410 }
411
412
413
414
415
416
417
418
419
420 public boolean checkIsAccessToSubFormAllowed( HttpServletRequest request, String strSubFormName )
421 throws UserNotSignedException
422 {
423 SubForm subform = this.getSubForm( strSubFormName );
424 boolean bAllowed = false;
425
426 while ( ( subform != null ) )
427 {
428 bAllowed = subform.getIsSubFormAllowed( request );
429
430 if ( !bAllowed )
431 {
432 break;
433 }
434
435 subform = subform.getPreviousSubForm( );
436 }
437
438 return bAllowed;
439 }
440
441
442
443
444
445
446 public void setFormDocument( HttpServletRequest request, Object object )
447 {
448
449 this.setSessionAttribute( request, SESSION_ATTRIBUTE_FORM_DOCUMENT, object );
450 }
451
452
453
454
455
456
457
458
459 public String getXmlFormDocument( HttpServletRequest request )
460 {
461 return getXml( getFormDocument( request ) );
462 }
463
464
465
466
467
468
469
470 public Validator getXmlValidator( ) throws JAXBException
471 {
472 return _jaxbSpecificContext.createValidator( );
473 }
474
475
476
477
478
479
480
481 public Marshaller getXmlMarshaller( ) throws JAXBException
482 {
483 Marshaller marshaller = _jaxbSpecificContext.createMarshaller( );
484
485 if ( _javaxXsdSchema != null )
486 {
487
488 marshaller.setSchema( _javaxXsdSchema );
489 }
490
491 return marshaller;
492 }
493
494
495
496
497
498
499
500 public void processForm( HttpServletRequest request )
501 {
502
503 Boolean bForbidden = (Boolean) this.getSessionAttribute( request, SESSION_ATTRIBUTE_BLOCK_PROCESSING );
504
505
506
507
508
509 if ( ( bForbidden == null ) && ( this.getFormDocument( request ) == null ) )
510 {
511 bForbidden = Boolean.TRUE;
512 }
513
514 if ( ( bForbidden == null ) || ( !bForbidden.booleanValue( ) ) )
515 {
516 Outputs outputs = this.getOutputs( );
517
518 for ( OutputSet outputSet : outputs.getOutputSet( ) )
519 {
520 boolean bUseHeader = outputSet.isUseTransactionHeaders( );
521
522 Object transactionObject;
523
524
525 if ( bUseHeader )
526 {
527 IdGenerator idGenerator;
528
529
530 String strSpecificTransactionIdGenerator = outputSet.getSpecificTransactionIdGeneratorClassName( );
531
532 if ( ( strSpecificTransactionIdGenerator != null )
533 && ( !strSpecificTransactionIdGenerator.trim( ).equals( "" ) ) )
534 {
535 idGenerator = GeneratorFactory.getGenerator( strSpecificTransactionIdGenerator );
536 }
537 else
538 {
539
540 idGenerator = GeneratorFactory.getGenerator( TransactionFileIdGenerator.class.getName( ) );
541 }
542
543
544 String strNewId = idGenerator.getNewId( this );
545
546
547 this.setTransactionId( request, strNewId );
548
549
550 Transaction transaction = this.initializeTransactionHeaders( request );
551
552
553 transaction.setTransactionId( strNewId );
554
555
556 ObjectFactory factory = new ObjectFactory( );
557 TransactionData data = factory.createTransactionData( );
558 data.setAny( getFormDocument( request ) );
559 transaction.setTransactionData( data );
560 transactionObject = transaction;
561 }
562 else
563
564 {
565 transactionObject = this.getFormDocument( request );
566 }
567
568
569 Collection<Output> colOutputs = outputSet.getOutput( );
570
571 for ( Output output : colOutputs )
572 {
573 String strOutputClassName = output.getOutputProcessorClassName( );
574
575 OutputProcessor ouputProcessor = OutputFactory.getOutput( strOutputClassName );
576 ouputProcessor.process( this, transactionObject );
577 }
578 }
579
580
581 this.setSessionAttribute( request, SESSION_ATTRIBUTE_BLOCK_PROCESSING, Boolean.TRUE );
582 }
583 }
584
585
586
587
588
589
590 Transaction initializeTransactionHeaders( HttpServletRequest request )
591 {
592 ObjectFactory factory = new ObjectFactory( );
593
594 SenderInfo sender = factory.createSenderInfo( );
595 sender.setRemoteAddress( request.getRemoteAddr( ) );
596
597 String strUser = this.getRemoteUser( request );
598
599 if ( strUser != null )
600 {
601 sender.setRemoteUser( strUser );
602 }
603 else
604 {
605 sender.setRemoteUser( "" );
606 }
607
608 ServerInfo server = factory.createServerInfo( );
609 String strInstanceName = this.getInstanceName( );
610 server.setInstanceName( strInstanceName );
611
612 TransactionInfo tInfo = factory.createTransactionInfo( );
613 tInfo.setTransactionCode( this.getTransactionCode( ) );
614 tInfo.setTransactionName( this.getTransactionName( ) );
615
616 Transaction transaction = factory.createTransaction( );
617 transaction.setSenderInfo( sender );
618 transaction.setServerInfo( server );
619 transaction.setTransactionInfo( tInfo );
620
621
622 Date currentSqlDate = new Date( System.currentTimeMillis( ) );
623 Time currentSqlTime = new Time( System.currentTimeMillis( ) );
624 transaction.setTransactionDate( currentSqlDate );
625 transaction.setTransactionTime( currentSqlTime );
626
627 return transaction;
628 }
629
630
631
632
633
634
635
636
637 public String getRemoteUser( HttpServletRequest request )
638 {
639 return request.getRemoteUser( );
640 }
641
642
643
644
645
646
647 public void addError( HttpServletRequest request, String strErrorKey )
648 {
649 this.addError( request, strErrorKey, null );
650 }
651
652
653
654
655
656
657
658
659 public void addError( HttpServletRequest request, String strErrorKey, String strParameter )
660 {
661 FormErrorsList errors = (FormErrorsList) this.getSessionAttribute( request, SESSION_ATTRIBUTE_FORM_ERRORS );
662
663 if ( errors == null )
664 {
665 errors = new FormErrorsList( );
666 }
667
668 errors.addError( strErrorKey, strParameter );
669 setSessionAttribute( request, SESSION_ATTRIBUTE_FORM_ERRORS, errors );
670 }
671
672
673
674
675
676
677
678 public void addErrorMessage( HttpServletRequest request, String strErrorMessage )
679 {
680 FormErrorsList errors = (FormErrorsList) this.getSessionAttribute( request, SESSION_ATTRIBUTE_FORM_ERRORS );
681
682 if ( errors == null )
683 {
684 errors = new FormErrorsList( );
685 }
686
687 errors.addErrorMessage( strErrorMessage );
688 setSessionAttribute( request, SESSION_ATTRIBUTE_FORM_ERRORS, errors );
689 }
690
691
692
693
694
695 public void resetErrors( HttpServletRequest request )
696 {
697 FormErrorsList errors = (FormErrorsList) this.getSessionAttribute( request, SESSION_ATTRIBUTE_FORM_ERRORS );
698
699 if ( errors != null )
700 {
701 errors.clear( );
702 }
703
704 setSessionAttribute( request, SESSION_ATTRIBUTE_FORM_ERRORS, errors );
705 }
706
707
708
709
710
711
712 public String[] getErrors( HttpServletRequest request )
713 {
714 FormErrorsList list = (FormErrorsList) this.getSessionAttribute( request, SESSION_ATTRIBUTE_FORM_ERRORS );
715
716 if ( list == null )
717 {
718 return null;
719 }
720
721 String[] errors = new String[list.size( )];
722
723 for ( int i = 0; i < list.size( ); i++ )
724 {
725 errors[i] = (String) list.get( i );
726 }
727
728 return errors;
729 }
730
731
732
733
734
735
736
737 public Marshaller getFormElementsMarshaller( ) throws JAXBException
738 {
739 return _jaxbContextFormElements.createMarshaller( );
740 }
741
742
743
744
745
746
747
748 public void setSessionAttribute( HttpServletRequest request, String strAttributeName, Object attribute )
749 {
750 HttpSession session = request.getSession( true );
751 String strPrefix = SharedConstants.SESSION_PREFIX + "_" + this.getName( ) + "_";
752 String strSessionAttribute = strPrefix + strAttributeName.trim( );
753 strSessionAttribute = strSessionAttribute.toUpperCase( );
754 session.setAttribute( strSessionAttribute, attribute );
755 }
756
757
758
759
760
761
762
763 public Object getSessionAttribute( HttpServletRequest request, String strAttributeName )
764 {
765 HttpSession session = request.getSession( true );
766 String strPrefix = SharedConstants.SESSION_PREFIX + "_" + this.getName( ) + "_";
767 String strSessionAttribute = strPrefix + strAttributeName.trim( );
768 strSessionAttribute = strSessionAttribute.toUpperCase( );
769
770 return session.getAttribute( strSessionAttribute );
771 }
772
773
774
775
776
777
778 public void removeSessionAttribute( HttpServletRequest request, String strAttributeName )
779 {
780 HttpSession session = request.getSession( true );
781 String strPrefix = SharedConstants.SESSION_PREFIX + "_" + this.getName( ) + "_";
782 String strSessionAttribute = strPrefix + strAttributeName.trim( );
783 strSessionAttribute = strSessionAttribute.toUpperCase( );
784 session.removeAttribute( strSessionAttribute );
785 }
786
787
788
789
790
791
792
793 public void flushSession( HttpServletRequest request )
794 {
795 HttpSession session = request.getSession( true );
796
797 String strPrefix = SharedConstants.SESSION_PREFIX + "_" + this.getName( ) + "_";
798 strPrefix = strPrefix.toUpperCase( );
799
800 Enumeration names = session.getAttributeNames( );
801 Collection<String> luteceNamesCol = new ArrayList<String>( );
802
803 while ( names.hasMoreElements( ) )
804 {
805 String strName = (String) names.nextElement( );
806
807 if ( strName.startsWith( strPrefix ) )
808 {
809 luteceNamesCol.add( strName );
810 }
811 }
812
813 for ( String strName : luteceNamesCol )
814 {
815 session.removeAttribute( strName );
816 }
817 }
818
819
820
821
822
823 public void setDraftBackupService( DraftBackupService service )
824 {
825 _draftBackupService = service;
826 }
827
828
829
830
831
832 public void saveDraft( HttpServletRequest request )
833 {
834 if ( _draftBackupService != null )
835 {
836 _draftBackupService.saveDraft( request, this );
837 }
838 }
839
840
841
842
843
844
845 public void validateDraft( HttpServletRequest request, Form form )
846 {
847 if ( _draftBackupService != null )
848 {
849 _draftBackupService.validateDraft( request, form );
850 }
851 }
852
853
854
855
856
857
858 public byte[] getBlob( HttpServletRequest request )
859 {
860 return JSONUtils.buildJson( this, request ).getBytes( );
861 }
862
863
864
865
866
867
868 public boolean isOpen( Locale locale )
869 {
870 boolean bIsDateBeginCorrect = false;
871 boolean bIsDateEndCorrect = false;
872 ReferenceItem itemDateBegin = FormEngineParameterService.getService( ).getParamDefaultValue(
873 getName( ) + PARAMETER_DATE_BEGIN );
874 ReferenceItem itemDateEnd = FormEngineParameterService.getService( ).getParamDefaultValue(
875 getName( ) + PARAMETER_DATE_END );
876
877 java.util.Date dateBegin = null;
878 java.util.Date dateEnd = null;
879 java.util.Date dateToday = new java.util.Date( );
880
881 if ( itemDateBegin != null )
882 {
883 String strDateBegin = itemDateBegin.getName( );
884 dateBegin = DateUtil.formatDateLongYear( strDateBegin, locale );
885
886 if ( dateBegin != null )
887 {
888 if ( dateBegin.before( dateToday ) )
889 {
890 bIsDateBeginCorrect = true;
891 }
892 }
893 else
894 {
895 bIsDateBeginCorrect = true;
896 }
897 }
898 else
899 {
900 bIsDateBeginCorrect = true;
901 }
902
903 if ( itemDateEnd != null )
904 {
905 String strDateEnd = itemDateEnd.getName( );
906 dateEnd = DateUtil.formatDateLongYear( strDateEnd, locale );
907
908 if ( dateEnd != null )
909 {
910 if ( dateEnd.after( dateToday ) )
911 {
912 bIsDateEndCorrect = true;
913 }
914 }
915 else
916 {
917 bIsDateEndCorrect = true;
918 }
919 }
920 else
921 {
922 bIsDateEndCorrect = true;
923 }
924
925 return bIsDateBeginCorrect && bIsDateEndCorrect;
926 }
927
928
929
930
931
932
933 public boolean isClosed( Locale locale )
934 {
935 return !isOpen( locale );
936 }
937
938
939
940
941
942
943
944
945 boolean preprocessRequest( HttpServletRequest request ) throws SiteMessageException
946 {
947 if ( _draftBackupService != null )
948 {
949 return _draftBackupService.preProcessRequest( request, this );
950 }
951
952 return false;
953 }
954
955
956
957
958
959 public void removeSession( String strSessionId )
960 {
961 for ( Map<String, Map<String, List<FileItem>>> mapAsynchonousUploadsSubForm : _mapAsynchronousUploads.values( ) )
962 {
963
964 Map<String, List<FileItem>> map = mapAsynchonousUploadsSubForm.remove( strSessionId );
965
966 if ( map != null )
967 {
968 for ( List<FileItem> listFiles : map.values( ) )
969 {
970 for ( FileItem fileItem : listFiles )
971 {
972 fileItem.delete( );
973 }
974 }
975 }
976 }
977 }
978
979
980
981
982
983
984
985
986 public final void addFileItem( String strSubForm, String strIdSession, String strFieldName, FileItem fileItem )
987 {
988
989 String strAttributeName = SharedConstants.FILELIST_PREFIX + strFieldName;
990 Map<String, Map<String, List<FileItem>>> mapAsynchronousUploadedFilesSubForm = _mapAsynchronousUploads
991 .get( strSubForm );
992
993 if ( mapAsynchronousUploadedFilesSubForm == null )
994 {
995 mapAsynchronousUploadedFilesSubForm = new HashMap<String, Map<String, List<FileItem>>>( );
996 _mapAsynchronousUploads.put( strSubForm, mapAsynchronousUploadedFilesSubForm );
997 }
998
999 Map<String, List<FileItem>> mapUploadAttributes = mapAsynchronousUploadedFilesSubForm.get( strIdSession );
1000
1001 if ( mapUploadAttributes == null )
1002 {
1003 mapUploadAttributes = new HashMap<String, List<FileItem>>( );
1004 mapAsynchronousUploadedFilesSubForm.put( strIdSession, mapUploadAttributes );
1005 }
1006
1007 List<FileItem> listFiles = mapUploadAttributes.get( strAttributeName );
1008
1009 if ( listFiles == null )
1010 {
1011 listFiles = new ArrayList<FileItem>( );
1012 mapUploadAttributes.put( strAttributeName, listFiles );
1013 }
1014
1015 listFiles.add( fileItem );
1016 }
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026 public List<FileItem> getAsynchronousUploadedFiles( String strSubForm, String strSessionId, String strFieldName )
1027 {
1028 List<FileItem> listFileItems;
1029 String strAttributeName = SharedConstants.FILELIST_PREFIX + strFieldName;
1030 Map<String, Map<String, List<FileItem>>> mapAsynchronousUploadedFilesSubForm = _mapAsynchronousUploads
1031 .get( strSubForm );
1032
1033 if ( mapAsynchronousUploadedFilesSubForm != null )
1034 {
1035 Map<String, List<FileItem>> mapSessionUploadedFiles = mapAsynchronousUploadedFilesSubForm
1036 .get( strSessionId );
1037
1038 if ( mapSessionUploadedFiles != null )
1039 {
1040 listFileItems = mapSessionUploadedFiles.get( strAttributeName );
1041
1042 if ( listFileItems == null )
1043 {
1044 listFileItems = Collections.emptyList( );
1045 }
1046 }
1047 else
1048 {
1049 listFileItems = Collections.emptyList( );
1050 }
1051 }
1052 else
1053 {
1054 listFileItems = Collections.emptyList( );
1055 }
1056
1057 return listFileItems;
1058 }
1059 }