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);
}
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");
}
Aggregations