RED-7185 - Fix comment too long #139

Merged
andrei.isvoran.ext merged 1 commits from RED-7185-comments into release/1.363.x 2023-09-25 13:17:44 +02:00

View File

@ -15,6 +15,7 @@ import java.util.stream.Collectors;
import javax.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@ -99,6 +100,7 @@ public class ManualRedactionService {
private final RedactionLogService redactionLogService;
private final HashFunction hashFunction = Hashing.murmur3_128();
private final int COMMENT_MAX_LENGTH = 4000;
public List<ManualAddResponse> addAddRedaction(String dossierId, String fileId, List<AddRedactionRequest> addRedactionRequests) {
@ -912,9 +914,9 @@ public class ManualRedactionService {
}
}
private CommentEntity addComment(String fileId, String annotationId, String comment, String user) {
checkComment(comment);
return commentPersistenceService.insert(CommentEntity.builder()
.text(comment)
.fileId(fileId)
@ -924,6 +926,12 @@ public class ManualRedactionService {
.build());
}
private void checkComment(String text) {
if (!StringUtils.isEmpty(text) && text.length() >= COMMENT_MAX_LENGTH) {
throw new BadRequestException(String.format("The comment is too long (%s), max length %s", text.length(), COMMENT_MAX_LENGTH));
}
}
private boolean handleAddToDictionary(String fileId,
String annotationId,