comparison Core/Enumerations.cpp @ 2981:eff50153a7b3 db-changes

integration mainline->db-changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Dec 2018 15:58:08 +0100
parents cb5d75143da0
children db8f360fcb41
comparison
equal deleted inserted replaced
2896:3fabf9a673f6 2981:eff50153a7b3
42 #include <string.h> 42 #include <string.h>
43 #include <cassert> 43 #include <cassert>
44 44
45 namespace Orthanc 45 namespace Orthanc
46 { 46 {
47 static const char* const MIME_CSS = "text/css";
48 static const char* const MIME_DICOM = "application/dicom";
49 static const char* const MIME_GIF = "image/gif";
50 static const char* const MIME_GZIP = "application/gzip";
51 static const char* const MIME_HTML = "text/html";
52 static const char* const MIME_JAVASCRIPT = "application/javascript";
53 static const char* const MIME_JPEG2000 = "image/jp2";
54 static const char* const MIME_PLAIN_TEXT = "text/plain";
55 static const char* const MIME_WEB_ASSEMBLY = "application/wasm";
56 static const char* const MIME_XML_2 = "text/xml";
57 static const char* const MIME_ZIP = "application/zip";
58
47 // This function is autogenerated by the script 59 // This function is autogenerated by the script
48 // "Resources/GenerateErrorCodes.py" 60 // "Resources/GenerateErrorCodes.py"
49 const char* EnumerationToString(ErrorCode error) 61 const char* EnumerationToString(ErrorCode error)
50 { 62 {
51 switch (error) 63 switch (error)
1017 1029
1018 default: 1030 default:
1019 throw OrthancException(ErrorCode_ParameterOutOfRange); 1031 throw OrthancException(ErrorCode_ParameterOutOfRange);
1020 } 1032 }
1021 } 1033 }
1034
1035
1036 const char* EnumerationToString(MimeType mime)
1037 {
1038 switch (mime)
1039 {
1040 case MimeType_Binary:
1041 return MIME_BINARY;
1042
1043 case MimeType_Dicom:
1044 return MIME_DICOM;
1045
1046 case MimeType_Jpeg:
1047 return MIME_JPEG;
1048
1049 case MimeType_Jpeg2000:
1050 return MIME_JPEG2000;
1051
1052 case MimeType_Json:
1053 return MIME_JSON;
1054
1055 case MimeType_Pdf:
1056 return MIME_PDF;
1057
1058 case MimeType_Png:
1059 return MIME_PNG;
1060
1061 case MimeType_Xml:
1062 return MIME_XML;
1063
1064 case MimeType_PlainText:
1065 return MIME_PLAIN_TEXT;
1066
1067 case MimeType_Pam:
1068 return MIME_PAM;
1069
1070 case MimeType_Html:
1071 return MIME_HTML;
1072
1073 case MimeType_Gzip:
1074 return MIME_GZIP;
1075
1076 case MimeType_JavaScript:
1077 return MIME_JAVASCRIPT;
1078
1079 case MimeType_Css:
1080 return MIME_CSS;
1081
1082 case MimeType_WebAssembly:
1083 return MIME_WEB_ASSEMBLY;
1084
1085 case MimeType_Gif:
1086 return MIME_GIF;
1087
1088 case MimeType_Zip:
1089 return MIME_ZIP;
1090
1091 default:
1092 throw OrthancException(ErrorCode_ParameterOutOfRange);
1093 }
1094 }
1022 1095
1023 1096
1024 Encoding StringToEncoding(const char* encoding) 1097 Encoding StringToEncoding(const char* encoding)
1025 { 1098 {
1026 std::string s(encoding); 1099 std::string s(encoding);
1302 { 1375 {
1303 std::string s = "Unsupported value representation encountered: " + vr; 1376 std::string s = "Unsupported value representation encountered: " + vr;
1304 1377
1305 if (throwIfUnsupported) 1378 if (throwIfUnsupported)
1306 { 1379 {
1307 LOG(ERROR) << s; 1380 throw OrthancException(ErrorCode_ParameterOutOfRange, s);
1308 throw OrthancException(ErrorCode_ParameterOutOfRange);
1309 } 1381 }
1310 else 1382 else
1311 { 1383 {
1312 LOG(INFO) << s; 1384 LOG(INFO) << s;
1313 return ValueRepresentation_NotSupported; 1385 return ValueRepresentation_NotSupported;
1439 result = ModalityManufacturer_Generic; 1511 result = ModalityManufacturer_Generic;
1440 obsolete = true; 1512 obsolete = true;
1441 } 1513 }
1442 else 1514 else
1443 { 1515 {
1444 LOG(ERROR) << "Unknown modality manufacturer: \"" << manufacturer << "\""; 1516 throw OrthancException(ErrorCode_ParameterOutOfRange,
1445 throw OrthancException(ErrorCode_ParameterOutOfRange); 1517 "Unknown modality manufacturer: \"" + manufacturer + "\"");
1446 } 1518 }
1447 1519
1448 if (obsolete) 1520 if (obsolete)
1449 { 1521 {
1450 LOG(WARNING) << "The \"" << manufacturer << "\" manufacturer is obsolete since " 1522 LOG(WARNING) << "The \"" << manufacturer << "\" manufacturer is obsolete since "
1527 return RequestOrigin_Plugins; 1599 return RequestOrigin_Plugins;
1528 } 1600 }
1529 else if (origin == "Lua") 1601 else if (origin == "Lua")
1530 { 1602 {
1531 return RequestOrigin_Lua; 1603 return RequestOrigin_Lua;
1604 }
1605 else
1606 {
1607 throw OrthancException(ErrorCode_ParameterOutOfRange);
1608 }
1609 }
1610
1611
1612 MimeType StringToMimeType(const std::string& mime)
1613 {
1614 if (mime == MIME_BINARY)
1615 {
1616 return MimeType_Binary;
1617 }
1618 else if (mime == MIME_DICOM)
1619 {
1620 return MimeType_Dicom;
1621 }
1622 else if (mime == MIME_JPEG)
1623 {
1624 return MimeType_Jpeg;
1625 }
1626 else if (mime == MIME_JPEG2000)
1627 {
1628 return MimeType_Jpeg2000;
1629 }
1630 else if (mime == MIME_JSON)
1631 {
1632 return MimeType_Json;
1633 }
1634 else if (mime == MIME_PDF)
1635 {
1636 return MimeType_Pdf;
1637 }
1638 else if (mime == MIME_PNG)
1639 {
1640 return MimeType_Png;
1641 }
1642 else if (mime == MIME_XML ||
1643 mime == MIME_XML_2)
1644 {
1645 return MimeType_Xml;
1646 }
1647 else if (mime == MIME_PLAIN_TEXT)
1648 {
1649 return MimeType_PlainText;
1650 }
1651 else if (mime == MIME_PAM)
1652 {
1653 return MimeType_Pam;
1654 }
1655 else if (mime == MIME_HTML)
1656 {
1657 return MimeType_Html;
1658 }
1659 else if (mime == MIME_GZIP)
1660 {
1661 return MimeType_Gzip;
1662 }
1663 else if (mime == MIME_JAVASCRIPT)
1664 {
1665 return MimeType_JavaScript;
1666 }
1667 else if (mime == MIME_CSS)
1668 {
1669 return MimeType_Css;
1670 }
1671 else if (mime == MIME_WEB_ASSEMBLY)
1672 {
1673 return MimeType_WebAssembly;
1674 }
1675 else if (mime == MIME_GIF)
1676 {
1677 return MimeType_Gif;
1678 }
1679 else if (mime == MIME_ZIP)
1680 {
1681 return MimeType_Zip;
1532 } 1682 }
1533 else 1683 else
1534 { 1684 {
1535 throw OrthancException(ErrorCode_ParameterOutOfRange); 1685 throw OrthancException(ErrorCode_ParameterOutOfRange);
1536 } 1686 }
1833 case ErrorCode_NotAcceptable: 1983 case ErrorCode_NotAcceptable:
1834 return HttpStatus_406_NotAcceptable; 1984 return HttpStatus_406_NotAcceptable;
1835 1985
1836 case ErrorCode_DatabaseUnavailable: 1986 case ErrorCode_DatabaseUnavailable:
1837 return HttpStatus_503_ServiceUnavailable; 1987 return HttpStatus_503_ServiceUnavailable;
1988
1989 case ErrorCode_CreateDicomNotString:
1990 return HttpStatus_400_BadRequest;
1991
1992 case ErrorCode_CreateDicomOverrideTag:
1993 return HttpStatus_400_BadRequest;
1994
1995 case ErrorCode_CreateDicomUseContent:
1996 return HttpStatus_400_BadRequest;
1997
1998 case ErrorCode_CreateDicomNoPayload:
1999 return HttpStatus_400_BadRequest;
2000
2001 case ErrorCode_CreateDicomUseDataUriScheme:
2002 return HttpStatus_400_BadRequest;
2003
2004 case ErrorCode_CreateDicomBadParent:
2005 return HttpStatus_400_BadRequest;
2006
2007 case ErrorCode_CreateDicomParentIsInstance:
2008 return HttpStatus_400_BadRequest;
1838 2009
1839 default: 2010 default:
1840 return HttpStatus_500_InternalServerError; 2011 return HttpStatus_500_InternalServerError;
1841 } 2012 }
1842 } 2013 }