Skip to content
Snippets Groups Projects
Commit da06ee49 authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

allow id with dot if request with and without dots are in separate requests

parent 03c76893
No related branches found
No related tags found
2 merge requests!841Draft: Update version of default branch to 0.26.0-SNAPSHOT,!839allow id with dot if request with and without dots are in separate requests
Pipeline #240411 failed
......@@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.isNoneBlank;
......@@ -45,15 +46,19 @@ public class RecordUtil {
}
}
public String getKindForVersion(RecordMetadata record, String version) {
String versionPath =
record.getGcsVersionPaths()
public String getKindForVersion(RecordMetadata recordMetadata, String version) {
String gcsVersionPath =
recordMetadata.getGcsVersionPaths()
.stream()
.filter(path -> isNoneBlank(path) && path.contains(version))
.filter(isGcsVersionPathEndsWith(version))
.findFirst()
.orElseThrow(() -> throwVersionNotFound(record.getId(), version));
.orElseThrow(() -> throwVersionNotFound(recordMetadata.getId(), version));
return versionPath.split("/")[0];
return gcsVersionPath.split("/")[0];
}
private static Predicate<String> isGcsVersionPathEndsWith(String version) {
return gcsVersionPath -> isNoneBlank(gcsVersionPath) && gcsVersionPath.endsWith("/" + version);
}
private AppException throwVersionNotFound(String id, String version) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment