From 43e4dbadfe13a2cd786c5ea0f0205d04a061ba66 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 6 May 2014 16:30:13 +0200 Subject: [PATCH] Revert merge commit e246010df7ea726d --- .../EclipseLinkExceptionTranslator.java | 51 ----------------- .../EclipseLinkSystemException.java | 43 -------------- .../orm/eclipselink/EclipseLinkUtils.java | 42 -------------- .../EclipseLinkExceptionTranslatorTests.java | 44 --------------- .../EclipseLinkSystemExceptionTests.java | 56 ------------------- .../eclipselink/EclipseLinkUtilsTests.java | 40 ------------- 6 files changed, 276 deletions(-) delete mode 100644 spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslator.java delete mode 100644 spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkSystemException.java delete mode 100644 spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkUtils.java delete mode 100644 spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslatorTests.java delete mode 100644 spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkSystemExceptionTests.java delete mode 100644 spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkUtilsTests.java diff --git a/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslator.java b/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslator.java deleted file mode 100644 index 6bfcf169838..00000000000 --- a/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslator.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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. - */ - -package org.springframework.orm.eclipselink; - -import org.eclipse.persistence.exceptions.EclipseLinkException; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.support.PersistenceExceptionTranslator; - -/** - * {@link PersistenceExceptionTranslator} capable of translating {@link EclipseLinkException} - * instances to Spring's {@link DataAccessException} hierarchy. - * - * @author Jan Stamer - * @since 4.1 - * @see org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor - */ -public class EclipseLinkExceptionTranslator implements PersistenceExceptionTranslator { - - public DataAccessException translateExceptionIfPossible(RuntimeException ex) { - if (ex instanceof EclipseLinkException) { - return convertEclipseLinkAccessException((EclipseLinkException) ex); - } - return null; - } - - /** - * Convert the given EclipseLinkException to an appropriate exception from - * the {@code org.springframework.dao} hierarchy. - * @param ex EclipseLinkException that occurred - * @return a corresponding DataAccessException - * @see EclipseLinkUtils#convertEclipseLinkAccessException - */ - protected DataAccessException convertEclipseLinkAccessException(EclipseLinkException ex) { - return EclipseLinkUtils.convertEclipseLinkAccessException(ex); - } - -} diff --git a/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkSystemException.java b/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkSystemException.java deleted file mode 100644 index 4392b3de20a..00000000000 --- a/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkSystemException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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. - */ - -package org.springframework.orm.eclipselink; - -import org.eclipse.persistence.exceptions.EclipseLinkException; -import org.springframework.dao.UncategorizedDataAccessException; - -/** - * EclipseLink-specific subclass of UncategorizedDataAccessException, for - * EclipseLink system errors that do not match any concrete - * org.springframework.dao exceptions. - * - * @author Jan Stamer - * @since 4.1 - * @see EclipseLinkUtils#convertEclipseLinkAccessException(EclipseLinkException) - */ -@SuppressWarnings("serial") -public class EclipseLinkSystemException extends UncategorizedDataAccessException { - - /** - * Create a new HibernateSystemException, wrapping an arbitrary - * {@link EclipseLinkException}. - * @param cause the HibernateException thrown - */ - public EclipseLinkSystemException(EclipseLinkException cause) { - super(cause != null ? cause.getMessage() : null, cause); - } - -} diff --git a/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkUtils.java b/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkUtils.java deleted file mode 100644 index 0d5e9cef05f..00000000000 --- a/spring-orm/src/main/java/org/springframework/orm/eclipselink/EclipseLinkUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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. - */ - -package org.springframework.orm.eclipselink; - -import org.eclipse.persistence.exceptions.EclipseLinkException; -import org.springframework.dao.DataAccessException; - -/** - * Helper class featuring methods for Eclipse Link. Also provides support for - * exception translation. - * - * @author Jan Stamer - * @since 3.2 - */ -public abstract class EclipseLinkUtils { - - /** - * Convert the given EclipseLinkException to an appropriate exception from - * the org.springframework.dao hierarchy. - * @param ex EclipseLinkException that occurred - * @return the corresponding DataAccessException instance - * @see EclipseLinkExceptionTranslator#convertEclipseLinkAccessException(EclipseLinkException) - */ - public static DataAccessException convertEclipseLinkAccessException(EclipseLinkException ex) { - return new EclipseLinkSystemException(ex); - } - -} diff --git a/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslatorTests.java b/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslatorTests.java deleted file mode 100644 index 397c456222f..00000000000 --- a/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkExceptionTranslatorTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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. - */ - -package org.springframework.orm.eclipselink; - -import static org.junit.Assert.*; - -import org.eclipse.persistence.exceptions.DatabaseException; -import org.junit.Test; - -/** - * @author Jan Stamer - */ -public class EclipseLinkExceptionTranslatorTests { - - @Test - public void wrongException() { - EclipseLinkExceptionTranslator exceptionTranslator = new EclipseLinkExceptionTranslator(); - assertNull(exceptionTranslator.translateExceptionIfPossible(new IllegalArgumentException())); - } - - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - @Test - public void eclipseLinkException() { - EclipseLinkExceptionTranslator exceptionTranslator = new EclipseLinkExceptionTranslator(); - assertNotNull(exceptionTranslator.translateExceptionIfPossible(DatabaseException.databaseAccessorNotConnected())); - assertNotNull(exceptionTranslator.translateExceptionIfPossible( - DatabaseException.databaseAccessorNotConnected())); - } - -} diff --git a/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkSystemExceptionTests.java b/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkSystemExceptionTests.java deleted file mode 100644 index 0774dac0fe5..00000000000 --- a/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkSystemExceptionTests.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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. - */ - -package org.springframework.orm.eclipselink; - -import static org.junit.Assert.*; - -import org.eclipse.persistence.exceptions.DatabaseException; -import org.hibernate.HibernateException; -import org.junit.Test; - -/** - * @author Jan Stamer - */ -@SuppressWarnings("serial") -public class EclipseLinkSystemExceptionTests { - - @Test - public void withNull() { - EclipseLinkSystemException exception = new EclipseLinkSystemException(null); - assertNull(exception.getCause()); - assertNull(exception.getMessage()); - } - - @Test - public void createWithCause() { - DatabaseException dbExceptionWithCause = new DatabaseException("my custom exception cause") { - }; - EclipseLinkSystemException elSystemException = new EclipseLinkSystemException(dbExceptionWithCause); - assertEquals(dbExceptionWithCause, elSystemException.getCause()); - assertTrue(elSystemException.getMessage().contains("my custom exception cause")); - } - - @Test - public void createWithNullCause() throws HibernateException { - DatabaseException dbExceptionWithCause = new DatabaseException((String) null) { - }; - EclipseLinkSystemException elSystemException = new EclipseLinkSystemException(dbExceptionWithCause); - assertEquals(dbExceptionWithCause, elSystemException.getCause()); - assertTrue(elSystemException.getMessage().contains("null")); - } - -} diff --git a/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkUtilsTests.java b/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkUtilsTests.java deleted file mode 100644 index fa9d804efde..00000000000 --- a/spring-orm/src/test/java/org/springframework/orm/eclipselink/EclipseLinkUtilsTests.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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. - */ - -package org.springframework.orm.eclipselink; - -import static org.junit.Assert.*; - -import org.eclipse.persistence.exceptions.DatabaseException; -import org.junit.Test; - -/** - * @author Jan Stamer - */ -public class EclipseLinkUtilsTests { - - @Test - public void withNull() { - assertNotNull(EclipseLinkUtils.convertEclipseLinkAccessException(null)); - } - - @Test - public void testWithEclipseLinkException() { - assertNotNull(EclipseLinkUtils.convertEclipseLinkAccessException( - DatabaseException.databaseAccessorNotConnected())); - } - -}