Search in sources :

Example 1 with DatabaseServiceNetworkException

use of org.structr.common.error.DatabaseServiceNetworkException in project structr by structr.

the class TransactionCommand method beginTx.

public TransactionCommand beginTx() throws FrameworkException {
    final DatabaseService graphDb = (DatabaseService) arguments.get("graphDb");
    TransactionReference tx = transactions.get();
    if (graphDb != null) {
        if (tx == null) {
            try {
                // start new transaction
                tx = new TransactionReference(graphDb.beginTx());
            } catch (NetworkException nex) {
                throw new DatabaseServiceNetworkException(503, nex.getMessage());
            }
            queues.set(new ModificationQueue());
            buffers.set(new ErrorBuffer());
            transactions.set(tx);
            currentCommand.set(this);
        }
        // increase depth
        tx.begin();
    } else {
        throw new DatabaseServiceNotAvailableException(503, "Database service is not available, ensure the database is running and that there is a working network connection to it");
    }
    return this;
}
Also used : ErrorBuffer(org.structr.common.error.ErrorBuffer) DatabaseServiceNotAvailableException(org.structr.common.error.DatabaseServiceNotAvailableException) DatabaseService(org.structr.api.DatabaseService) NetworkException(org.structr.api.NetworkException) DatabaseServiceNetworkException(org.structr.common.error.DatabaseServiceNetworkException) DatabaseServiceNetworkException(org.structr.common.error.DatabaseServiceNetworkException)

Aggregations

DatabaseService (org.structr.api.DatabaseService)1 NetworkException (org.structr.api.NetworkException)1 DatabaseServiceNetworkException (org.structr.common.error.DatabaseServiceNetworkException)1 DatabaseServiceNotAvailableException (org.structr.common.error.DatabaseServiceNotAvailableException)1 ErrorBuffer (org.structr.common.error.ErrorBuffer)1