Smile 4892 DocumentReference Attachment url (#4237)
* failing test * fix * increase test Attachment url size to new max * decrease limit to 500 * ci fix Co-authored-by: nathaniel.doef <nathaniel.doef@smilecdr.com>
This commit is contained in:
parent
590ddf1627
commit
52aa09ff0c
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 4240
|
||||
jira: SMILE-4892
|
||||
title: "Previously, when creating a `DocumentReference` with an `Attachment` containing a URL over 254 characters
|
||||
an error was thrown. This has been corrected and now an `Attachment` URL can be up to 500 characters."
|
|
@ -103,6 +103,11 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
|||
.modifyColumn("20221017.1", "BLOB_SIZE")
|
||||
.nullable()
|
||||
.withType(ColumnTypeEnum.LONG);
|
||||
|
||||
version.onTable("HFJ_SPIDX_URI")
|
||||
.modifyColumn("20221103.1", "SP_URI")
|
||||
.nullable()
|
||||
.withType(ColumnTypeEnum.STRING, 500);
|
||||
}
|
||||
|
||||
private void init610() {
|
||||
|
|
|
@ -59,9 +59,11 @@ import static org.apache.commons.lang3.StringUtils.defaultString;
|
|||
public class ResourceIndexedSearchParamUri extends BaseResourceIndexedSearchParam {
|
||||
|
||||
/*
|
||||
* Note that MYSQL chokes on unique indexes for lengths > 255 so be careful here
|
||||
* Be careful when modifying this value
|
||||
* MySQL chokes on indexes with combined column length greater than 3052 bytes (768 chars)
|
||||
* https://dev.mysql.com/doc/refman/8.0/en/innodb-limits.html
|
||||
*/
|
||||
public static final int MAX_LENGTH = 254;
|
||||
public static final int MAX_LENGTH = 500;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column(name = "SP_URI", nullable = true, length = MAX_LENGTH)
|
||||
|
|
|
@ -130,6 +130,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.util.AopTestUtils;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
|
@ -4823,6 +4824,33 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDocumentReferenceWith500CharAttachmentUrl() throws IOException {
|
||||
final DocumentReference.ReferredDocumentStatus docStatus = DocumentReference.ReferredDocumentStatus.FINAL;
|
||||
final String longUrl = StringUtils.repeat("a", 500);
|
||||
|
||||
DocumentReference submittedDocumentReference = new DocumentReference();
|
||||
submittedDocumentReference.setDocStatus(docStatus);
|
||||
|
||||
Attachment attachment = new Attachment();
|
||||
attachment.setUrl(longUrl);
|
||||
submittedDocumentReference.getContentFirstRep().setAttachment(attachment);
|
||||
|
||||
String json = myFhirContext.newJsonParser().encodeResourceToString(submittedDocumentReference);
|
||||
HttpPost post = new HttpPost(ourServerBase + "/DocumentReference");
|
||||
post.setEntity(new StringEntity(json, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
||||
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(post)) {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(resp);
|
||||
assertEquals(HttpStatus.CREATED.value(), response.getStatusLine().getStatusCode());
|
||||
|
||||
DocumentReference createdDocumentReferenced = myFhirContext.newJsonParser().parseResource(DocumentReference.class, resp);
|
||||
assertEquals(docStatus, createdDocumentReferenced.getDocStatus());
|
||||
assertEquals(longUrl, createdDocumentReferenced.getContentFirstRep().getAttachment().getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
private String toStr(Date theDate) {
|
||||
return new InstantDt(theDate).getValueAsString();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
|
Loading…
Reference in New Issue