diff --git a/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocation.java b/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocation.java index 9704387f..b4c918ff 100644 --- a/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocation.java +++ b/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocation.java @@ -20,6 +20,8 @@ import static org.cobbzilla.util.daemon.ZillaRuntime.*; @NoArgsConstructor @Accessors(chain=true) @ToString(of={"lat", "lon"}) public class GeoLocation { + public static final GeoLocation NULL_LOCATION = new GeoLocation().setLat("-1.0").setLon("-1.0"); + @Getter @Setter private String country; public boolean hasCountry() { return !empty(country); } diff --git a/bubble-server/src/main/java/bubble/cloud/geoTime/GeoTimeZone.java b/bubble-server/src/main/java/bubble/cloud/geoTime/GeoTimeZone.java index 2ab5e3e3..a3cba338 100644 --- a/bubble-server/src/main/java/bubble/cloud/geoTime/GeoTimeZone.java +++ b/bubble-server/src/main/java/bubble/cloud/geoTime/GeoTimeZone.java @@ -13,6 +13,8 @@ import lombok.experimental.Accessors; @NoArgsConstructor @AllArgsConstructor @Accessors(chain=true) public class GeoTimeZone { + public static final GeoTimeZone UTC = new GeoTimeZone("Etc/UTC", "UTC", 0L); + @Getter @Setter private String timeZoneId; @Getter @Setter private String standardName; @Getter @Setter private Long currentOffsetMs; diff --git a/bubble-server/src/main/java/bubble/model/cloud/RegionalServiceDriver.java b/bubble-server/src/main/java/bubble/model/cloud/RegionalServiceDriver.java index e6305143..2999a766 100644 --- a/bubble-server/src/main/java/bubble/model/cloud/RegionalServiceDriver.java +++ b/bubble-server/src/main/java/bubble/model/cloud/RegionalServiceDriver.java @@ -62,7 +62,7 @@ public interface RegionalServiceDriver { if (latLonIsValid) { r.setDistance(latitude, longitude); } else { - r.setDistance(0); + r.setDistance(-1); } allRegions.add(r); } @@ -74,12 +74,6 @@ public interface RegionalServiceDriver { List getRegions(); - default List getRegionsExcluding(Collection exclude) { - ArrayList filtered = new ArrayList<>(getRegions()); - filtered.removeIf(r -> exclude.contains(r.getInternalName()) || exclude.contains(r.getName())); - return filtered; - } - default List getRegions(BubbleFootprint footprint) { return getRegions().stream() .filter(r -> footprint == null || footprint.isAllowedCountry(r.getLocation().getCountry())) diff --git a/bubble-server/src/main/java/bubble/resources/DetectResource.java b/bubble-server/src/main/java/bubble/resources/DetectResource.java index cdfc658e..76582725 100644 --- a/bubble-server/src/main/java/bubble/resources/DetectResource.java +++ b/bubble-server/src/main/java/bubble/resources/DetectResource.java @@ -4,6 +4,7 @@ */ package bubble.resources; +import bubble.cloud.CloudServiceType; import bubble.service.cloud.GeoService; import lombok.extern.slf4j.Slf4j; import org.glassfish.grizzly.http.server.Request; @@ -20,8 +21,7 @@ import javax.ws.rs.core.Response; import static bubble.ApiConstants.*; import static org.cobbzilla.util.http.HttpContentTypes.APPLICATION_JSON; -import static org.cobbzilla.wizard.resources.ResourceUtil.ok; -import static org.cobbzilla.wizard.resources.ResourceUtil.optionalUserPrincipal; +import static org.cobbzilla.wizard.resources.ResourceUtil.*; @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) diff --git a/bubble-server/src/main/java/bubble/resources/cloud/CloudServiceRegionsResource.java b/bubble-server/src/main/java/bubble/resources/cloud/CloudServiceRegionsResource.java index 375dc726..fab392dd 100644 --- a/bubble-server/src/main/java/bubble/resources/cloud/CloudServiceRegionsResource.java +++ b/bubble-server/src/main/java/bubble/resources/cloud/CloudServiceRegionsResource.java @@ -82,7 +82,7 @@ public class CloudServiceRegionsResource { if (footprint == null) return notFound(footprintId); } - return ok(findClosestRegions(configuration, computeClouds(), footprint, loc.getLatitude(), loc.getLongitude())); + return ok(findClosestRegions(configuration, computeClouds(), footprint, loc.getLatitude(), loc.getLongitude(), null, geoService.supportsGeoLocation())); } public List findRegions(List clouds, BubbleFootprint footprint) { diff --git a/bubble-server/src/main/java/bubble/service/cloud/GeoService.java b/bubble-server/src/main/java/bubble/service/cloud/GeoService.java index 53ce2852..1f6e2b30 100644 --- a/bubble-server/src/main/java/bubble/service/cloud/GeoService.java +++ b/bubble-server/src/main/java/bubble/service/cloud/GeoService.java @@ -80,7 +80,8 @@ public class GeoService { public GeoLocation locate (String accountUuid, String ip, boolean cacheOnly) { if (!supportsGeoLocation()) { - throw invalidEx("err.geoLocateService.notFound"); + log.warn("locate: no geoLocation cloud services defined, returning null location"); + return GeoLocation.NULL_LOCATION; } final String cacheKey = hashOf(accountUuid, ip); return locateCache.computeIfAbsent(cacheKey, k -> { @@ -103,8 +104,9 @@ public class GeoService { } private GeoLocation getLocation(String accountUuid, String ip, String cacheKey) { - if (!supportsGeoCode()) { - throw invalidEx("err.geoCodeService.notFound"); + if (!supportsGeoLocation()) { + log.warn("getLocation: no geoLocation cloud services defined, returning null location"); + return GeoLocation.NULL_LOCATION; } List geoLocationServices = null; if (accountUuid != null) { @@ -128,7 +130,7 @@ public class GeoService { try { final GeoLocation result = geo.getGeoLocateDriver(configuration).geolocate(ip); if (result != null) { - if (!result.hasLatLon()) { + if (!result.hasLatLon() && supportsGeoCode()) { if (geoCodeDriver == null) { List geoCodeServices = null; if (accountUuid != null) { @@ -211,7 +213,8 @@ public class GeoService { public GeoTimeZone getTimeZone (final Account account, String ip) { if (!supportsGeoTime()) { - throw invalidEx("err.geoTimeService.notFound"); + log.warn("getTimeZone: no geoTime clouds configured, returning UTC time zone"); + return GeoTimeZone.UTC; } final AtomicReference acct = new AtomicReference<>(account); return timezoneCache.computeIfAbsent(ip, k -> { @@ -289,9 +292,6 @@ public class GeoService { public CloudAndRegion selectCloudAndRegion(BubbleNetwork network, NetLocation netLocation, Collection exclude) { - if (!supportsGeoLocation()) { - throw invalidEx("err.geoLocateService.notFound"); - } final CloudRegion closest; final String cloudUuid; if (netLocation.hasIp()) { diff --git a/bubble-web b/bubble-web index 6b016bdd..9cfcf662 160000 --- a/bubble-web +++ b/bubble-web @@ -1 +1 @@ -Subproject commit 6b016bdd3e0640cb31154ac39d33ac26f10e49ba +Subproject commit 9cfcf6620419200505c9105c74cb256af80d1ce8