Mercurial > hg > orthanc
comparison OrthancServer/Sources/main.cpp @ 4226:7bd5eab3ba25
prototyping IWebDavBucket
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 04 Oct 2020 13:23:53 +0200 |
parents | d962a2996637 |
children | 7fff7e683d65 |
comparison
equal
deleted
inserted
replaced
4225:81f2d1484886 | 4226:7bd5eab3ba25 |
---|---|
41 #include "../../OrthancFramework/Sources/DicomNetworking/DicomAssociationParameters.h" | 41 #include "../../OrthancFramework/Sources/DicomNetworking/DicomAssociationParameters.h" |
42 #include "../../OrthancFramework/Sources/DicomNetworking/DicomServer.h" | 42 #include "../../OrthancFramework/Sources/DicomNetworking/DicomServer.h" |
43 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | 43 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
44 #include "../../OrthancFramework/Sources/HttpServer/FilesystemHttpHandler.h" | 44 #include "../../OrthancFramework/Sources/HttpServer/FilesystemHttpHandler.h" |
45 #include "../../OrthancFramework/Sources/HttpServer/HttpServer.h" | 45 #include "../../OrthancFramework/Sources/HttpServer/HttpServer.h" |
46 #include "../../OrthancFramework/Sources/HttpServer/IWebDavBucket.h" // TODO | |
46 #include "../../OrthancFramework/Sources/Logging.h" | 47 #include "../../OrthancFramework/Sources/Logging.h" |
47 #include "../../OrthancFramework/Sources/Lua/LuaFunctionCall.h" | 48 #include "../../OrthancFramework/Sources/Lua/LuaFunctionCall.h" |
48 #include "../Plugins/Engine/OrthancPlugins.h" | 49 #include "../Plugins/Engine/OrthancPlugins.h" |
49 #include "EmbeddedResourceHttpHandler.h" | 50 #include "EmbeddedResourceHttpHandler.h" |
50 #include "OrthancConfiguration.h" | 51 #include "OrthancConfiguration.h" |
604 } | 605 } |
605 | 606 |
606 std::string info = message.toStyledString(); | 607 std::string info = message.toStyledString(); |
607 output.SendStatus(httpStatus, info); | 608 output.SendStatus(httpStatus, info); |
608 } | 609 } |
610 } | |
611 }; | |
612 | |
613 | |
614 | |
615 | |
616 class DummyBucket : public IWebDavBucket // TODO | |
617 { | |
618 private: | |
619 ServerContext& context_; | |
620 | |
621 public: | |
622 DummyBucket(ServerContext& context) : | |
623 context_(context) | |
624 { | |
625 } | |
626 | |
627 virtual bool ListCollection(Collection& collection, | |
628 const UriComponents& path) ORTHANC_OVERRIDE | |
629 { | |
630 if (path.size() == 0 || | |
631 (path.size() == 1 && path[0] == "Folder1") || | |
632 (path.size() == 2 && path[0] == "Folder1" && path[1] == "Folder2")) | |
633 { | |
634 for (unsigned int i = 0; i < 5; i++) | |
635 { | |
636 std::unique_ptr<File> f(new File("IM" + boost::lexical_cast<std::string>(i) + ".dcm")); | |
637 f->SetContentLength(1024 * i); | |
638 collection.AddResource(f.release()); | |
639 } | |
640 | |
641 for (unsigned int i = 0; i < 5; i++) | |
642 { | |
643 collection.AddResource(new Folder("Folder" + boost::lexical_cast<std::string>(i))); | |
644 } | |
645 | |
646 return true; | |
647 } | |
648 else | |
649 { | |
650 return false; | |
651 } | |
652 } | |
653 | |
654 virtual bool GetFileContent(std::string& content, | |
655 const UriComponents& path) ORTHANC_OVERRIDE | |
656 { | |
657 std::string s = "/"; | |
658 for (size_t i = 0; i < path.size(); i++) | |
659 { | |
660 s += path[i] + "/"; | |
661 } | |
662 | |
663 content = "Hello world!\r\n" + s + "\r\n"; | |
664 return true; | |
609 } | 665 } |
610 }; | 666 }; |
611 | 667 |
612 | 668 |
613 | 669 |
1046 | 1102 |
1047 httpServer.SetIncomingHttpRequestFilter(httpFilter); | 1103 httpServer.SetIncomingHttpRequestFilter(httpFilter); |
1048 httpServer.SetHttpExceptionFormatter(exceptionFormatter); | 1104 httpServer.SetHttpExceptionFormatter(exceptionFormatter); |
1049 httpServer.Register(context.GetHttpHandler()); | 1105 httpServer.Register(context.GetHttpHandler()); |
1050 | 1106 |
1107 { | |
1108 std::vector<std::string> root; // TODO | |
1109 root.push_back("davfs"); | |
1110 httpServer.Register(root, new DummyBucket(context)); | |
1111 } | |
1112 | |
1051 if (httpServer.GetPortNumber() < 1024) | 1113 if (httpServer.GetPortNumber() < 1024) |
1052 { | 1114 { |
1053 LOG(WARNING) << "The HTTP port is privileged (" | 1115 LOG(WARNING) << "The HTTP port is privileged (" |
1054 << httpServer.GetPortNumber() << " is below 1024), " | 1116 << httpServer.GetPortNumber() << " is below 1024), " |
1055 << "make sure you run Orthanc as root/administrator"; | 1117 << "make sure you run Orthanc as root/administrator"; |