Commit 01e516ff authored by Spencer Sutton's avatar Spencer Sutton
Browse files

Merge branch 'master' into dev

parents 502ebcf8 80cbbe7c
Pipeline #74116 failed with stages
in 36 minutes and 4 seconds
This diff is collapsed.
......@@ -52,8 +52,14 @@ spec:
cpu: "500m"
readinessProbe:
httpGet:
path: /api/indexer/v2/swagger-ui.html
port: 80
path: /actuator/health
port: 8081
livenessProbe:
httpGet:
path: /actuator/health
port: 8081
initialDelaySeconds: 250
periodSeconds: 10
volumeMounts:
- name: azure-keyvault
mountPath: "/mnt/azure-keyvault"
......
......@@ -16,7 +16,7 @@
<properties>
<commons-beanutils.version>1.9.4</commons-beanutils.version>
<osdu.oscorecommon.version>0.11.0-rc4</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.12.0-rc3</osdu.oscorecommon.version>
</properties>
<dependencies>
......
......@@ -17,6 +17,8 @@ package org.opengroup.osdu.indexer.error;
import javax.validation.ValidationException;
import javassist.NotFoundException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
......@@ -29,6 +31,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.opengroup.osdu.core.common.model.http.AppException;
import java.io.IOException;
@Order(Ordered.HIGHEST_PRECEDENCE - 1)
@ControllerAdvice
public class GlobalExceptionMapperCore extends ResponseEntityExceptionHandler {
......@@ -59,6 +63,17 @@ public class GlobalExceptionMapperCore extends ResponseEntityExceptionHandler {
new AppException(HttpStatus.FORBIDDEN.value(), "Access denied", e.getMessage(), e));
}
@ExceptionHandler(IOException.class)
public ResponseEntity<Object> handleIOException(IOException e) {
if (StringUtils.containsIgnoreCase(ExceptionUtils.getRootCauseMessage(e), "Broken pipe")) {
this.logger.warning("Client closed the connection while request still being processed");
return null;
} else {
return this.getErrorResponse(
new AppException(HttpStatus.SERVICE_UNAVAILABLE.value(), "Unknown error", e.getMessage(), e));
}
}
@ExceptionHandler(Exception.class)
protected ResponseEntity<Object> handleGeneralException(Exception e) {
return this.getErrorResponse(
......
......@@ -14,8 +14,10 @@
package org.opengroup.osdu.indexer.model.geojson;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.opengroup.osdu.indexer.model.geojson.jackson.FeatureCollectionDeserializer;
import org.opengroup.osdu.indexer.model.geojson.jackson.FeatureCollectionSerializer;
import java.util.ArrayList;
......@@ -25,6 +27,7 @@ import java.util.List;
@Data
@JsonSerialize(using = FeatureCollectionSerializer.class)
@JsonDeserialize(using = FeatureCollectionDeserializer.class)
public class FeatureCollection extends GeoJsonObject implements Iterable<Feature> {
private List<Feature> features = new ArrayList<Feature>();
......
......@@ -29,7 +29,6 @@ import java.io.Serializable;
@Getter
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@AllArgsConstructor
@JsonDeserialize(using = PositionDeserializer.class)
@JsonSerialize(using = PositionSerializer.class)
public class Position implements Serializable {
......@@ -44,6 +43,12 @@ public class Position implements Serializable {
this.setLatitude(latitude);
}
public Position(double longitude, double latitude, double altitude) {
this.setLongitude(longitude);
this.setLatitude(latitude);
this.altitude = altitude;
}
public void setLongitude(double longitude) {
if (Double.isNaN(longitude))
throw new IllegalArgumentException("latitude must be number");
......
// Copyright © Schlumberger
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.indexer.model.geojson.jackson;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import org.opengroup.osdu.indexer.model.geojson.Feature;
import org.opengroup.osdu.indexer.model.geojson.FeatureCollection;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class FeatureCollectionDeserializer extends JsonDeserializer<FeatureCollection> {
@Override
public FeatureCollection deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
FeatureCollection featureCollection = new FeatureCollection();
featureCollection.setFeatures(extractFeature(jsonParser));
return featureCollection;
}
private List<Feature> extractFeature(JsonParser jsonParser) throws IOException {
ObjectCodec codec = jsonParser.getCodec();
JsonNode featureCollection = codec.readTree(jsonParser);
JsonNode features = featureCollection.get("features");
final List<Feature> result = new ArrayList<>();
for (JsonNode node : features) {
result.add(codec.treeToValue(node, Feature.class));
}
return result;
}
}
......@@ -34,7 +34,6 @@ public class FeatureCollectionSerializer extends JsonSerializer<FeatureCollectio
jsonGenerator.writeArrayFieldStart("geometries");
for (Feature feature : value.getFeatures()) {
jsonGenerator.writeStartObject();
if (feature.getGeometry() instanceof GeometryCollection) {
GeometryCollection geometryCollection = (GeometryCollection) feature.getGeometry();
for (GeoJsonObject shape : geometryCollection.getGeometries()) {
......@@ -43,7 +42,6 @@ public class FeatureCollectionSerializer extends JsonSerializer<FeatureCollectio
} else {
serializeGeoShape(feature.getGeometry(), jsonGenerator);
}
jsonGenerator.writeEndObject();
}
jsonGenerator.writeEndArray();
......@@ -59,23 +57,35 @@ public class FeatureCollectionSerializer extends JsonSerializer<FeatureCollectio
private void serializeGeoShape(GeoJsonObject geoJsonObject, JsonGenerator jsonGenerator) throws IOException {
if (geoJsonObject instanceof Point) {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("type", "point");
jsonGenerator.writeObjectField("coordinates", ((Point) geoJsonObject).getCoordinates());
jsonGenerator.writeEndObject();
} else if (geoJsonObject instanceof LineString) {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("type", "linestring");
jsonGenerator.writeObjectField("coordinates", ((LineString) geoJsonObject).getCoordinates());
jsonGenerator.writeEndObject();
} else if (geoJsonObject instanceof Polygon) {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("type", "polygon");
jsonGenerator.writeObjectField("coordinates", ((Polygon) geoJsonObject).getCoordinates());
jsonGenerator.writeEndObject();
} else if (geoJsonObject instanceof MultiPoint) {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("type", "multipoint");
jsonGenerator.writeObjectField("coordinates", ((MultiPoint) geoJsonObject).getCoordinates());
jsonGenerator.writeEndObject();
} else if (geoJsonObject instanceof MultiLineString) {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("type", "multilinestring");
jsonGenerator.writeObjectField("coordinates", ((MultiLineString) geoJsonObject).getCoordinates());
jsonGenerator.writeEndObject();
} else if (geoJsonObject instanceof MultiPolygon) {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("type", "multipolygon");
jsonGenerator.writeObjectField("coordinates", ((MultiPolygon) geoJsonObject).getCoordinates());
jsonGenerator.writeEndObject();
}
}
}
......@@ -29,8 +29,9 @@ import org.springframework.security.access.AccessDeniedException;
import javax.validation.ValidationException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import static org.junit.Assert.*;
@RunWith(PowerMockRunner.class)
public class GlobalExceptionMapperCoreTest {
......@@ -90,4 +91,20 @@ public class GlobalExceptionMapperCoreTest {
ResponseEntity<Object> response = sut.handleAppException(exception);
assertEquals(RequestStatus.INVALID_RECORD, response.getStatusCodeValue());
}
@Test
public void should_returnNullResponse_when_BrokenPipeIOExceptionIsCaptured() {
IOException ioException = new IOException("Broken pipe");
ResponseEntity response = this.sut.handleIOException(ioException);
assertNull(response);
}
@Test
public void should_returnServiceUnavailable_when_IOExceptionIsCaptured() {
IOException ioException = new IOException("Not broken yet");
ResponseEntity response = this.sut.handleIOException(ioException);
assertEquals(HttpStatus.SC_SERVICE_UNAVAILABLE, response.getStatusCodeValue());
}
}
\ No newline at end of file
......@@ -44,122 +44,140 @@ public class GeoShapeParserTest {
public void should_throwException_provided_emptyGeoJson() {
String shapeJson = "{}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "shape not included");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "shape not included");
}
@Test
public void should_throwException_parseInvalidPoint() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-205.01621,39.57422]}}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "unable to parse FeatureCollection");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection");
}
@Test
public void should_throwException_parseInvalidPoint_NaN() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-205.01621,NaN]}}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "unable to parse FeatureCollection");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection");
}
@Test
public void should_throwException_parseInvalidPoint_missingLatitude() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-105.01621]}}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "unable to parse FeatureCollection");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection");
}
@Test
public void should_throwException_missingMandatoryAttribute() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"mistype\":\"Point\",\"coordinates\":[-205.01621,39.57422]}}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "must be a valid FeatureCollection");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "must be a valid FeatureCollection");
}
@Test
public void should_throwException_parseInvalidShape() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"InvalidShape\",\"coordinates\":[-105.01621,39.57422]}}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "must be a valid FeatureCollection");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "must be a valid FeatureCollection");
}
@Test
public void should_parseValidPoint() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-105.01621,39.57422]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"point\",\"coordinates\":[-105.01621,39.57422]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_parseValidMultiPoint() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPoint\",\"coordinates\":[[-105.01621,39.57422],[-80.666513,35.053994]]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"multipoint\",\"coordinates\":[[-105.01621,39.57422],[-80.666513,35.053994]]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_parseValidLineString() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-101.744384,39.32155],[-101.552124,39.330048],[-101.403808,39.330048],[-101.332397,39.364032],[-101.041259,39.368279],[-100.975341,39.304549],[-100.914916,39.245016],[-100.843505,39.164141],[-100.805053,39.104488],[-100.491943,39.100226],[-100.437011,39.095962],[-100.338134,39.095962],[-100.195312,39.027718],[-100.008544,39.010647],[-99.865722,39.00211],[-99.684448,38.972221],[-99.51416,38.929502],[-99.382324,38.920955],[-99.321899,38.895308],[-99.113159,38.869651],[-99.0802,38.85682],[-98.822021,38.85682],[-98.448486,38.848264],[-98.206787,38.848264],[-98.020019,38.878204],[-97.635498,38.873928]]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"linestring\",\"coordinates\":[[-101.744384,39.32155],[-101.552124,39.330048],[-101.403808,39.330048],[-101.332397,39.364032],[-101.041259,39.368279],[-100.975341,39.304549],[-100.914916,39.245016],[-100.843505,39.164141],[-100.805053,39.104488],[-100.491943,39.100226],[-100.437011,39.095962],[-100.338134,39.095962],[-100.195312,39.027718],[-100.008544,39.010647],[-99.865722,39.00211],[-99.684448,38.972221],[-99.51416,38.929502],[-99.382324,38.920955],[-99.321899,38.895308],[-99.113159,38.869651],[-99.0802,38.85682],[-98.822021,38.85682],[-98.448486,38.848264],[-98.206787,38.848264],[-98.020019,38.878204],[-97.635498,38.873928]]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_parseValidMultiLineString() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiLineString\",\"coordinates\":[[[-105.021443,39.578057],[-105.021507,39.577809],[-105.021572,39.577495],[-105.021572,39.577164],[-105.021572,39.577032],[-105.021529,39.576784]],[[-105.019898,39.574997],[-105.019598,39.574898],[-105.019061,39.574782]],[[-105.017173,39.574402],[-105.01698,39.574385],[-105.016636,39.574385],[-105.016508,39.574402],[-105.01595,39.57427]],[[-105.014276,39.573972],[-105.014126,39.574038],[-105.013825,39.57417],[-105.01331,39.574452]]]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"multilinestring\",\"coordinates\":[[[-105.021443,39.578057],[-105.021507,39.577809],[-105.021572,39.577495],[-105.021572,39.577164],[-105.021572,39.577032],[-105.021529,39.576784]],[[-105.019898,39.574997],[-105.019598,39.574898],[-105.019061,39.574782]],[[-105.017173,39.574402],[-105.01698,39.574385],[-105.016636,39.574385],[-105.016508,39.574402],[-105.01595,39.57427]],[[-105.014276,39.573972],[-105.014126,39.574038],[-105.013825,39.57417],[-105.01331,39.574452]]]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_parseValidPolygon() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[100,0],[101,0],[101,1],[100,1],[100,0]]]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"polygon\",\"coordinates\":[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_throwException_parseInvalidPolygon_malformedLatitude() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[100,\"afgg\"],[101,0],[101,1],[100,1],[100,0]]]}}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "unable to parse FeatureCollection");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "unable to parse FeatureCollection");
}
@Test
public void should_parseValidMultiPolygon() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[107,7],[108,7],[108,8],[107,8],[107,7]]],[[[100,0],[101,0],[101,1],[100,1],[100,0]]]]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"multipolygon\",\"coordinates\":[[[[107.0,7.0],[108.0,7.0],[108.0,8.0],[107.0,8.0],[107.0,7.0]]],[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_parseValidGeometryCollection() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Point\",\"coordinates\":[-80.660805,35.049392]},{\"type\":\"Polygon\",\"coordinates\":[[[-80.664582,35.044965],[-80.663874,35.04428],[-80.662586,35.04558],[-80.663444,35.046036],[-80.664582,35.044965]]]},{\"type\":\"LineString\",\"coordinates\":[[-80.662372,35.059509],[-80.662693,35.059263],[-80.662844,35.05893],[-80.66308,35.058332],[-80.663595,35.057753],[-80.663874,35.057401],[-80.66441,35.057033],[-80.664861,35.056787],[-80.665419,35.056506],[-80.665633,35.056312],[-80.666019,35.055891],[-80.666191,35.055452],[-80.666191,35.055171],[-80.666255,35.05489],[-80.666213,35.054222],[-80.666213,35.053924],[-80.665955,35.052905],[-80.665698,35.052044],[-80.665504,35.051482],[-80.665762,35.050481],[-80.66617,35.049725],[-80.666513,35.049286],[-80.666921,35.048531],[-80.667006,35.048215],[-80.667071,35.047775],[-80.667049,35.047389],[-80.666964,35.046985],[-80.666813,35.046353],[-80.666599,35.045966],[-80.666406,35.045615],[-80.665998,35.045193],[-80.665526,35.044877],[-80.664989,35.044543],[-80.664496,35.044174],[-80.663852,35.043876],[-80.663037,35.043717]]}]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"point\",\"coordinates\":[-80.660805,35.049392]},{\"type\":\"polygon\",\"coordinates\":[[[-80.664582,35.044965],[-80.663874,35.04428],[-80.662586,35.04558],[-80.663444,35.046036],[-80.664582,35.044965]]]},{\"type\":\"linestring\",\"coordinates\":[[-80.662372,35.059509],[-80.662693,35.059263],[-80.662844,35.05893],[-80.66308,35.058332],[-80.663595,35.057753],[-80.663874,35.057401],[-80.66441,35.057033],[-80.664861,35.056787],[-80.665419,35.056506],[-80.665633,35.056312],[-80.666019,35.055891],[-80.666191,35.055452],[-80.666191,35.055171],[-80.666255,35.05489],[-80.666213,35.054222],[-80.666213,35.053924],[-80.665955,35.052905],[-80.665698,35.052044],[-80.665504,35.051482],[-80.665762,35.050481],[-80.66617,35.049725],[-80.666513,35.049286],[-80.666921,35.048531],[-80.667006,35.048215],[-80.667071,35.047775],[-80.667049,35.047389],[-80.666964,35.046985],[-80.666813,35.046353],[-80.666599,35.045966],[-80.666406,35.045615],[-80.665998,35.045193],[-80.665526,35.044877],[-80.664989,35.044543],[-80.664496,35.044174],[-80.663852,35.043876],[-80.663037,35.043717]]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_parseValidFeatureCollection() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[1.9496737127045984,58.41415669686543],[1.8237672363511042,58.42946998193435],[1.8422735102001124,58.471472136376455],[1.9683241046247606,58.45614207250076],[1.9496737127045984,58.41415669686543]]]}}]}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"polygon\",\"coordinates\":[[[1.9496737127045984,58.41415669686543],[1.8237672363511042,58.42946998193435],[1.8422735102001124,58.471472136376455],[1.9683241046247606,58.45614207250076],[1.9496737127045984,58.41415669686543]]]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY);
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_parseValidFeatureCollection_withZCoordinate() {
String shapeJson = "{\"type\":\"FeatureCollection\",\"bbox\":null,\"features\":[{\"type\":\"Feature\",\"bbox\":null,\"geometry\":{\"type\":\"Point\",\"bbox\":null,\"coordinates\":[5.7500000010406245,59.000000000399105, 1.0]},\"properties\":{}}],\"properties\":{},\"persistableReferenceCrs\":null,\"persistableReferenceUnitZ\":\"{\\\"scaleOffset\\\":{\\\"scale\\\":1.0,\\\"offset\\\":0.0},\\\"symbol\\\":\\\"m\\\",\\\"baseMeasurement\\\":{\\\"ancestry\\\":\\\"Length\\\",\\\"type\\\":\\\"UM\\\"},\\\"type\\\":\\\"USO\\\"}\"}";
String expectedParsedShape = "{\"type\":\"geometrycollection\",\"geometries\":[{\"type\":\"point\",\"coordinates\":[5.7500000010406245,59.000000000399105,1.0]}]}";
this.validateInput(this.sut::parseGeoJson, shapeJson, expectedParsedShape, Strings.EMPTY);
}
@Test
public void should_throwException_parseUnsupportedType_feature() {
String shapeJson = "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-80.724878,35.265454],[-80.722646,35.260338],[-80.720329,35.260618],[-80.718698,35.260267],[-80.715093,35.260548],[-80.71681,35.255361],[-80.710887,35.255361],[-80.703248,35.265033],[-80.704793,35.268397],[-80.70857,35.268257],[-80.712518,35.270359],[-80.715179,35.267696],[-80.721359,35.267276],[-80.724878,35.265454]]]},\"properties\":{\"name\":\"Plaza Road Park\"}}";
this.validateInput(this.sut::parseGeoJson, shapeJson, "must be a valid FeatureCollection");
this.validateInput(this.sut::parseGeoJson, shapeJson, Strings.EMPTY, "must be a valid FeatureCollection");
}
private void validateInput(Function<Map<String, Object>, Map<String, Object>> parser, String shapeJson, String errorMessage) {
private void validateInput(Function<Map<String, Object>, Map<String, Object>> parser, String shapeJson, String expectedParsedShape, String errorMessage) {
try {
Type type = new TypeToken<Map<String, Object>>() {}.getType();
Map<String, Object> shapeObj = new Gson().fromJson(shapeJson, type);
Map<String, Object> expectedShape = new Gson().fromJson(expectedParsedShape, type);
Map<String, Object> parsedShape = parser.apply(shapeObj);
assertNotNull(parsedShape);
assertTrue(Strings.isNullOrEmpty(errorMessage));
assertTrue(parsedShape.equals(expectedShape));
} catch (IllegalArgumentException e) {
if (Strings.isNullOrEmpty(errorMessage)) {
fail(String.format("error parsing valid geo-json %s", shapeJson));
......
......@@ -19,7 +19,7 @@
<java.version>1.8</java.version>
<springfox-version>2.7.0</springfox-version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
<os-core-common.version>0.11.0-rc4</os-core-common.version>
<os-core-common.version>0.12.0-rc3</os-core-common.version>
<snakeyaml.version>1.26</snakeyaml.version>
<hibernate-validator.version>6.1.5.Final</hibernate-validator.version>
<jackson.version>2.11.4</jackson.version>
......
......@@ -41,7 +41,8 @@
<nimbus-jose-jwt.version>8.2</nimbus-jose-jwt.version>
<indexer-core.version>0.12.0-SNAPSHOT</indexer-core.version>
<spring-security-jwt.version>1.1.1.RELEASE</spring-security-jwt.version>
<osdu.corelibazure.version>0.11.0-rc5</osdu.corelibazure.version>
<osdu.corelibazure.version>0.12.0-rc10</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.12.0-rc3</osdu.oscorecommon.version>
<reactor-netty.version>0.9.12.RELEASE</reactor-netty.version>
<java-jwt.version>3.8.1</java-jwt.version>
<powermock.version>2.0.2</powermock.version>
......@@ -78,6 +79,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${osdu.oscorecommon.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......
......@@ -18,6 +18,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.github.resilience4j.core.IntervalFunction;
import io.github.resilience4j.retry.RetryConfig;
import lombok.Data;
import lombok.extern.java.Log;
......@@ -27,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.time.Duration;
import java.util.function.Predicate;
/**
......@@ -44,8 +44,8 @@ public class RetryPolicy {
@Autowired
private JaxRsDpsLog logger;
private int attempts = 3;
private int waitDuration = 1000;
private static int MAX_ATTEMPTS = 5;
private static int INITIAL_DELAY = 1000;
private final String RECORD_NOT_FOUND = "notFound";
/**
......@@ -53,8 +53,8 @@ public class RetryPolicy {
*/
public RetryConfig retryConfig(Predicate<HttpResponse> predicate) {
return RetryConfig.<HttpResponse>custom()
.maxAttempts(attempts)
.waitDuration(Duration.ofMillis(waitDuration))
.maxAttempts(MAX_ATTEMPTS)
.intervalFunction(IntervalFunction.ofExponentialBackoff(INITIAL_DELAY, 2))
.retryOnResult(predicate)
.build();
}
......
......@@ -86,8 +86,11 @@ logging.ignore.servlet.paths=/swagger-ui.html
# core-lib-azure configuration
tenantFactoryImpl.required=true
# Disable keyVault for actuator health check
# Configuration for health checks
management.server.port=8081
management.health.azure-key-vault.enabled=false
management.health.elasticsearch.enabled=false
#Redis
redis.database=${REDIS_DATABASE}
\ No newline at end of file
......@@ -16,64 +16,27 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu.indexer</groupId>
<artifactId>indexer-core</artifactId>
<version>0.12.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.10.0</version>
<version>0.12.0-rc3</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
<version>1.38.1</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>1.72.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-logging</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev150-1.25.0</version>
<groupId>org.opengroup.osdu.indexer</groupId>
<artifactId>indexer-core</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- excluded due to runtime conflict with latest core-lib-gcp transient dependencies -->
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava-jdk5</artifactId>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudkms</artifactId>
<version>v1-rev81-1.25.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-pubsub -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.60.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.30.11</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
......@@ -147,11 +110,6 @@