Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-80744 || Add item attribute max length validation #1640

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ dependencies {
} else {
compile 'com.github.reportportal:commons-dao:94ffb40'
compile 'com.github.reportportal:commons-rules:5.3.0'
compile 'com.github.reportportal:commons-model:750a1d7'
compile 'com.github.reportportal:commons-model:7440eb5'
compile 'com.github.reportportal:commons:7480d61'
compile 'com.github.reportportal:commons-fonts:10d1054'
compile 'com.github.reportportal:plugin-api:886ac55'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,26 @@
*/
public class ItemAttributeConverter {

public static final int MAX_ATTRIBUTE_LENGTH = 512;

private ItemAttributeConverter() {
//static only
}

public static final Function<ItemAttributeResource, ItemAttribute> FROM_RESOURCE = it -> {
ItemAttribute itemAttribute = new ItemAttribute();
itemAttribute.setKey(it.getKey());
itemAttribute.setValue(it.getValue());

String key = it.getKey();
if (key != null && key.length() > MAX_ATTRIBUTE_LENGTH){
key = key.substring(0, MAX_ATTRIBUTE_LENGTH);
}
String value = it.getValue();
if (value != null && value.length() > MAX_ATTRIBUTE_LENGTH){
value = value.substring(0, MAX_ATTRIBUTE_LENGTH);
}
itemAttribute.setKey(key);
itemAttribute.setValue(value);

if (it instanceof ItemAttributesRQ) {
itemAttribute.setSystem(((ItemAttributesRQ) it).isSystem());
} else {
Expand Down