int invoiceSubscriptionId = subscription.getInvoiceSubscriptionId();
if (invoiceSubscriptionId == INVALID) {
String msg = "Not a invoiced subscription, subscription id: "
+ subscription.getId() + ".";
log.error(msg);
throw new BillingException(msg);
}
List<Item> items = new ArrayList<Item>();
try {
String sql = "SELECT BC_ITEM_ID, BC_COST " +
"FROM BC_INVOICE_SUBSCRIPTION_ITEM WHERE BC_INVOICE_SUBSCRIPTION_ID=?";
ps = conn.prepareStatement(sql);
ps.setInt(1, invoiceSubscriptionId);
result = ps.executeQuery();
while (result.next()) {
Item item = getItem(result.getInt("BC_ITEM_ID"));
String cost = result.getString("BC_COST");
if (cost != null) {
item.setCost(new Cash(cost));
}
items.add(item);
}
} catch (SQLException e) {
String msg = "Failed to get the invoiced subscription items for " +
"invoice subscription id: " + invoiceSubscriptionId + ".";
log.error(msg, e);
throw new BillingException(msg, e);
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException ex) {
String msg = RegistryConstants.RESULT_SET_PREPARED_STATEMENT_CLOSE_ERROR
+ ex.getMessage();
log.error(msg, ex);
throw new BillingException(msg, ex);
}
try {
if (result != null) {
result.close();