use of org.mobicents.slee.resource.diameter.cca.events.CreditControlRequestImpl in project jain-slee.diameter by RestComm.
the class CreditControlMessageFactoryImpl method createCreditControlMessage.
// Private Methods -------------------------------------------------
private CreditControlMessage createCreditControlMessage(DiameterHeader diameterHeader, DiameterAvp[] avps) throws IllegalArgumentException {
// List<DiameterAvp> list = (List<DiameterAvp>) this.avpList.clone();
boolean isRequest = diameterHeader == null;
CreditControlMessage 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 CreditControlAnswerImpl(raw);
} else {
Message raw = createMessage(null, avps);
raw.setProxiable(true);
raw.setRequest(true);
msg = new CreditControlRequestImpl(raw);
}
return msg;
}
use of org.mobicents.slee.resource.diameter.cca.events.CreditControlRequestImpl in project jain-slee.diameter by RestComm.
the class CreditControlMessageFactoryImpl method createCreditControlAnswer.
/*
* (non-Javadoc)
*
* @see net.java.slee.resource.diameter.cca.CreditControlMessageFactory#createCreditControlAnswer
* (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
*/
public CreditControlAnswer createCreditControlAnswer(CreditControlRequest request) {
// Create the answer from the request
CreditControlRequestImpl ccr = (CreditControlRequestImpl) 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);
// }
CreditControlAnswerImpl msg = (CreditControlAnswerImpl) createCreditControlMessage(ccr.getHeader(), new DiameterAvp[0]);
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
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;
}
Aggregations