Package org.apache.camel

Examples of org.apache.camel.InvalidPayloadException


    public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
        Message instance = getInstance(exchange);
        Builder builder = instance.newBuilderForType().mergeFrom(inputStream);
        if (!builder.isInitialized()) {
            // TODO which exception should be thrown here?
            throw new InvalidPayloadException(exchange, instance.getClass());
        }

        return builder.build();
    }
View Full Code Here


        try {
            service.invalidReturnType("<order type=\"beer\">Carlsberg</order>");
            fail("Should have thrown exception");
        } catch (Exception e) {
            // expected
            InvalidPayloadException cause = assertIsInstanceOf(InvalidPayloadException.class, e.getCause());
            assertEquals(Integer.class, cause.getType());
        }
    }
View Full Code Here

    }

    public Object getMandatoryBody() throws InvalidPayloadException {
        Object answer = getBody();
        if (answer == null) {
            throw new InvalidPayloadException(getExchange(), Object.class, this);
        }
        return answer;
    }
View Full Code Here

        if (e != null) {
            TypeConverter converter = e.getContext().getTypeConverter();
            try {
                return converter.mandatoryConvertTo(type, e, getBody());
            } catch (Exception cause) {
                throw new InvalidPayloadException(e, type, this, cause);
            }
        }
        throw new InvalidPayloadException(e, type, this);
    }
View Full Code Here

    public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
        Message instance = getInstance(exchange);
        Builder builder = instance.newBuilderForType().mergeFrom(inputStream);
        if (!builder.isInitialized()) {
            // TODO which exception should be thrown here?
            throw new InvalidPayloadException(exchange, instance.getClass());
        }

        return builder.build();
    }
View Full Code Here

        if (body instanceof String) {
            return new Gson().toJsonTree(body);
        } else if (body instanceof JsonElement) {
            return (JsonElement) body;
        } else {
            throw new InvalidPayloadException(exchange, body != null ? body.getClass() : null);
        }
    }
View Full Code Here

        ObjectHelper.notNull(defaultInstance, "defaultInstance or instanceClassName must be set", this);

        Builder builder = defaultInstance.newBuilderForType().mergeFrom(inputStream);
        if (!builder.isInitialized()) {
            // TODO which exception should be thrown here?
            throw new InvalidPayloadException(exchange, defaultInstance.getClass());
        }

        return builder.build();
    }
View Full Code Here

    }

    public Object getMandatoryBody() throws InvalidPayloadException {
        Object answer = getBody();
        if (answer == null) {
            throw new InvalidPayloadException(getExchange(), Object.class, this);
        }
        return answer;
    }
View Full Code Here

        if (e != null) {
            TypeConverter converter = e.getContext().getTypeConverter();
            try {
                return converter.mandatoryConvertTo(type, e, getBody());
            } catch (Exception cause) {
                throw new InvalidPayloadException(e, type, this, cause);
            }
        }
        throw new InvalidPayloadException(e, type, this);
    }
View Full Code Here

     * an exception if it is not present
     */
    public static Object getMandatoryInBody(Exchange exchange) throws InvalidPayloadException {
        Object answer = exchange.getIn().getBody();
        if (answer == null) {
            throw new InvalidPayloadException(exchange, Object.class);
        }
        return answer;
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.InvalidPayloadException

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.