Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5446:912565317b9a
plugins are now allowed to modify/delete private metadata/attachments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 24 Nov 2023 12:12:03 +0100 |
parents | 59e3b6f8c5be |
children | 68e9f7815fb8 |
comparison
equal
deleted
inserted
replaced
5445:b853a63e9830 | 5446:912565317b9a |
---|---|
1910 const std::string publicId = call.GetUriComponent("id", ""); | 1910 const std::string publicId = call.GetUriComponent("id", ""); |
1911 | 1911 |
1912 std::string name = call.GetUriComponent("name", ""); | 1912 std::string name = call.GetUriComponent("name", ""); |
1913 MetadataType metadata = StringToMetadata(name); | 1913 MetadataType metadata = StringToMetadata(name); |
1914 | 1914 |
1915 if (IsUserMetadata(metadata)) // It is forbidden to modify internal metadata | 1915 if (IsUserMetadata(metadata) || // It is forbidden to delete internal metadata... |
1916 call.GetRequestOrigin() == RequestOrigin_Plugins) // ...except for plugins | |
1916 { | 1917 { |
1917 bool found; | 1918 bool found; |
1918 int64_t revision; | 1919 int64_t revision; |
1919 std::string md5; | 1920 std::string md5; |
1920 if (GetRevisionHeader(revision, md5, call, "if-match")) | 1921 if (GetRevisionHeader(revision, md5, call, "if-match")) |
1976 MetadataType metadata = StringToMetadata(name); | 1977 MetadataType metadata = StringToMetadata(name); |
1977 | 1978 |
1978 std::string value; | 1979 std::string value; |
1979 call.BodyToString(value); | 1980 call.BodyToString(value); |
1980 | 1981 |
1981 if (IsUserMetadata(metadata)) // It is forbidden to modify internal metadata | 1982 if (IsUserMetadata(metadata) || // It is forbidden to modify internal metadata... |
1983 call.GetRequestOrigin() == RequestOrigin_Plugins) // ...except for plugins | |
1982 { | 1984 { |
1983 int64_t oldRevision; | 1985 int64_t oldRevision; |
1984 std::string oldMD5; | 1986 std::string oldMD5; |
1985 bool hasOldRevision = GetRevisionHeader(oldRevision, oldMD5, call, "if-match"); | 1987 bool hasOldRevision = GetRevisionHeader(oldRevision, oldMD5, call, "if-match"); |
1986 | 1988 |
2572 | 2574 |
2573 std::string publicId = call.GetUriComponent("id", ""); | 2575 std::string publicId = call.GetUriComponent("id", ""); |
2574 std::string name = call.GetUriComponent("name", ""); | 2576 std::string name = call.GetUriComponent("name", ""); |
2575 | 2577 |
2576 FileContentType contentType = StringToContentType(name); | 2578 FileContentType contentType = StringToContentType(name); |
2577 if (IsUserContentType(contentType)) // It is forbidden to modify internal attachments | 2579 if (IsUserContentType(contentType) || // It is forbidden to modify internal attachments... |
2580 call.GetRequestOrigin() == RequestOrigin_Plugins) // ...except for plugins | |
2578 { | 2581 { |
2579 int64_t oldRevision; | 2582 int64_t oldRevision; |
2580 std::string oldMD5; | 2583 std::string oldMD5; |
2581 bool hasOldRevision = GetRevisionHeader(oldRevision, oldMD5, call, "if-match"); | 2584 bool hasOldRevision = GetRevisionHeader(oldRevision, oldMD5, call, "if-match"); |
2582 | 2585 |
2631 std::string publicId = call.GetUriComponent("id", ""); | 2634 std::string publicId = call.GetUriComponent("id", ""); |
2632 std::string name = call.GetUriComponent("name", ""); | 2635 std::string name = call.GetUriComponent("name", ""); |
2633 FileContentType contentType = StringToContentType(name); | 2636 FileContentType contentType = StringToContentType(name); |
2634 | 2637 |
2635 bool allowed; | 2638 bool allowed; |
2636 if (IsUserContentType(contentType)) | 2639 if (IsUserContentType(contentType) || // It is forbidden to delete internal attachments... |
2640 call.GetRequestOrigin() == RequestOrigin_Plugins) // ...except for plugins | |
2637 { | 2641 { |
2638 allowed = true; | 2642 allowed = true; |
2639 } | 2643 } |
2640 else | 2644 else |
2641 { | 2645 { |