mirror of https://github.com/apache/openjpa.git
OPENJPA-1111 Validation mode of callback should cause a PersistenceException when no provider is available. Part 2 - updated WrapperedException to properly pass on the exception, updated ValidationException to allow for setting the fatal flag, and updated the location of the localizer messages for ValidationUtils.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@785861 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
472cf99ab4
commit
bc9654cfc5
|
@ -18,20 +18,36 @@
|
|||
*/
|
||||
package org.apache.openjpa.util;
|
||||
|
||||
import org.apache.openjpa.lib.util.Localizer.Message;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
/**
|
||||
* Identifiable exception type which wraps an internal runtime exception.
|
||||
*/
|
||||
public class WrappedException extends OpenJPAException {
|
||||
|
||||
private RuntimeException _wrappedException = null;
|
||||
|
||||
public WrappedException(RuntimeException e) {
|
||||
_wrappedException = e;
|
||||
/*
|
||||
* Methods extending OpenJPAException
|
||||
* See StoreException for similar behavior
|
||||
*/
|
||||
public WrappedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public RuntimeException getWrapped() {
|
||||
return _wrappedException;
|
||||
|
||||
public WrappedException(Message msg) {
|
||||
super(msg.getMessage());
|
||||
}
|
||||
|
||||
public WrappedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public WrappedException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
public WrappedException(Message msg, Throwable cause) {
|
||||
super(msg.getMessage(), cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,4 +26,9 @@ public class ValidationException extends WrappedException {
|
|||
public ValidationException(RuntimeException e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public ValidationException(RuntimeException e, boolean fatal) {
|
||||
super(e);
|
||||
setFatal(fatal);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,8 @@ public class ValidationUtils {
|
|||
// fatal error - ValidationMode requires a validator
|
||||
log.error(_loc.get("vlem-creation-error"), e);
|
||||
// rethrow as a WrappedException
|
||||
throw new ValidationException(new RuntimeException(e));
|
||||
throw new ValidationException(
|
||||
new RuntimeException(e), true);
|
||||
} else {
|
||||
// no optional validation provider, so just trace output
|
||||
if (log.isTraceEnabled()) {
|
||||
|
@ -106,7 +107,7 @@ public class ValidationUtils {
|
|||
// fatal error - ValidationMode requires a validator
|
||||
log.error(_loc.get("vlem-creation-error"), e);
|
||||
// rethrow as a WrappedException
|
||||
throw new ValidationException(e);
|
||||
throw new ValidationException(e, true);
|
||||
} else {
|
||||
// unexpected, but validation is optional,
|
||||
// so just log it as a warning
|
||||
|
|
|
@ -196,9 +196,5 @@ invalid-orderBy: This is not a valid OrderBy annotation. The property or \
|
|||
dynamic-agent: OpenJPA dynamically loaded the class enhancer. Any classes \
|
||||
that were not enhanced at build time will be enhanced when they are \
|
||||
loaded by the JVM.
|
||||
vlem-creation-warn: Could not create the optional validation provider. \
|
||||
Reason returned: "{0}"
|
||||
vlem-creation-error: A fatal error occurred while trying to \
|
||||
create the required validation provider.
|
||||
vlem-creation-info: OpenJPA dynamically loaded a validation provider.
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
vlem-creation-warn: Could not create the optional validation provider. \
|
||||
Reason returned: "{0}"
|
||||
vlem-creation-error: A fatal error occurred while trying to \
|
||||
create the required validation provider.
|
||||
|
Loading…
Reference in New Issue