/** * Updates the SMPP_SMS_ROUTING_RULE table, sets the CLUSTER_NAME for passed * ADDRESS * * @param dbSmsRoutingRule * @throws PersistenceException */ public void c2_updateSmppSmsRoutingRule(DbSmsRoutingRule dbSmsRoutingRule) throws PersistenceException { try { BoundStatement boundStatement = new BoundStatement(updateSmppSmsRoutingRule); boundStatement.bind(dbSmsRoutingRule.getAddress(), dbSmsRoutingRule.getNetworkId(), dbSmsRoutingRule.getClusterName()); session.execute(boundStatement); } catch (Exception e) { String msg = "Failed to updateSmppSmsRoutingRule for address=" + dbSmsRoutingRule.getAddress() + " networkId=" + dbSmsRoutingRule.getNetworkId() + " !"; throw new PersistenceException(msg, e); } }
@Override public void updateDbSmsRoutingRule(SmsRoutingRuleType dbSmsRoutingRuleType, String address, int networkId, String clusterName) throws PersistenceException { DbSmsRoutingRule dbSmsRoutingRule = new DbSmsRoutingRule(dbSmsRoutingRuleType, address, networkId, clusterName); // if (smscPropertiesManagement.getDatabaseType() == DatabaseType.Cassandra_1) { // dbOperations_C1.updateDbSmsRoutingRule(dbSmsRoutingRule); // } else { switch (dbSmsRoutingRuleType) { case SMPP: dbOperations_C2.c2_updateSmppSmsRoutingRule(dbSmsRoutingRule); break; case SIP: dbOperations_C2.c2_updateSipSmsRoutingRule(dbSmsRoutingRule); break; default: throw new PersistenceException("Unknown DbSmsRoutingRuleType=" + dbSmsRoutingRuleType); } // } }
@Override public String getSipClusterName(int ton, int npi, String address, int networkId) { String clusterName = null; if (!dbOperations_C2.isDatabaseAvailable()) return null; try { DbSmsRoutingRule rr; // if (smscPropertiesManagement.getDatabaseType() == DatabaseType.Cassandra_1) { // return null; // } rr = dbOperations_C2.c2_getSipSmsRoutingRule(address, networkId); if (rr != null) { clusterName = rr.getClusterName(); } } catch (PersistenceException e) { logger.error("PersistenceException while selecting from table SmsRoutingRule", e); } return clusterName; }
else sb.append("\n"); sb.append(rr.toString());
/** * Returns SIP Cluster name for passed address. If not found returns null * * @param address * @return * @throws PersistenceException */ public DbSmsRoutingRule c2_getSipSmsRoutingRule(final String address, int networkId) throws PersistenceException { try { BoundStatement boundStatement = new BoundStatement(getSipSmsRoutingRule); boundStatement.bind(address, networkId); ResultSet result = session.execute(boundStatement); Row row = result.one(); if (row == null) { return null; } else { String name = row.getString(Schema.COLUMN_CLUSTER_NAME); DbSmsRoutingRule res = new DbSmsRoutingRule(SmsRoutingRuleType.SIP, address, networkId, name); return res; } } catch (Exception e) { String msg = "Failed to getSipSmsRoutingRule for address=" + address + " networkId=" + networkId + " !"; throw new PersistenceException(msg, e); } }
clusterName = rr.getClusterName(); } else { if (smscPropertiesManagement == null)
return String.format(SMSCOAMMessages.NO_ROUTING_RULE_DEFINED_YET, smsRoutingRuleType.name(), address, networkId); return res.toString();
/** * Updates the SIP_SMS_ROUTING_RULE table, sets the CLUSTER_NAME for passed * ADDRESS * * @param dbSmsRoutingRule * @throws PersistenceException */ public void c2_updateSipSmsRoutingRule(DbSmsRoutingRule dbSmsRoutingRule) throws PersistenceException { try { BoundStatement boundStatement = new BoundStatement(updateSipSmsRoutingRule); boundStatement.bind(dbSmsRoutingRule.getAddress(), dbSmsRoutingRule.getNetworkId(), dbSmsRoutingRule.getClusterName()); session.execute(boundStatement); } catch (Exception e) { String msg = "Failed to updateSipSmsRoutingRule for address=" + dbSmsRoutingRule.getAddress() + " networkId=" + dbSmsRoutingRule.getNetworkId() + " !"; throw new PersistenceException(msg, e); } }
/** * Returns the SMPP Cluster name for passed address. If not found returns * null * * @param address * @return * @throws PersistenceException */ public DbSmsRoutingRule c2_getSmppSmsRoutingRule(final String address, int networkId) throws PersistenceException { try { BoundStatement boundStatement = new BoundStatement(getSmppSmsRoutingRule); boundStatement.bind(address, networkId); ResultSet result = session.execute(boundStatement); Row row = result.one(); if (row == null) { return null; } else { String name = row.getString(Schema.COLUMN_CLUSTER_NAME); DbSmsRoutingRule res = new DbSmsRoutingRule(SmsRoutingRuleType.SMPP, address, networkId, name); return res; } } catch (Exception e) { String msg = "Failed to getSmppSmsRoutingRule for address=" + address + " networkId=" + networkId + " !"; throw new PersistenceException(msg, e); } }
int networkId = row.getInt(Schema.COLUMN_NETWORK_ID); DbSmsRoutingRule res = new DbSmsRoutingRule(SmsRoutingRuleType.SMPP, address, networkId, name);
int networkId = row.getInt(Schema.COLUMN_NETWORK_ID); DbSmsRoutingRule res = new DbSmsRoutingRule(SmsRoutingRuleType.SIP, address, networkId, name);