Revision 9244
Added by ben leinfelder over 9 years ago
src/edu/ucsb/nceas/metacat/restservice/v2/MNResourceHandler.java | ||
---|---|---|
76 | 76 |
import org.dataone.service.types.v2.MediaType; |
77 | 77 |
import org.dataone.service.types.v2.MediaTypeProperty; |
78 | 78 |
import org.dataone.service.types.v2.Node; |
79 |
import org.dataone.service.types.v2.ObjectFormat; |
|
79 | 80 |
import org.dataone.service.types.v2.OptionList; |
80 | 81 |
import org.dataone.service.types.v2.SystemMetadata; |
81 | 82 |
import org.dataone.service.util.Constants; |
... | ... | |
1168 | 1169 |
// set the headers for the content |
1169 | 1170 |
String mimeType = null; |
1170 | 1171 |
String charset = null; |
1172 |
ObjectFormat objectFormat = null; |
|
1171 | 1173 |
|
1174 |
try { |
|
1175 |
objectFormat = ObjectFormatCache.getInstance().getFormat(sm.getFormatId()); |
|
1176 |
} catch (BaseException be) { |
|
1177 |
logMetacat.warn("Could not lookup ObjectFormat for: " + sm.getFormatId(), be); |
|
1178 |
} |
|
1172 | 1179 |
// do we have mediaType/encoding in SM? |
1173 | 1180 |
MediaType mediaType = sm.getMediaType(); |
1174 | 1181 |
if (mediaType == null) { |
1175 | 1182 |
try { |
1176 |
mediaType = ObjectFormatCache.getInstance().getFormat(sm.getFormatId()).getMediaType();
|
|
1177 |
} catch (BaseException be) {
|
|
1178 |
logMetacat.warn("Could not lookup ObjectFormat MediaType for: " + sm.getFormatId(), be);
|
|
1183 |
mediaType = objectFormat.getMediaType();
|
|
1184 |
} catch (Exception e) {
|
|
1185 |
logMetacat.warn("Could not lookup MediaType for: " + sm.getFormatId(), e);
|
|
1179 | 1186 |
} |
1180 | 1187 |
} |
1181 | 1188 |
if (mediaType != null) { |
... | ... | |
1208 | 1215 |
String filename = sm.getFileName(); |
1209 | 1216 |
// then fallback to using id and extension |
1210 | 1217 |
if (filename == null) { |
1211 |
String extension = ObjectFormatInfo.instance().getExtension(sm.getFormatId().getValue()); |
|
1218 |
String extension = objectFormat.getExtension(); |
|
1219 |
if (extension == null) { |
|
1220 |
extension = ObjectFormatInfo.instance().getExtension(sm.getFormatId().getValue()); |
|
1221 |
} |
|
1212 | 1222 |
filename = id.getValue(); |
1213 | 1223 |
if (extension != null) { |
1214 | 1224 |
filename = id.getValue() + extension; |
Also available in: Unified diff
use objectFormat.extension in cases where we need to construct a filename for download. https://redmine.dataone.org/issues/3312