.bind("Mixing {0} and {1} parameters is not allowed.", new Object[] { ProtocolConstants.KEY_PATH, GitConstants.KEY_TAG_COMMIT });
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
}
JSONArray paths = toReset.optJSONArray(ProtocolConstants.KEY_PATH);
Git git = new Git(db);
ResetCommand reset = git.reset().setRef(Constants.HEAD);
if (paths != null) {
for (int i = 0; i < paths.length(); i++) {
reset.addPath(paths.getString(i));
}
} else {
// path format is /file/{workspaceId}/{projectName}[/{path}]
String projectRelativePath = path.removeFirstSegments(3).toString();
if (projectRelativePath.isEmpty()) {
String msg = "Path cannot be empty.";
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
}
reset.addPath(projectRelativePath);
}
try {
reset.call();
} catch (GitAPIException e) {
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), e));
}
return true;
}