Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2071:27fd34970c52
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 14 Jul 2016 14:21:29 +0200 |
parents | 02c543c42e61 |
children | f8d4543e3fef |
comparison
equal
deleted
inserted
replaced
2070:7e6afa0beaf6 | 2071:27fd34970c52 |
---|---|
681 if (!GetInstancesToExport(request, instances, remote, call)) | 681 if (!GetInstancesToExport(request, instances, remote, call)) |
682 { | 682 { |
683 return; | 683 return; |
684 } | 684 } |
685 | 685 |
686 static const char* LOCAL_AET = "LocalAet"; | 686 std::string localAet = Toolbox::GetJsonStringField(request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle()); |
687 std::string localAet = context.GetDefaultLocalApplicationEntityTitle(); | 687 bool permissive = Toolbox::GetJsonBooleanField(request, "Permissive", false); |
688 if (request.type() == Json::objectValue && | 688 int moveOriginatorID = Toolbox::GetJsonIntegerField(request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */); |
689 request.isMember(LOCAL_AET)) | 689 |
690 { | 690 if (moveOriginatorID < 0 || |
691 if (request[LOCAL_AET].type() == Json::stringValue) | 691 moveOriginatorID >= 65536) |
692 { | 692 { |
693 localAet = request[LOCAL_AET].asString(); | 693 throw OrthancException(ErrorCode_ParameterOutOfRange); |
694 } | 694 } |
695 else | 695 |
696 { | |
697 throw OrthancException(ErrorCode_BadFileFormat); | |
698 } | |
699 } | |
700 | |
701 uint16_t moveOriginatorID = 0; /* By default, not a C-MOVE */ | |
702 | |
703 static const char* MOVE_ORIGINATOR_ID = "MoveOriginatorID"; | |
704 if (request.type() == Json::objectValue && | |
705 request.isMember(MOVE_ORIGINATOR_ID)) | |
706 { | |
707 if (request[MOVE_ORIGINATOR_ID].type() != Json::intValue) | |
708 { | |
709 throw OrthancException(ErrorCode_BadFileFormat); | |
710 } | |
711 | |
712 int v = request[MOVE_ORIGINATOR_ID].asInt(); | |
713 if (v <= 0 || v >= 65536) | |
714 { | |
715 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
716 } | |
717 else | |
718 { | |
719 moveOriginatorID = boost::lexical_cast<uint16_t>(v); | |
720 } | |
721 } | |
722 | |
723 static const char* PERMISSIVE = "Permissive"; | |
724 bool permissive = false; | |
725 if (request.type() == Json::objectValue && | |
726 request.isMember(PERMISSIVE)) | |
727 { | |
728 if (request[PERMISSIVE].type() == Json::booleanValue) | |
729 { | |
730 permissive = request[PERMISSIVE].asBool(); | |
731 } | |
732 else | |
733 { | |
734 throw OrthancException(ErrorCode_BadFileFormat); | |
735 } | |
736 } | |
737 | |
738 RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote); | 696 RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote); |
739 | 697 |
740 ServerJob job; | 698 ServerJob job; |
741 for (std::list<std::string>::const_iterator | 699 for (std::list<std::string>::const_iterator |
742 it = instances.begin(); it != instances.end(); ++it) | 700 it = instances.begin(); it != instances.end(); ++it) |
743 { | 701 { |
744 job.AddCommand(new StoreScuCommand(context, localAet, p, permissive, | 702 job.AddCommand(new StoreScuCommand(context, localAet, p, permissive, |
745 moveOriginatorID)).AddInput(*it); | 703 static_cast<uint16_t>(moveOriginatorID))).AddInput(*it); |
746 } | 704 } |
747 | 705 |
748 job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\""); | 706 job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\""); |
749 | 707 |
750 if (context.GetScheduler().SubmitAndWait(job)) | 708 if (context.GetScheduler().SubmitAndWait(job)) |
782 throw OrthancException(ErrorCode_BadFileFormat); | 740 throw OrthancException(ErrorCode_BadFileFormat); |
783 } | 741 } |
784 | 742 |
785 ResourceType level = StringToResourceType(request["Level"].asCString()); | 743 ResourceType level = StringToResourceType(request["Level"].asCString()); |
786 | 744 |
787 static const char* LOCAL_AET = "LocalAet"; | 745 std::string localAet = Toolbox::GetJsonStringField(request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle()); |
788 std::string localAet = context.GetDefaultLocalApplicationEntityTitle(); | 746 std::string targetAet = Toolbox::GetJsonStringField(request, "TargetAet", context.GetDefaultLocalApplicationEntityTitle()); |
789 if (request.isMember(LOCAL_AET)) | |
790 { | |
791 if (request[LOCAL_AET].type() == Json::stringValue) | |
792 { | |
793 localAet = request[LOCAL_AET].asString(); | |
794 } | |
795 else | |
796 { | |
797 throw OrthancException(ErrorCode_BadFileFormat); | |
798 } | |
799 } | |
800 | |
801 static const char* TARGET_AET = "TargetAet"; | |
802 std::string targetAet = context.GetDefaultLocalApplicationEntityTitle(); | |
803 if (request.isMember(TARGET_AET)) | |
804 { | |
805 if (request[TARGET_AET].type() == Json::stringValue) | |
806 { | |
807 targetAet = request[TARGET_AET].asString(); | |
808 } | |
809 else | |
810 { | |
811 throw OrthancException(ErrorCode_BadFileFormat); | |
812 } | |
813 } | |
814 | 747 |
815 const RemoteModalityParameters source = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); | 748 const RemoteModalityParameters source = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
816 | 749 |
817 for (Json::Value::ArrayIndex i = 0; i < request[RESOURCES].size(); i++) | 750 for (Json::Value::ArrayIndex i = 0; i < request[RESOURCES].size(); i++) |
818 { | 751 { |