RED-7185 - Fix comment too long #139
@ -15,6 +15,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -99,6 +100,7 @@ public class ManualRedactionService {
|
|||||||
private final RedactionLogService redactionLogService;
|
private final RedactionLogService redactionLogService;
|
||||||
|
|
||||||
private final HashFunction hashFunction = Hashing.murmur3_128();
|
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) {
|
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) {
|
private CommentEntity addComment(String fileId, String annotationId, String comment, String user) {
|
||||||
|
|
||||||
|
checkComment(comment);
|
||||||
return commentPersistenceService.insert(CommentEntity.builder()
|
return commentPersistenceService.insert(CommentEntity.builder()
|
||||||
.text(comment)
|
.text(comment)
|
||||||
.fileId(fileId)
|
.fileId(fileId)
|
||||||
@ -924,6 +926,12 @@ public class ManualRedactionService {
|
|||||||
.build());
|
.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,
|
private boolean handleAddToDictionary(String fileId,
|
||||||
String annotationId,
|
String annotationId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user