 ClsiManager = require '../Compile/ClsiManager'
 ProjectFileAgent = require './ProjectFileAgent'
 _ = require "underscore"
-LinkedFilesErrors = require './LinkedFilesErrors'
+{
+	BadDataError,
+	AccessDeniedError,
+	BadEntityTypeError,
+	OutputFileFetchFailedError
+} = require './LinkedFilesErrors'
 LinkedFilesHandler = require './LinkedFilesHandler'
 logger = require 'logger-sharelatex'
 

	_prepare: (project_id, linkedFileData, user_id, callback=(err, linkedFileData)->) ->
		@_checkAuth project_id, linkedFileData, user_id, (err, allowed) =>
			return callback(err) if err?
			return callback(new LinkedFilesErrors.AccessDeniedError()) if !allowed
			@_decorateLinkedFileData linkedFileData, (err, newLinkedFileData) =>
				return callback(err) if err?
				if !@_validate(newLinkedFileData)

								return callback(err) if err?
								callback(null, file._id) # Created
					else
						err = new OutputFileFetchFailedError(
							"Output file fetch failed: #{linkedFileData.build_id}, #{linkedFileData.source_output_file_path}"
						)
						err.statusCode = response.statusCode
