diff --git a/core/domain/src/main/java/org/mobicents/smsc/domain/SMSCShellExecutor.java b/core/domain/src/main/java/org/mobicents/smsc/domain/SMSCShellExecutor.java index aa5a781a7..ce3863235 100644 --- a/core/domain/src/main/java/org/mobicents/smsc/domain/SMSCShellExecutor.java +++ b/core/domain/src/main/java/org/mobicents/smsc/domain/SMSCShellExecutor.java @@ -32,6 +32,7 @@ import javolution.util.FastMap; import org.apache.log4j.Logger; +import org.mobicents.smsc.library.SmsSet; import org.restcomm.protocols.ss7.indicator.GlobalTitleIndicator; import org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion; import org.restcomm.protocols.ss7.map.api.errors.SMEnumeratedDeliveryFailureCause; @@ -592,6 +593,10 @@ private String executeSmsc(String[] args) { return this.updateCcMccmnstable(args); } else if (args[1].toLowerCase().equals("hrccmccmnc")) { return this.ccMccmnsValueUpdate(args); + } else if (args[1].toLowerCase().equals("deletesmsset")) { + if (args.length < 3) + return SMSCOAMMessages.INVALID_COMMAND; + return this.deleteSmsSets(Arrays.copyOfRange(args, 2, args.length)); } return SMSCOAMMessages.INVALID_COMMAND; @@ -601,6 +606,32 @@ private String executeSmsc(String[] args) { } } + /** + * Delete all SMS sets for specified targetIds from SmsSetCache + * @param targetIds + * @return + */ + private String deleteSmsSets(String[] targetIds) { + SmsSetCache smsSetCache = SmsSetCache.getInstance(); + StringBuilder report = new StringBuilder(); + report.append("SmsSetCache size: ").append(smsSetCache.getProcessingSmsSetSize()); + report.append("\nDeleting message sets:"); + for (String targetId: targetIds) { + SmsSet deletedSmsSet = smsSetCache.removeProcessingSmsSet(targetId); + if (deletedSmsSet == null) { + report.append("\n\tno messages for targetId=").append(targetId); + } else { + report.append("\n\tmessage deleted: ").append(formatSmsSet(deletedSmsSet)); + } + } + return report.toString(); + } + + + private String formatSmsSet(SmsSet smsSet) { + return String.format("SMS targetId=%s, destAdd=%s, count=%d", smsSet.getTargetId(), smsSet.getDestAddr(), smsSet.getSmsCount()); + } + /** * smsc mapcache get *