use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class ShServerMessageFactoryImpl method addAvp.
protected void addAvp(DiameterAvp avp, AvpSet set) {
// FIXME: alexandre: Should we look at the types and add them with proper function?
if (avp instanceof GroupedAvp) {
AvpSet avpSet = set.addGroupedAvp(avp.getCode(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
DiameterAvp[] groupedAVPs = ((GroupedAvp) avp).getExtensionAvps();
for (DiameterAvp avpFromGroup : groupedAVPs) {
addAvp(avpFromGroup, avpSet);
}
} else if (avp != null) {
set.addAvp(avp.getCode(), avp.byteArrayValue(), avp.getVendorId(), avp.getMandatoryRule() == 1, avp.getProtectedRule() == 1);
}
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class ShServerMessageFactoryImpl method createUserDataAnswer.
public UserDataAnswer createUserDataAnswer(UserDataRequest request) {
// Message msg = createShMessage(UserDataAnswer.commandCode, session !=
// null ? session.getSessionId() : null, false);
List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
DiameterAvp sessionIdAvp = null;
try {
sessionIdAvp = localFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, request.getSessionId());
avps.add(sessionIdAvp);
} catch (NoSuchAvpException e) {
logger.error("Unable to create Session-Id AVP.", e);
}
if (request.getUserIdentity() != null)
avps.add(request.getUserIdentity());
Message msg = createShMessage(request.getHeader(), avps.toArray(new DiameterAvp[avps.size()]));
UserDataAnswerImpl answer = new UserDataAnswerImpl(msg);
answer.setRouteRecords(request.getRouteRecords());
// add more :) ?
addOrigin(answer);
return answer;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class ShServerMessageFactoryImpl method createMessage.
protected Message createMessage(DiameterHeader header, DiameterAvp[] avps) throws AvpNotAllowedException {
try {
Message msg = createRawMessage(header);
AvpSet set = msg.getAvps();
for (DiameterAvp avp : avps) {
addAvp(avp, set);
}
return msg;
} catch (Exception e) {
logger.error("Failed to create message.", e);
}
return null;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class ShServerMessageFactoryImpl method createPushNotificationRequest.
public PushNotificationRequest createPushNotificationRequest() {
List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
if (session != null)
try {
DiameterAvp sessionIdAvp = null;
sessionIdAvp = localFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, session.getSessionId());
avps.add(sessionIdAvp);
} catch (NoSuchAvpException e) {
logger.error("Unable to create Session-Id AVP.", e);
}
Message msg = createShMessage(null, avps.toArray(new DiameterAvp[avps.size()]));
PushNotificationRequestImpl request = new PushNotificationRequestImpl(msg);
addOrigin(request);
return request;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class ShServerMessageFactoryImpl method createSubscribeNotificationsAnswer.
public SubscribeNotificationsAnswer createSubscribeNotificationsAnswer(SubscribeNotificationsRequest request) {
// Message msg = createShMessage(UserDataAnswer.commandCode, session !=
// null ? session.getSessionId() : null, false);
List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
DiameterAvp sessionIdAvp = null;
try {
sessionIdAvp = localFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, request.getSessionId());
avps.add(sessionIdAvp);
} catch (NoSuchAvpException e) {
logger.error("Unable to create Session-Id AVP.", e);
}
if (request.getUserIdentity() != null) {
avps.add(request.getUserIdentity());
}
Message msg = createShMessage(request.getHeader(), avps.toArray(new DiameterAvp[avps.size()]));
SubscribeNotificationsAnswerImpl answer = new SubscribeNotificationsAnswerImpl(msg);
answer.setRouteRecords(request.getRouteRecords());
// add more :) ?
addOrigin(answer);
return answer;
}
Aggregations