Search in sources :

Example 1 with ArtifactsBrowserImpl

use of jetbrains.buildServer.web.artifacts.browser.ArtifactsBrowserImpl in project teamcity-rest by JetBrains.

the class BuildArtifactsFinder method getArtifactElement.

@NotNull
public static Element getArtifactElement(@NotNull final BuildPromotion buildPromotion, @NotNull final String path, @NotNull final ServiceLocator serviceLocator) {
    final BuildPromotionEx buildPromotionEx = (BuildPromotionEx) buildPromotion;
    final BuildArtifacts artifacts = buildPromotionEx.getArtifacts(BuildArtifactsViewMode.VIEW_ALL_WITH_ARCHIVES_CONTENT);
    if (!artifacts.isAvailable()) {
        return new BuildHoldingElement(artifacts.getRootArtifact(), buildPromotion);
    }
    final BuildArtifactHolder holder = artifacts.findArtifact(path);
    if (!holder.isAvailable() && !"".equals(path)) {
        // "".equals(path) is a workaround for no artifact directory case
        return getItem(new ArtifactsBrowserImpl(artifacts), path, LogUtil.describe(buildPromotionEx), serviceLocator);
    }
    if (!holder.isAccessible()) {
        throw new AuthorizationFailedException("Artifact is not accessible with current user permissions. Relative path: '" + holder.getRelativePath() + "'");
    }
    return new BuildHoldingElement(holder.getArtifact(), buildPromotion);
}
Also used : BuildArtifactHolder(jetbrains.buildServer.serverSide.artifacts.BuildArtifactHolder) ArtifactsBrowserImpl(jetbrains.buildServer.web.artifacts.browser.ArtifactsBrowserImpl) BuildPromotionEx(jetbrains.buildServer.serverSide.BuildPromotionEx) BuildArtifacts(jetbrains.buildServer.serverSide.artifacts.BuildArtifacts) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

BuildPromotionEx (jetbrains.buildServer.serverSide.BuildPromotionEx)1 BuildArtifactHolder (jetbrains.buildServer.serverSide.artifacts.BuildArtifactHolder)1 BuildArtifacts (jetbrains.buildServer.serverSide.artifacts.BuildArtifacts)1 ArtifactsBrowserImpl (jetbrains.buildServer.web.artifacts.browser.ArtifactsBrowserImpl)1 NotNull (org.jetbrains.annotations.NotNull)1