def wopiRenameFile(fileid, reqheaders, acctok):
'''Implements the RenameFile WOPI call. This seems to be broken in Office Online, thus it is disabled for the time being.'''
targetName = reqheaders['X-WOPI-RequestedName']
lock = reqheaders['X-WOPI-Lock']
retrievedLock = _retrieveWopiLock(fileid, 'RENAMEFILE', lock, acctok)
if retrievedLock != None and not _compareWopiLocks(retrievedLock, lock):
return _makeConflictResponse('RENAMEFILE', retrievedLock, lock, '', acctok['filename'])
try:
# the destination name comes without base path and without extension
targetName = os.path.dirname(acctok['filename']) + '/' + targetName + os.path.splitext(acctok['filename'])[1]
Wopi.log.info('msg="RenameFile" user="%s:%s" filename="%s" token="%s" targetname="%s"' % \
(acctok['ruid'], acctok['rgid'], acctok['filename'], flask.request.args['access_token'][-20:], targetName))
xrdcl.renamefile(acctok['filename'], targetName, acctok['ruid'], acctok['rgid'])
xrdcl.renamefile(_getLockName(acctok['filename']), _getLockName(targetName), Wopi.lockruid, Wopi.lockrgid)
# prepare and send the response as JSON
renamemd = {}
renamemd['Name'] = reqheaders['X-WOPI-RequestedName']
return flask.Response(json.dumps(renamemd), mimetype='application/json')
except IOError, e:
# assume the rename failed because of the destination filename and report the error
Wopi.log.info('msg="RenameFile" token="%s" error="%s"' % (flask.request.args['access_token'][-20:], e))
resp = flask.Response()
resp.headers['X-WOPI-InvalidFileNameError'] = 'Failed to rename: %s' % e
resp.status_code = httplib.BAD_REQUEST
return resp
评论列表
文章目录