List of usage examples for javax.activation MimeType MimeType
public MimeType(String rawdata) throws MimeTypeParseException
From source file:org.kalypso.commons.java.activation.MimeTypeUtils.java
/** * Tries to parse a mime type via {@link MimeType#MimeType(String)}, but silently ignores any error. * //from w w w. jav a 2 s.c om * @return <code>null</code>, if a {@link MimeTypeParseException} is thrown. */ public static MimeType createQuietly(final String mimetype) { try { if (StringUtils.isBlank(mimetype)) return null; return new MimeType(mimetype); } catch (final MimeTypeParseException e) { // ignored } return null; }
From source file:org.mule.transformer.types.SimpleDataType.java
public SimpleDataType(Class<?> type, String mimeType) { this.type = type; if (mimeType == null) { this.mimeType = ANY_MIME_TYPE; } else {/* www. j ava 2 s . c o m*/ try { MimeType mt = new MimeType(mimeType); this.mimeType = mt.getPrimaryType() + "/" + mt.getSubType(); if (mt.getParameter("charset") != null) { encoding = mt.getParameter("charset"); } } catch (MimeTypeParseException e) { //TODO, this should really get thrown throw new MuleRuntimeException(e); } } }
From source file:ddf.catalog.source.opensearch.SecureRemoteConnectionImpl.java
private static MimeType createDefaultMimeType() { try {//www. java2 s . c o m return new MimeType("application/octet-stream"); } catch (MimeTypeParseException e) { LOGGER.debug("Problem creating default mime type."); } return new MimeType(); }
From source file:ddf.service.kml.internal.TransformedContentImpl.java
@Override public MimeType getMimeType() { MimeType type = null;/*from www. j a v a 2 s. c o m*/ try { type = new MimeType(mimetype); } catch (MimeTypeParseException e) { } return type; }
From source file:ddf.catalog.data.BinaryContentImplTest.java
@Before public void setUp() { content = new File("src/test/resources/data/i4ce.png"); MimetypesFileTypeMap mimeMapper = new MimetypesFileTypeMap(); try {/*from w w w .j av a2 s . c o m*/ mimeType = new MimeType(mimeMapper.getContentType(content)); } catch (MimeTypeParseException e) { LOGGER.error("Mime parser Failure", e); new Failure(null, e); } }
From source file:eu.fusepool.deduplication.transformer.DuplicatesTransformer.java
@Override public Set<MimeType> getSupportedInputFormats() { try {//w w w. jav a 2 s .c o m MimeType mimeType = new MimeType("text/plain;charset=UTF-8"); return Collections.singleton(mimeType); } catch (MimeTypeParseException ex) { throw new RuntimeException(ex); } }
From source file:org.mule.intents.TypeChecker.java
public Object onCall(MuleEventContext eventContext) throws Exception { //Check outbound first since this would override the inbound Content-type in the flow String contentType = (String) eventContext.getMessage().getOutboundProperty(("Content-Type")); if (contentType == null) { contentType = (String) eventContext.getMessage().getInboundProperty(("Content-Type")); if (contentType == null) { logger.error("current message doesn't have a 'Content-Type' header set"); logger.error(eventContext.getMessage().toString()); return eventContext; }/*from w w w.j a v a 2 s . co m*/ } MimeType mimeType = new MimeType(contentType); if (!filter.accept(mimeType.getPrimaryType() + "/" + mimeType.getSubType())) { throw new IllegalArgumentException("The current message content type: " + contentType + " is not compatible with return data-type for template: " + getTemplate() + ". This Template output data type should be: " + getTypes()); } return eventContext.getMessage(); }
From source file:org.osaf.cosmo.dav.impl.StandardDavRequest.java
private static final MimeType registerMimeType(String s) { try {/* w w w .j av a 2s .com*/ return new MimeType(s); } catch (Exception e) { throw new RuntimeException("Can't register MIME type " + s, e); } }
From source file:org.codice.ddf.spatial.kml.transformer.KmzTransformerTest.java
@Before public void setup() throws IOException, MimeTypeParseException { kmzTransformer = new KmzTransformer(kmlTransformer); kmzMimetype = new MimeType("application/vnd.google-earth.kmz"); }
From source file:ddf.content.provider.filesystem.ContentFile.java
protected ContentFile(File file, String id, String mimeTypeRawData, String filename) { this.file = file; this.mimeTypeRawData = mimeTypeRawData; this.id = id; this.mimeType = null; this.filename = filename; // DDF-1856 if (filename == null && file != null) { LOGGER.debug("Input filename is NULL, setting to file.getName()"); this.filename = file.getName(); }//from ww w .jav a 2 s . com // Determine mime type only if incoming raw data is non-null. // The mime type raw data is null for content items to be deleted since // deletion operation only needs the id. if (mimeTypeRawData != null) { try { this.mimeType = new MimeType(mimeTypeRawData); } catch (MimeTypeParseException e) { LOGGER.debug("Unable to create MimeType from raw data " + mimeTypeRawData); this.mimeType = null; } } }