public void FileNameCanBeSetAndRetrieved() { var request = new FileTransferRequest(); var projectName = "projectName"; request.FileName = projectName; Assert.AreEqual(projectName, request.FileName); }
public void FullConstructorInitialisesTheValues() { var sessionId = "MyNewSession"; var projectName = "projectName"; var fileName = "fileName"; var request = new FileTransferRequest(sessionId, projectName, fileName); Assert.AreEqual(sessionId, request.SessionToken); Assert.AreEqual(projectName, request.ProjectName); Assert.AreEqual(fileName, request.FileName); }
/// <summary> /// Retrieves a file transfer instance. /// </summary> /// <param name="projectName">The name of the project.</param> /// <param name="fileName">The name of the file.</param> /// <returns>The file transfer instance.</returns> public override IFileTransfer RetrieveFileTransfer(string projectName, string fileName) { if (string.IsNullOrEmpty(projectName)) throw new ArgumentNullException("projectName"); var request = new FileTransferRequest(SessionToken, projectName, fileName); request.ServerName = TargetServer; var response = connection.SendMessage("RetrieveFileTransfer", request); ValidateResponse(response); return (response as FileTransferResponse).FileTransfer; }
/// <summary> /// Retrieve a file transfer object. /// </summary> public FileTransferResponse RetrieveFileTransfer(FileTransferRequest request) { return cruiseServer.RetrieveFileTransfer(request); }
/// <summary> /// Retrieve a file transfer object. /// </summary> /// <param name="project">The project to retrieve the file for.</param> /// <param name="fileName">The name of the file.</param> public virtual RemotingFileTransfer RetrieveFileTransfer(string project, string fileName) { var request = new FileTransferRequest(); request.ProjectName = project; request.FileName = fileName; var response = cruiseServer.RetrieveFileTransfer(request); ValidateResponse(response); return response.FileTransfer as RemotingFileTransfer; }
/// <summary> /// Retrieve a file transfer object. /// </summary> /// <param name="request"></param> public virtual FileTransferResponse RetrieveFileTransfer(FileTransferRequest request) { var response = new FileTransferResponse(request); try { // Validate that the path is valid var sourceProject = GetIntegrator(request.ProjectName).Project; var filePath = Path.Combine(sourceProject.ArtifactDirectory, request.FileName); var fileInfo = new FileInfo(filePath); if (!fileInfo.FullName.StartsWith(sourceProject.ArtifactDirectory, StringComparison.OrdinalIgnoreCase)) { var message = string.Format(CultureInfo.CurrentCulture, "Files can only be retrieved from the artefact folder - unable to retrieve {0}", request.FileName); Log.Warning(message); throw new CruiseControlException(message); } else if (fileInfo.FullName.StartsWith(Path.Combine(sourceProject.ArtifactDirectory, "buildlogs"), StringComparison.OrdinalIgnoreCase)) { var message = string.Format(CultureInfo.CurrentCulture, "Unable to retrieve files from the build logs folder - unable to retrieve {0}", request.FileName); Log.Warning(message); throw new CruiseControlException(message); } RemotingFileTransfer fileTransfer = null; if (fileInfo.Exists) { Log.Debug(string.Format(CultureInfo.CurrentCulture, "Retrieving file '{0}' from '{1}'", request.FileName, request.ProjectName)); fileTransfer = new RemotingFileTransfer(File.OpenRead(filePath)); } else { Log.Warning(string.Format(CultureInfo.CurrentCulture, "Unable to find file '{0}' in '{1}'", request.FileName, request.ProjectName)); } response.FileTransfer = fileTransfer; response.Result = ResponseResult.Success; } catch (Exception error) { response.Result = ResponseResult.Failure; response.ErrorMessages.Add( new ErrorMessage(error.Message)); } return response; }
public void SessionConstructorInitialisesTheValues() { var sessionId = "MyNewSession"; var request = new FileTransferRequest(sessionId); Assert.AreEqual(sessionId, request.SessionToken); }
/// <summary> /// Retrieve a file transfer object. /// </summary> public virtual FileTransferResponse RetrieveFileTransfer(FileTransferRequest request) { return server.RetrieveFileTransfer(request); }