Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1701:4aaaecae5803 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 12 Oct 2015 14:47:58 +0200 |
parents | de1413733c97 f5ddbd9239dd |
children | 9980875edc7c |
comparison
equal
deleted
inserted
replaced
1683:21d31da73374 | 1701:4aaaecae5803 |
---|---|
477 FileInfo info; | 477 FileInfo info; |
478 if (GetAttachmentInfo(info, call)) | 478 if (GetAttachmentInfo(info, call)) |
479 { | 479 { |
480 Json::Value operations = Json::arrayValue; | 480 Json::Value operations = Json::arrayValue; |
481 | 481 |
482 operations.append("compress"); | |
482 operations.append("compressed-data"); | 483 operations.append("compressed-data"); |
483 | 484 |
484 if (info.GetCompressedMD5() != "") | 485 if (info.GetCompressedMD5() != "") |
485 { | 486 { |
486 operations.append("compressed-md5"); | 487 operations.append("compressed-md5"); |
487 } | 488 } |
488 | 489 |
489 operations.append("compressed-size"); | 490 operations.append("compressed-size"); |
490 operations.append("data"); | 491 operations.append("data"); |
492 operations.append("is-compressed"); | |
491 | 493 |
492 if (info.GetUncompressedMD5() != "") | 494 if (info.GetUncompressedMD5() != "") |
493 { | 495 { |
494 operations.append("md5"); | 496 operations.append("md5"); |
495 } | 497 } |
496 | 498 |
497 operations.append("size"); | 499 operations.append("size"); |
500 operations.append("uncompress"); | |
498 | 501 |
499 if (info.GetCompressedMD5() != "" && | 502 if (info.GetCompressedMD5() != "" && |
500 info.GetUncompressedMD5() != "") | 503 info.GetUncompressedMD5() != "") |
501 { | 504 { |
502 operations.append("verify-md5"); | 505 operations.append("verify-md5"); |
657 contentType <= FileContentType_EndUser) | 660 contentType <= FileContentType_EndUser) |
658 { | 661 { |
659 // It is forbidden to delete internal attachments | 662 // It is forbidden to delete internal attachments |
660 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType); | 663 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType); |
661 call.GetOutput().AnswerBuffer("{}", "application/json"); | 664 call.GetOutput().AnswerBuffer("{}", "application/json"); |
665 } | |
666 } | |
667 | |
668 | |
669 template <enum CompressionType compression> | |
670 static void ChangeAttachmentCompression(RestApiPostCall& call) | |
671 { | |
672 CheckValidResourceType(call); | |
673 | |
674 std::string publicId = call.GetUriComponent("id", ""); | |
675 std::string name = call.GetUriComponent("name", ""); | |
676 FileContentType contentType = StringToContentType(name); | |
677 | |
678 OrthancRestApi::GetContext(call).ChangeAttachmentCompression(publicId, contentType, compression); | |
679 call.GetOutput().AnswerBuffer("{}", "application/json"); | |
680 } | |
681 | |
682 | |
683 static void IsAttachmentCompressed(RestApiGetCall& call) | |
684 { | |
685 FileInfo info; | |
686 if (GetAttachmentInfo(info, call)) | |
687 { | |
688 std::string answer = (info.GetCompressionType() == CompressionType_None) ? "0" : "1"; | |
689 call.GetOutput().AnswerBuffer(answer, "text/plain"); | |
662 } | 690 } |
663 } | 691 } |
664 | 692 |
665 | 693 |
666 // Raw access to the DICOM tags of an instance ------------------------------ | 694 // Raw access to the DICOM tags of an instance ------------------------------ |
1123 Register("/{resourceType}/{id}/metadata/{name}", SetMetadata); | 1151 Register("/{resourceType}/{id}/metadata/{name}", SetMetadata); |
1124 | 1152 |
1125 Register("/{resourceType}/{id}/attachments", ListAttachments); | 1153 Register("/{resourceType}/{id}/attachments", ListAttachments); |
1126 Register("/{resourceType}/{id}/attachments/{name}", DeleteAttachment); | 1154 Register("/{resourceType}/{id}/attachments/{name}", DeleteAttachment); |
1127 Register("/{resourceType}/{id}/attachments/{name}", GetAttachmentOperations); | 1155 Register("/{resourceType}/{id}/attachments/{name}", GetAttachmentOperations); |
1156 Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment); | |
1157 Register("/{resourceType}/{id}/attachments/{name}/compress", ChangeAttachmentCompression<CompressionType_ZlibWithSize>); | |
1128 Register("/{resourceType}/{id}/attachments/{name}/compressed-data", GetAttachmentData<0>); | 1158 Register("/{resourceType}/{id}/attachments/{name}/compressed-data", GetAttachmentData<0>); |
1129 Register("/{resourceType}/{id}/attachments/{name}/compressed-md5", GetAttachmentCompressedMD5); | 1159 Register("/{resourceType}/{id}/attachments/{name}/compressed-md5", GetAttachmentCompressedMD5); |
1130 Register("/{resourceType}/{id}/attachments/{name}/compressed-size", GetAttachmentCompressedSize); | 1160 Register("/{resourceType}/{id}/attachments/{name}/compressed-size", GetAttachmentCompressedSize); |
1131 Register("/{resourceType}/{id}/attachments/{name}/data", GetAttachmentData<1>); | 1161 Register("/{resourceType}/{id}/attachments/{name}/data", GetAttachmentData<1>); |
1162 Register("/{resourceType}/{id}/attachments/{name}/is-compressed", IsAttachmentCompressed); | |
1132 Register("/{resourceType}/{id}/attachments/{name}/md5", GetAttachmentMD5); | 1163 Register("/{resourceType}/{id}/attachments/{name}/md5", GetAttachmentMD5); |
1133 Register("/{resourceType}/{id}/attachments/{name}/size", GetAttachmentSize); | 1164 Register("/{resourceType}/{id}/attachments/{name}/size", GetAttachmentSize); |
1165 Register("/{resourceType}/{id}/attachments/{name}/uncompress", ChangeAttachmentCompression<CompressionType_None>); | |
1134 Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment); | 1166 Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment); |
1135 Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment); | |
1136 | 1167 |
1137 Register("/tools/lookup", Lookup); | 1168 Register("/tools/lookup", Lookup); |
1138 Register("/tools/find", Find); | 1169 Register("/tools/find", Find); |
1139 | 1170 |
1140 Register("/patients/{id}/studies", GetChildResources<ResourceType_Patient, ResourceType_Study>); | 1171 Register("/patients/{id}/studies", GetChildResources<ResourceType_Patient, ResourceType_Study>); |