Search in sources :

Example 6 with Transaction

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

the class StandardAuditService method addActions.

@Override
public void addActions(Collection<Action> actions) {
    Transaction transaction = null;
    writeLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // seed the accounts
        AddActionsAction addActions = new AddActionsAction(actions);
        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();
    }
}
Also used : TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) AddActionsAction(org.apache.nifi.admin.service.action.AddActionsAction) AdministrationException(org.apache.nifi.admin.service.AdministrationException) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 7 with Transaction

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

the class StandardAuditService method getAction.

@Override
public Action getAction(Integer actionId) {
    Transaction transaction = null;
    Action action = null;
    readLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // seed the accounts
        GetActionAction getAction = new GetActionAction(actionId);
        action = transaction.execute(getAction);
        // 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 action;
}
Also used : GetActionAction(org.apache.nifi.admin.service.action.GetActionAction) GetActionsAction(org.apache.nifi.admin.service.action.GetActionsAction) PurgeActionsAction(org.apache.nifi.admin.service.action.PurgeActionsAction) GetActionAction(org.apache.nifi.admin.service.action.GetActionAction) AddActionsAction(org.apache.nifi.admin.service.action.AddActionsAction) Action(org.apache.nifi.action.Action) TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) AdministrationException(org.apache.nifi.admin.service.AdministrationException) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 8 with Transaction

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

the class StandardAuditService method getPreviousValues.

@Override
public Map<String, List<PreviousValue>> getPreviousValues(String componentId) {
    Transaction transaction = null;
    Map<String, List<PreviousValue>> previousValues = null;
    readLock.lock();
    try {
        // start the transaction
        transaction = transactionBuilder.start();
        // seed the accounts
        GetPreviousValues getActions = new GetPreviousValues(componentId);
        previousValues = 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 previousValues;
}
Also used : TransactionException(org.apache.nifi.admin.service.transaction.TransactionException) Transaction(org.apache.nifi.admin.service.transaction.Transaction) GetPreviousValues(org.apache.nifi.admin.service.action.GetPreviousValues) List(java.util.List) 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