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

com.clarolab.bamboo.entities.BambooArtifact Maven / Gradle / Ivy

package com.clarolab.bamboo.entities;

import com.clarolab.bamboo.client.BambooApiClient;
import com.clarolab.bamboo.utils.UrlUtils;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.io.FilenameUtils;
import org.apache.http.auth.AuthenticationException;

import java.io.IOException;
import java.net.URISyntaxException;

@Getter
@Setter
@ToString
public class BambooArtifact {

    private BambooApiClient bambooApiClient;
    @ToString.Include
    private String name;
    @ToString.Include
    @SerializedName("producerJobKey")
    private String jobKey;
    @ToString.Include
    private BambooLink link;

    public String getContent() throws URISyntaxException, IOException, AuthenticationException {
        return bambooApiClient.getHttpClient().get(UrlUtils.getEndpoint(link.getHref()).toString());
    }

    public String getResourceLink(){
        return link.getHref();
    }

    public String getResourceName(){
        return getResourceLink().substring(getResourceLink().lastIndexOf("/") + 1);
    }

    public String getResourceExtension(){
        return FilenameUtils.getExtension(getResourceName());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy