com.teamscale.commons.links.TeamscaleLinkProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-commons Show documentation
Show all versions of teamscale-commons Show documentation
Provides common DTOs for Teamscale
/*
* Copyright (c) CQSE GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.teamscale.commons.links;
import org.conqat.lib.commons.string.StringUtils;
/**
* Helper class for obtaining links to global services of the current Teamscale
* instance.
*/
public class TeamscaleLinkProvider {
/** The base URL of the Teamscale instance. */
protected final String baseUrl;
public TeamscaleLinkProvider(String baseUrl) {
if (StringUtils.isEmpty(baseUrl)) {
baseUrl = "https://no-teamscale-base-url-configured-in-teamscale-server-options.com";
}
this.baseUrl = StringUtils.ensureEndsWith(baseUrl, "/");
}
/** Returns the URL for the static findings badge. */
public String createStaticFindingsBadgeUrl(int addedFindings, int inChangedCodeFindings, int removedFindings) {
String badgeServiceUrl = "api/badges/findings/static";
return baseUrl + badgeServiceUrl + "?added=" + addedFindings + "&changed=" + inChangedCodeFindings + "&removed="
+ removedFindings;
}
/** Returns the URL for the static spec items badge. */
public String createStaticSpecItemsBadgeUrl(int affectedSpecItems) {
String badgeServiceUrl = "api/badges/spec-items/static";
return baseUrl + badgeServiceUrl + "?affectedItems=" + affectedSpecItems;
}
/**
* Returns a link to the Teamscale logo (with gray 'Teamscale' text). We use a
* PNG here (no SVG) as this is guaranteed to be rendered in the correct size.
*/
public String createTeamscaleLogoLink() {
return baseUrl + "images/teamscale-logo-gray-text.png";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy