TSK-56 refactor Exceptions. Introduce TaskanaException and TaskanaRuntimeException
This commit is contained in:
parent
2d5ca63c67
commit
fe587844e3
|
|
@ -5,7 +5,7 @@ package pro.taskana.exceptions;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class AutocommitFailedException extends RuntimeException {
|
public class AutocommitFailedException extends TaskanaRuntimeException {
|
||||||
public AutocommitFailedException(Throwable cause) {
|
public AutocommitFailedException(Throwable cause) {
|
||||||
super("Autocommit failed", cause);
|
super("Autocommit failed", cause);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ package pro.taskana.exceptions;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ConnectionNotSetException extends RuntimeException {
|
public class ConnectionNotSetException extends TaskanaRuntimeException {
|
||||||
|
|
||||||
public ConnectionNotSetException() {
|
public ConnectionNotSetException() {
|
||||||
super("Connection not set");
|
super("Connection not set");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ package pro.taskana.exceptions;
|
||||||
* This exception is used to communicate a not authorized user.
|
* This exception is used to communicate a not authorized user.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class NotAuthorizedException extends Exception {
|
public class NotAuthorizedException extends TaskanaException {
|
||||||
|
|
||||||
public NotAuthorizedException(String msg) {
|
public NotAuthorizedException(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ package pro.taskana.exceptions;
|
||||||
* This exception will be thrown if a specific object is not in the database.
|
* This exception will be thrown if a specific object is not in the database.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class NotFoundException extends Exception {
|
public class NotFoundException extends TaskanaException {
|
||||||
|
|
||||||
public NotFoundException(String id) {
|
public NotFoundException(String id) {
|
||||||
super(id);
|
super(id);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package pro.taskana.exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* common base class for Taskana's checked exceptions.
|
||||||
|
* @author bbr
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TaskanaException extends Exception {
|
||||||
|
|
||||||
|
public TaskanaException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package pro.taskana.exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common base class for Taskana's runtime exceptions.
|
||||||
|
* @author bbr
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TaskanaRuntimeException extends RuntimeException {
|
||||||
|
|
||||||
|
public TaskanaRuntimeException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaRuntimeException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaRuntimeException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaRuntimeException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskanaRuntimeException(String message, Throwable cause, boolean enableSuppression,
|
||||||
|
boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -115,7 +115,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
mode = ConnectionManagementMode.EXPLICIT;
|
mode = ConnectionManagementMode.EXPLICIT;
|
||||||
sessionManager.startManagedSession(connection);
|
sessionManager.startManagedSession(connection);
|
||||||
} else {
|
} else if (this.connection != null) {
|
||||||
this.connection = null;
|
this.connection = null;
|
||||||
if (sessionManager.isManagedSessionStarted()) {
|
if (sessionManager.isManagedSessionStarted()) {
|
||||||
sessionManager.close();
|
sessionManager.close();
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
workbasket.setName("Megabasket");
|
workbasket.setName("Megabasket");
|
||||||
workBasketService.createWorkbasket(workbasket);
|
workBasketService.createWorkbasket(workbasket);
|
||||||
Assert.assertEquals(before + 1, workBasketService.getWorkbaskets().size());
|
Assert.assertEquals(before + 1, workBasketService.getWorkbaskets().size());
|
||||||
connection.close();
|
taskanaEngineImpl.closeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -104,7 +104,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
workBasketService.createWorkbasket(workbasket2);
|
workBasketService.createWorkbasket(workbasket2);
|
||||||
Assert.assertEquals(before + THREE, workBasketService.getWorkbaskets().size());
|
Assert.assertEquals(before + THREE, workBasketService.getWorkbaskets().size());
|
||||||
connection.commit();
|
connection.commit();
|
||||||
connection.close();
|
taskanaEngineImpl.closeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -130,7 +130,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
Workbasket foundWorkbasket = workBasketService.getWorkbasket(id2);
|
Workbasket foundWorkbasket = workBasketService.getWorkbasket(id2);
|
||||||
Assert.assertEquals(id2, foundWorkbasket.getId());
|
Assert.assertEquals(id2, foundWorkbasket.getId());
|
||||||
connection.commit();
|
connection.commit();
|
||||||
connection.close();
|
taskanaEngineImpl.closeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = WorkbasketNotFoundException.class)
|
@Test(expected = WorkbasketNotFoundException.class)
|
||||||
|
|
@ -140,7 +140,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
workBasketService = taskanaEngine.getWorkbasketService();
|
workBasketService = taskanaEngine.getWorkbasketService();
|
||||||
workBasketService.getWorkbasket("fail");
|
workBasketService.getWorkbasket("fail");
|
||||||
connection.commit();
|
connection.commit();
|
||||||
connection.close();
|
taskanaEngineImpl.closeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -168,7 +168,6 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
Assert.assertEquals(id2, foundWorkbasket.getId());
|
Assert.assertEquals(id2, foundWorkbasket.getId());
|
||||||
Assert.assertEquals(2, foundWorkbasket.getDistributionTargets().size());
|
Assert.assertEquals(2, foundWorkbasket.getDistributionTargets().size());
|
||||||
connection.commit();
|
connection.commit();
|
||||||
connection.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -213,7 +212,6 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
Assert.assertEquals(workBasketService.getWorkbasket(id3).getCreated(),
|
Assert.assertEquals(workBasketService.getWorkbasket(id3).getCreated(),
|
||||||
workBasketService.getWorkbasket(id3).getModified());
|
workBasketService.getWorkbasket(id3).getModified());
|
||||||
connection.commit();
|
connection.commit();
|
||||||
connection.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -231,7 +229,6 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
|
|
||||||
Assert.assertEquals(1, workBasketService.getAllAuthorizations().size());
|
Assert.assertEquals(1, workBasketService.getAllAuthorizations().size());
|
||||||
connection.commit();
|
connection.commit();
|
||||||
connection.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -255,7 +252,6 @@ public class WorkbasketServiceImplIntExplicitTest {
|
||||||
Assert.assertEquals("Zaphod Beeblebrox",
|
Assert.assertEquals("Zaphod Beeblebrox",
|
||||||
workBasketService.getWorkbasketAuthorization(accessItem.getId()).getAccessId());
|
workBasketService.getWorkbasketAuthorization(accessItem.getId()).getAccessId());
|
||||||
connection.commit();
|
connection.commit();
|
||||||
connection.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue