use of org.mobicents.slee.resource.diameter.gx.events.GxCreditControlAnswerImpl in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxCreditControlAnswer.
public GxCreditControlAnswer createGxCreditControlAnswer(final GxCreditControlRequest request) {
// Create the answer from the request
final GxCreditControlRequestImpl ccr = (GxCreditControlRequestImpl) request;
// final GxCreditControlAnswerImpl msg = new GxCreditControlAnswerImpl(createMessage(ccr.getHeader(), new DiameterAvp[]{}));
final Message raw = createGxMessage(ccr.getHeader(), new DiameterAvp[] {}, GxCreditControlRequest.commandCode);
raw.setProxiable(ccr.getHeader().isProxiable());
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
final GxCreditControlAnswerImpl msg = new GxCreditControlAnswerImpl(raw);
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);
}
}
}
addOrigin(msg);
return msg;
}
use of org.mobicents.slee.resource.diameter.gx.events.GxCreditControlAnswerImpl in project jain-slee.diameter by RestComm.
the class DiameterGxResourceAdaptor method createEvent.
/**
* Create Event object from a JDiameter message (request or answer).
*
* @return a DiameterMessage object wrapping the request/answer
* @throws OperationNotSupportedException
*/
private DiameterMessage createEvent(final Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
final int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
final boolean isRequest = message.isRequest();
switch(commandCode) {
case // CCR/CCA
GxCreditControlRequest.commandCode:
return isRequest ? new GxCreditControlRequestImpl(message) : new GxCreditControlAnswerImpl(message);
case // ASR/ASA
AbortSessionAnswer.commandCode:
return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message);
case // STR/STA
SessionTerminationAnswer.commandCode:
return isRequest ? new SessionTerminationRequestImpl(message) : new SessionTerminationAnswerImpl(message);
case // RAR/RAA
GxReAuthAnswer.commandCode:
return isRequest ? new GxReAuthRequestImpl(message) : new GxReAuthAnswerImpl(message);
case // ACR/ACA
AccountingAnswer.commandCode:
return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
use of org.mobicents.slee.resource.diameter.gx.events.GxCreditControlAnswerImpl in project jain-slee.diameter by RestComm.
the class GxMessageFactoryImpl method createGxCreditControlRequest.
private GxCreditControlMessage createGxCreditControlRequest(final DiameterHeader diameterHeader, final DiameterAvp[] avps) throws IllegalArgumentException {
boolean isRequest = false;
if (diameterHeader == null) {
isRequest = true;
}
GxCreditControlMessage msg = null;
if (!isRequest) {
final Message raw = createGxMessage(diameterHeader, avps, GxCreditControlRequest.commandCode);
raw.setProxiable(true);
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = new GxCreditControlAnswerImpl(raw);
} else {
final Message raw = createGxMessage(null, avps, GxCreditControlRequest.commandCode);
raw.setProxiable(true);
raw.setRequest(true);
msg = new GxCreditControlRequestImpl(raw);
}
return msg;
}
Aggregations