Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import io.micrometer.core.annotation.Timed;
import jakarta.annotation.Nullable;
import jakarta.persistence.EntityManager;
import jakarta.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
Expand Down Expand Up @@ -96,6 +97,7 @@ public class GeoServiceProxyController {
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private final AuthorisationService authorisationService;
private final HttpClient httpClient;
private final EntityManager entityManager;

public static final String TILES3D_DESCRIPTION_PATH = "tiles3dDescription";

Expand All @@ -105,8 +107,9 @@ public class GeoServiceProxyController {
@Value("${tailormap-api.proxy.passthrough.hostnames:}")
private Set<String> proxyPassthroughHostNames = Set.of();

public GeoServiceProxyController(AuthorisationService authorisationService) {
public GeoServiceProxyController(AuthorisationService authorisationService, EntityManager entityManager) {
this.authorisationService = authorisationService;
this.entityManager = entityManager;

final HttpClient.Builder builder = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NORMAL);
this.httpClient = builder.build();
Expand All @@ -123,6 +126,9 @@ public ResponseEntity<?> proxy3dtiles(

checkRequestValidity(application, service, layer, GeoServiceProtocol.TILES3D, request);

// after all validations we can close the JPA session
this.entityManager.close();

Comment on lines +129 to +131
return doProxy(build3DTilesUrl(service, request), service, request);
}

Expand All @@ -139,6 +145,9 @@ public ResponseEntity<?> proxy(

checkRequestValidity(application, service, layer, protocol, request);

// after all validations we can close the JPA session
this.entityManager.close();

Comment on lines +148 to +150
return switch (protocol) {
case WMS, WMTS -> doProxy(buildWMSUrl(service, request), service, request);
case LEGEND -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import io.micrometer.core.annotation.Counted;
import io.micrometer.core.annotation.Timed;
import jakarta.persistence.EntityManager;
import jakarta.validation.Valid;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
Expand Down Expand Up @@ -67,17 +68,20 @@ public class LayerExtractController {
private final FeatureSourceRepository featureSourceRepository;
private final CreateLayerExtractService createLayerExtractService;
private final FeatureSourceFactoryHelper featureSourceFactoryHelper;
private final EntityManager entityManager;

@Value("#{'${tailormap-api.extract.allowed-outputformats}'.split(',')}")
private List<ExtractOutputFormat> allowedExtractOutputFormats;

public LayerExtractController(
FeatureSourceRepository featureSourceRepository,
CreateLayerExtractService createLayerExtractService,
FeatureSourceFactoryHelper featureSourceFactoryHelper) {
FeatureSourceFactoryHelper featureSourceFactoryHelper,
EntityManager entityManager) {
this.featureSourceRepository = featureSourceRepository;
this.createLayerExtractService = createLayerExtractService;
this.featureSourceFactoryHelper = featureSourceFactoryHelper;
this.entityManager = entityManager;
}

/**
Expand Down Expand Up @@ -137,7 +141,7 @@ public ResponseEntity<?> formats(
.toList());
}

@Transactional
@Transactional(readOnly = true)
@PostMapping("/{clientId}")
@Timed(value = "tailormap_api_extract", description = "Time taken to process a layer extract request")
public ResponseEntity<?> extract(
Expand Down Expand Up @@ -213,6 +217,9 @@ public ResponseEntity<?> extract(
validateExcelLimits(sourceFT, attributes, parsedCQL);
}

// after all validations we can close the JPA session
this.entityManager.close();

Comment on lines +220 to +222
SortOrder sortingOrder = SortOrder.ASCENDING;
if (null != sortOrder && (sortOrder.equalsIgnoreCase("desc") || sortOrder.equalsIgnoreCase("asc"))) {
sortingOrder = SortOrder.valueOf(sortOrder.toUpperCase(Locale.ROOT));
Expand Down
Loading