Search in sources :

Example 26 with DataAccessException

use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.

the class StandardKeyDAO method findKeyById.

@Override
public Key findKeyById(int id) {
    Key key = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    try {
        // add each authority for the specified user
        statement = connection.prepareStatement(SELECT_KEY_FOR_USER_BY_ID);
        statement.setInt(1, id);
        // execute the query
        rs = statement.executeQuery();
        // if the key was found, add it
        if (rs.next()) {
            key = new Key();
            key.setId(rs.getInt("ID"));
            key.setIdentity(rs.getString("IDENTITY"));
            key.setKey(rs.getString("KEY"));
        }
    } catch (SQLException sqle) {
        throw new DataAccessException(sqle);
    } finally {
        RepositoryUtils.closeQuietly(rs);
        RepositoryUtils.closeQuietly(statement);
    }
    return key;
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Key(org.apache.nifi.key.Key) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 27 with DataAccessException

use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.

the class StandardKeyDAO method deleteKeys.

@Override
public void deleteKeys(String identity) {
    PreparedStatement statement = null;
    try {
        // add each authority for the specified user
        statement = connection.prepareStatement(DELETE_KEYS);
        statement.executeUpdate();
    } catch (SQLException sqle) {
        throw new DataAccessException(sqle);
    } catch (DataAccessException dae) {
        throw dae;
    } finally {
        RepositoryUtils.closeQuietly(statement);
    }
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) DataAccessException(org.apache.nifi.admin.dao.DataAccessException)

Example 28 with DataAccessException

use of org.apache.nifi.admin.dao.DataAccessException 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 29 with DataAccessException

use of org.apache.nifi.admin.dao.DataAccessException 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 30 with DataAccessException

use of org.apache.nifi.admin.dao.DataAccessException 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)30 PreparedStatement (java.sql.PreparedStatement)22 SQLException (java.sql.SQLException)22 ResultSet (java.sql.ResultSet)14 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 Key (org.apache.nifi.key.Key)5 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 Component (org.apache.nifi.action.Component)3 FlowChangeAction (org.apache.nifi.action.FlowChangeAction)3 ComponentDetails (org.apache.nifi.action.component.details.ComponentDetails)3 ActionDetails (org.apache.nifi.action.details.ActionDetails)3 List (java.util.List)2 Action (org.apache.nifi.action.Action)2 Operation (org.apache.nifi.action.Operation)2 FlowChangeExtensionDetails (org.apache.nifi.action.component.details.FlowChangeExtensionDetails)2 FlowChangeRemoteProcessGroupDetails (org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails)2 FlowChangeConfigureDetails (org.apache.nifi.action.details.FlowChangeConfigureDetails)2