org.springframework.oxm.ValidationFailureException Java Examples

The following examples show how to use org.springframework.oxm.ValidationFailureException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Jaxb2Marshaller.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Convert the given {@code JAXBException} to an appropriate exception
 * from the {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occurred
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertJaxbException(JAXBException ex) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JAXB validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		return new MarshallingFailureException("JAXB marshalling exception", ex);
	}
	else if (ex instanceof UnmarshalException) {
		return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown JAXB exception", ex);
	}
}
 
Example #2
Source File: Jaxb2Marshaller.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Convert the given {@code JAXBException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occurred
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertJaxbException(JAXBException ex) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JAXB validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		return new MarshallingFailureException("JAXB marshalling exception", ex);
	}
	else if (ex instanceof UnmarshalException) {
		return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown JAXB exception", ex);
	}
}
 
Example #3
Source File: CastorMarshaller.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Convert the given {@code XMLException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since Castor itself does not make this distinction in its exception hierarchy.
 * @param ex the Castor {@code XMLException} that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertCastorException(XMLException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("Castor validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		if (marshalling) {
			return new MarshallingFailureException("Castor marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("Castor unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown Castor exception", ex);
	}
}
 
Example #4
Source File: Jaxb2Marshaller.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the given {@code JAXBException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occured
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertJaxbException(JAXBException ex) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JAXB validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		return new MarshallingFailureException("JAXB marshalling exception", ex);
	}
	else if (ex instanceof UnmarshalException) {
		return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown JAXB exception", ex);
	}
}
 
Example #5
Source File: CastorMarshaller.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the given {@code XMLException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since Castor itself does not make this distinction in its exception hierarchy.
 * @param ex Castor {@code XMLException} that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertCastorException(XMLException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("Castor validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		if (marshalling) {
			return new MarshallingFailureException("Castor marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("Castor unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown Castor exception", ex);
	}
}
 
Example #6
Source File: XmlBeansMarshaller.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the given XMLBeans exception to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since XMLBeans itself does not make this distinction in its exception hierarchy.
 * @param ex XMLBeans Exception that occured
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertXmlBeansException(Exception ex, boolean marshalling) {
	if (ex instanceof XMLStreamValidationException) {
		return new ValidationFailureException("XMLBeans validation exception", ex);
	}
	else if (ex instanceof XmlException || ex instanceof SAXException) {
		if (marshalling) {
			return new MarshallingFailureException("XMLBeans marshalling exception",  ex);
		}
		else {
			return new UnmarshallingFailureException("XMLBeans unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown XMLBeans exception", ex);
	}
}
 
Example #7
Source File: JibxMarshaller.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Convert the given {@code JiBXException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since JiBX itself does not make this distinction in its exception hierarchy.
 * @param ex {@code JiBXException} that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
public XmlMappingException convertJibxException(JiBXException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JiBX validation exception", ex);
	}
	else {
		if (marshalling) {
			return new MarshallingFailureException("JiBX marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("JiBX unmarshalling exception", ex);
		}
	}
}
 
Example #8
Source File: JibxMarshaller.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Convert the given {@code JiBXException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since JiBX itself does not make this distinction in its exception hierarchy.
 * @param ex {@code JiBXException} that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
public XmlMappingException convertJibxException(JiBXException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JiBX validation exception", ex);
	}
	else {
		if (marshalling) {
			return new MarshallingFailureException("JiBX marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("JiBX unmarshalling exception", ex);
		}
	}
}
 
Example #9
Source File: JibxMarshaller.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Convert the given {@code JiBXException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since JiBX itself does not make this distinction in its exception hierarchy.
 * @param ex {@code JiBXException} that occured
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
public XmlMappingException convertJibxException(JiBXException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JiBX validation exception", ex);
	}
	else {
		if (marshalling) {
			return new MarshallingFailureException("JiBX marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("JiBX unmarshalling exception", ex);
		}
	}
}
 
Example #10
Source File: XmlBeansUnmarshallerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test(expected = ValidationFailureException.class)
public void validate() throws Exception {
	unmarshaller.setValidating(true);
	String invalidInput = "<tns:flights xmlns:tns=\"http://samples.springframework.org/flight\">" +
			"<tns:flight><tns:number>abc</tns:number></tns:flight></tns:flights>";
	unmarshaller.unmarshal(new StreamSource(new StringReader(invalidInput)));
}