Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii Nahornyi committed Aug 4, 2021
1 parent e8696cb commit c346eb9
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -610,36 +610,6 @@ private void mergeFirstPartyDataFromData(Imp imp, ExtImpContext context, ObjectN
}
}

private String getAdSlot(Imp imp, ExtImpContext context) {
final ObjectNode contextDataNode = context != null ? context.getData() : null;
final JsonNode dataNode = imp.getExt().get(FPD_DATA_FIELD);

return ObjectUtils.firstNonNull(
// or imp[].ext.context.data.adserver.adslot
getAdSlotFromAdServer(contextDataNode),
// or imp[].ext.data.adserver.adslot
getAdSlotFromAdServer(dataNode));
}

private String getAdSlotFromAdServer(JsonNode dataNode) {
final ExtImpContextDataAdserver adServer = extImpContextDataAdserver(dataNode);
return adServer != null && Objects.equals(adServer.getName(), FPD_ADSERVER_NAME_GAM)
? adServer.getAdslot()
: null;
}

private ExtImpContextDataAdserver extImpContextDataAdserver(JsonNode contextData) {
final JsonNode adServerNode = contextData != null ? contextData.get(FPD_ADSERVER_FIELD) : null;
if (adServerNode == null || adServerNode.isNull()) {
return null;
}
try {
return mapper.mapper().convertValue(adServerNode, ExtImpContextDataAdserver.class);
} catch (IllegalArgumentException e) {
throw new PreBidException(e.getMessage(), e);
}
}

private void mergeFirstPartyDataKeywords(Imp imp, ExtImpContext context, ObjectNode result) {
// merge OPENRTB.imp[].ext.context.keywords to XAPI.imp[].ext.rp.target.keywords
final JsonNode keywordsNode = context != null ? context.getProperty("keywords") : null;
Expand Down Expand Up @@ -774,6 +744,36 @@ private Integer getMaxBids(ExtRequest extRequest) {
return multibidMaxBids != null ? multibidMaxBids : 1;
}

private String getAdSlot(Imp imp, ExtImpContext context) {
final ObjectNode contextDataNode = context != null ? context.getData() : null;
final JsonNode dataNode = imp.getExt().get(FPD_DATA_FIELD);

return ObjectUtils.firstNonNull(
// or imp[].ext.context.data.adserver.adslot
getAdSlotFromAdServer(contextDataNode),
// or imp[].ext.data.adserver.adslot
getAdSlotFromAdServer(dataNode));
}

private String getAdSlotFromAdServer(JsonNode dataNode) {
final ExtImpContextDataAdserver adServer = extImpContextDataAdserver(dataNode);
return adServer != null && Objects.equals(adServer.getName(), FPD_ADSERVER_NAME_GAM)
? adServer.getAdslot()
: null;
}

private ExtImpContextDataAdserver extImpContextDataAdserver(JsonNode contextData) {
final JsonNode adServerNode = contextData != null ? contextData.get(FPD_ADSERVER_FIELD) : null;
if (adServerNode == null || adServerNode.isNull()) {
return null;
}
try {
return mapper.mapper().convertValue(adServerNode, ExtImpContextDataAdserver.class);
} catch (IllegalArgumentException e) {
throw new PreBidException(e.getMessage(), e);
}
}

private static boolean isVideo(Imp imp) {
final Video video = imp.getVideo();
if (video != null) {
Expand Down

0 comments on commit c346eb9

Please sign in to comment.