Search in sources :

Example 1 with CommitTransactionDatabaseAction

use of org.bimserver.database.actions.CommitTransactionDatabaseAction in project BIMserver by opensourceBIM.

the class LowLevelServiceImpl method commitTransaction.

@Override
public Long commitTransaction(Long tid, String comment) throws UserException, ServerException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        LongTransaction longTransaction = getBimServer().getLongTransactionManager().get(tid);
        if (longTransaction == null) {
            throw new UserException("No transaction with tid " + tid + " was found");
        }
        CommitTransactionDatabaseAction action = new CommitTransactionDatabaseAction(getBimServer(), session, getInternalAccessMethod(), getAuthorization(), longTransaction, comment);
        try {
            session.executeAndCommitAction(action);
            return action.getRevision().getOid();
        } catch (BimserverDatabaseException e) {
            LOGGER.error("", e);
        } finally {
            session.close();
        }
    } catch (NoTransactionException e) {
        LOGGER.error("", e);
    }
    return -1L;
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) NoTransactionException(org.bimserver.webservices.NoTransactionException) DatabaseSession(org.bimserver.database.DatabaseSession) CommitTransactionDatabaseAction(org.bimserver.database.actions.CommitTransactionDatabaseAction) UserException(org.bimserver.shared.exceptions.UserException) LongTransaction(org.bimserver.webservices.LongTransaction)

Aggregations

BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 CommitTransactionDatabaseAction (org.bimserver.database.actions.CommitTransactionDatabaseAction)1 UserException (org.bimserver.shared.exceptions.UserException)1 LongTransaction (org.bimserver.webservices.LongTransaction)1 NoTransactionException (org.bimserver.webservices.NoTransactionException)1