Search in sources :

Example 1 with GetOrCreateKeyAction

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

Aggregations

DataAccessException (org.apache.nifi.admin.dao.DataAccessException)1 AdministrationException (org.apache.nifi.admin.service.AdministrationException)1 GetOrCreateKeyAction (org.apache.nifi.admin.service.action.GetOrCreateKeyAction)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