All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clarolab.bamboo.client.BambooServerClient Maven / Gradle / Ivy

Go to download

This library allows to extract information from projects, plans and builds on Bamboo

There is a newer version: 1.8
Show newest version
package com.clarolab.bamboo.client;

import com.clarolab.bamboo.entities.BambooInfo;
import com.clarolab.bamboo.utils.Constants;
import lombok.Builder;
import lombok.Data;
import lombok.extern.java.Log;
import org.apache.http.client.HttpResponseException;

@Log
@Data
public class BambooServerClient extends BambooClient{

    @Builder
    public BambooServerClient(BambooApiClient bambooApiClient) {
        super(bambooApiClient, Constants.AMOUNT_OF_ELEMENTS_TO_GET);
    }

    public String getServerVersion() throws Exception {
        return perform(Constants.BAMBOO_INFO, BambooInfo.class).getVersion();
    }

    public boolean isServerRunning(){
        try {
            return perform(Constants.BAMBOO_INFO, BambooInfo.class).getState().toLowerCase().equals(Constants.BAMBOO_STATE_OK);
        } catch (HttpResponseException re) {
            if(re.getStatusCode() == 401)
                //It means that user should be authenticated, but the server is running
                return true;
        } catch (Exception e) {
            log.info("There was an error trying to get information about bamboo server, or server is down.");
        }
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy