use of org.eclipse.openvsx.json.ResultJson in project openvsx by eclipse.
the class AdminService method editNamespaceMember.
@Transactional(rollbackOn = ErrorResultException.class)
public ResultJson editNamespaceMember(String namespaceName, String userName, String provider, String role, UserData admin) throws ErrorResultException {
var namespace = repositories.findNamespace(namespaceName);
if (namespace == null) {
throw new ErrorResultException("Namespace not found: " + namespaceName);
}
var user = repositories.findUserByLoginName(provider, userName);
if (user == null) {
throw new ErrorResultException("User not found: " + provider + "/" + userName);
}
ResultJson result;
if (role.equals("remove")) {
result = users.removeNamespaceMember(namespace, user);
} else {
result = users.addNamespaceMember(namespace, user, role);
}
for (var extension : repositories.findActiveExtensions(namespace)) {
search.updateSearchEntry(extension);
}
logAdminAction(admin, result);
return result;
}
use of org.eclipse.openvsx.json.ResultJson in project openvsx by eclipse.
the class AdminAPI method deleteExtension.
@PostMapping(path = "/admin/extension/{namespaceName}/{extensionName}/delete", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResultJson> deleteExtension(@PathVariable String namespaceName, @PathVariable String extensionName, @RequestBody(required = false) List<String> versions) {
try {
ResultJson result;
var adminUser = admins.checkAdminUser();
if (versions == null) {
result = admins.deleteExtension(namespaceName, extensionName, adminUser);
} else {
var results = new ArrayList<ResultJson>();
for (var version : versions) {
results.add(admins.deleteExtensionVersion(namespaceName, extensionName, version, adminUser));
}
result = new ResultJson();
result.error = results.stream().map(r -> r.error).filter(Objects::nonNull).collect(Collectors.joining("\n"));
result.success = results.stream().map(r -> r.success).filter(Objects::nonNull).collect(Collectors.joining("\n"));
}
return ResponseEntity.ok(result);
} catch (ErrorResultException exc) {
return exc.toResponseEntity();
}
}
Aggregations