use of org.mobicents.slee.resource.diameter.ro.events.RoCreditControlRequestImpl in project jain-slee.diameter by RestComm.
the class RoMessageFactoryImpl method createRoCreditControlAnswer.
public RoCreditControlAnswer createRoCreditControlAnswer(RoCreditControlRequest request) {
// Create the answer from the request
RoCreditControlRequestImpl ccr = (RoCreditControlRequestImpl) request;
// DiameterAvp sessionIdAvp = null;
// try {
// sessionIdAvp = creditControlAvpFactory.getBaseFactory().createAvp(0,
// DiameterAvpCodes.SESSION_ID, this.session.getSessionId());
// }
// catch (NoSuchAvpException e1) {
// logger.error("Session-Id AVP not found in message", e1);
// }
RoCreditControlAnswerImpl msg = new RoCreditControlAnswerImpl(createMessage(ccr.getHeader(), new DiameterAvp[] {}));
// FIXME: ammendonca: go through proper methods...
Message raw = msg.getGenericData();
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
raw.getAvps().removeAvp(DiameterAvpCodes.DESTINATION_HOST);
raw.getAvps().removeAvp(DiameterAvpCodes.DESTINATION_REALM);
raw.getAvps().removeAvp(DiameterAvpCodes.ORIGIN_HOST);
raw.getAvps().removeAvp(DiameterAvpCodes.ORIGIN_REALM);
msg.setSessionId(request.getSessionId());
// Now copy the needed AVPs
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.ro.events.RoCreditControlRequestImpl in project jain-slee.diameter by RestComm.
the class DiameterRoResourceAdaptor 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(Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
boolean isRequest = message.isRequest();
switch(commandCode) {
case // CCR/CCA
RoCreditControlRequest.commandCode:
return isRequest ? new RoCreditControlRequestImpl(message) : new RoCreditControlAnswerImpl(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
ReAuthAnswer.commandCode:
return isRequest ? new ReAuthRequestImpl(message) : new ReAuthAnswerImpl(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.ro.events.RoCreditControlRequestImpl in project jain-slee.diameter by RestComm.
the class RoMessageFactoryImpl method createRoCreditControlRequest.
private RoCreditControlMessage createRoCreditControlRequest(DiameterHeader diameterHeader, DiameterAvp[] avps) throws IllegalArgumentException {
// List<DiameterAvp> list = (List<DiameterAvp>) this.avpList.clone();
boolean isRequest = diameterHeader == null;
RoCreditControlMessage msg = null;
if (!isRequest) {
Message raw = createMessage(diameterHeader, avps);
raw.setProxiable(diameterHeader.isProxiable());
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = new RoCreditControlAnswerImpl(raw);
} else {
Message raw = createMessage(null, avps);
raw.setProxiable(true);
raw.setRequest(true);
msg = new RoCreditControlRequestImpl(raw);
}
return msg;
}
Aggregations