{
throw new MappingFailedException("No mapping found for notification type: '" +
n.getType() + "'");
}
Mapping m = (Mapping)this.notificationMapList.get(index);
// Create trap
SnmpPduTrap trapPdu = new SnmpPduTrap();
trapPdu.setTimeStamp(this.clock.uptime());
// Organise the 'variable' payload
trapPdu.setGeneric(m.getGeneric());
trapPdu.setSpecific(m.getSpecific());
trapPdu.setEnterprise(m.getEnterprise());
// Append the specified varbinds. Get varbinds from mapping and for
// each one of the former use the wrapper to get the corresponding
// values
// Get the coresponding wrapper to get access to notification payload
NotificationWrapper wrapper =
(NotificationWrapper)this.notificationWrapperCache.get(index);
if(wrapper != null)
{
// Prime the wrapper with the notification contents
wrapper.prime(n);
// Iterate through mapping specified varbinds and organise values
// for each
List vbList = m.getVarBindList().getVarBindList();
for (int i = 0; i < vbList.size(); i++)
{
VarBind vb = (VarBind)vbList.get(i);
// Append the var bind. Interrogate read vb for OID and
// variable tag. The later is used as the key passed to the
// wrapper in order for it to locate the required value. That
// value and the aforementioned OID are used to generate the
// variable binding
trapPdu.addVarBind(
this.snmpVBFactory.make(vb.getOid(), wrapper.get(vb.getTag())));
}
}
else
{
throw new MappingFailedException(
"Varbind mapping failure: null wrapper defined for " +
" notification type '" + m.getNotificationType() + "'" );
}
return trapPdu;
}