Search in sources :

Example 1 with StringUtil

use of jetbrains.buildServer.util.StringUtil in project teamcity-rest by JetBrains.

the class FederationRequest method addServer.

@PUT
@Path("/servers")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
public FederationServers addServer(FederationServers servers) {
    if (servers.servers.stream().map(FederationServer::getUrl).anyMatch(StringUtil::isEmpty)) {
        throw new BadRequestException("Server url cannot be empty.");
    }
    ConnectedServers connectedServers = myServiceLocator.getSingletonService(ConnectedServers.class);
    myPermissionChecker.checkGlobalPermission(connectedServers.getRequiredPermissionForSetServers());
    connectedServers.setAttachedServer(servers.servers.stream().map(server -> new TeamCityServer(server.getUrl(), server.getName())).collect(toList()));
    return servers;
}
Also used : TeamCityServer(jetbrains.buildServer.federation.TeamCityServer) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) StringUtil(jetbrains.buildServer.util.StringUtil) ConnectedServers(jetbrains.buildServer.federation.ConnectedServers)

Aggregations

ConnectedServers (jetbrains.buildServer.federation.ConnectedServers)1 TeamCityServer (jetbrains.buildServer.federation.TeamCityServer)1 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)1 StringUtil (jetbrains.buildServer.util.StringUtil)1