use of javax.xml.bind.ValidationException in project OpenAM by OpenRock.
the class ValidatorImpl method validate.
private boolean validate(Object o, boolean validateId) throws ValidationException {
try {
//ValidatableObject vo = Util.toValidatableObject(o);
ValidatableObject vo = jaxbContext.getGrammarInfo().castToValidatableObject(o);
if (vo == null)
throw new ValidationException(Messages.format(Messages.NOT_VALIDATABLE));
EventInterceptor ei = new EventInterceptor(eventHandler);
ValidationContext context = new ValidationContext(jaxbContext, ei, validateId);
context.validate(vo);
context.reconcileIDs();
return !ei.hadError();
} catch (SAXException e) {
// we need a consistent mechanism to convert SAXException into JAXBException
Exception nested = e.getException();
if (nested != null) {
throw new ValidationException(nested);
} else {
throw new ValidationException(e);
}
//return false;
}
}
use of javax.xml.bind.ValidationException in project OpenAM by OpenRock.
the class ValidatorImpl method validate.
private boolean validate(Object o, boolean validateId) throws ValidationException {
try {
//ValidatableObject vo = Util.toValidatableObject(o);
ValidatableObject vo = jaxbContext.getGrammarInfo().castToValidatableObject(o);
if (vo == null)
throw new ValidationException(Messages.format(Messages.NOT_VALIDATABLE));
EventInterceptor ei = new EventInterceptor(eventHandler);
ValidationContext context = new ValidationContext(jaxbContext, ei, validateId);
context.validate(vo);
context.reconcileIDs();
return !ei.hadError();
} catch (SAXException e) {
// we need a consistent mechanism to convert SAXException into JAXBException
Exception nested = e.getException();
if (nested != null) {
throw new ValidationException(nested);
} else {
throw new ValidationException(e);
}
//return false;
}
}
use of javax.xml.bind.ValidationException in project OpenAM by OpenRock.
the class ValidatorImpl method validate.
private boolean validate(Object o, boolean validateId) throws ValidationException {
try {
//ValidatableObject vo = Util.toValidatableObject(o);
ValidatableObject vo = jaxbContext.getGrammarInfo().castToValidatableObject(o);
if (vo == null)
throw new ValidationException(Messages.format(Messages.NOT_VALIDATABLE));
EventInterceptor ei = new EventInterceptor(eventHandler);
ValidationContext context = new ValidationContext(jaxbContext, ei, validateId);
context.validate(vo);
context.reconcileIDs();
return !ei.hadError();
} catch (SAXException e) {
// we need a consistent mechanism to convert SAXException into JAXBException
Exception nested = e.getException();
if (nested != null) {
throw new ValidationException(nested);
} else {
throw new ValidationException(e);
}
//return false;
}
}
use of javax.xml.bind.ValidationException in project OpenAM by OpenRock.
the class ValidatorImpl method validate.
private boolean validate(Object o, boolean validateId) throws ValidationException {
try {
//ValidatableObject vo = Util.toValidatableObject(o);
ValidatableObject vo = jaxbContext.getGrammarInfo().castToValidatableObject(o);
if (vo == null)
throw new ValidationException(Messages.format(Messages.NOT_VALIDATABLE));
EventInterceptor ei = new EventInterceptor(eventHandler);
ValidationContext context = new ValidationContext(jaxbContext, ei, validateId);
context.validate(vo);
context.reconcileIDs();
return !ei.hadError();
} catch (SAXException e) {
// we need a consistent mechanism to convert SAXException into JAXBException
Exception nested = e.getException();
if (nested != null) {
throw new ValidationException(nested);
} else {
throw new ValidationException(e);
}
//return false;
}
}
use of javax.xml.bind.ValidationException in project tomee by apache.
the class JaxbOpenejb method writeConfig.
public static void writeConfig(final String configFile, final Openejb openejb) throws OpenEJBException {
OutputStream out = null;
try {
final File file = new File(configFile);
out = IO.write(file);
marshal(Openejb.class, openejb, out);
} catch (final IOException e) {
throw new OpenEJBException(messages().format("conf.1040", configFile, e.getLocalizedMessage()), e);
} catch (final MarshalException e) {
if (e.getCause() instanceof IOException) {
throw new OpenEJBException(messages().format("conf.1040", configFile, e.getLocalizedMessage()), e);
} else {
throw new OpenEJBException(messages().format("conf.1050", configFile, e.getLocalizedMessage()), e);
}
} catch (final ValidationException e) {
/* NOTE: This doesn't seem to ever happen. When the object graph
* is invalid, the MarshalException is thrown, not this one as you
* would think.
*/
throw new OpenEJBException(messages().format("conf.1060", configFile, e.getLocalizedMessage()), e);
} catch (final JAXBException e) {
throw new OpenEJBException(e);
} finally {
if (out != null) {
try {
out.close();
} catch (final Exception e) {
// no-op
}
}
}
}
Aggregations