Examples of FileTypeMap


Examples of javax.activation.FileTypeMap

   * or a default ConfigurableMimeFileTypeMap if none found for the message
   * @see ConfigurableMimeFileTypeMap
   */
  protected FileTypeMap getDefaultFileTypeMap(MimeMessage mimeMessage) {
    if (mimeMessage instanceof SmartMimeMessage) {
      FileTypeMap fileTypeMap = ((SmartMimeMessage) mimeMessage).getDefaultFileTypeMap();
      if (fileTypeMap != null) {
        return fileTypeMap;
      }
    }
    ConfigurableMimeFileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
    fileTypeMap.afterPropertiesSet();
    return fileTypeMap;
  }
View Full Code Here

Examples of javax.activation.FileTypeMap

                + "/resource/" + file.getPath();
        String viewURI = absUrl
                + "/resources/" + website.getHandle()
                + "/" + file.getPath();
       
        FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
        // TODO: figure out why PNG is missing from Java MIME types
        if (map instanceof MimetypesFileTypeMap) {
            try {
                ((MimetypesFileTypeMap)map).addMimeTypes("image/png png PNG");
            } catch (Exception ignored) {}
        }
        String contentType = map.getContentType(file.getName());
       
        Entry entry = new Entry();
        entry.setId(editMediaURI);
        entry.setTitle(file.getName());
        entry.setUpdated(new Date(file.getLastModified()));
View Full Code Here

Examples of javax.activation.FileTypeMap

   * Introduced to dispel claims in a thread on Stack Overflow:
   * <a href="http://stackoverflow.com/questions/22986109/testing-spring-managed-servlet">Testing Spring managed servlet</a>
   */
  @Test
  public void getMimeTypeWithCustomConfiguredType() {
    FileTypeMap defaultFileTypeMap = FileTypeMap.getDefaultFileTypeMap();
    assertThat(defaultFileTypeMap, instanceOf(MimetypesFileTypeMap.class));
    MimetypesFileTypeMap mimetypesFileTypeMap = (MimetypesFileTypeMap) defaultFileTypeMap;
    mimetypesFileTypeMap.addMimeTypes("text/enigma    enigma");
    assertEquals("text/enigma", sc.getMimeType("filename.enigma"));
  }
View Full Code Here

Examples of javax.activation.FileTypeMap

    sender.setUsername("username");
    sender.setPassword("password");

    MimeMessageHelper message = new MimeMessageHelper(sender.createMimeMessage(), "UTF-8");
    assertEquals("UTF-8", message.getEncoding());
    FileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
    message.setFileTypeMap(fileTypeMap);
    assertEquals(fileTypeMap, message.getFileTypeMap());

    message.setTo("you@mail.org");
    sender.send(message.getMimeMessage());
View Full Code Here

Examples of javax.activation.FileTypeMap

    sender.setHost("host");
    sender.setUsername("username");
    sender.setPassword("password");
    sender.setDefaultEncoding("UTF-8");

    FileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
    sender.setDefaultFileTypeMap(fileTypeMap);
    MimeMessageHelper message = new MimeMessageHelper(sender.createMimeMessage());
    assertEquals("UTF-8", message.getEncoding());
    assertEquals(fileTypeMap, message.getFileTypeMap());
View Full Code Here

Examples of javax.activation.FileTypeMap

                    mimeMappings.put(parts[i], parts[0]);
                }
            }
        }

        return new FileTypeMap() {
            @Override
            public String getContentType(File file) {
                return getContentType(file.getName());
            }
View Full Code Here

Examples of javax.activation.FileTypeMap

                + "/resource/" + file.getName();
        String viewURI = absUrl
                + "/resources/" + website.getHandle()
                + "/" + file.getName();
       
        FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
        // TODO: figure out why PNG is missing from Java MIME types
        if (map instanceof MimetypesFileTypeMap) {
            try {
                ((MimetypesFileTypeMap)map).addMimeTypes("image/png png PNG");
            } catch (Exception ignored) {}
        }
        String contentType = map.getContentType(file);
       
        Entry entry = new Entry();
        entry.setId(editMediaURI);
        entry.setTitle(file.getName());
        entry.setUpdated(new Date(file.lastModified()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.