Search in sources :

Example 1 with ArtifactFolder

use of com.thoughtworks.go.server.web.ArtifactFolder in project gocd by gocd.

the class LocalArtifactsView method createView.

public final ModelAndView createView(String filePath, String sha) throws Exception {
    //return the artifact itself if this is a single file
    File file = isConsoleOutput(filePath) ? consoleService.findConsoleArtifact(translatedId) : artifactsService.findArtifact(translatedId, filePath);
    if (file.exists() && file.isFile()) {
        return FileModelAndView.createFileView(file, sha);
    }
    //return the contents of the specified directory formatted as required
    //NOTE THAT THIS IS ONLY CALLED FOR JSON OR HTML
    String convertedURL = filePath.replaceFirst("\\.(html|json|zip)$", "");
    File directory = artifactsService.findArtifact(translatedId, convertedURL);
    if (directory.exists() && directory.isDirectory()) {
        ArtifactFolder folder = new ArtifactFolder(translatedId, directory, convertedURL);
        return folderViewFactory.createView(translatedId, folder);
    }
    return FileModelAndView.fileNotFound(filePath);
}
Also used : File(java.io.File) ArtifactFolder(com.thoughtworks.go.server.web.ArtifactFolder)

Example 2 with ArtifactFolder

use of com.thoughtworks.go.server.web.ArtifactFolder in project gocd by gocd.

the class ZipArtifactCacheTest method setUp.

@Before
public void setUp() throws Exception {
    folder = TestFileUtil.createTempFolder("ZipArtifactCacheTest-" + System.currentTimeMillis());
    File artifact = new File(folder, JOB_FOLDERS);
    artifact.mkdirs();
    TestFileUtil.createTestFolder(artifact, "dir");
    TestFileUtil.createTestFile(artifact, "dir/file1");
    artifactsDirHolder = context.mock(ArtifactsDirHolder.class);
    context.checking(new Expectations() {

        {
            allowing(artifactsDirHolder).getArtifactsDir();
            will(returnValue(folder));
        }
    });
    zipArtifactCache = new ZipArtifactCache(this.artifactsDirHolder, new ZipUtil());
    artifactFolder = new ArtifactFolder(JOB_IDENTIFIER, new File(artifact, "dir"), "dir");
}
Also used : Expectations(org.jmock.Expectations) ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File) ArtifactsDirHolder(com.thoughtworks.go.server.service.ArtifactsDirHolder) ArtifactFolder(com.thoughtworks.go.server.web.ArtifactFolder) Before(org.junit.Before)

Aggregations

ArtifactFolder (com.thoughtworks.go.server.web.ArtifactFolder)2 File (java.io.File)2 ArtifactsDirHolder (com.thoughtworks.go.server.service.ArtifactsDirHolder)1 ZipUtil (com.thoughtworks.go.util.ZipUtil)1 Expectations (org.jmock.Expectations)1 Before (org.junit.Before)1