use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class RxMessageFactoryImpl method createAAAnswer.
public AAAnswer createAAAnswer(final AARequest request) {
// Create the answer from the request
final AAAnswerImpl msg = (AAAnswerImpl) createDiameterMessage(request.getHeader(), EMPTY_AVP_ARRAY, 0, rxAppId);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
msg.getGenericData().getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
msg.setSessionId(request.getSessionId());
// Now copy the needed AVPs
final DiameterAvp[] messageAvps = request.getAvps();
if (messageAvps != null) {
for (DiameterAvp a : messageAvps) {
try {
if (ids.contains(a.getCode())) {
msg.addAvp(a);
}
} catch (Exception e) {
logger.error("Failed to add AVP to answer. Code[" + a.getCode() + "]", e);
}
}
}
return msg;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class RfServerSessionActivityImpl method createRfAccountingAnswer.
public RfAccountingAnswer createRfAccountingAnswer(RfAccountingRequest request) {
try {
// Extract interesting AVPs
ArrayList<DiameterAvp> copyAvps = new ArrayList<DiameterAvp>();
copyAvps.add(avpFactory.createAvp(Avp.SESSION_ID, serverSession.getSessions().get(0).getSessionId()));
copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_HOST, this.originHost.getBytes()));
copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_REALM, this.originRealm.getBytes()));
for (DiameterAvp avp : request.getAvps()) {
if (avp.getCode() == Avp.ACC_RECORD_NUMBER || avp.getCode() == Avp.ACC_RECORD_TYPE) /* ||
avp.getCode() == Avp.ACCT_APPLICATION_ID || avp.getCode() == Avp.VENDOR_SPECIFIC_APPLICATION_ID*/
{
copyAvps.add((DiameterAvp) avp.clone());
}
}
RfAccountingAnswerImpl answer = (RfAccountingAnswerImpl) ((RfMessageFactoryImpl) rfMessageFactory).createRfAccountingMessage(request.getHeader(), copyAvps.toArray(new DiameterAvp[copyAvps.size()]));
// Get the raw Answer
Message rawAnswer = answer.getGenericData();
// This is an answer.
rawAnswer.setRequest(false);
// just in case. answers never have T flag set
rawAnswer.setReTransmitted(false);
answer.setData(request);
return answer;
} catch (Exception e) {
logger.error("", e);
}
return null;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class S6aClientSessionImpl method createDeleteSubscriberDataAnswer.
public DeleteSubscriberDataAnswer createDeleteSubscriberDataAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof DeleteSubscriberDataRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
DeleteSubscriberDataAnswer dsa = (DeleteSubscriberDataAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, DeleteSubscriberDataAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(dsa);
return dsa;
} catch (InternalException e) {
logger.error("Failed to create Delete-Subscriber-Data-Answer.", e);
}
return null;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class S6aServerSessionImpl method createPurgeUEAnswer.
public PurgeUEAnswer createPurgeUEAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof PurgeUERequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
PurgeUEAnswer aia = (PurgeUEAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, PurgeUEAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(aia);
return aia;
} catch (InternalException e) {
logger.error("Failed to create Purge-UE-Answer.", e);
}
return null;
}
use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.
the class S6aServerSessionImpl method createNotifyAnswer.
public NotifyAnswer createNotifyAnswer() {
// Make sure we have the correct type of Request
if (!(lastRequest instanceof NotifyRequest)) {
logger.warn("Invalid type of answer for this activity.");
return null;
}
try {
// Create the answer
NotifyAnswer aia = (NotifyAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, NotifyAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
// Fill session related AVPs, if present
fillSessionAVPs(aia);
return aia;
} catch (InternalException e) {
logger.error("Failed to create Notify-Answer.", e);
}
return null;
}
Aggregations