Search in sources :

Example 1 with GetKeyByIdAction

use of org.apache.nifi.admin.service.action.GetKeyByIdAction 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)

Aggregations

DataAccessException (org.apache.nifi.admin.dao.DataAccessException)1 AdministrationException (org.apache.nifi.admin.service.AdministrationException)1 GetKeyByIdAction (org.apache.nifi.admin.service.action.GetKeyByIdAction)1 Transaction (org.apache.nifi.admin.service.transaction.Transaction)1 TransactionException (org.apache.nifi.admin.service.transaction.TransactionException)1 Key (org.apache.nifi.key.Key)1