Example usage for javax.activation MimeTypeParseException getCause

List of usage examples for javax.activation MimeTypeParseException getCause

Introduction

In this page you can find the example usage for javax.activation MimeTypeParseException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.osaf.cosmo.dav.impl.StandardDavRequest.java

private Document getSafeRequestDocument(boolean requireDocument) throws DavException {
    try {/*from  ww w . jav a 2  s  .  co m*/
        if (StringUtils.isBlank(getContentType())) {
            if (requireDocument)
                throw new BadRequestException("No Content-Type specified");
            return null;
        }
        MimeType mimeType = new MimeType(getContentType());
        if (!(mimeType.match(APPLICATION_XML) || mimeType.match(TEXT_XML)))
            throw new UnsupportedMediaTypeException(
                    "Expected Content-Type " + APPLICATION_XML + " or " + TEXT_XML);
        return getRequestDocument();
    } catch (MimeTypeParseException e) {
        throw new UnsupportedMediaTypeException(e.getMessage());
    } catch (IllegalArgumentException e) {
        Throwable cause = e.getCause();
        String msg = cause != null ? cause.getMessage() : null;
        if (msg == null)
            msg = "Unknown error parsing request document";
        throw new BadRequestException(msg);
    }
}