Search in sources :

Example 1 with ArtifactsView

use of com.thoughtworks.go.server.view.artifacts.ArtifactsView in project gocd by gocd.

the class ArtifactsController method getArtifact.

ModelAndView getArtifact(String filePath, ArtifactFolderViewFactory folderViewFactory, String pipelineName, String counterOrLabel, String stageName, String stageCounter, String buildName, String sha, String serverAlias) throws Exception {
    LOGGER.info(String.format("[Artifact Download] Trying to resolve '%s' for '%s/%s/%s/%s/%s'", filePath, pipelineName, counterOrLabel, stageName, stageCounter, buildName));
    long before = System.currentTimeMillis();
    ArtifactsView view;
    //Work out the job that we are trying to retrieve
    JobIdentifier translatedId;
    try {
        translatedId = restfulService.findJob(pipelineName, counterOrLabel, stageName, stageCounter, buildName);
    } catch (Exception e) {
        return buildNotFound(pipelineName, counterOrLabel, stageName, stageCounter, buildName);
    }
    if (filePath.contains("..")) {
        return FileModelAndView.forbiddenUrl(filePath);
    }
    view = new LocalArtifactsView(folderViewFactory, artifactsService, translatedId, consoleService);
    ModelAndView createdView = view.createView(filePath, sha);
    LOGGER.info(String.format("[Artifact Download] Successfully resolved '%s' for '%s/%s/%s/%s/%s'. It took: %sms", filePath, pipelineName, counterOrLabel, stageName, stageCounter, buildName, System.currentTimeMillis() - before));
    return createdView;
}
Also used : FileModelAndView(com.thoughtworks.go.server.web.FileModelAndView) ModelAndView(org.springframework.web.servlet.ModelAndView) LocalArtifactsView(com.thoughtworks.go.server.view.artifacts.LocalArtifactsView) ArtifactsView(com.thoughtworks.go.server.view.artifacts.ArtifactsView) LocalArtifactsView(com.thoughtworks.go.server.view.artifacts.LocalArtifactsView) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) IllegalArtifactLocationException(com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)

Aggregations

JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)1 ArtifactsView (com.thoughtworks.go.server.view.artifacts.ArtifactsView)1 LocalArtifactsView (com.thoughtworks.go.server.view.artifacts.LocalArtifactsView)1 FileModelAndView (com.thoughtworks.go.server.web.FileModelAndView)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1