view agent/src/jetbrains/buildServer/symbols/FileUrlProvider.java @ 29:6ac3c2491e1a

removed copyright
author Evgeniy.Koshkin
date Thu, 08 Aug 2013 19:08:42 +0400
parents 646f64aca657
children b983676b66f9
line wrap: on
line source

package jetbrains.buildServer.symbols;

import java.io.File;
import java.io.IOException;

/**
 * @author Evgeniy.Koshkin
 */
public class FileUrlProvider {
  private static final String GUEST_AUTH_APP_SOURCES = "guestAuth/app/sources";

  private final String myServerUrl;
  private final long myBuildId;
  private final File mySourcesRootDirectory;

  public FileUrlProvider(String serverUrl, long buildId, File sourcesRootDirectory) {
    myServerUrl = serverUrl;
    myBuildId = buildId;
    mySourcesRootDirectory = sourcesRootDirectory;
  }

  public String getHttpAlias() {
    return String.format("%s/%s/builds/id-%d/sources/files", myServerUrl, GUEST_AUTH_APP_SOURCES, myBuildId);
  }

  public String getFileUrl(String path) throws IOException {
    String sourcesRootDirectoryPath = mySourcesRootDirectory.getCanonicalPath();
    return path.substring(sourcesRootDirectoryPath.length() + 1).replace(File.separator, "/");
  }
}