db = FileRepositoryBuilder.create(gitDir);
Set<String> configNames = db.getConfig().getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
JSONObject result = new JSONObject();
JSONArray children = new JSONArray();
for (String configName : configNames) {
Remote remote = new Remote(cloneLocation, db, configName);
children.put(remote.toJSON(false));
}
result.put(ProtocolConstants.KEY_CHILDREN, children);
result.put(ProtocolConstants.KEY_TYPE, Remote.TYPE);
OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
return true;
} finally {
if (db != null) {
db.close();
}
}
} else if (p.segment(1).equals("file")) { //$NON-NLS-1$
// /git/remote/{remote}/file/{path}
RemoteDetailsJob job;
String commits = request.getParameter(GitConstants.KEY_TAG_COMMITS);
int commitsNumber = commits == null ? 0 : Integer.parseInt(commits);
String nameFilter = request.getParameter("filter");
String page = request.getParameter("page");
if (page != null) {
int pageNo = Integer.parseInt(page);
int pageSize = request.getParameter("pageSize") == null ? PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
job = new RemoteDetailsJob(TaskJobHandler.getUserId(request), p.segment(0), p.removeFirstSegments(1), BaseToCloneConverter.getCloneLocation(
getURI(request), BaseToCloneConverter.REMOTE), commitsNumber, pageNo, pageSize, request.getRequestURI(), nameFilter);
} else {
job = new RemoteDetailsJob(TaskJobHandler.getUserId(request), p.segment(0), p.removeFirstSegments(1), BaseToCloneConverter.getCloneLocation(
getURI(request), BaseToCloneConverter.REMOTE), commitsNumber, nameFilter);
}
return TaskJobHandler.handleTaskJob(request, response, job, statusHandler, JsonURIUnqualificationStrategy.ALL_NO_GIT);
} else if (p.segment(2).equals("file")) { //$NON-NLS-1$
// /git/remote/{remote}/{branch}/file/{path}
File gitDir = GitUtils.getGitDir(p.removeFirstSegments(2));
URI cloneLocation = BaseToCloneConverter.getCloneLocation(getURI(request), BaseToCloneConverter.REMOTE_BRANCH);
Repository db = null;
try {
db = FileRepositoryBuilder.create(gitDir);
Remote remote = new Remote(cloneLocation, db, p.segment(0));
RemoteBranch remoteBranch = new RemoteBranch(cloneLocation, db, remote, GitUtils.decode(p.segment(1)));
if (remoteBranch.exists()) {
JSONObject result = remoteBranch.toJSON();
OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
return true;