@Test
 public void mimetype_with_value_set_from_mimetype() throws Exception {
   final MimeType value = new MimeType(SOME_IMAGE_MIME_TYPE);
   imageBuilder.setMimeType(value);
   assertEquals(
       "Mime Type should have been set correctly.", value.toString(), imageBuilder.getMimeType());
 }
 private void setMimeType(CMVisual mediaItem, MediaContent mediaContent) {
   try {
     String type = mediaItem.getData().getContentType().toString();
     MimeType mimeType = new MimeType(type);
     mediaContent.setMedium(mimeType.getPrimaryType());
     mediaContent.setType(mimeType.toString());
   } catch (MimeTypeParseException e) {
     LOG.error("Cannot create mimetype for " + mediaItem, e);
   }
 }
Esempio n. 3
0
 /**
  * Returns the must probable resource type for a MimeType.
  *
  * @param mimeType
  * @return
  */
 public static String getResourceType(final MimeType mimeType) {
   final String result = DEFAULT_FILE_EXTENSIONS.get(mimeType.toString());
   return result != null ? result : DEFAULT_FILE_EXTENSION;
 }