} else if (RpcRequest.CREATE_REPOSITORY.equals(reqType)) {\r
// create repository\r
RepositoryModel model = deserialize(request, response, RepositoryModel.class);\r
- GitBlit.self().updateRepositoryModel(model.name, model, true);\r
+ try {\r
+ GitBlit.self().updateRepositoryModel(model.name, model, true);\r
+ } catch (GitBlitException e) {\r
+ response.setStatus(failureCode);\r
+ }\r
} else if (RpcRequest.EDIT_REPOSITORY.equals(reqType)) {\r
// edit repository\r
RepositoryModel model = deserialize(request, response, RepositoryModel.class);\r
if (repoName == null) {\r
repoName = model.name;\r
}\r
- GitBlit.self().updateRepositoryModel(repoName, model, false);\r
+ try {\r
+ GitBlit.self().updateRepositoryModel(repoName, model, false);\r
+ } catch (GitBlitException e) {\r
+ response.setStatus(failureCode);\r
+ }\r
} else if (RpcRequest.DELETE_REPOSITORY.equals(reqType)) {\r
// delete repository\r
RepositoryModel model = deserialize(request, response, RepositoryModel.class);\r
} else if (RpcRequest.CREATE_USER.equals(reqType)) {\r
// create user\r
UserModel model = deserialize(request, response, UserModel.class);\r
- GitBlit.self().updateUserModel(model.username, model, true);\r
+ try {\r
+ GitBlit.self().updateUserModel(model.username, model, true);\r
+ } catch (GitBlitException e) {\r
+ response.setStatus(failureCode);\r
+ }\r
} else if (RpcRequest.EDIT_USER.equals(reqType)) {\r
// edit user\r
UserModel model = deserialize(request, response, UserModel.class);\r
if (username == null) {\r
username = model.username;\r
}\r
- GitBlit.self().updateUserModel(username, model, false);\r
+ try {\r
+ GitBlit.self().updateUserModel(username, model, false);\r
+ } catch (GitBlitException e) {\r
+ response.setStatus(failureCode);\r
+ }\r
} else if (RpcRequest.DELETE_USER.equals(reqType)) {\r
// delete user\r
UserModel model = deserialize(request, response, UserModel.class);\r
- GitBlit.self().deleteUser(model.username);\r
+ if (!GitBlit.self().deleteUser(model.username)) {\r
+ response.setStatus(failureCode);\r
+ }\r
} else if (RpcRequest.LIST_REPOSITORY_MEMBERS.equals(reqType)) {\r
// get repository members\r
RepositoryModel model = GitBlit.self().getRepositoryModel(objectName);\r
Collection<String> names = deserialize(request, response, RpcUtils.NAMES_TYPE);\r
List<String> users = new ArrayList<String>(names);\r
if (!GitBlit.self().setRepositoryUsers(model, users)) {\r
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);\r
+ response.setStatus(failureCode);\r
}\r
} else if (RpcRequest.LIST_FEDERATION_REGISTRATIONS.equals(reqType)) {\r
// return the list of federation registrations\r
if (GitBlit.canFederate()) {\r
result = GitBlit.self().getFederationResultRegistrations();\r
} else {\r
- response.sendError(HttpServletResponse.SC_FORBIDDEN);\r
+ response.sendError(notAllowedCode);\r
}\r
} else if (RpcRequest.LIST_FEDERATION_PROPOSALS.equals(reqType)) {\r
// return the list of federation proposals\r
if (GitBlit.canFederate()) {\r
result = GitBlit.self().getPendingFederationProposals();\r
} else {\r
- response.sendError(HttpServletResponse.SC_FORBIDDEN);\r
+ response.sendError(notAllowedCode);\r
}\r
} else if (RpcRequest.LIST_FEDERATION_SETS.equals(reqType)) {\r
// return the list of federation sets\r
String gitblitUrl = HttpUtils.getGitblitURL(request);\r
result = GitBlit.self().getFederationSets(gitblitUrl);\r
} else {\r
- response.sendError(HttpServletResponse.SC_FORBIDDEN);\r
+ response.sendError(notAllowedCode);\r
}\r
} else if (RpcRequest.LIST_SETTINGS.equals(reqType)) {\r
// return the server's settings\r
- Properties settings = new Properties(); \r
+ Properties settings = new Properties();\r
List<String> keys = GitBlit.getAllKeys(null);\r
- for (String key:keys) {\r
+ for (String key : keys) {\r
String value = GitBlit.getString(key, null);\r
if (value != null) {\r
settings.put(key, value);\r