View Javadoc
1   /*
2    * Copyright (c) 2002-2017, Mairie de 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.lang.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       * @return RSID value
99       */
100     private int getGeolocationRSID(  )
101     {
102         return AppPropertiesService.getPropertyInt( PROPERTY_GEOLOCATION_RSID, CONSTANTE_DEFAULT_GEOLOCATION_RSID );
103     }
104 
105     /**
106      * Finds the geolocalsation.
107      * Uses {@link #getGeolocationRSID()} as RSID.
108      * @throws RemoteException the RemoteExecption
109      * @param request Request
110      * @param bIsTest if true test connect at web service, if false search an adress
111      * @return the XML flux of an adress
112      *
113      */
114     public Adresse getGeolocalisation( HttpServletRequest request, String addresse, String date, boolean bIsTest )
115         throws RemoteException
116     {
117         return getGeolocalisation( request, getGeolocationRSID(  ), addresse, date, bIsTest );
118     }
119 
120     /**
121      * @throws RemoteException the RemoteExecption
122      * @param request Request
123      * @param id the rsid
124      * @param bIsTest if true test connect at web service, if false search an adress
125      * @return the XML flux of an adress
126      *
127      */
128     public Adresse getGeolocalisation( HttpServletRequest request, long id, String addresse, String date,
129         boolean bIsTest ) throws RemoteException
130     {
131         String responseWebService = null;
132         AdresseService adresseService = new AdresseServiceLocator(  );
133 
134         try
135         {
136             URL urlWS = null;
137 
138             Stub portType = null;
139 
140             if ( ( getUrlWS(  ) == null ) || getUrlWS(  ).equals( "" ) )
141             {
142                 portType = (Stub) adresseService.getAdresseServiceHttpPort(  );
143             }
144             else
145             {
146                 try
147                 {
148                     urlWS = new URL( getUrlWS(  ) );
149                 }
150                 catch ( MalformedURLException e )
151                 {
152                     AppLogService.error( e.getMessage(  ), e );
153                 }
154 
155                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
156             }
157 
158             portType.setUsername( getUserName(  ) );
159             portType.setPassword( getPassword(  ) );
160 
161             setTimeout( portType );
162 
163             responseWebService = ( (AdresseServicePortType) portType ).geolocalization( getDefaultCity(  ), addresse,
164                     String.valueOf( id ), date );
165         }
166         catch ( ServiceException e )
167         {
168             AppLogService.error( e.getMessage(  ), e );
169         }
170 
171         Adresse adresseReturn = new Adresse(  );
172 
173         LibraryAddressUtils.fillAddressGeolocation( adresseReturn, responseWebService );
174 
175         cleanListWSAdresses( request, SESSION_LIST_ADDRESS_NAME );
176 
177         return adresseReturn;
178     }
179 
180     /**
181     * @throws RemoteException the RemoteExecption
182     * @param request Request
183     * @param id the adress id
184     * @param bIsTest if true test connect at web service, if false search an adress
185     * @return the XML flux of an adress
186     *
187     */
188     public Adresse getAdresseInfo( HttpServletRequest request, long id, boolean bIsTest )
189         throws RemoteException
190     {
191         String responseWebService = null;
192         AdresseService adresseService = new AdresseServiceLocator(  );
193 
194         try
195         {
196             URL urlWS = null;
197 
198             Stub portType = null;
199 
200             if ( ( getUrlWS(  ) == null ) || getUrlWS(  ).equals( "" ) )
201             {
202                 portType = (Stub) adresseService.getAdresseServiceHttpPort(  );
203             }
204             else
205             {
206                 try
207                 {
208                     urlWS = new URL( getUrlWS(  ) );
209                 }
210                 catch ( MalformedURLException e )
211                 {
212                     AppLogService.error( e.getMessage(  ), e );
213                 }
214 
215                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
216             }
217 
218             portType.setUsername( getUserName(  ) );
219             portType.setPassword( getPassword(  ) );
220 
221             setTimeout( portType );
222 
223             responseWebService = ( (AdresseServicePortType) portType ).getAdresseInfo( getDefaultCity(  ), id );
224         }
225         catch ( ServiceException e )
226         {
227             AppLogService.error( e.getMessage(  ), e );
228         }
229 
230         //      traitement du flux xml
231         fr.paris.lutece.plugins.address.business.jaxb.wsFicheAdresse.Adresse adresse = null;
232 
233         JAXBContext jc;
234 
235         try
236         {
237             jc = JAXBContext.newInstance( JAXB_CONTEXT_WS_FICHE_ADDRESS );
238 
239             Unmarshaller u = jc.createUnmarshaller(  );
240             StringBuffer xmlStr = new StringBuffer( responseWebService );
241             adresse = (fr.paris.lutece.plugins.address.business.jaxb.wsFicheAdresse.Adresse) u.unmarshal( new StreamSource( 
242                         new StringReader( xmlStr.toString(  ) ) ) );
243         }
244         catch ( JAXBException e )
245         {
246             AppLogService.error( e.getMessage(  ), e );
247         }
248 
249         Adresse adresseReturn = new Adresse(  );
250 
251         adresseReturn.setIadresse( adresse.getIdentifiant(  ) );
252         adresseReturn.setDunumero( adresse.getNumero(  ) );
253         adresseReturn.setDubis( adresse.getSuffixe1(  ) );
254         adresseReturn.setCodeCommune( adresse.getCodeInsee(  ).toString(  ) );
255         adresseReturn.setVille( adresse.getCommune(  ) );
256 
257         // FIXME : use this when SRID can be passed to getAdressInfo
258         // String strGeometry = adresse.getGeometry(  );
259         // 
260         // LibraryAddressUtils.fillAddressGeolocation( adresseReturn, strGeometry );
261         if ( !bIsTest )
262         {
263             List<fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse> listAddress = getListWSAdresses( request )
264                                                                                                           .getAdresse(  );
265 
266             for ( fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse currentAdresse : listAddress )
267             {
268                 if ( String.valueOf( currentAdresse.getIdentifiant(  ) ).equals( String.valueOf( id ) ) )
269                 {
270                     adresseReturn.setTypeVoie( currentAdresse.getTypeVoie(  ) );
271                     adresseReturn.setLibelleVoie( currentAdresse.getNomVoie(  ) );
272 
273                     // FIXME : see on top
274                     LibraryAddressUtils.fillAddressGeolocation( adresseReturn, currentAdresse.getGeometry(  ) );
275 
276                     break;
277                 }
278             }
279         }
280 
281         cleanListWSAdresses( request, SESSION_LIST_ADDRESS_NAME );
282 
283         return adresseReturn;
284     }
285 
286     /**
287     * @throws RemoteException the RemoteExecption
288     * @param request Request
289     * @param labeladresse the  label adress
290     * @return the XML flux of all adress corresponding
291     *
292     */
293     public ReferenceList searchAddress( HttpServletRequest request, String labeladresse )
294         throws RemoteException
295     {
296         String responseWebService = null;
297         AdresseService adresseService = new AdresseServiceLocator(  );
298 
299         try
300         {
301             URL urlWS = null;
302 
303             Stub portType = null;
304 
305             if ( ( getUrlWS(  ) == null ) || getUrlWS(  ).equals( "" ) )
306             {
307                 portType = (Stub) adresseService.getAdresseServiceHttpPort(  );
308             }
309             else
310             {
311                 try
312                 {
313                     urlWS = new URL( getUrlWS(  ) );
314                 }
315                 catch ( MalformedURLException e )
316                 {
317                     AppLogService.error( e.getMessage(  ), e );
318                 }
319 
320                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
321             }
322 
323             portType.setUsername( getUserName(  ) );
324             portType.setPassword( getPassword(  ) );
325 
326             setTimeout( portType );
327 
328             responseWebService = ( (AdresseServicePortType) portType ).searchAddress( getDefaultCity(  ), labeladresse,
329                     null, getDateSearch(  ) );
330 
331             // check null result and then return null list
332             if ( responseWebService == null )
333             {
334                 return null;
335             }
336         }
337         catch ( ServiceException e )
338         {
339             AppLogService.error( e.getMessage(  ), e );
340         }
341 
342         //traitement du flux xml		
343         Adresses adresses = null;
344 
345         JAXBContext jc;
346 
347         try
348         {
349             jc = JAXBContext.newInstance( JAXB_CONTEXT_WS_SEARCH_ADDRESS );
350 
351             Unmarshaller u = jc.createUnmarshaller(  );
352             StringBuffer xmlStr = new StringBuffer( responseWebService );
353             adresses = (Adresses) u.unmarshal( new StreamSource( new StringReader( xmlStr.toString(  ) ) ) );
354         }
355         catch ( JAXBException e )
356         {
357             AppLogService.error( e.getMessage(  ), e );
358         }
359 
360         List<fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse> listAdresses = adresses.getAdresse(  );
361 
362         ReferenceList refList = null;
363 
364         //      Added for filter the double adresse
365         Set<AdresseElement> eltSet = null;
366 
367         //build the list choice
368         if ( ( listAdresses != null ) && !listAdresses.isEmpty(  ) )
369         {
370             refList = new ReferenceList(  );
371 
372             //Added for filter the double adresse
373             eltSet = new HashSet<AdresseElement>(  );
374 
375             for ( fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse currentAdresse : listAdresses )
376             {
377                 String suffixe = "";
378 
379                 if ( currentAdresse.getSuffixe(  ) != null )
380                 {
381                     suffixe = currentAdresse.getSuffixe(  );
382                 }
383 
384                 String strCurrentAdresse = "";
385 
386                 if ( currentAdresse.getTypeVoie(  ) == null )
387                 {
388                     strCurrentAdresse = currentAdresse.getNumero(  ) + " " + suffixe + " " +
389                         currentAdresse.getNomVoie(  ) + " " + currentAdresse.getCommune(  );
390                 }
391                 else if ( LibraryAddressUtils.isTerminateByApostrophe( currentAdresse.getTypeVoie(  ) ) )
392                 {
393                     strCurrentAdresse = currentAdresse.getNumero(  ) + " " + suffixe + " " +
394                         currentAdresse.getTypeVoie(  ) + currentAdresse.getNomVoie(  ) + " " +
395                         currentAdresse.getCommune(  );
396                 }
397                 else
398                 {
399                     strCurrentAdresse = currentAdresse.getNumero(  ) + " " + suffixe + " " +
400                         currentAdresse.getTypeVoie(  ) + " " + currentAdresse.getNomVoie(  ) + " " +
401                         currentAdresse.getCommune(  );
402                 }
403 
404                 String strIdAdresse = currentAdresse.getIdentifiant(  ).toString(  );
405 
406                 //Added for filter the double adresse
407                 boolean isAdded = eltSet.add( new AdresseElement( strIdAdresse, strCurrentAdresse ) );
408 
409                 if ( isAdded )
410                 {
411                     refList.addItem( strIdAdresse, strCurrentAdresse );
412                 }
413             }
414 
415             setListWSAdresses( request, adresses );
416         }
417 
418         return refList;
419     }
420 
421     /**
422      * @throws RemoteException the RemoteExecption
423      * @param request Request
424      * @param labeladresse the  label adress
425      * @param strArrondissement Arrondissement
426      * @return the XML flux of all adress corresponding
427      * @see <a href="http://dev.lutece.paris.fr/jira/browse/ADDRESS-8">ADDRESS-8</a>
428      *
429      */
430     public ReferenceList searchAddress( HttpServletRequest request, String labeladresse, String strArrondissement )
431         throws RemoteException
432     {
433         return searchAddress( request, labeladresse, Integer.toString( getGeolocationRSID(  ) ), strArrondissement );
434     }
435 
436     /**
437      * @throws RemoteException the RemoteExecption
438      * @param strSRID the srsid
439      * @param request Request
440      * @param labeladresse the  label adress
441      * @param strArrondissement Arrondissement
442      * @return the XML flux of all adress corresponding
443      * @see <a href="http://dev.lutece.paris.fr/jira/browse/ADDRESS-8">ADDRESS-8</a>
444      */
445     public ReferenceList searchAddress( HttpServletRequest request, String labeladresse, String strSRID,
446         String strArrondissement ) throws RemoteException
447     {
448         String responseWebService = null;
449         AdresseService adresseService = new AdresseServiceLocator(  );
450 
451         try
452         {
453             URL urlWS = null;
454 
455             Stub portType = null;
456 
457             if ( ( getUrlWS(  ) == null ) || getUrlWS(  ).equals( "" ) )
458             {
459                 portType = (Stub) adresseService.getAdresseServiceHttpPort(  );
460             }
461             else
462             {
463                 try
464                 {
465                     urlWS = new URL( getUrlWS(  ) );
466                 }
467                 catch ( MalformedURLException e )
468                 {
469                     AppLogService.error( e.getMessage(  ), e );
470                 }
471 
472                 portType = (Stub) adresseService.getAdresseServiceHttpPort( urlWS );
473             }
474 
475             portType.setUsername( getUserName(  ) );
476             portType.setPassword( getPassword(  ) );
477 
478             setTimeout( portType );
479 
480             responseWebService = ( (AdresseServicePortType) portType ).searchAddress( getDefaultCity(  ), labeladresse,
481                     strSRID, getDateSearch(  ) );
482 
483             // check null result and then return null list
484             if ( responseWebService == null )
485             {
486                 return null;
487             }
488         }
489         catch ( ServiceException e )
490         {
491             AppLogService.error( e.getMessage(  ), e );
492         }
493 
494         //traitement du flux xml		
495         Adresses adresses = null;
496 
497         JAXBContext jc;
498 
499         try
500         {
501             jc = JAXBContext.newInstance( JAXB_CONTEXT_WS_SEARCH_ADDRESS );
502 
503             Unmarshaller u = jc.createUnmarshaller(  );
504             StringBuffer xmlStr = new StringBuffer( responseWebService );
505             adresses = (Adresses) u.unmarshal( new StreamSource( new StringReader( xmlStr.toString(  ) ) ) );
506         }
507         catch ( JAXBException e )
508         {
509             AppLogService.error( e.getMessage(  ), e );
510         }
511 
512         List<fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse> listAdresses = adresses.getAdresse(  );
513 
514         ReferenceList refList = null;
515 
516         //      Added for filter the double adresse
517         Set<AdresseElement> eltSet = null;
518 
519         //build the list choice
520         if ( ( listAdresses != null ) && !listAdresses.isEmpty(  ) )
521         {
522             refList = new ReferenceList(  );
523 
524             //Added for filter the double adresse
525             eltSet = new HashSet<AdresseElement>(  );
526 
527             for ( fr.paris.lutece.plugins.address.business.jaxb.wsSearchAdresse.Adresse currentAdresse : listAdresses )
528             {
529                 String suffixe = "";
530 
531                 if ( currentAdresse.getSuffixe(  ) != null )
532                 {
533                     suffixe = currentAdresse.getSuffixe(  );
534                 }
535 
536                 String strCurrentAdresse = "";
537 
538                 if ( currentAdresse.getTypeVoie(  ) == null )
539                 {
540                     strCurrentAdresse = currentAdresse.getNumero(  ) + " " + suffixe + " " +
541                         currentAdresse.getNomVoie(  ) + " " + currentAdresse.getCommune(  );
542                 }
543                 else if ( LibraryAddressUtils.isTerminateByApostrophe( currentAdresse.getTypeVoie(  ) ) )
544                 {
545                     strCurrentAdresse = currentAdresse.getNumero(  ) + " " + suffixe + " " +
546                         currentAdresse.getTypeVoie(  ) + currentAdresse.getNomVoie(  ) + " " +
547                         currentAdresse.getCommune(  );
548                 }
549                 else
550                 {
551                     strCurrentAdresse = currentAdresse.getNumero(  ) + " " + suffixe + " " +
552                         currentAdresse.getTypeVoie(  ) + " " + currentAdresse.getNomVoie(  ) + " " +
553                         currentAdresse.getCommune(  );
554                 }
555 
556                 String strIdAdresse = currentAdresse.getIdentifiant(  ).toString(  );
557 
558                 String arr = currentAdresse.getCommune(  );
559                 int index = arr.indexOf( "E" );
560                 if ( index > 2 )
561                 {
562                     arr = arr.substring( index - 2, index );
563                     index = arr.indexOf( "-" );
564 
565                     if ( index != -1 )
566                     {
567                         arr = arr.substring( 1, 2 );
568                     }
569                 }
570                 else
571                 {
572                     arr = StringUtils.EMPTY;
573                 }
574 
575                 //Added for filter the double adresse
576                 boolean isAdded = eltSet.add( new AdresseElement( strIdAdresse, strCurrentAdresse ) );
577 
578                 if ( isAdded )
579                 {
580                     if ( arr.equals( strArrondissement ) )
581                     {
582                         refList.addItem( strIdAdresse, strCurrentAdresse );
583                     }
584                 }
585             }
586 
587             setListWSAdresses( request, adresses );
588         }
589 
590         return refList;
591     }
592 
593     /**
594     *
595     * @return the date for parameter methodes of web service
596     */
597     public String getDateSearch(  )
598     {
599         return _strDateSearch;
600     }
601 
602     /**
603      *
604      * @param strDateSearch the new date search
605      */
606     public void setDateSearch( String strDateSearch )
607     {
608         _strDateSearch = strDateSearch;
609     }
610 
611     /**
612      *
613      * @return the default city for parameter methodes of web service
614      */
615     public String getDefaultCity(  )
616     {
617         return _strDefaultCity;
618     }
619 
620     /**
621      *
622      * @param strDefaultCity the new default city
623      */
624     public void setDefaultCity( String strDefaultCity )
625     {
626         _strDefaultCity = strDefaultCity;
627     }
628 
629     /**
630      *
631      * @return the url of the web service
632      */
633     public String getUrlWS(  )
634     {
635         return _strUrlWS;
636     }
637 
638     /**
639      *
640      * @param strUrlWS the new web service url
641      */
642     public void setUrlWS( String strUrlWS )
643     {
644         _strUrlWS = strUrlWS;
645     }
646 
647     /**
648      *
649      * @return the password
650      */
651     public String getPassword(  )
652     {
653         return _strPassword;
654     }
655 
656     /**
657      *
658      * @param password the password
659      */
660     public void setPassword( String password )
661     {
662         _strPassword = password;
663     }
664 
665     /**
666      *
667      * @return the user name
668      */
669     public String getUserName(  )
670     {
671         return _strUserName;
672     }
673 
674     /**
675      *
676      * @param userName the user name
677      */
678     public void setUserName( String userName )
679     {
680         _strUserName = userName;
681     }
682 
683     /**
684     *
685     * @return the timeout
686     */
687     public String getTimeOut(  )
688     {
689         return _strTimeOut;
690     }
691 
692     /**
693      *
694      * @param timeOut the timeout
695      */
696     public void setTimeOut( String timeOut )
697     {
698         _strTimeOut = timeOut;
699     }
700 
701     /**
702      * Sets the timeout to the stub
703      * @param portType
704      */
705     private void setTimeout( Stub portType )
706     {
707         try
708         {
709             portType.setTimeout( Integer.parseInt( getTimeOut(  ) ) );
710         }
711         catch ( NumberFormatException e )
712         {
713             AppLogService.error( 
714                 "WebServiceAddressService : timeOut is not set correctly for WebServiceAddressService. Please check address_context.xml. Will use no timeout" );
715         }
716     }
717 
718     /**
719      *
720      * @param request Resquest
721      * @return adresses
722      */
723     private Adresses getListWSAdresses( HttpServletRequest request )
724     {
725         HttpSession session = request.getSession( true );
726         String strSessionAttribute = SESSION_LIST_ADDRESS_NAME;
727         strSessionAttribute = strSessionAttribute.toUpperCase(  );
728 
729         return (Adresses) session.getAttribute( strSessionAttribute );
730     }
731 
732     /**
733      *
734      * @param request Request
735      * @param adresses Adresses
736      */
737     private void setListWSAdresses( HttpServletRequest request, Adresses adresses )
738     {
739         HttpSession session = request.getSession( true );
740         String strSessionAttribute = SESSION_LIST_ADDRESS_NAME;
741         strSessionAttribute = strSessionAttribute.toUpperCase(  );
742         session.setAttribute( strSessionAttribute, adresses );
743     }
744 
745     /**
746     *
747     * @param request Request
748     * @param strAttributeName Name attribute
749     */
750     private void cleanListWSAdresses( HttpServletRequest request, String strAttributeName )
751     {
752         HttpSession session = request.getSession( true );
753         String strSessionAttribute = strAttributeName;
754         strSessionAttribute = strSessionAttribute.toUpperCase(  );
755         session.removeAttribute( strSessionAttribute );
756     }
757 
758     /**
759      * Added for filter the double adresse
760      * An adresse element for eliminate element already present
761      */
762     private class AdresseElement
763     {
764         private String _idAdresse;
765         private String _labelAdresse;
766 
767         /**
768          * Instance a new AdresseElement
769          *
770          * @param strIdAdresse the adresse id
771          * @param strLabelAdresse the adresse label
772          */
773         public AdresseElement( String strIdAdresse, String strLabelAdresse )
774         {
775             _idAdresse = strIdAdresse;
776             _labelAdresse = strLabelAdresse;
777         }
778 
779         /**
780          * Get The label adresse
781          * @return the _labelAdresse
782          */
783         public String getLabelAdresse(  )
784         {
785             return _labelAdresse;
786         }
787 
788         /**
789          * Get The label adresse
790          * @return the _idAdresse
791          */
792         public String getIdAdresse(  )
793         {
794             return _idAdresse;
795         }
796 
797         /**
798          * Get The hashcode for labelAdresse
799          * @return the _idAdresse
800          */
801         public int hashCode(  )
802         {
803             return _labelAdresse.hashCode(  );
804         }
805 
806         /**
807          * @param o Object
808          * @return boolean
809          */
810         public boolean equals( Object o )
811         {
812             AdresseElement adresseToCompare = (AdresseElement) o;
813 
814             return this._labelAdresse.equals( adresseToCompare.getLabelAdresse(  ) );
815         }
816     }
817 }