comparison OrthancServer/ServerContext.cpp @ 233:c11273198cef

rename
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 30 Nov 2012 14:30:05 +0100
parents 5368bbe813cf
children 6d9be2b470b4
comparison
equal deleted inserted replaced
232:5368bbe813cf 233:c11273198cef
66 const Json::Value& dicomJson, 66 const Json::Value& dicomJson,
67 const std::string& remoteAet) 67 const std::string& remoteAet)
68 { 68 {
69 //accessor_.SetCompressionForNextOperations(CompressionType_Zlib); 69 //accessor_.SetCompressionForNextOperations(CompressionType_Zlib);
70 70
71 FileInfo dicomInfo = accessor_.Write(dicomFile, dicomSize, FileType_Dicom); 71 FileInfo dicomInfo = accessor_.Write(dicomFile, dicomSize, FileContentType_Dicom);
72 FileInfo jsonInfo = accessor_.Write(dicomJson.toStyledString(), FileType_Json); 72 FileInfo jsonInfo = accessor_.Write(dicomJson.toStyledString(), FileContentType_Json);
73 73
74 ServerIndex::Attachments attachments; 74 ServerIndex::Attachments attachments;
75 attachments.push_back(dicomInfo); 75 attachments.push_back(dicomInfo);
76 attachments.push_back(jsonInfo); 76 attachments.push_back(jsonInfo);
77 77
102 } 102 }
103 103
104 104
105 void ServerContext::AnswerFile(RestApiOutput& output, 105 void ServerContext::AnswerFile(RestApiOutput& output,
106 const std::string& instancePublicId, 106 const std::string& instancePublicId,
107 FileType content) 107 FileContentType content)
108 { 108 {
109 FileInfo attachment; 109 FileInfo attachment;
110 if (index_.LookupAttachment(attachment, instancePublicId, FileType_Dicom)) 110 if (index_.LookupAttachment(attachment, instancePublicId, FileContentType_Dicom))
111 { 111 {
112 assert(attachment.GetCompressionType() == CompressionType_None); 112 assert(attachment.GetCompressionType() == CompressionType_None);
113 assert(attachment.GetFileType() == FileType_Dicom); 113 assert(attachment.GetContentType() == FileContentType_Dicom);
114 114
115 FilesystemHttpSender sender(storage_, attachment.GetUuid()); 115 FilesystemHttpSender sender(storage_, attachment.GetUuid());
116 sender.SetDownloadFilename(attachment.GetUuid() + ".dcm"); 116 sender.SetDownloadFilename(attachment.GetUuid() + ".dcm");
117 sender.SetContentType("application/dicom"); 117 sender.SetContentType("application/dicom");
118 output.AnswerFile(sender); 118 output.AnswerFile(sender);
122 122
123 void ServerContext::ReadJson(Json::Value& result, 123 void ServerContext::ReadJson(Json::Value& result,
124 const std::string& instancePublicId) 124 const std::string& instancePublicId)
125 { 125 {
126 std::string s; 126 std::string s;
127 ReadFile(s, instancePublicId, FileType_Json); 127 ReadFile(s, instancePublicId, FileContentType_Json);
128 128
129 Json::Reader reader; 129 Json::Reader reader;
130 if (!reader.parse(s, result)) 130 if (!reader.parse(s, result))
131 { 131 {
132 throw OrthancException("Corrupted JSON file"); 132 throw OrthancException("Corrupted JSON file");
134 } 134 }
135 135
136 136
137 void ServerContext::ReadFile(std::string& result, 137 void ServerContext::ReadFile(std::string& result,
138 const std::string& instancePublicId, 138 const std::string& instancePublicId,
139 FileType content) 139 FileContentType content)
140 { 140 {
141 FileInfo attachment; 141 FileInfo attachment;
142 if (!index_.LookupAttachment(attachment, instancePublicId, content)) 142 if (!index_.LookupAttachment(attachment, instancePublicId, content))
143 { 143 {
144 throw OrthancException(ErrorCode_InternalError); 144 throw OrthancException(ErrorCode_InternalError);