EPlanning: Add schain support#3914
Merged
Merged
Conversation
AntoxaAntoxic
suggested changes
Apr 23, 2025
Comment on lines
+299
to
+347
| private String makeSupplyChain(SupplyChain supplyChain) { | ||
| if (supplyChain.getNodes() == null || supplyChain.getNodes().isEmpty()) { | ||
| return Strings.EMPTY; | ||
| } | ||
|
|
||
| final StringBuilder sb = new StringBuilder(); | ||
| sb.append(supplyChain.getVer()) | ||
| .append(",") | ||
| .append(supplyChain.getComplete() != null ? supplyChain.getComplete() : 0); | ||
|
|
||
| for (SupplyChainNode node : supplyChain.getNodes()) { | ||
| sb.append("!") | ||
| .append(formatNodeValue(node.getAsi())) | ||
| .append(",") | ||
| .append(formatNodeValue(node.getSid())) | ||
| .append(",") | ||
| .append(formatNodeValue(node.getHp())) | ||
| .append(",") | ||
| .append(formatNodeValue(node.getRid())) | ||
| .append(",") | ||
| .append(formatNodeValue(node.getName())) | ||
| .append(",") | ||
| .append(formatNodeValue(node.getDomain())) | ||
| .append(",") | ||
| .append(formatNodeValue(node.getExt())); | ||
| } | ||
|
|
||
| return sb.toString(); | ||
| } | ||
|
|
||
| private String formatNodeValue(Object value) { | ||
| if (value == null) { | ||
| return Strings.EMPTY; | ||
| } | ||
|
|
||
| if (value instanceof String) { | ||
| return (String) value; | ||
| } | ||
|
|
||
| if (value instanceof Number) { | ||
| return value.toString(); | ||
| } | ||
|
|
||
| if (value instanceof ObjectNode) { | ||
| return value.toString(); | ||
| } | ||
|
|
||
| return Strings.EMPTY; | ||
| } |
Collaborator
There was a problem hiding this comment.
private String getSchainParameter(Source source) {
return Optional.ofNullable(source)
.map(Source::getExt)
.map(ExtSource::getSchain)
.map(this::resolveSupplyChain)
.orElse(null);
}
private String resolveSupplyChain(SupplyChain schain) {
final List<SupplyChainNode> nodes = schain.getNodes();
if (CollectionUtils.isEmpty(nodes) || nodes.size() > 2) {
return null;
}
final StringBuilder schainBuilder = new StringBuilder();
schainBuilder.append(schain.getVer());
schainBuilder.append(",");
schainBuilder.append(ObjectUtils.defaultIfNull(schain.getComplete(), 0));
for (SupplyChainNode node : schain.getNodes()) {
schainBuilder.append("!");
schainBuilder.append(encodeValue(node.getAsi()));
schainBuilder.append(",");
schainBuilder.append(encodeValue(node.getSid()));
schainBuilder.append(",");
schainBuilder.append(node.getHp() == null ? StringUtils.EMPTY : node.getHp());
schainBuilder.append(",");
schainBuilder.append(encodeValue(node.getRid()));
schainBuilder.append(",");
schainBuilder.append(encodeValue(node.getName()));
schainBuilder.append(",");
schainBuilder.append(encodeValue(node.getDomain()));
schainBuilder.append(",");
schainBuilder.append(node.getExt() == null
? StringUtils.EMPTY
: HttpUtil.encodeUrl(mapper.encodeToString(node.getExt())));
}
return schainBuilder.toString();
}
private static String encodeValue(String value) {
return value == null ? StringUtils.EMPTY : HttpUtil.encodeUrl(value);
}
Comment on lines
+277
to
+288
| final Source source = request.getSource(); | ||
| if (source != null && source.getExt() != null && source.getExt().getSchain() != null) { | ||
| final SupplyChain supplyChain = source.getExt().getSchain(); | ||
| if (supplyChain.getNodes() != null && supplyChain.getNodes().size() <= 2) { | ||
| final String schValue = makeSupplyChain(supplyChain); | ||
| if (StringUtils.isNotEmpty(schValue)) { | ||
| uriBuilder.addParameter("sch", schValue); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return uriBuilder.toString().replace("+", "%20"); |
Collaborator
There was a problem hiding this comment.
final String schain = getSchainParameter(request.getSource());
if (schain != null) {
uriBuilder.addParameter("sch", schain);
}
return uriBuilder.toString();
CTMBNara
requested changes
Apr 23, 2025
AntoxaAntoxic
approved these changes
May 9, 2025
CTMBNara
approved these changes
May 15, 2025
Collaborator
There was a problem hiding this comment.
@przemkaczmarek Please, comment or emote to indicate that logic follows the logic of GO version
Collaborator
@przemkaczmarek can you confirm this one? |
Collaborator
Author
|
@osulzhenko logic in Java fallows Go, confim |
riteshghodrao
pushed a commit
to riteshghodrao/prebid-server-java
that referenced
this pull request
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Type of changes
✨ What's the context?
#3895