null));
Repository db = null;
try {
db = FileRepositoryBuilder.create(gitDir);
URI cloneLocation = BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.CONFIG);
ConfigOption configOption = new ConfigOption(cloneLocation, db);
OrionServlet.writeJSONResponse(request, response, configOption.toJSON(/* all */), JsonURIUnqualificationStrategy.ALL_NO_GIT);
return true;
} finally {
if (db != null) {
db.close();
}
}
} else if (p.segment(1).equals(Clone.RESOURCE) && p.segment(2).equals("file")) { //$NON-NLS-1$
// expected path /gitapi/config/{key}/clone/file/{path}
File gitDir = GitUtils.getGitDir(p.removeFirstSegments(2));
if (gitDir == null)
return statusHandler.handleRequest(request, response,
new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No repository found under {0}", p.removeFirstSegments(2)),
null));
URI cloneLocation = BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.CONFIG_OPTION);
Repository db = null;
try {
db = FileRepositoryBuilder.create(gitDir);
ConfigOption configOption = new ConfigOption(cloneLocation, db, p.segment(0));
if (!configOption.exists())
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND,
"There is no config entry with key provided", null));
OrionServlet.writeJSONResponse(request, response, configOption.toJSON(), JsonURIUnqualificationStrategy.ALL_NO_GIT);
return true;
} catch (IllegalArgumentException e) {
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), e));
} finally {
if (db != null) {