private String getAddress(GoogleMapsService gMapsService, Coordinate coordinate) { // Si no se encuentra la dirección, se pone como vacío. Si el servidor falla, se pone a null try { return gMapsService.getAddress(coordinate); } catch (GoogleMapsServiceException e) { return null; } catch (GoogleMapsAddressException e) { return ""; } }
private TIPDetailsDto create( TIPtype tipType, String name, String description, String photoUrl, String infoUrl, Geometry geom, Long osmId, boolean reviewed, boolean getAddress, Long facebookUserId) throws TIPLocationException, InvalidTIPUrlException, InstanceNotFoundException { TIP tip = new TIP(); tip.setType(tipType); tip.setName(name); tip.setDescription(description); tip.setGeom(geom); tip.setPhotoUrl(photoUrl); tip.setInfoUrl(infoUrl); tip.setOsmId(osmId); tip.setReviewed(reviewed); tip.setCreationDate(Calendar.getInstance()); tip.setUserAccount(userAccountDao.findByFBUserID(facebookUserId)); if (getAddress) { Coordinate coordinate = tip.getGeom().getCoordinate(); tip.setGoogleMapsUrl(gMapsServiceForUsers.getTIPGoogleMapsUrl(coordinate)); tip.setAddress(getAddress(gMapsServiceForUsers, coordinate)); } City city = cityService.getCityFromLocation(geom); tip.setCity(city); URLvalidator.checkURLs(tip); tipDao.save(tip); return dtoService.TIP2TIPDetailsDto(tip, null); }