Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 2639:75a404e40323 jobs
simplification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 May 2018 14:39:22 +0200 |
parents | 6db878376018 |
children | c691fcf66071 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon May 28 10:58:07 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon May 28 14:39:22 2018 +0200 @@ -110,12 +110,18 @@ } - static void AnonymizeOrModifyResource(DicomModification& modification, + static void AnonymizeOrModifyResource(DicomModification* modificationRaw, // Takes ownership MetadataType metadataType, - ChangeType changeType, ResourceType resourceType, RestApiPostCall& call) { + if (modificationRaw == NULL) + { + throw OrthancException(ErrorCode_NullPointer); + } + + std::auto_ptr<DicomModification> modification(modificationRaw); + bool isFirst = true; Json::Value result(Json::objectValue); @@ -163,7 +169,7 @@ **/ std::auto_ptr<ParsedDicomFile> modified(original.Clone(true)); - modification.Apply(*modified); + modification->Apply(*modified); DicomInstanceToStore toStore; toStore.SetRestOrigin(call); @@ -289,30 +295,24 @@ } - template <enum ChangeType changeType, - enum ResourceType resourceType> + template <enum ResourceType resourceType> static void ModifyResource(RestApiPostCall& call) { - DicomModification modification; - - ParseModifyRequest(modification, call); + std::auto_ptr<DicomModification> modification(new DicomModification); + ParseModifyRequest(*modification, call); - modification.SetLevel(resourceType); - AnonymizeOrModifyResource(modification, MetadataType_ModifiedFrom, - changeType, resourceType, call); + modification->SetLevel(resourceType); + AnonymizeOrModifyResource(modification.release(), MetadataType_ModifiedFrom, resourceType, call); } - template <enum ChangeType changeType, - enum ResourceType resourceType> + template <enum ResourceType resourceType> static void AnonymizeResource(RestApiPostCall& call) { - DicomModification modification; + std::auto_ptr<DicomModification> modification(new DicomModification); + ParseAnonymizationRequest(*modification, call); - ParseAnonymizationRequest(modification, call); - - AnonymizeOrModifyResource(modification, MetadataType_AnonymizedFrom, - changeType, resourceType, call); + AnonymizeOrModifyResource(modification.release(), MetadataType_AnonymizedFrom, resourceType, call); } @@ -729,14 +729,14 @@ void OrthancRestApi::RegisterAnonymizeModify() { Register("/instances/{id}/modify", ModifyInstance); - Register("/series/{id}/modify", ModifyResource<ChangeType_ModifiedSeries, ResourceType_Series>); - Register("/studies/{id}/modify", ModifyResource<ChangeType_ModifiedStudy, ResourceType_Study>); - Register("/patients/{id}/modify", ModifyResource<ChangeType_ModifiedPatient, ResourceType_Patient>); + Register("/series/{id}/modify", ModifyResource<ResourceType_Series>); + Register("/studies/{id}/modify", ModifyResource<ResourceType_Study>); + Register("/patients/{id}/modify", ModifyResource<ResourceType_Patient>); Register("/instances/{id}/anonymize", AnonymizeInstance); - Register("/series/{id}/anonymize", AnonymizeResource<ChangeType_AnonymizedSeries, ResourceType_Series>); - Register("/studies/{id}/anonymize", AnonymizeResource<ChangeType_AnonymizedStudy, ResourceType_Study>); - Register("/patients/{id}/anonymize", AnonymizeResource<ChangeType_AnonymizedPatient, ResourceType_Patient>); + Register("/series/{id}/anonymize", AnonymizeResource<ResourceType_Series>); + Register("/studies/{id}/anonymize", AnonymizeResource<ResourceType_Study>); + Register("/patients/{id}/anonymize", AnonymizeResource<ResourceType_Patient>); Register("/tools/create-dicom", CreateDicom); }