comparison OrthancServer/Sources/ServerContext.cpp @ 4919:676e03e69703

added origin in OrthancPluginReceivedInstanceCallback
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Feb 2022 09:30:42 +0100
parents c1b19f95e166
children 309fb4f02704
comparison
equal deleted inserted replaced
4917:95378de340d4 4919:676e03e69703
696 #if ORTHANC_ENABLE_PLUGINS == 1 696 #if ORTHANC_ENABLE_PLUGINS == 1
697 if (HasPlugins()) 697 if (HasPlugins())
698 { 698 {
699 // New in Orthanc 1.10.0 699 // New in Orthanc 1.10.0
700 700
701 OrthancPluginReceivedInstanceCallbackResult action = GetPlugins().ApplyReceivedInstanceCallbacks( 701 OrthancPluginReceivedInstanceAction action = GetPlugins().ApplyReceivedInstanceCallbacks(
702 modifiedBuffer, receivedDicom.GetBufferData(), receivedDicom.GetBufferSize()); 702 modifiedBuffer, receivedDicom.GetBufferData(), receivedDicom.GetBufferSize(), receivedDicom.GetOrigin().GetRequestOrigin());
703 703
704 switch (action) 704 switch (action)
705 { 705 {
706 case OrthancPluginReceivedInstanceCallbackResult_Discard: 706 case OrthancPluginReceivedInstanceAction_Discard:
707 { 707 {
708 CLOG(INFO, PLUGINS) << "A plugin has discarded the instance in its ReceivedInstanceCallback"; 708 CLOG(INFO, PLUGINS) << "A plugin has discarded the instance in its ReceivedInstanceCallback";
709 StoreResult result; 709 StoreResult result;
710 result.SetStatus(StoreStatus_FilteredOut); 710 result.SetStatus(StoreStatus_FilteredOut);
711 return result; 711 return result;
712 } 712 }
713 713
714 case OrthancPluginReceivedInstanceCallbackResult_KeepAsIs: 714 case OrthancPluginReceivedInstanceAction_KeepAsIs:
715 // This path is also used when no ReceivedInstanceCallback is installed by the plugins
715 break; 716 break;
716 717
717 case OrthancPluginReceivedInstanceCallbackResult_Modify: 718 case OrthancPluginReceivedInstanceAction_Modify:
718 if (modifiedBuffer.GetSize() > 0 && 719 if (modifiedBuffer.GetSize() > 0 &&
719 modifiedBuffer.GetData() != NULL) 720 modifiedBuffer.GetData() != NULL)
720 { 721 {
721 CLOG(INFO, PLUGINS) << "A plugin has modified the instance in its ReceivedInstanceCallback"; 722 CLOG(INFO, PLUGINS) << "A plugin has modified the instance in its ReceivedInstanceCallback";
722 modifiedDicom.reset(DicomInstanceToStore::CreateFromBuffer(modifiedBuffer.GetData(), modifiedBuffer.GetSize())); 723 modifiedDicom.reset(DicomInstanceToStore::CreateFromBuffer(modifiedBuffer.GetData(), modifiedBuffer.GetSize()));
723 modifiedDicom->SetOrigin(dicom->GetOrigin()); 724 modifiedDicom->SetOrigin(receivedDicom.GetOrigin());
724 dicom = modifiedDicom.get(); 725 dicom = modifiedDicom.get();
725 } 726 }
726 else 727 else
727 { 728 {
728 throw OrthancException(ErrorCode_Plugin, "The ReceivedInstanceCallback plugin is not returning a modified buffer while it has modified the instance"); 729 throw OrthancException(ErrorCode_Plugin, "The ReceivedInstanceCallback plugin is not returning a modified buffer while it has modified the instance");