Examples of MimetypesFileTypeMap


Examples of javax.activation.MimetypesFileTypeMap

  private static FileTypeMap loadFileTypeMapFromContextSupportModule() {
    // see if we can find the extended mime.types from the context-support module
    InputStream is = ClassLoader.getSystemResourceAsStream("com/sampullara/mustache/mimes.txt");
    if (null != is) {
      return new MimetypesFileTypeMap(is);
    }
    return FileTypeMap.getDefaultFileTypeMap();
  }
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

            if (!f.exists()){
                resp.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                return;
            }

            MediaType mimetype = new MediaType(new MimetypesFileTypeMap().getContentType(f));
            resp.setEntity(new FileRepresentation(f, mimetype, 10));
    }
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

            if ( currentFile != null && !currentFile.equals( "" ) )
            {
                String dir;

                //TODO: maybe create a plexus component for this so that additional mimetypes can be easily added
                MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
                mimeTypesMap.addMimeTypes( "application/java-archive jar war ear" );
                mimeTypesMap.addMimeTypes( "application/java-class class" );
                mimeTypesMap.addMimeTypes( "image/png png" );

                if ( FILE_SEPARATOR.equals( userDirectory ) )
                {
                    dir = userDirectory;
                }
                else
                {
                    dir = FILE_SEPARATOR + userDirectory + FILE_SEPARATOR;
                }

                downloadFile = new File( getContinuum().getWorkingDirectory( projectId ) + dir + currentFile );
                mimeType = mimeTypesMap.getContentType( downloadFile );
                downloadFileLength = Long.toString( downloadFile.length() );
                downloadFileName = downloadFile.getName();

                if ( ( mimeType.indexOf( "image" ) >= 0 ) || ( mimeType.indexOf( "java-archive" ) >= 0 ) ||
                    ( mimeType.indexOf( "java-class" ) >= 0 ) || ( downloadFile.length() > 100000 ) )
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

                    SYSTEM_GADGETS_PATH + file.getAbsolutePath().substring(rootPath.length())
                            .replaceAll("[/\\\\]+", "/");

            // Adding the file to the Registry            
            Resource fileResource = registry.newResource();
            fileResource.setMediaType(new MimetypesFileTypeMap().getContentType(file));
            fileResource.setContentStream(new FileInputStream(file));
            registry.put(fileRegistryPath, fileResource);

        } catch (DashboardPopulatorException e) {
            log.error(e);
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

                    if (filename.contains(".")) {
                        String fileExt = filename.substring(filename.lastIndexOf(".") + 1);
                        mediaType = extensionToMediaTypeMap.get(fileExt.toLowerCase());
                    }
                    if (mediaType == null) {
                        mediaType = new MimetypesFileTypeMap().getContentType(file);
                    }
                    newResource.setMediaType(mediaType);
                    newResource.setContentStream(new FileInputStream(file));
                    registry.put(fileRegistryPath, newResource);
                }
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

                    SYSTEM_DEFAULT_THEMES_PATH + file.getAbsolutePath().substring(rootPath.length())
                            .replaceAll("[/\\\\]+", "/");

            // Adding the file to the Registry
            Resource fileResource = registry.newResource();
            fileResource.setMediaType(new MimetypesFileTypeMap().getContentType(file));

            fileResource.setContentStream(new FileInputStream(file));
            registry.put(fileRegistryPath, fileResource);

        } catch (ThemePopulatorException e) {
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

    String temp = Normalizer.normalize(s, Normalizer.Form.NFKD);
    return temp.replaceAll("[^\\p{ASCII}]", ""); //$NON-NLS-1$ //$NON-NLS-2$
  }

  public String getMIMEType(String fileName) {
    return new MimetypesFileTypeMap().getContentType(fileName);
  }
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

  public String getMIMEType(String fileName) {
    return new MimetypesFileTypeMap().getContentType(fileName);
  }
 
  public String getMIMEType(File file) {
    return new MimetypesFileTypeMap().getContentType(file);
  }
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

   * @param fileName
   *            path of input file.
   * @return MIME type.
   */
  public static String getContentType(String fileName) {
    return new MimetypesFileTypeMap().getContentType(fileName);
  }
View Full Code Here

Examples of javax.activation.MimetypesFileTypeMap

   *
   * @param file File
   * @return MIME type.
   */
  public static String getContentType(File file) {
    return new MimetypesFileTypeMap().getContentType(file);
  }
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.