Skip to content

Commit

Permalink
feat(impl):[#370] fix pmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-ext-kmassalski committed Jan 31, 2024
1 parent b3915c0 commit d9fc950
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.eclipse.tractusx.irs.services.validation.SchemaNotFoundException;
import org.eclipse.tractusx.irs.services.validation.ValidationResult;
import org.eclipse.tractusx.irs.util.JsonUtil;
import org.jetbrains.annotations.Nullable;
import org.springframework.web.client.RestClientException;

/**
Expand Down Expand Up @@ -122,13 +123,13 @@ private List<Submodel> getSubmodels(final SubmodelDescriptor submodelDescriptor,
final org.eclipse.tractusx.irs.edc.client.model.SubmodelDescriptor submodel = requestSubmodel(
submodelFacade, connectorEndpointsService, endpoint, bpn);
final String submodelRawPayload = submodel.getPayload();
final String cid = auditContractNegotiation ? submodel.getCid() : null;
final String contractAgreementId = getContractAgreementId(auditContractNegotiation, submodel);

final ValidationResult validationResult = jsonValidatorService.validate(jsonSchema, submodelRawPayload);

if (validationResult.isValid()) {
submodels.add(Submodel.from(submodelDescriptor.getId(), submodelDescriptor.getAspectType(),
cid, jsonUtil.fromString(submodelRawPayload, Map.class)));
contractAgreementId, jsonUtil.fromString(submodelRawPayload, Map.class)));
} else {
final String errors = String.join(", ", validationResult.getValidationErrors());
itemContainerBuilder.tombstone(Tombstone.from(itemId, endpoint.getProtocolInformation().getHref(),
Expand Down Expand Up @@ -156,4 +157,10 @@ private List<Submodel> getSubmodels(final SubmodelDescriptor submodelDescriptor,
return submodels;
}

@Nullable
private String getContractAgreementId(final boolean auditContractNegotiation,
final org.eclipse.tractusx.irs.edc.client.model.SubmodelDescriptor submodel) {
return auditContractNegotiation ? submodel.getCid() : null;
}

}

0 comments on commit d9fc950

Please sign in to comment.