String resource = request.getResource();
File rootPath = new File(context.getRootPagePath());
final File pathName = new File(rootPath, resource);
if (!FileResponder.isInFilesDirectory(rootPath, pathName)) {
return new ErrorResponder("Invalid path: " + resource).makeResponse(context, request);
}
final String oldFileName = (String) request.getInput("filename");
final String newFileName = ((String) request.getInput("newName")).trim();
final File oldFile = new File(pathName, oldFileName);
final File newFile = new File(pathName, newFileName);
if (!FileResponder.isInFilesDirectory(rootPath, oldFile)) {
return new ErrorResponder("Invalid path: " + oldFileName).makeResponse(context, request);
}
if (!FileResponder.isInFilesDirectory(rootPath, newFile)) {
return new ErrorResponder("Invalid path: " + newFileName).makeResponse(context, request);
}
context.versionsController.rename(new FileVersion() {
@Override