Skip to content

Commit

Permalink
Refactor PublicationDeliveryImporter makes AuthorizationService confi…
Browse files Browse the repository at this point in the history
…gurable with spring properties.
  • Loading branch information
assadriaz committed Oct 8, 2024
1 parent 6df41a0 commit 2db1415
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Timer;
Expand All @@ -59,6 +60,7 @@ public class PublicationDeliveryImporter {
private final TopographicPlaceImportHandler topographicPlaceImportHandler;
private final BackgroundJobs backgroundJobs;
private final AuthorizationService authorizationService;
private final boolean authorizationEnabled;

@Autowired
public PublicationDeliveryImporter(PublicationDeliveryHelper publicationDeliveryHelper, NetexMapper netexMapper,
Expand All @@ -69,7 +71,9 @@ public PublicationDeliveryImporter(PublicationDeliveryHelper publicationDelivery
GroupOfTariffZonesImportHandler groupOfTariffZonesImportHandler,
StopPlaceImportHandler stopPlaceImportHandler,
ParkingsImportHandler parkingsImportHandler,
BackgroundJobs backgroundJobs, AuthorizationService authorizationService) {
BackgroundJobs backgroundJobs,
AuthorizationService authorizationService,
@Value("${authorization.enabled:true}") boolean authorizationEnabled) {
this.publicationDeliveryHelper = publicationDeliveryHelper;
this.parkingsImportHandler = parkingsImportHandler;
this.publicationDeliveryCreator = publicationDeliveryCreator;
Expand All @@ -80,6 +84,7 @@ public PublicationDeliveryImporter(PublicationDeliveryHelper publicationDelivery
this.stopPlaceImportHandler = stopPlaceImportHandler;
this.backgroundJobs = backgroundJobs;
this.authorizationService = authorizationService;
this.authorizationEnabled = authorizationEnabled;
}


Expand All @@ -89,8 +94,9 @@ public PublicationDeliveryStructure importPublicationDelivery(PublicationDeliver

@SuppressWarnings("unchecked")
public PublicationDeliveryStructure importPublicationDelivery(PublicationDeliveryStructure incomingPublicationDelivery, ImportParams importParams) {

authorizationService.verifyCanEditAllEntities();
if(authorizationEnabled){
authorizationService.verifyCanEditAllEntities();
}

if (incomingPublicationDelivery.getDataObjects() == null) {
String responseMessage = "Received publication delivery but it does not contain any data objects.";
Expand Down

0 comments on commit 2db1415

Please sign in to comment.