com.synopsys.integration.blackduck.http.BlackDuckUrl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blackduck-common Show documentation
Show all versions of blackduck-common Show documentation
A library for using various capabilities of Black Duck, notably the REST API and signature scanning.
/*
* blackduck-common
*
* Copyright (c) 2021 Synopsys, Inc.
*
* Use subject to the terms and conditions of the Synopsys End User Software License and Maintenance Agreement. All rights reserved worldwide.
*/
package com.synopsys.integration.blackduck.http;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.synopsys.integration.rest.HttpUrl;
/**
* A url of the form:
* https://{black_duck_hostname}/api/{searchTerm1}/{searchTerm1Id}/
* {searchTerm2}/{searchTerm2Id}/{searchTerm3}/{searchTerm3Id}...
*/
public class BlackDuckUrl {
private final HttpUrl url;
public BlackDuckUrl(HttpUrl url) {
this.url = url;
}
public String parseId(List searchTerms) {
String searching = url.string();
int afterLastTermIndex = -1;
for (BlackDuckUrlSearchTerm searchTerm : searchTerms) {
afterLastTermIndex = searching.indexOf(searchTerm.getTerm(), afterLastTermIndex) + 1;
}
int afterFirstSlashIndex = searching.indexOf('/', afterLastTermIndex) + 1;
int secondSlashIndex = searching.indexOf('/', afterFirstSlashIndex);
int end = secondSlashIndex > afterFirstSlashIndex ? secondSlashIndex : searching.length();
searching = searching.substring(afterFirstSlashIndex, end);
return searching;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy