Search in sources :

Example 1 with Transaction

use of org.apache.nifi.admin.service.transaction.Transaction in project nifi by apache.

the class StandardAuditService method purgeActions.

@Override
public void purgeActions(Date end, Action purgeAction) {
    Transaction transaction = null;
    writeLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // purge the action database
        PurgeActionsAction purgeActions = new PurgeActionsAction(end, purgeAction);
        transaction.execute(purgeActions);
        // commit the transaction
        transaction.commit();
    } catch (TransactionException | DataAccessException te) {
        rollback(transaction);
        throw new AdministrationException(te);
    } catch (Throwable t) {
        rollback(transaction);
        throw t;
    } finally {
        closeQuietly(transaction);
        writeLock.unlock();
    }
}
Also used : TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) PurgeActionsAction(org.apache.nifi.admin.service.action.PurgeActionsAction) AdministrationException(org.apache.nifi.admin.service.AdministrationException) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 2 with Transaction

use of org.apache.nifi.admin.service.transaction.Transaction in project nifi by apache.

the class StandardAuditService method getActions.

@Override
public History getActions(HistoryQuery query) {
    Transaction transaction = null;
    History history = null;
    readLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // seed the accounts
        GetActionsAction getActions = new GetActionsAction(query);
        history = transaction.execute(getActions);
        // commit the transaction
        transaction.commit();
    } catch (TransactionException | DataAccessException te) {
        rollback(transaction);
        throw new AdministrationException(te);
    } catch (Throwable t) {
        rollback(transaction);
        throw t;
    } finally {
        closeQuietly(transaction);
        readLock.unlock();
    }
    return history;
}
Also used : TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) GetActionsAction(org.apache.nifi.admin.service.action.GetActionsAction) History(org.apache.nifi.history.History) AdministrationException(org.apache.nifi.admin.service.AdministrationException) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 3 with Transaction

use of org.apache.nifi.admin.service.transaction.Transaction in project nifi by apache.

the class StandardKeyService method getOrCreateKey.

@Override
public Key getOrCreateKey(String identity) {
    Transaction transaction = null;
    Key key = null;
    writeLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // get or create a key
        GetOrCreateKeyAction addActions = new GetOrCreateKeyAction(identity);
        key = transaction.execute(addActions);
        // commit the transaction
        transaction.commit();
    } catch (TransactionException | DataAccessException te) {
        rollback(transaction);
        throw new AdministrationException(te);
    } catch (Throwable t) {
        rollback(transaction);
        throw t;
    } finally {
        closeQuietly(transaction);
        writeLock.unlock();
    }
    return key;
}
Also used : TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) GetOrCreateKeyAction(org.apache.nifi.admin.service.action.GetOrCreateKeyAction) AdministrationException(org.apache.nifi.admin.service.AdministrationException) Key(org.apache.nifi.key.Key) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 4 with Transaction

use of org.apache.nifi.admin.service.transaction.Transaction in project nifi by apache.

the class StandardKeyService method getKey.

@Override
public Key getKey(int id) {
    Transaction transaction = null;
    Key key = null;
    readLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // get the key
        GetKeyByIdAction addActions = new GetKeyByIdAction(id);
        key = transaction.execute(addActions);
        // commit the transaction
        transaction.commit();
    } catch (TransactionException | DataAccessException te) {
        rollback(transaction);
        throw new AdministrationException(te);
    } catch (Throwable t) {
        rollback(transaction);
        throw t;
    } finally {
        closeQuietly(transaction);
        readLock.unlock();
    }
    return key;
}
Also used : TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) GetKeyByIdAction(org.apache.nifi.admin.service.action.GetKeyByIdAction) AdministrationException(org.apache.nifi.admin.service.AdministrationException) Key(org.apache.nifi.key.Key) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 5 with Transaction

use of org.apache.nifi.admin.service.transaction.Transaction in project nifi by apache.

the class StandardKeyService method deleteKey.

@Override
public void deleteKey(String identity) {
    Transaction transaction = null;
    writeLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // delete the keys
        DeleteKeysAction deleteKeys = new DeleteKeysAction(identity);
        transaction.execute(deleteKeys);
        // commit the transaction
        transaction.commit();
    } catch (TransactionException | DataAccessException te) {
        rollback(transaction);
        throw new AdministrationException(te);
    } catch (Throwable t) {
        rollback(transaction);
        throw t;
    } finally {
        closeQuietly(transaction);
        writeLock.unlock();
    }
}
Also used : TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) DeleteKeysAction(org.apache.nifi.admin.service.action.DeleteKeysAction) AdministrationException(org.apache.nifi.admin.service.AdministrationException) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Aggregations

DataAccessException (org.apache.nifi.admin.dao.DataAccessException)8 AdministrationException (org.apache.nifi.admin.service.AdministrationException)8 Transaction (org.apache.nifi.admin.service.transaction.Transaction)8 TransactionException (org.apache.nifi.admin.service.transaction.TransactionException)8 AddActionsAction (org.apache.nifi.admin.service.action.AddActionsAction)2 GetActionsAction (org.apache.nifi.admin.service.action.GetActionsAction)2 PurgeActionsAction (org.apache.nifi.admin.service.action.PurgeActionsAction)2 Key (org.apache.nifi.key.Key)2 List (java.util.List)1 Action (org.apache.nifi.action.Action)1 DeleteKeysAction (org.apache.nifi.admin.service.action.DeleteKeysAction)1 GetActionAction (org.apache.nifi.admin.service.action.GetActionAction)1 GetKeyByIdAction (org.apache.nifi.admin.service.action.GetKeyByIdAction)1 GetOrCreateKeyAction (org.apache.nifi.admin.service.action.GetOrCreateKeyAction)1 GetPreviousValues (org.apache.nifi.admin.service.action.GetPreviousValues)1 History (org.apache.nifi.history.History)1