Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancWebDav.cpp @ 4252:f047e2734655
fix webdav
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 15 Oct 2020 17:13:35 +0200 |
parents | 6c3721ff284c |
children | 2221051b42df |
comparison
equal
deleted
inserted
replaced
4250:cbf9afa17415 | 4252:f047e2734655 |
---|---|
550 } | 550 } |
551 } | 551 } |
552 | 552 |
553 virtual bool DeleteItem(const UriComponents& path) ORTHANC_OVERRIDE | 553 virtual bool DeleteItem(const UriComponents& path) ORTHANC_OVERRIDE |
554 { | 554 { |
555 std::string instanceId; | 555 if (path.empty()) |
556 if (LookupInstanceId(instanceId, path)) | 556 { |
557 { | 557 // Delete all |
558 Json::Value info; | 558 std::list<std::string> resources; |
559 return context_.DeleteResource(info, instanceId, ResourceType_Instance); | 559 try |
560 } | 560 { |
561 else | 561 context_.GetIndex().GetChildren(resources, parentSeries_); |
562 { | 562 } |
563 return false; | 563 catch (OrthancException&) |
564 { | |
565 // Unknown (or deleted) parent series | |
566 return true; | |
567 } | |
568 | |
569 for (std::list<std::string>::const_iterator it = resources.begin(); | |
570 it != resources.end(); ++it) | |
571 { | |
572 Json::Value info; | |
573 context_.DeleteResource(info, *it, ResourceType_Instance); | |
574 } | |
575 | |
576 return true; | |
577 } | |
578 else | |
579 { | |
580 std::string instanceId; | |
581 if (LookupInstanceId(instanceId, path)) | |
582 { | |
583 Json::Value info; | |
584 return context_.DeleteResource(info, instanceId, ResourceType_Instance); | |
585 } | |
586 else | |
587 { | |
588 return false; | |
589 } | |
564 } | 590 } |
565 } | 591 } |
566 }; | 592 }; |
567 | 593 |
568 | 594 |
694 { | 720 { |
695 Refresh(); | 721 Refresh(); |
696 | 722 |
697 if (path.empty()) | 723 if (path.empty()) |
698 { | 724 { |
699 IWebDavBucket::Collection tmp; | 725 IWebDavBucket::Collection collection; |
700 if (ListSubfolders(tmp)) | 726 if (ListSubfolders(collection)) |
701 { | 727 { |
702 return (tmp.GetSize() == 0); | 728 std::set<std::string> content; |
729 collection.ListDisplayNames(content); | |
730 | |
731 for (std::set<std::string>::const_iterator | |
732 it = content.begin(); it != content.end(); ++it) | |
733 { | |
734 INode* node = GetChild(*it); | |
735 if (node) | |
736 { | |
737 node->DeleteItem(path); | |
738 } | |
739 } | |
740 | |
741 return true; | |
703 } | 742 } |
704 else | 743 else |
705 { | 744 { |
706 return false; | 745 return false; |
707 } | 746 } |
1314 } | 1353 } |
1315 else if (path[0] == BY_PATIENTS || | 1354 else if (path[0] == BY_PATIENTS || |
1316 path[0] == BY_STUDIES || | 1355 path[0] == BY_STUDIES || |
1317 path[0] == BY_DATES) | 1356 path[0] == BY_DATES) |
1318 { | 1357 { |
1319 IWebDavBucket::Collection tmp; | 1358 IWebDavBucket::Collection collection; |
1320 return GetRootNode(path[0]).ListCollection(tmp, UriComponents(path.begin() + 1, path.end())); | 1359 return GetRootNode(path[0]).ListCollection(collection, UriComponents(path.begin() + 1, path.end())); |
1321 } | 1360 } |
1322 else if (allowUpload_ && | 1361 else if (allowUpload_ && |
1323 path[0] == UPLOADS) | 1362 path[0] == UPLOADS) |
1324 { | 1363 { |
1325 return uploads_.IsExistingFolder(UriComponents(path.begin() + 1, path.end())); | 1364 return uploads_.IsExistingFolder(UriComponents(path.begin() + 1, path.end())); |
1551 | 1590 |
1552 if (path.size() >= 3) | 1591 if (path.size() >= 3) |
1553 { | 1592 { |
1554 if (path[2] == STUDY_INFO) | 1593 if (path[2] == STUDY_INFO) |
1555 { | 1594 { |
1556 return true; // Allow deletion of virtual files | 1595 return true; // Allow deletion of virtual files (to avoid blocking recursive DELETE) |
1557 } | 1596 } |
1558 | 1597 |
1559 query.AddRestConstraint(DICOM_TAG_SERIES_INSTANCE_UID, path[2], | 1598 query.AddRestConstraint(DICOM_TAG_SERIES_INSTANCE_UID, path[2], |
1560 true /* case sensitive */, true /* mandatory tag */); | 1599 true /* case sensitive */, true /* mandatory tag */); |
1561 level = ResourceType_Series; | 1600 level = ResourceType_Series; |
1563 | 1602 |
1564 if (path.size() == 4) | 1603 if (path.size() == 4) |
1565 { | 1604 { |
1566 if (path[3] == SERIES_INFO) | 1605 if (path[3] == SERIES_INFO) |
1567 { | 1606 { |
1568 return true; // Allow deletion of virtual files | 1607 return true; // Allow deletion of virtual files (to avoid blocking recursive DELETE) |
1569 } | 1608 } |
1570 else if (boost::ends_with(path[3], ".dcm")) | 1609 else if (boost::ends_with(path[3], ".dcm")) |
1571 { | 1610 { |
1572 const std::string sopInstanceUid = path[3].substr(0, path[3].size() - 4); | 1611 const std::string sopInstanceUid = path[3].substr(0, path[3].size() - 4); |
1573 | 1612 |
1580 return false; | 1619 return false; |
1581 } | 1620 } |
1582 } | 1621 } |
1583 | 1622 |
1584 DicomDeleteVisitor visitor(context_, level); | 1623 DicomDeleteVisitor visitor(context_, level); |
1585 context_.Apply(visitor, query, ResourceType_Instance, 0 /* since */, 0 /* no limit */); | 1624 context_.Apply(visitor, query, level, 0 /* since */, 0 /* no limit */); |
1586 return true; | 1625 return true; |
1587 } | 1626 } |
1588 else | 1627 else |
1589 { | 1628 { |
1590 return false; // read-only | 1629 return false; // read-only |