MessageRecipients messageRecipients = new MessageRecipients();
for (int i = 0; i < type.length; i++) {
if (type[i].equals(inType)) {
if (!names[i].equals("")) {
MessageRecipient messageRecipient = new MessageRecipient();
// Is there a channel for this index? Is it not empty?
if (channel.length > i && !channel[i].equals("")) {
// set the channel for the recipient
messageRecipient.setChannelName(channel[i]);
if (channel[i].equals("smsc")) {
// The channel is smsc so set the MSISDN rather
// than the address
messageRecipient.setMSISDN(names[i]);
} else if (channel[i].equals("wappush")) {
// The channel is wappush so set the MSISDN rather
// than the address
messageRecipient.setMSISDN(names[i]);
} else if (channel[i].equals("mmsc") &&
names[i].charAt(0) == '+') {
messageRecipient.setMSISDN(names[i]);
} else {
messageRecipient.setAddress(
new InternetAddress(names[i]));
}
} else {
// channel is not present or empty so use smtp
// as default - This will have to be changed if the
// smtp channel is not present in the mcs-config file
messageRecipient.setChannelName("smtp");
}
// If there is a device then set it otherwise let MPS use
// the defaults
if (devices.length > i) {
String device = devices[i];
if (!device.equals("")) {
messageRecipient.setDeviceName(device);
}
}
// Add recipient to the list of MessageRecipients
messageRecipients.addRecipient(messageRecipient);