View Javadoc
1   /*
2    * Copyright (c) 2002-2021, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.address.service;
35  
36  import fr.paris.lutece.plugins.address.business.axis.AdresseService;
37  import fr.paris.lutece.plugins.address.business.axis.AdresseServiceLocator;
38  import fr.paris.lutece.plugins.address.business.axis.AdresseServicePortType;
39  import fr.paris.lutece.plugins.address.business.jaxb.Adresse;
40  import fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresses;
41  import fr.paris.lutece.plugins.address.util.LibraryAddressUtils;
42  import fr.paris.lutece.portal.service.util.AppLogService;
43  import fr.paris.lutece.portal.service.util.AppPropertiesService;
44  import fr.paris.lutece.util.ReferenceList;
45  
46  import org.apache.axis.client.Stub;
47  
48  import java.io.StringReader;
49  
50  import java.net.MalformedURLException;
51  import java.net.URL;
52  
53  import java.rmi.RemoteException;
54  
55  import java.util.HashSet;
56  import java.util.List;
57  import java.util.Set;
58  
59  import javax.servlet.http.HttpServletRequest;
60  import javax.servlet.http.HttpSession;
61  
62  import javax.xml.bind.JAXBContext;
63  import javax.xml.bind.JAXBException;
64  import javax.xml.bind.Unmarshaller;
65  import javax.xml.rpc.ServiceException;
66  import javax.xml.transform.stream.StreamSource;
67  
68  import org.apache.commons.lang3.StringUtils;
69  
70  /**
71   *
72   */
73  public class WebServiceAddressService implements IAddressService
74  {
75      // jaxb context
76      private static final String JAXB_CONTEXT_WS_FICHE_ADDRESS = "fr.paris.lutece.plugins.address.business.jaxb.wsFicheAdresse";
77      private static final String JAXB_CONTEXT_WS_SEARCH_ADDRESS = "fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse";
78      private static final String SESSION_LIST_ADDRESS_NAME = "LIBRARY" + "_WSLISTADDRESS";
79  
80      /**
81       * address.geolocation.rsid
82       */
83      private static final String PROPERTY_GEOLOCATION_RSID = "address.geolocation.rsid";
84  
85      /**
86       * Default RSID for geolocalization.
87       */
88      private static final int CONSTANTE_DEFAULT_GEOLOCATION_RSID = 27561;
89      private String _strUrlWS;
90      private String _strDefaultCity;
91      private String _strDateSearch;
92      private String _strUserName;
93      private String _strPassword;
94      private String _strTimeOut;
95  
96      /**
97       * RSID using {@link #PROPERTY_GEOLOCATION_RSID} if found, {@link #CONSTANTE_DEFAULT_GEOLOCATION_RSID} otherwise.
98       * 
99       * @return RSID value
100      */
101     private int getGeolocationRSID( )
102     {
103         return AppPropertiesService.getPropertyInt( PROPERTY_GEOLOCATION_RSID, CONSTANTE_DEFAULT_GEOLOCATION_RSID );
104     }
105 
106     /**
107      * Finds the geolocalsation. Uses {@link #getGeolocationRSID()} as RSID.
108      * 
109      * @throws RemoteException
110      *             the RemoteExecption
111      * @param request
112      *            Request
113      * @param bIsTest
114      *            if true test connect at web service, if false search an adress
115      * @return the XML flux of an adress
116      *
117      */
118     public Adresse getGeolocalisation( HttpServletRequest request, String addresse, String date, boolean bIsTest ) throws RemoteException
119     {
120         return getGeolocalisation( request, getGeolocationRSID( ), addresse, date, bIsTest );
121     }
122 
123     /**
124      * @throws RemoteException
125      *             the RemoteExecption
126      * @param request
127      *            Request
128      * @param id
129      *            the rsid
130      * @param bIsTest
131      *            if true test connect at web service, if false search an adress
132      * @return the XML flux of an adress
133      *
134      */
135     public Adresse getGeolocalisation( HttpServletRequest request, long id, String addresse, String date, boolean bIsTest ) throws RemoteException
136     {
137         String responseWebService = null;
138         AdresseService adresseService = new AdresseServiceLocator( );
139 
140         try
141         {
142             URL urlWS = null;
143 
144             Stub portType = null;
145 
146             if ( ( getUrlWS( ) == null ) || getUrlWS( ).equals( "" ) )
147             {
148                 portType = (Stub) adresseService.getAdresseServiceHttpPort( );
149             }
150             else
151             {
152                 try
153                 {
154                     urlWS = new URL( getUrlWS( ) );
155                 }
156                 catch( MalformedURLException e )
157                 {
158                     AppLogService.error( e.getMessage( ), e );
159                 }
160 
161                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
162             }
163 
164             portType.setUsername( getUserName( ) );
165             portType.setPassword( getPassword( ) );
166 
167             setTimeout( portType );
168 
169             responseWebService = ( (AdresseServicePortType) portType ).geolocalization( getDefaultCity( ), addresse, String.valueOf( id ), date );
170         }
171         catch( ServiceException e )
172         {
173             AppLogService.error( e.getMessage( ), e );
174         }
175 
176         Adresse adresseReturn = new Adresse( );
177 
178         LibraryAddressUtils.fillAddressGeolocation( adresseReturn, responseWebService );
179 
180         cleanListWSAdresses( request, SESSION_LIST_ADDRESS_NAME );
181 
182         return adresseReturn;
183     }
184 
185     /**
186      * @throws RemoteException
187      *             the RemoteExecption
188      * @param request
189      *            Request
190      * @param id
191      *            the adress id
192      * @param bIsTest
193      *            if true test connect at web service, if false search an adress
194      * @return the XML flux of an adress
195      *
196      */
197     public Adresse getAdresseInfo( HttpServletRequest request, long id, boolean bIsTest ) throws RemoteException
198     {
199         String responseWebService = null;
200         AdresseService adresseService = new AdresseServiceLocator( );
201 
202         try
203         {
204             URL urlWS = null;
205 
206             Stub portType = null;
207 
208             if ( ( getUrlWS( ) == null ) || getUrlWS( ).equals( "" ) )
209             {
210                 portType = (Stub) adresseService.getAdresseServiceHttpPort( );
211             }
212             else
213             {
214                 try
215                 {
216                     urlWS = new URL( getUrlWS( ) );
217                 }
218                 catch( MalformedURLException e )
219                 {
220                     AppLogService.error( e.getMessage( ), e );
221                 }
222 
223                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
224             }
225 
226             portType.setUsername( getUserName( ) );
227             portType.setPassword( getPassword( ) );
228 
229             setTimeout( portType );
230 
231             responseWebService = ( (AdresseServicePortType) portType ).getAdresseInfo( getDefaultCity( ), id );
232         }
233         catch( ServiceException e )
234         {
235             AppLogService.error( e.getMessage( ), e );
236         }
237 
238         // traitement du flux xml
239         fr.paris.lutece.plugins.address.business.jaxb.wsFicheAdresse.Adresse adresse = null;
240 
241         JAXBContext jc;
242 
243         try
244         {
245             jc = JAXBContext.newInstance( JAXB_CONTEXT_WS_FICHE_ADDRESS );
246 
247             Unmarshaller u = jc.createUnmarshaller( );
248             StringBuffer xmlStr = new StringBuffer( responseWebService );
249             adresse = (fr.paris.lutece.plugins.address.business.jaxb.wsFicheAdresse.Adresse) u
250                     .unmarshal( new StreamSource( new StringReader( xmlStr.toString( ) ) ) );
251         }
252         catch( JAXBException e )
253         {
254             AppLogService.error( e.getMessage( ), e );
255         }
256 
257         Adresse adresseReturn = new Adresse( );
258 
259         adresseReturn.setIadresse( adresse.getIdentifiant( ) );
260         adresseReturn.setDunumero( adresse.getNumero( ) );
261         adresseReturn.setDubis( adresse.getSuffixe1( ) );
262         adresseReturn.setCodeCommune( adresse.getCodeInsee( ).toString( ) );
263         adresseReturn.setVille( adresse.getCommune( ) );
264 
265         // FIXME : use this when SRID can be passed to getAdressInfo
266         // String strGeometry = adresse.getGeometry( );
267         //
268         // LibraryAddressUtils.fillAddressGeolocation( adresseReturn, strGeometry );
269         if ( !bIsTest )
270         {
271             List<fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse> listAddress = getListWSAdresses( request ).getAdresse( );
272 
273             for ( fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse currentAdresse : listAddress )
274             {
275                 if ( String.valueOf( currentAdresse.getIdentifiant( ) ).equals( String.valueOf( id ) ) )
276                 {
277                     adresseReturn.setTypeVoie( currentAdresse.getTypeVoie( ) );
278                     adresseReturn.setLibelleVoie( currentAdresse.getNomVoie( ) );
279 
280                     // FIXME : see on top
281                     LibraryAddressUtils.fillAddressGeolocation( adresseReturn, currentAdresse.getGeometry( ) );
282 
283                     break;
284                 }
285             }
286         }
287 
288         cleanListWSAdresses( request, SESSION_LIST_ADDRESS_NAME );
289 
290         return adresseReturn;
291     }
292 
293     /**
294      * @throws RemoteException
295      *             the RemoteExecption
296      * @param request
297      *            Request
298      * @param labeladresse
299      *            the label adress
300      * @return the XML flux of all adress corresponding
301      *
302      */
303     public ReferenceList searchAddress( HttpServletRequest request, String labeladresse ) throws RemoteException
304     {
305         String responseWebService = null;
306         AdresseService adresseService = new AdresseServiceLocator( );
307 
308         try
309         {
310             URL urlWS = null;
311 
312             Stub portType = null;
313 
314             if ( ( getUrlWS( ) == null ) || getUrlWS( ).equals( "" ) )
315             {
316                 portType = (Stub) adresseService.getAdresseServiceHttpPort( );
317             }
318             else
319             {
320                 try
321                 {
322                     urlWS = new URL( getUrlWS( ) );
323                 }
324                 catch( MalformedURLException e )
325                 {
326                     AppLogService.error( e.getMessage( ), e );
327                 }
328 
329                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
330             }
331 
332             portType.setUsername( getUserName( ) );
333             portType.setPassword( getPassword( ) );
334 
335             setTimeout( portType );
336 
337             responseWebService = ( (AdresseServicePortType) portType ).searchAddress( getDefaultCity( ), labeladresse, null, getDateSearch( ) );
338 
339             // check null result and then return null list
340             if ( responseWebService == null )
341             {
342                 return null;
343             }
344         }
345         catch( ServiceException e )
346         {
347             AppLogService.error( e.getMessage( ), e );
348         }
349 
350         // traitement du flux xml
351         Adresses adresses = null;
352 
353         JAXBContext jc;
354 
355         try
356         {
357             jc = JAXBContext.newInstance( JAXB_CONTEXT_WS_SEARCH_ADDRESS );
358 
359             Unmarshaller u = jc.createUnmarshaller( );
360             StringBuffer xmlStr = new StringBuffer( responseWebService );
361             adresses = (Adresses) u.unmarshal( new StreamSource( new StringReader( xmlStr.toString( ) ) ) );
362         }
363         catch( JAXBException e )
364         {
365             AppLogService.error( e.getMessage( ), e );
366         }
367 
368         List<fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse> listAdresses = adresses.getAdresse( );
369 
370         ReferenceList refList = null;
371 
372         // Added for filter the double adresse
373         Set<AdresseElement> eltSet = null;
374 
375         // build the list choice
376         if ( ( listAdresses != null ) && !listAdresses.isEmpty( ) )
377         {
378             refList = new ReferenceList( );
379 
380             // Added for filter the double adresse
381             eltSet = new HashSet<AdresseElement>( );
382 
383             for ( fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse currentAdresse : listAdresses )
384             {
385                 String suffixe = "";
386 
387                 if ( currentAdresse.getSuffixe( ) != null )
388                 {
389                     suffixe = currentAdresse.getSuffixe( );
390                 }
391 
392                 String strCurrentAdresse = "";
393 
394                 if ( currentAdresse.getTypeVoie( ) == null )
395                 {
396                     strCurrentAdresse = currentAdresse.getNumero( ) + " " + suffixe + " " + currentAdresse.getNomVoie( ) + " " + currentAdresse.getCommune( );
397                 }
398                 else
399                     if ( LibraryAddressUtils.isTerminateByApostrophe( currentAdresse.getTypeVoie( ) ) )
400                     {
401                         strCurrentAdresse = currentAdresse.getNumero( ) + " " + suffixe + " " + currentAdresse.getTypeVoie( ) + currentAdresse.getNomVoie( )
402                                 + " " + currentAdresse.getCommune( );
403                     }
404                     else
405                     {
406                         strCurrentAdresse = currentAdresse.getNumero( ) + " " + suffixe + " " + currentAdresse.getTypeVoie( ) + " "
407                                 + currentAdresse.getNomVoie( ) + " " + currentAdresse.getCommune( );
408                     }
409 
410                 String strIdAdresse = currentAdresse.getIdentifiant( ).toString( );
411 
412                 // Added for filter the double adresse
413                 boolean isAdded = eltSet.add( new AdresseElement( strIdAdresse, strCurrentAdresse ) );
414 
415                 if ( isAdded )
416                 {
417                     refList.addItem( strIdAdresse, strCurrentAdresse );
418                 }
419             }
420 
421             setListWSAdresses( request, adresses );
422         }
423 
424         return refList;
425     }
426 
427     /**
428      * @throws RemoteException
429      *             the RemoteExecption
430      * @param request
431      *            Request
432      * @param labeladresse
433      *            the label adress
434      * @param strArrondissement
435      *            Arrondissement
436      * @return the XML flux of all adress corresponding
437      * @see <a href="http://dev.lutece.paris.fr/jira/browse/ADDRESS-8">ADDRESS-8</a>
438      *
439      */
440     public ReferenceList searchAddress( HttpServletRequest request, String labeladresse, String strArrondissement ) throws RemoteException
441     {
442         return searchAddress( request, labeladresse, Integer.toString( getGeolocationRSID( ) ), strArrondissement );
443     }
444 
445     /**
446      * @throws RemoteException
447      *             the RemoteExecption
448      * @param strSRID
449      *            the srsid
450      * @param request
451      *            Request
452      * @param labeladresse
453      *            the label adress
454      * @param strArrondissement
455      *            Arrondissement
456      * @return the XML flux of all adress corresponding
457      * @see <a href="http://dev.lutece.paris.fr/jira/browse/ADDRESS-8">ADDRESS-8</a>
458      */
459     public ReferenceList searchAddress( HttpServletRequest request, String labeladresse, String strSRID, String strArrondissement ) throws RemoteException
460     {
461         String responseWebService = null;
462         AdresseService adresseService = new AdresseServiceLocator( );
463 
464         try
465         {
466             URL urlWS = null;
467 
468             Stub portType = null;
469 
470             if ( ( getUrlWS( ) == null ) || getUrlWS( ).equals( "" ) )
471             {
472                 portType = (Stub) adresseService.getAdresseServiceHttpPort( );
473             }
474             else
475             {
476                 try
477                 {
478                     urlWS = new URL( getUrlWS( ) );
479                 }
480                 catch( MalformedURLException e )
481                 {
482                     AppLogService.error( e.getMessage( ), e );
483                 }
484 
485                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
486             }
487 
488             portType.setUsername( getUserName( ) );
489             portType.setPassword( getPassword( ) );
490 
491             setTimeout( portType );
492 
493             responseWebService = ( (AdresseServicePortType) portType ).searchAddress( getDefaultCity( ), labeladresse, strSRID, getDateSearch( ) );
494 
495             // check null result and then return null list
496             if ( responseWebService == null )
497             {
498                 return null;
499             }
500         }
501         catch( ServiceException e )
502         {
503             AppLogService.error( e.getMessage( ), e );
504         }
505 
506         // traitement du flux xml
507         Adresses adresses = null;
508 
509         JAXBContext jc;
510 
511         try
512         {
513             jc = JAXBContext.newInstance( JAXB_CONTEXT_WS_SEARCH_ADDRESS );
514 
515             Unmarshaller u = jc.createUnmarshaller( );
516             StringBuffer xmlStr = new StringBuffer( responseWebService );
517             adresses = (Adresses) u.unmarshal( new StreamSource( new StringReader( xmlStr.toString( ) ) ) );
518         }
519         catch( JAXBException e )
520         {
521             AppLogService.error( e.getMessage( ), e );
522         }
523 
524         List<fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse> listAdresses = adresses.getAdresse( );
525 
526         ReferenceList refList = null;
527 
528         // Added for filter the double adresse
529         Set<AdresseElement> eltSet = null;
530 
531         // build the list choice
532         if ( ( listAdresses != null ) && !listAdresses.isEmpty( ) )
533         {
534             refList = new ReferenceList( );
535 
536             // Added for filter the double adresse
537             eltSet = new HashSet<AdresseElement>( );
538 
539             for ( fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse currentAdresse : listAdresses )
540             {
541                 String suffixe = "";
542 
543                 if ( currentAdresse.getSuffixe( ) != null )
544                 {
545                     suffixe = currentAdresse.getSuffixe( );
546                 }
547 
548                 String strCurrentAdresse = "";
549 
550                 if ( currentAdresse.getTypeVoie( ) == null )
551                 {
552                     strCurrentAdresse = currentAdresse.getNumero( ) + " " + suffixe + " " + currentAdresse.getNomVoie( ) + " " + currentAdresse.getCommune( );
553                 }
554                 else
555                     if ( LibraryAddressUtils.isTerminateByApostrophe( currentAdresse.getTypeVoie( ) ) )
556                     {
557                         strCurrentAdresse = currentAdresse.getNumero( ) + " " + suffixe + " " + currentAdresse.getTypeVoie( ) + currentAdresse.getNomVoie( )
558                                 + " " + currentAdresse.getCommune( );
559                     }
560                     else
561                     {
562                         strCurrentAdresse = currentAdresse.getNumero( ) + " " + suffixe + " " + currentAdresse.getTypeVoie( ) + " "
563                                 + currentAdresse.getNomVoie( ) + " " + currentAdresse.getCommune( );
564                     }
565 
566                 String strIdAdresse = currentAdresse.getIdentifiant( ).toString( );
567 
568                 String arr = currentAdresse.getCommune( );
569                 int index = arr.indexOf( "E" );
570                 if ( index > 2 )
571                 {
572                     arr = arr.substring( index - 2, index );
573                     index = arr.indexOf( "-" );
574 
575                     if ( index != -1 )
576                     {
577                         arr = arr.substring( 1, 2 );
578                     }
579                 }
580                 else
581                 {
582                     arr = StringUtils.EMPTY;
583                 }
584 
585                 // Added for filter the double adresse
586                 boolean isAdded = eltSet.add( new AdresseElement( strIdAdresse, strCurrentAdresse ) );
587 
588                 if ( isAdded )
589                 {
590                     if ( arr.equals( strArrondissement ) )
591                     {
592                         refList.addItem( strIdAdresse, strCurrentAdresse );
593                     }
594                 }
595             }
596 
597             setListWSAdresses( request, adresses );
598         }
599 
600         return refList;
601     }
602 
603     /**
604      *
605      * @return the date for parameter methodes of web service
606      */
607     public String getDateSearch( )
608     {
609         return _strDateSearch;
610     }
611 
612     /**
613      *
614      * @param strDateSearch
615      *            the new date search
616      */
617     public void setDateSearch( String strDateSearch )
618     {
619         _strDateSearch = strDateSearch;
620     }
621 
622     /**
623      *
624      * @return the default city for parameter methodes of web service
625      */
626     public String getDefaultCity( )
627     {
628         return _strDefaultCity;
629     }
630 
631     /**
632      *
633      * @param strDefaultCity
634      *            the new default city
635      */
636     public void setDefaultCity( String strDefaultCity )
637     {
638         _strDefaultCity = strDefaultCity;
639     }
640 
641     /**
642      *
643      * @return the url of the web service
644      */
645     public String getUrlWS( )
646     {
647         return _strUrlWS;
648     }
649 
650     /**
651      *
652      * @param strUrlWS
653      *            the new web service url
654      */
655     public void setUrlWS( String strUrlWS )
656     {
657         _strUrlWS = strUrlWS;
658     }
659 
660     /**
661      *
662      * @return the password
663      */
664     public String getPassword( )
665     {
666         return _strPassword;
667     }
668 
669     /**
670      *
671      * @param password
672      *            the password
673      */
674     public void setPassword( String password )
675     {
676         _strPassword = password;
677     }
678 
679     /**
680      *
681      * @return the user name
682      */
683     public String getUserName( )
684     {
685         return _strUserName;
686     }
687 
688     /**
689      *
690      * @param userName
691      *            the user name
692      */
693     public void setUserName( String userName )
694     {
695         _strUserName = userName;
696     }
697 
698     /**
699      *
700      * @return the timeout
701      */
702     public String getTimeOut( )
703     {
704         return _strTimeOut;
705     }
706 
707     /**
708      *
709      * @param timeOut
710      *            the timeout
711      */
712     public void setTimeOut( String timeOut )
713     {
714         _strTimeOut = timeOut;
715     }
716 
717     /**
718      * Sets the timeout to the stub
719      * 
720      * @param portType
721      */
722     private void setTimeout( Stub portType )
723     {
724         try
725         {
726             portType.setTimeout( Integer.parseInt( getTimeOut( ) ) );
727         }
728         catch( NumberFormatException e )
729         {
730             AppLogService.error(
731                     "WebServiceAddressService : timeOut is not set correctly for WebServiceAddressService. Please check address_context.xml. Will use no timeout" );
732         }
733     }
734 
735     /**
736      *
737      * @param request
738      *            Resquest
739      * @return adresses
740      */
741     private Adresses getListWSAdresses( HttpServletRequest request )
742     {
743         HttpSession session = request.getSession( true );
744         String strSessionAttribute = SESSION_LIST_ADDRESS_NAME;
745         strSessionAttribute = strSessionAttribute.toUpperCase( );
746 
747         return (Adresses) session.getAttribute( strSessionAttribute );
748     }
749 
750     /**
751      *
752      * @param request
753      *            Request
754      * @param adresses
755      *            Adresses
756      */
757     private void setListWSAdresses( HttpServletRequest request, Adresses adresses )
758     {
759         HttpSession session = request.getSession( true );
760         String strSessionAttribute = SESSION_LIST_ADDRESS_NAME;
761         strSessionAttribute = strSessionAttribute.toUpperCase( );
762         session.setAttribute( strSessionAttribute, adresses );
763     }
764 
765     /**
766      *
767      * @param request
768      *            Request
769      * @param strAttributeName
770      *            Name attribute
771      */
772     private void cleanListWSAdresses( HttpServletRequest request, String strAttributeName )
773     {
774         HttpSession session = request.getSession( true );
775         String strSessionAttribute = strAttributeName;
776         strSessionAttribute = strSessionAttribute.toUpperCase( );
777         session.removeAttribute( strSessionAttribute );
778     }
779 
780     /**
781      * Added for filter the double adresse An adresse element for eliminate element already present
782      */
783     private class AdresseElement
784     {
785         private String _idAdresse;
786         private String _labelAdresse;
787 
788         /**
789          * Instance a new AdresseElement
790          *
791          * @param strIdAdresse
792          *            the adresse id
793          * @param strLabelAdresse
794          *            the adresse label
795          */
796         public AdresseElement( String strIdAdresse, String strLabelAdresse )
797         {
798             _idAdresse = strIdAdresse;
799             _labelAdresse = strLabelAdresse;
800         }
801 
802         /**
803          * Get The label adresse
804          * 
805          * @return the _labelAdresse
806          */
807         public String getLabelAdresse( )
808         {
809             return _labelAdresse;
810         }
811 
812         /**
813          * Get The label adresse
814          * 
815          * @return the _idAdresse
816          */
817         public String getIdAdresse( )
818         {
819             return _idAdresse;
820         }
821 
822         /**
823          * Get The hashcode for labelAdresse
824          * 
825          * @return the _idAdresse
826          */
827         public int hashCode( )
828         {
829             return _labelAdresse.hashCode( );
830         }
831 
832         /**
833          * @param o
834          *            Object
835          * @return boolean
836          */
837         public boolean equals( Object o )
838         {
839             AdresseElement adresseToCompare = (AdresseElement) o;
840 
841             return this._labelAdresse.equals( adresseToCompare.getLabelAdresse( ) );
842         }
843     }
844 }