use of org.mobicents.smsc.slee.resources.persistence.PersistenceRAInterface in project smscgateway by RestComm.
the class AlertSbb method setupAlert.
private void setupAlert(ISDNAddressString msisdn, AddressString serviceCentreAddress, int networkId) {
PersistenceRAInterface pers = this.getStore();
SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
// checking if SMSC is paused
if (smscPropertiesManagement.isDeliveryPause())
return;
// checking if database is available
if (!pers.isDatabaseAvailable())
return;
int addrTon = msisdn.getAddressNature().getIndicator();
int addrNpi = msisdn.getNumberingPlan().getIndicator();
String addr = msisdn.getAddress();
TargetAddress lock = pers.obtainSynchroObject(new TargetAddress(addrTon, addrNpi, addr, networkId));
try {
synchronized (lock) {
try {
long dueSlot = 0;
SmsSet smsSet0 = new SmsSet();
smsSet0.setDestAddr(addr);
smsSet0.setDestAddrNpi(addrNpi);
smsSet0.setDestAddrTon(addrTon);
smsSet0.setNetworkId(networkId);
SmsSet smsSet1 = SmsSetCache.getInstance().getProcessingSmsSet(smsSet0.getTargetId());
if (smsSet1 != null) {
// message is already in process
if (logger.isInfoEnabled()) {
logger.info(String.format("\nReceived AlertServiceCentre for MSISDN=%s but the delivering for this dest is already in progress", addr));
}
return;
}
dueSlot = pers.c2_getDueSlotForTargetId(smsSet0.getTargetId());
if (dueSlot != 0 && dueSlot > pers.c2_getCurrentDueSlot() && pers.c2_checkDueSlotWritingPossibility(dueSlot) == dueSlot) {
pers.c2_registerDueSlotWriting(dueSlot);
try {
if (dueSlot != 0 && dueSlot > pers.c2_getCurrentDueSlot()) {
SmsSet smsSet = pers.c2_getRecordListForTargeId(dueSlot, smsSet0.getTargetId());
if (smsSet != null) {
if (logger.isInfoEnabled()) {
logger.info(String.format("\nReceived AlertServiceCentre for MSISDN=%s, SmsSet was loaded with %d messages", addr, smsSet.getSmsCount()));
}
for (int i1 = 0; i1 < smsSet.getSmsCount(); i1++) {
Sms sms = smsSet.getSms(i1);
sms.setInvokedByAlert(true);
}
ArrayList<SmsSet> lstS = new ArrayList<SmsSet>();
lstS.add(smsSet);
ArrayList<SmsSet> lst = pers.c2_sortRecordList(lstS);
if (lst.size() > 0) {
smsSet = lst.get(0);
smsSet.setProcessingStarted();
this.scheduler.injectSmsDatabase(smsSet);
}
} else {
if (logger.isInfoEnabled()) {
logger.info(String.format("\nReceived AlertServiceCentre for MSISDN=%s, dueSlot was scheduled but no SmsSet was loaded", addr));
}
}
} else {
if (logger.isInfoEnabled()) {
logger.info(String.format("\nReceived AlertServiceCentre for MSISDN=%s but no dueSlot was scheduled or the scheduled dueSlot will come soon - 2", addr));
}
}
} finally {
pers.c2_unregisterDueSlotWriting(dueSlot);
}
} else {
if (logger.isInfoEnabled()) {
logger.info(String.format("\nReceived AlertServiceCentre for MSISDN=%s but no dueSlot was scheduled or the scheduled dueSlot will come soon - 1", addr));
}
}
} catch (PersistenceException e) {
this.logger.severe("PersistenceException when setupAlert()" + e.getMessage(), e);
} catch (Exception e) {
this.logger.severe("Exception when setupAlert()" + e.getMessage(), e);
}
}
} finally {
pers.releaseSynchroObject(lock);
}
}
Aggregations