use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method getPreviousValues.
@Override
public Map<String, List<PreviousValue>> getPreviousValues(String componentId) {
Map<String, List<PreviousValue>> previousValues = new LinkedHashMap<>();
PreparedStatement statement = null;
ResultSet rs = null;
try {
// create the statement
statement = connection.prepareStatement(SELECT_PREVIOUSLY_CONFIGURED_FIELDS);
statement.setString(1, componentId);
// execute the query
rs = statement.executeQuery();
// ensure results
while (rs.next()) {
final String property = rs.getString("NAME");
previousValues.put(property, getPreviousValuesForProperty(componentId, property));
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
return previousValues;
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method getPurgeDetails.
private PurgeDetails getPurgeDetails(Integer actionId) throws DataAccessException {
FlowChangePurgeDetails purgeDetails = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
// create the statement
statement = connection.prepareStatement(SELECT_PURGE_DETAILS_FOR_ACTION);
statement.setInt(1, actionId);
// execute the query
rs = statement.executeQuery();
// ensure results
if (rs.next()) {
purgeDetails = new FlowChangePurgeDetails();
purgeDetails.setEndDate(new Date(rs.getTimestamp("END_DATE").getTime()));
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
return purgeDetails;
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method getMoveDetails.
private MoveDetails getMoveDetails(Integer actionId) throws DataAccessException {
FlowChangeMoveDetails moveDetails = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
// create the statement
statement = connection.prepareStatement(SELECT_MOVE_DETAILS_FOR_ACTION);
statement.setInt(1, actionId);
// execute the query
rs = statement.executeQuery();
// ensure results
if (rs.next()) {
moveDetails = new FlowChangeMoveDetails();
moveDetails.setGroupId(rs.getString("GROUP_ID"));
moveDetails.setGroup(rs.getString("GROUP_NAME"));
moveDetails.setPreviousGroupId(rs.getString("PREVIOUS_GROUP_ID"));
moveDetails.setPreviousGroup(rs.getString("PREVIOUS_GROUP_NAME"));
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
return moveDetails;
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardActionDAO method getRemoteProcessGroupDetails.
private RemoteProcessGroupDetails getRemoteProcessGroupDetails(Integer actionId) throws DataAccessException {
FlowChangeRemoteProcessGroupDetails remoteProcessGroupDetails = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
// create the statement
statement = connection.prepareStatement(SELECT_REMOTE_PROCESS_GROUP_DETAILS_FOR_ACTION);
statement.setInt(1, actionId);
// execute the query
rs = statement.executeQuery();
// ensure results
if (rs.next()) {
remoteProcessGroupDetails = new FlowChangeRemoteProcessGroupDetails();
remoteProcessGroupDetails.setUri(rs.getString("URI"));
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
return remoteProcessGroupDetails;
}
use of org.apache.nifi.admin.dao.DataAccessException in project nifi by apache.
the class StandardKeyDAO method createKey.
@Override
public Key createKey(final String identity) {
PreparedStatement statement = null;
ResultSet rs = null;
try {
final String keyValue = UUID.randomUUID().toString();
// add each authority for the specified user
statement = connection.prepareStatement(INSERT_KEY, Statement.RETURN_GENERATED_KEYS);
statement.setString(1, identity);
statement.setString(2, keyValue);
// insert the key
int updateCount = statement.executeUpdate();
rs = statement.getGeneratedKeys();
// verify the results
if (updateCount == 1 && rs.next()) {
final Key key = new Key();
key.setId(rs.getInt(1));
key.setIdentity(identity);
key.setKey(keyValue);
return key;
} else {
throw new DataAccessException("Unable to add key for user.");
}
} catch (SQLException sqle) {
throw new DataAccessException(sqle);
} finally {
RepositoryUtils.closeQuietly(rs);
RepositoryUtils.closeQuietly(statement);
}
}
Aggregations