Skip to content

Commit

Permalink
chore: improved naming and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneSchroederLJ committed Jun 18, 2024
1 parent 05453dc commit 3048073
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public enum AssetType {
PRODUCTION_SUBMODEL("urn:samm:io.catenax.planned_production_output:2.0.0#PlannedProductionOutput", "$value"),
DEMAND_SUBMODEL("urn:samm:io.catenax.short_term_material_demand:1.0.0#ShortTermMaterialDemand", "$value"),
DELIVERY_SUBMODEL("urn:samm:io.catenax.delivery_information:2.0.0#DeliveryInformation", "$value"),
NOTIFICATION("urn:samm:io.catenax.demand_and_capacity_notification:2.0.0#DemandAndCapacityNotification", "$value"),
NOTIFICATION("urn:samm:io.catenax.demand_and_capacity_notification:2.0.0#DemandAndCapacityNotification", "none"),
PART_TYPE_INFORMATION_SUBMODEL("urn:samm:io.catenax.part_type_information:1.0.0#PartTypeInformation", "$value");

public final String URN_SEMANTIC_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,6 @@ private JsonNode postNotificationToPartner(Partner partner, AssetType type, Json
default -> throw new IllegalArgumentException("Unsupported type " + type);
};
try {


String contractId = edcContractMappingService.getContractId(partner, type, assetId, partnerDspUrl);
if (contractId == null) {
log.info("Need Contract for " + type + " with " + partner.getBpnl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ public JsonNode buildNotificationRegistrationBody(String assetId, String endpoin
return body;
}

public JsonNode createDataAddressObject(String endpoint, String proxyMethod) {
public JsonNode createDataAddressObject(String endpoint, String proxyMethodAndBody) {
var dataAddress = MAPPER.createObjectNode();
dataAddress.put("@type", "DataAddress");
dataAddress.put("proxyPath", "true");
dataAddress.put("proxyQueryParams", "false");
dataAddress.put("proxyMethod", proxyMethod);
dataAddress.put("proxyBody", proxyMethod);
dataAddress.put("proxyMethod", proxyMethodAndBody);
dataAddress.put("proxyBody", proxyMethodAndBody);
dataAddress.put("type", "HttpData");
dataAddress.put("baseUrl", endpoint);
dataAddress.put("authKey", "x-api-key");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class DemandAndCapacityNotificationRequestApiController {
@Autowired
private ObjectMapper objectMapper;

@Operation(summary = "This endpoint receives the DemandAndCapacityNotification Submodel 2.0.0 requests")
@Operation(summary = "This endpoint receives the DemandAndCapacityNotification 2.0.0 requests")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
Expand All @@ -60,18 +60,18 @@ public ResponseEntity<DemandAndCapacityNotificationSamm> postDemandAndCapacityNo
@RequestBody String body)
{
if (!bpnlPattern.matcher(bpnl).matches()) {
log.warn("Rejecting request at DemandAndCapacityNotification Submodel request 2.0.0 endpoint. Invalid BPNL");
log.warn("Rejecting request at DemandAndCapacityNotification request 2.0.0 endpoint. Invalid BPNL");
return ResponseEntity.badRequest().build();
}
try {
var data = objectMapper.readTree(body);
log.info("Received POST request for DemandAndCapacityNotification Submodel 2.0.0 with BPNL: " + bpnl);
log.info("Received POST request for DemandAndCapacityNotification 2.0.0 with BPNL: " + bpnl);
var notification = objectMapper.readValue(
data.get("content").get("demandAndCapacityNotification").toString(),
DemandAndCapacityNotificationSamm.class);
demandAndCapacityNotificationRequestApiService.handleIncomingNotification(bpnl, notification);
} catch (Exception e) {
log.warn("Rejecting invalid request body at DemandAndCapacityNotification Submodel request 2.0.0 endpoint");
log.warn("Rejecting invalid request body at DemandAndCapacityNotification request 2.0.0 endpoint");
return ResponseEntity.badRequest().build();
}
return ResponseEntity.ok(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ See the NOTICE file(s) distributed with this work for additional
import org.eclipse.tractusx.puris.backend.demandandcapacitynotification.domain.model.EffectEnumeration;
import org.eclipse.tractusx.puris.backend.demandandcapacitynotification.domain.model.LeadingRootCauseEnumeration;
import org.eclipse.tractusx.puris.backend.demandandcapacitynotification.domain.model.StatusEnumeration;

import java.util.Date;
import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;
import java.util.UUID;

import javax.management.openmbean.KeyAlreadyExistsException;

import org.eclipse.tractusx.puris.backend.common.edc.domain.model.AssetType;
import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EdcAdapterService;
import org.eclipse.tractusx.puris.backend.demandandcapacitynotification.domain.model.OwnDemandAndCapacityNotification;
Expand All @@ -55,7 +52,7 @@ public class DemandAndCapacityNotifcationRequestApiService {
private ObjectMapper objectMapper;

public static final String DEMAND_AND_CAPACITY_NOTIFICATION_CONTEXT = "CX-DemandAndCapacityNotification:2.0";
public static final String DEMAND_AND_CAPACITY_NOTIFICATION_VERSION = "3.0.0";
public static final String MESSAGE_HEADER_VERSION = "3.0.0";

public ReportedDemandAndCapacityNotification handleIncomingNotification(String bpnl, DemandAndCapacityNotificationSamm samm) {
Partner partner = partnerService.findByBpnl(bpnl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ puris.itemstocksubmodel.apiassetid=itemstocksubmodel-api-asset
puris.productionsubmodel.apiassetid=productionsubmodel-api-asset
puris.demandsubmodel.apiassetid=demandsubmodel-api-asset
puris.deliverysubmodel.apiassetid=deliverysubmodel-api-asset
puris.notificationsubmodel.apiassetid=notificationsubmodel-api-asset
puris.notification.apiassetid=notification-api-asset
puris.frameworkagreement.credential=Puris
puris.frameworkagreement.version=1.0
puris.purpose.name=cx.puris.base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ puris.itemstocksubmodel.apiassetid=itemstocksubmodel-api-asset
puris.productionsubmodel.apiassetid=productionsubmodel-api-asset
puris.demandsubmodel.apiassetid=demandsubmodel-api-asset
puris.deliverysubmodel.apiassetid=deliverysubmodel-api-asset
puris.notificationsubmodel.apiassetid=notificationsubmodel-api-asset
puris.notification.apiassetid=notification-api-asset
puris.frameworkagreement.credential=Puris
puris.frameworkagreement.version=1.0
puris.purpose.name=cx.puris.base
Expand Down

0 comments on commit 3048073

Please sign in to comment.