Java 类org.springframework.util.InvalidMimeTypeException 实例源码

项目:spring4-understanding    文件:StompDecoder.java   
private void readHeaders(ByteBuffer buffer, StompHeaderAccessor headerAccessor) {
    while (true) {
        ByteArrayOutputStream headerStream = new ByteArrayOutputStream(256);
        boolean headerComplete = false;
        while (buffer.hasRemaining()) {
            if (tryConsumeEndOfLine(buffer)) {
                headerComplete = true;
                break;
            }
            headerStream.write(buffer.get());
        }
        if (headerStream.size() > 0 && headerComplete) {
            String header = new String(headerStream.toByteArray(), UTF8_CHARSET);
            int colonIndex = header.indexOf(':');
            if (colonIndex <= 0) {
                if (buffer.remaining() > 0) {
                    throw new StompConversionException("Illegal header: '" + header +
                            "'. A header must be of the form <name>:[<value>].");
                }
            }
            else {
                String headerName = unescape(header.substring(0, colonIndex));
                String headerValue = unescape(header.substring(colonIndex + 1));
                try {
                    headerAccessor.addNativeHeader(headerName, headerValue);
                }
                catch (InvalidMimeTypeException ex) {
                    if (buffer.remaining() > 0) {
                        throw ex;
                    }
                }
            }
        }
        else {
            break;
        }
    }
}
项目:spring4-understanding    文件:DefaultContentTypeResolverTests.java   
@Test(expected = InvalidMimeTypeException.class)
public void resolveInvalidStringContentType() {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(MessageHeaders.CONTENT_TYPE, "invalidContentType");
    MessageHeaders headers = new MessageHeaders(map);
    this.resolver.resolve(headers);
}
项目:dhis2-core    文件:FileResourceUtils.java   
/**
 * Indicates whether the content type represented by the given string
 * is a valid, known content type.
 * 
 * @param contentType the content type string.
 * @return true if the content is valid, false if not.
 */
public static boolean isValidContentType( String contentType )
{
    try
    {
        MimeTypeUtils.parseMimeType( contentType );
    }
    catch ( InvalidMimeTypeException ignored )
    {
        return false;
    }

    return true;
}
项目:AgileAlligators    文件:FileResourceController.java   
private boolean isValidContentType( String contentType )
{
    try
    {
        MimeTypeUtils.parseMimeType( contentType );
    }
    catch ( InvalidMimeTypeException e )
    {
        return false;
    }

    return true;
}
项目:lams    文件:InvalidMediaTypeException.java   
/**
 * Constructor that allows wrapping {@link InvalidMimeTypeException}.
 */
InvalidMediaTypeException(InvalidMimeTypeException ex) {
    super(ex.getMessage(), ex);
    this.mediaType = ex.getMimeType();
}
项目:spring4-understanding    文件:StompCodecTests.java   
@Test(expected = InvalidMimeTypeException.class)
public void decodeFrameWithInvalidContentType() {
    assertIncompleteDecode("SEND\ncontent-type:text/plain;charset=U\n\nThe body\0");
}
项目:spring4-understanding    文件:InvalidMediaTypeException.java   
/**
 * Constructor that allows wrapping {@link InvalidMimeTypeException}.
 */
InvalidMediaTypeException(InvalidMimeTypeException ex) {
    super(ex.getMessage(), ex);
    this.mediaType = ex.getMimeType();
}