Return 204 No Content if project/group description was deleted by PUT
Change-Id: I110ee16aacfc898326f2565be716ef8fea0aad4b Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -47,13 +47,11 @@ public class PutDescription implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<String> apply(GroupResource resource, Input input)
|
||||
public Object apply(GroupResource resource, Input input)
|
||||
throws MethodNotAllowedException, AuthException, NoSuchGroupException,
|
||||
ResourceNotFoundException, OrmException {
|
||||
boolean delete = false;
|
||||
if (input == null) {
|
||||
input = new Input(); // Delete would set description to null.
|
||||
delete = true;
|
||||
}
|
||||
|
||||
if (resource.toAccountGroup() == null) {
|
||||
@@ -72,9 +70,8 @@ public class PutDescription implements RestModifyView<GroupResource, Input> {
|
||||
db.accountGroups().update(Collections.singleton(group));
|
||||
groupCache.evict(group);
|
||||
|
||||
if (delete) {
|
||||
return Response.none();
|
||||
}
|
||||
return Response.ok(Strings.nullToEmpty(input.description));
|
||||
return Strings.isNullOrEmpty(input.description)
|
||||
? Response.none()
|
||||
: input.description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +57,11 @@ class PutDescription implements RestModifyView<ProjectResource, Input> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<String> apply(ProjectResource resource, Input input)
|
||||
public Object apply(ProjectResource resource, Input input)
|
||||
throws AuthException, BadRequestException, ResourceConflictException,
|
||||
ResourceNotFoundException, IOException {
|
||||
boolean delete = false;
|
||||
if (input == null) {
|
||||
input = new Input(); // Delete would set description to null.
|
||||
delete = true;
|
||||
}
|
||||
|
||||
ProjectControl ctl = resource.getControl();
|
||||
@@ -93,10 +91,9 @@ class PutDescription implements RestModifyView<ProjectResource, Input> {
|
||||
resource.getNameKey(),
|
||||
project.getDescription());
|
||||
|
||||
if (delete) {
|
||||
return Response.none();
|
||||
}
|
||||
return Response.ok(Strings.nullToEmpty(project.getDescription()));
|
||||
return Strings.isNullOrEmpty(project.getDescription())
|
||||
? Response.none()
|
||||
: project.getDescription();
|
||||
} finally {
|
||||
md.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user