Package javax.activation

Examples of javax.activation.MimetypesFileTypeMap


          logger.trace("Loading Java Activation Framework FileTypeMap from " + resource);
        }
        InputStream inputStream = null;
        try {
          inputStream = resource.getInputStream();
          return new MimetypesFileTypeMap(inputStream);
        }
        catch (IOException ex) {
          // ignore
        }
        finally {
View Full Code Here


      Resource mappingLocation = new ClassPathResource("org/springframework/mail/javamail/mime.types");
      if (mappingLocation.exists()) {
        InputStream inputStream = null;
        try {
          inputStream = mappingLocation.getInputStream();
          return new MimetypesFileTypeMap(inputStream);
        }
        catch (IOException ex) {
          // ignore
        }
        finally {
View Full Code Here

      Resource mappingLocation = new ClassPathResource("org/springframework/mail/javamail/mime.types");
      if (mappingLocation.exists()) {
        InputStream inputStream = null;
        try {
          inputStream = mappingLocation.getInputStream();
          return new MimetypesFileTypeMap(inputStream);
        }
        catch (IOException ex) {
          // ignore
        }
        finally {
View Full Code Here

          logger.trace("Loading Java Activation Framework FileTypeMap from " + mappingLocation);
        }
        InputStream inputStream = null;
        try {
          inputStream = mappingLocation.getInputStream();
          return new MimetypesFileTypeMap(inputStream);
        }
        catch (IOException ex) {
          // ignore
        }
        finally {
View Full Code Here

   * @throws IOException if resource access failed
   * @see javax.activation.MimetypesFileTypeMap#MimetypesFileTypeMap(java.io.InputStream)
   * @see javax.activation.MimetypesFileTypeMap#addMimeTypes(String)
   */
  protected FileTypeMap createFileTypeMap(Resource mappingLocation, String[] mappings) throws IOException {
    MimetypesFileTypeMap fileTypeMap = null;
    if (mappingLocation != null) {
      InputStream is = mappingLocation.getInputStream();
      try {
        fileTypeMap = new MimetypesFileTypeMap(is);
      }
      finally {
        is.close();
      }
    }
    else {
      fileTypeMap = new MimetypesFileTypeMap();
    }
    if (mappings != null) {
      for (int i = 0; i < mappings.length; i++) {
        fileTypeMap.addMimeTypes(mappings[i]);
      }
    }
    return fileTypeMap;
  }
View Full Code Here

    private MimetypesFileTypeMap mimeTypes;

    @Override
    public void initialise() throws InitialisationException
    {
        mimeTypes = new MimetypesFileTypeMap();
        mimeTypes.addMimeTypes("text/javascript js");
        mimeTypes.addMimeTypes("text/css css");
    }
View Full Code Here

     *
     * @param file for which the mime type needs to be detected
     * @return the detected mime type
     */
    private String determineMimeType(File file){
        String mimeType = new MimetypesFileTypeMap().getContentType(file);
        // if mimeType detection failed, fall back to the default
        if (mimeType == null || mimeType.equalsIgnoreCase("")){
            mimeType = DEFAULT_MIMETYPE;
        }
        return mimeType;
View Full Code Here

        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 );

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

        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 );

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

          logger.trace("Loading Java Activation Framework FileTypeMap from " + mappingLocation);
        }
        InputStream inputStream = null;
        try {
          inputStream = mappingLocation.getInputStream();
          return new MimetypesFileTypeMap(inputStream);
        }
        catch (IOException ex) {
          // ignore
        }
        finally {
View Full Code Here

TOP

Related Classes of javax.activation.MimetypesFileTypeMap

Copyright © 2018 www.massapicom. 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.