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