Skip to content

Commit

Permalink
fix: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eschrewe committed Sep 10, 2024
1 parent 5087ddf commit d7ca575
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ public ResponseEntity<?> createMaterialPartnerRelation(
example = "true") @RequestParam boolean partnerSupplies,
@Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.",
example = "true") @RequestParam boolean partnerBuys) {

ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber));
try {
ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber));
} catch (Exception e) {
log.error("parameters were not properly encoded in base64");
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
}
if (!materialPattern.matcher(ownMaterialNumber).matches() || !materialPattern.matcher(partnerMaterialNumber).matches()
|| !bpnlPattern.matcher(partnerBpnl).matches()) {
log.warn("Rejected message parameters. ");
Expand Down Expand Up @@ -146,9 +150,14 @@ public ResponseEntity<?> updateMaterialPartnerRelation(
example = "true") @RequestParam(required = false) Boolean partnerSupplies,
@Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.",
example = "true") @RequestParam(required = false) Boolean partnerBuys) {
ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
try {
ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber));
partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber));
} catch (Exception e) {
log.error("parameters were not properly encoded in base64");
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
}
MaterialPartnerRelation existingRelation = null;

if (!bpnlPattern.matcher(partnerBpnl).matches() || !materialPattern.matcher(ownMaterialNumber).matches() ||
(partnerMaterialNumber != null && !materialPattern.matcher(partnerMaterialNumber).matches())) {

Check warning

Code scanning / CodeQL

Useless null check Warning

This check is useless.
partnerMaterialNumber
cannot be null at this check, since
new String(...)
always is non-null.
log.warn("Rejected message parameters. ");
Expand Down

0 comments on commit d7ca575

Please sign in to comment.