diff 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
line wrap: on
line diff
--- a/Core/Enumerations.cpp	Thu Oct 18 10:48:11 2018 +0200
+++ b/Core/Enumerations.cpp	Thu Dec 06 15:58:08 2018 +0100
@@ -44,6 +44,18 @@
 
 namespace Orthanc
 {
+  static const char* const MIME_CSS = "text/css";
+  static const char* const MIME_DICOM = "application/dicom";
+  static const char* const MIME_GIF = "image/gif";
+  static const char* const MIME_GZIP = "application/gzip";
+  static const char* const MIME_HTML = "text/html";
+  static const char* const MIME_JAVASCRIPT = "application/javascript";
+  static const char* const MIME_JPEG2000 = "image/jp2";
+  static const char* const MIME_PLAIN_TEXT = "text/plain";
+  static const char* const MIME_WEB_ASSEMBLY = "application/wasm";
+  static const char* const MIME_XML_2 = "text/xml";
+  static const char* const MIME_ZIP = "application/zip";
+
   // This function is autogenerated by the script
   // "Resources/GenerateErrorCodes.py"
   const char* EnumerationToString(ErrorCode error)
@@ -1019,6 +1031,67 @@
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
   }
+
+
+  const char* EnumerationToString(MimeType mime)
+  {
+    switch (mime)
+    {
+      case MimeType_Binary:
+        return MIME_BINARY;
+        
+      case MimeType_Dicom:
+        return MIME_DICOM;
+        
+      case MimeType_Jpeg:
+        return MIME_JPEG;
+        
+      case MimeType_Jpeg2000:
+        return MIME_JPEG2000;
+        
+      case MimeType_Json:
+        return MIME_JSON;
+        
+      case MimeType_Pdf:
+        return MIME_PDF;
+        
+      case MimeType_Png:
+        return MIME_PNG;
+        
+      case MimeType_Xml:
+        return MIME_XML;
+        
+      case MimeType_PlainText:
+        return MIME_PLAIN_TEXT;
+                
+      case MimeType_Pam:
+        return MIME_PAM;
+                
+      case MimeType_Html:
+        return MIME_HTML;
+                
+      case MimeType_Gzip:
+        return MIME_GZIP;
+                
+      case MimeType_JavaScript:
+        return MIME_JAVASCRIPT;
+                
+      case MimeType_Css:
+        return MIME_CSS;
+                
+      case MimeType_WebAssembly:
+        return MIME_WEB_ASSEMBLY;
+                
+      case MimeType_Gif:
+        return MIME_GIF;
+                
+      case MimeType_Zip:
+        return MIME_ZIP;
+                
+      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
   
 
   Encoding StringToEncoding(const char* encoding)
@@ -1304,8 +1377,7 @@
 
       if (throwIfUnsupported)
       {
-        LOG(ERROR) << s;
-        throw OrthancException(ErrorCode_ParameterOutOfRange);
+        throw OrthancException(ErrorCode_ParameterOutOfRange, s);
       }
       else
       {
@@ -1441,8 +1513,8 @@
     }
     else
     {
-      LOG(ERROR) << "Unknown modality manufacturer: \"" << manufacturer << "\"";
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
+      throw OrthancException(ErrorCode_ParameterOutOfRange,
+                             "Unknown modality manufacturer: \"" + manufacturer + "\"");
     }
 
     if (obsolete)
@@ -1535,6 +1607,84 @@
       throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
   }
+
+
+  MimeType StringToMimeType(const std::string& mime)
+  {
+    if (mime == MIME_BINARY)
+    {
+      return MimeType_Binary;
+    }
+    else if (mime == MIME_DICOM)
+    {
+      return MimeType_Dicom;
+    }
+    else if (mime == MIME_JPEG)
+    {
+      return MimeType_Jpeg;
+    }
+    else if (mime == MIME_JPEG2000)
+    {
+      return MimeType_Jpeg2000;
+    }
+    else if (mime == MIME_JSON)
+    {
+      return MimeType_Json;
+    }
+    else if (mime == MIME_PDF)
+    {
+      return MimeType_Pdf;
+    }
+    else if (mime == MIME_PNG)
+    {
+      return MimeType_Png;
+    }
+    else if (mime == MIME_XML ||
+             mime == MIME_XML_2)
+    {
+      return MimeType_Xml;
+    }
+    else if (mime == MIME_PLAIN_TEXT)
+    {
+      return MimeType_PlainText;
+    }
+    else if (mime == MIME_PAM)
+    {
+      return MimeType_Pam;
+    }
+    else if (mime == MIME_HTML)
+    {
+      return MimeType_Html;
+    }
+    else if (mime == MIME_GZIP)
+    {
+      return MimeType_Gzip;
+    }
+    else if (mime == MIME_JAVASCRIPT)
+    {
+      return MimeType_JavaScript;
+    }
+    else if (mime == MIME_CSS)
+    {
+      return MimeType_Css;
+    }
+    else if (mime == MIME_WEB_ASSEMBLY)
+    {
+      return MimeType_WebAssembly;
+    }
+    else if (mime == MIME_GIF)
+    {
+      return MimeType_Gif;
+    }
+    else if (mime == MIME_ZIP)
+    {
+      return MimeType_Zip;
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
   
 
   unsigned int GetBytesPerPixel(PixelFormat format)
@@ -1836,6 +1986,27 @@
       case ErrorCode_DatabaseUnavailable:
         return HttpStatus_503_ServiceUnavailable;
 
+      case ErrorCode_CreateDicomNotString:
+        return HttpStatus_400_BadRequest;
+
+      case ErrorCode_CreateDicomOverrideTag:
+        return HttpStatus_400_BadRequest;
+
+      case ErrorCode_CreateDicomUseContent:
+        return HttpStatus_400_BadRequest;
+
+      case ErrorCode_CreateDicomNoPayload:
+        return HttpStatus_400_BadRequest;
+
+      case ErrorCode_CreateDicomUseDataUriScheme:
+        return HttpStatus_400_BadRequest;
+
+      case ErrorCode_CreateDicomBadParent:
+        return HttpStatus_400_BadRequest;
+
+      case ErrorCode_CreateDicomParentIsInstance:
+        return HttpStatus_400_BadRequest;
+
       default:
         return HttpStatus_500_InternalServerError;
     }