2014-02-12 10:23:40 +00:00
|
|
|
ProjectEntityHandler = require "../Project/ProjectEntityHandler"
|
|
|
|
Errors = require "../../errors"
|
|
|
|
logger = require("logger-sharelatex")
|
|
|
|
|
2014-05-08 12:42:30 +00:00
|
|
|
module.exports =
|
2014-02-12 10:23:40 +00:00
|
|
|
getDocument: (req, res, next = (error) ->) ->
|
|
|
|
project_id = req.params.Project_id
|
|
|
|
doc_id = req.params.doc_id
|
|
|
|
logger.log doc_id:doc_id, project_id:project_id, "receiving get document request from api (docupdater)"
|
2014-05-15 11:44:08 +00:00
|
|
|
ProjectEntityHandler.getDoc project_id, doc_id, (error, lines, rev) ->
|
2014-02-12 10:23:40 +00:00
|
|
|
if error?
|
|
|
|
logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument"
|
|
|
|
return next(error)
|
|
|
|
res.type "json"
|
|
|
|
res.send JSON.stringify {
|
2014-05-08 12:42:30 +00:00
|
|
|
lines: lines
|
2014-02-12 10:23:40 +00:00
|
|
|
}
|
|
|
|
req.session.destroy()
|
|
|
|
|
|
|
|
setDocument: (req, res, next = (error) ->) ->
|
|
|
|
project_id = req.params.Project_id
|
|
|
|
doc_id = req.params.doc_id
|
|
|
|
lines = req.body.lines
|
|
|
|
logger.log doc_id:doc_id, project_id:project_id, "receiving set document request from api (docupdater)"
|
2014-05-15 11:44:08 +00:00
|
|
|
ProjectEntityHandler.updateDocLines project_id, doc_id, lines, (error) ->
|
2014-02-12 10:23:40 +00:00
|
|
|
if error?
|
|
|
|
logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument"
|
|
|
|
return next(error)
|
|
|
|
res.send 200
|
|
|
|
req.session.destroy()
|
|
|
|
|
|
|
|
|
|
|
|
|