use of org.apache.nifi.admin.dao.DataAccessException 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();
}
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method deleteActions.
@Override
public void deleteActions(Date endDate) throws DataAccessException {
PreparedStatement statement = null;
try {
// -----------------
// component details
// -----------------
// create the move delete statement
statement = connection.prepareStatement(String.format(DELETE_SPECIFIC_ACTIONS, "PROCESSOR_DETAILS", "ACTION_ID"));
statement.setTimestamp(1, new java.sql.Timestamp(endDate.getTime()));
statement.executeUpdate();
statement.close();
// create the move delete statement
statement = connection.prepareStatement(String.format(DELETE_SPECIFIC_ACTIONS, "REMOTE_PROCESS_GROUP_DETAILS", "ACTION_ID"));
statement.setTimestamp(1, new java.sql.Timestamp(endDate.getTime()));
statement.executeUpdate();
statement.close();
// --------------
// action details
// --------------
// create the move delete statement
statement = connection.prepareStatement(String.format(DELETE_SPECIFIC_ACTIONS, "MOVE_DETAILS", "ACTION_ID"));
statement.setTimestamp(1, new java.sql.Timestamp(endDate.getTime()));
statement.executeUpdate();
statement.close();
// create the configure delete statement
statement = connection.prepareStatement(String.format(DELETE_SPECIFIC_ACTIONS, "CONFIGURE_DETAILS", "ACTION_ID"));
statement.setTimestamp(1, new java.sql.Timestamp(endDate.getTime()));
statement.executeUpdate();
statement.close();
// create the connect delete statement
statement = connection.prepareStatement(String.format(DELETE_SPECIFIC_ACTIONS, "CONNECT_DETAILS", "ACTION_ID"));
statement.setTimestamp(1, new java.sql.Timestamp(endDate.getTime()));
statement.executeUpdate();
statement.close();
// create the relationship delete statement
statement = connection.prepareStatement(String.format(DELETE_SPECIFIC_ACTIONS, "PURGE_DETAILS", "ACTION_ID"));
statement.setTimestamp(1, new java.sql.Timestamp(endDate.getTime()));
statement.executeUpdate();
statement.close();
// -------
// actions
// -------
// create the action delete statement
statement = connection.prepareStatement(DELETE_ACTIONS);
statement.setTimestamp(1, new java.sql.Timestamp(endDate.getTime()));
statement.executeUpdate();
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(statement);
}
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method getConfigureDetails.
private ConfigureDetails getConfigureDetails(Integer actionId) throws DataAccessException {
FlowChangeConfigureDetails configurationDetails = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
// create the statement
statement = connection.prepareStatement(SELECT_CONFIGURE_DETAILS_FOR_ACTION);
statement.setInt(1, actionId);
// execute the query
rs = statement.executeQuery();
// ensure results
if (rs.next()) {
configurationDetails = new FlowChangeConfigureDetails();
configurationDetails.setName(rs.getString("NAME"));
configurationDetails.setValue(rs.getString("VALUE"));
configurationDetails.setPreviousValue(rs.getString("PREVIOUS_VALUE"));
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
return configurationDetails;
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method getAction.
@Override
public Action getAction(Integer actionId) throws DataAccessException {
FlowChangeAction action = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
// create the statement
statement = connection.prepareStatement(SELECT_ACTION_BY_ID);
statement.setInt(1, actionId);
// execute the query
rs = statement.executeQuery();
// ensure results
if (rs.next()) {
Operation operation = Operation.valueOf(rs.getString("OPERATION"));
Component component = Component.valueOf(rs.getString("SOURCE_TYPE"));
// populate the action
action = new FlowChangeAction();
action.setId(rs.getInt("ID"));
action.setUserIdentity(rs.getString("IDENTITY"));
action.setOperation(operation);
action.setTimestamp(new Date(rs.getTimestamp("ACTION_TIMESTAMP").getTime()));
action.setSourceId(rs.getString("SOURCE_ID"));
action.setSourceName(rs.getString("SOURCE_NAME"));
action.setSourceType(component);
// get the component details if appropriate
ComponentDetails componentDetails = null;
if (Component.Processor.equals(component) || Component.ControllerService.equals(component) || Component.ReportingTask.equals(component)) {
componentDetails = getExtensionDetails(actionId);
} else if (Component.RemoteProcessGroup.equals(component)) {
componentDetails = getRemoteProcessGroupDetails(actionId);
}
if (componentDetails != null) {
action.setComponentDetails(componentDetails);
}
// get the action details if appropriate
ActionDetails actionDetails = null;
if (Operation.Move.equals(operation)) {
actionDetails = getMoveDetails(actionId);
} else if (Operation.Configure.equals(operation)) {
actionDetails = getConfigureDetails(actionId);
} else if (Operation.Connect.equals(operation) || Operation.Disconnect.equals(operation)) {
actionDetails = getConnectDetails(actionId);
} else if (Operation.Purge.equals(operation)) {
actionDetails = getPurgeDetails(actionId);
}
// set the action details
if (actionDetails != null) {
action.setActionDetails(actionDetails);
}
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
return action;
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method getConnectDetails.
private ConnectDetails getConnectDetails(Integer actionId) throws DataAccessException {
FlowChangeConnectDetails connectionDetails = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
// create the statement
statement = connection.prepareStatement(SELECT_CONNECT_DETAILS_FOR_ACTION);
statement.setInt(1, actionId);
// execute the query
rs = statement.executeQuery();
// ensure results
if (rs.next()) {
final Component sourceComponent = Component.valueOf(rs.getString("SOURCE_TYPE"));
final Component destinationComponent = Component.valueOf(rs.getString("DESTINATION_TYPE"));
connectionDetails = new FlowChangeConnectDetails();
connectionDetails.setSourceId(rs.getString("SOURCE_ID"));
connectionDetails.setSourceName(rs.getString("SOURCE_NAME"));
connectionDetails.setSourceType(sourceComponent);
connectionDetails.setRelationship(rs.getString("RELATIONSHIP"));
connectionDetails.setDestinationId(rs.getString("DESTINATION_ID"));
connectionDetails.setDestinationName(rs.getString("DESTINATION_NAME"));
connectionDetails.setDestinationType(destinationComponent);
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
return connectionDetails;
}
Aggregations