Skip to content
Snippets Groups Projects
Commit dceb31d4 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Make use of prepare methods for CommentServiceImpl

This enables the manipulation of Comments (creatorId) before creation
for API v3.

Closes !80.
parent 01785180
Branches
1 merge request!89Foundation for development of version 3.0
......@@ -120,11 +120,7 @@ public class CommentController extends PaginationController {
de.thm.arsnova.entities.Comment commentV3 = fromV2Migrator.migrate(comment);
Room roomV3 = roomService.getByShortId(roomShortId);
commentV3.setRoomId(roomV3.getId());
if (commentService.save(commentV3)) {
return;
}
throw new BadRequestException();
commentService.create(commentV3);
}
@ApiOperation(value = "Deletes a Comment",
......
......@@ -7,8 +7,6 @@ import java.io.IOException;
import java.util.List;
public interface CommentService extends EntityService<Comment> {
boolean save(Comment comment);
int count(String roomId);
CommentReadingCount countRead(String roomId, String username);
......
......@@ -55,7 +55,7 @@ public class CommentServiceImpl extends DefaultEntityServiceImpl<Comment> implem
@Override
@PreAuthorize("isAuthenticated()")
public boolean save(final Comment comment) {
public void prepareCreate(final Comment comment) {
final Room room = roomRepository.findOne(comment.getRoomId());
final ClientAuthentication user = userService.getCurrentUser();
comment.setCreatorId(user.getId());
......@@ -63,14 +63,7 @@ public class CommentServiceImpl extends DefaultEntityServiceImpl<Comment> implem
if (comment.getTimestamp() == null) {
comment.setTimestamp(new Date());
}
final Comment result = super.create(comment);
if (null != result) {
final NewCommentEvent event = new NewCommentEvent(this, room, result);
this.publisher.publishEvent(event);
return true;
}
return false;
/* TODO: fire event */
}
@Override
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment