Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1773:613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 12 Nov 2015 15:24:23 +0100 |
parents | e268412adcf1 |
children | 5ad4e4d92ecb |
comparison
equal
deleted
inserted
replaced
1772:53e045b5a8ec | 1773:613df4362575 |
---|---|
403 | 403 |
404 std::string publicId = call.GetUriComponent("id", ""); | 404 std::string publicId = call.GetUriComponent("id", ""); |
405 std::string name = call.GetUriComponent("name", ""); | 405 std::string name = call.GetUriComponent("name", ""); |
406 MetadataType metadata = StringToMetadata(name); | 406 MetadataType metadata = StringToMetadata(name); |
407 | 407 |
408 if (metadata >= MetadataType_StartUser && | 408 if (IsUserMetadata(metadata)) // It is forbidden to modify internal metadata |
409 metadata <= MetadataType_EndUser) | 409 { |
410 { | |
411 // It is forbidden to modify internal metadata | |
412 OrthancRestApi::GetIndex(call).DeleteMetadata(publicId, metadata); | 410 OrthancRestApi::GetIndex(call).DeleteMetadata(publicId, metadata); |
413 call.GetOutput().AnswerBuffer("", "text/plain"); | 411 call.GetOutput().AnswerBuffer("", "text/plain"); |
414 } | 412 } |
415 } | 413 } |
416 | 414 |
424 MetadataType metadata = StringToMetadata(name); | 422 MetadataType metadata = StringToMetadata(name); |
425 | 423 |
426 std::string value; | 424 std::string value; |
427 call.BodyToString(value); | 425 call.BodyToString(value); |
428 | 426 |
429 if (metadata >= MetadataType_StartUser && | 427 if (IsUserMetadata(metadata)) // It is forbidden to modify internal metadata |
430 metadata <= MetadataType_EndUser) | |
431 { | 428 { |
432 // It is forbidden to modify internal metadata | 429 // It is forbidden to modify internal metadata |
433 OrthancRestApi::GetIndex(call).SetMetadata(publicId, metadata, value); | 430 OrthancRestApi::GetIndex(call).SetMetadata(publicId, metadata, value); |
434 call.GetOutput().AnswerBuffer("", "text/plain"); | 431 call.GetOutput().AnswerBuffer("", "text/plain"); |
435 } | 432 } |
636 | 633 |
637 std::string publicId = call.GetUriComponent("id", ""); | 634 std::string publicId = call.GetUriComponent("id", ""); |
638 std::string name = call.GetUriComponent("name", ""); | 635 std::string name = call.GetUriComponent("name", ""); |
639 | 636 |
640 FileContentType contentType = StringToContentType(name); | 637 FileContentType contentType = StringToContentType(name); |
641 if (contentType >= FileContentType_StartUser && // It is forbidden to modify internal attachments | 638 if (IsUserContentType(contentType) && // It is forbidden to modify internal attachments |
642 contentType <= FileContentType_EndUser && | |
643 context.AddAttachment(publicId, StringToContentType(name), call.GetBodyData(), call.GetBodySize())) | 639 context.AddAttachment(publicId, StringToContentType(name), call.GetBodyData(), call.GetBodySize())) |
644 { | 640 { |
645 call.GetOutput().AnswerBuffer("{}", "application/json"); | 641 call.GetOutput().AnswerBuffer("{}", "application/json"); |
646 } | 642 } |
647 } | 643 } |
653 | 649 |
654 std::string publicId = call.GetUriComponent("id", ""); | 650 std::string publicId = call.GetUriComponent("id", ""); |
655 std::string name = call.GetUriComponent("name", ""); | 651 std::string name = call.GetUriComponent("name", ""); |
656 FileContentType contentType = StringToContentType(name); | 652 FileContentType contentType = StringToContentType(name); |
657 | 653 |
658 if (contentType >= FileContentType_StartUser && | 654 if (IsUserContentType(contentType)) // It is forbidden to delete internal attachments |
659 contentType <= FileContentType_EndUser) | 655 { |
660 { | |
661 // It is forbidden to delete internal attachments | |
662 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType); | 656 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType); |
663 call.GetOutput().AnswerBuffer("{}", "application/json"); | 657 call.GetOutput().AnswerBuffer("{}", "application/json"); |
664 } | 658 } |
665 } | 659 } |
666 | 660 |