@Override public boolean nodeExists(String nodeId) throws IOException { try { Connection conn = dbConnectionPool.getConnection(); try { PreparedStatement statement = getNodeExistsStatement(conn, nodeId); try { return dbQueryExecutor.hasResults(statement); } finally { statement.close(); } } finally { conn.close(); } } catch (SQLException e) { throw new IOException("Exception checking existence of node` " + nodeId, e); } }
@Override public boolean exists(String name) throws IOException { try { Connection conn = dbConnectionPool.getConnection(); try { PreparedStatement statement = conn.prepareStatement( "SELECT name FROM pluginMeta WHERE " + "tenant_id=? AND plugin_type=? AND plugin_name=? AND resource_type=? AND name=? AND deleted=false"); try { setConstantFields(statement); statement.setString(5, name); return dbQueryExecutor.hasResults(statement); } finally { statement.close(); } } finally { conn.close(); } } catch (SQLException e) { LOG.error("Exception checking existance of resource {} for tenant {}.", name, tenant); throw new IOException(e); } }
@Override public boolean clusterExists(String clusterId) throws IOException { long clusterNum = Long.parseLong(clusterId); try { Connection conn = dbConnectionPool.getConnection(); try { PreparedStatement statement = getClusterExistsStatement(conn, clusterNum); try { return dbQueryExecutor.hasResults(statement); } finally { statement.close(); } } finally { conn.close(); } } catch (SQLException e) { throw new IOException("Exception checking existence of cluster " + clusterId, e); } }
@Override public boolean exists(String name, int version) throws IOException { try { Connection conn = dbConnectionPool.getConnection(); try { PreparedStatement statement = conn.prepareStatement( "SELECT name FROM pluginMeta WHERE tenant_id=? AND plugin_type=? AND plugin_name=? " + "AND resource_type=? AND name=? AND version=? AND deleted=false"); try { setConstantFields(statement); statement.setString(5, name); statement.setInt(6, version); return dbQueryExecutor.hasResults(statement); } finally { statement.close(); } } finally { conn.close(); } } catch (SQLException e) { LOG.error("Exception checking existance of version {} of resource {} for tenant {}.", version, name, tenant); throw new IOException(e); } }