Search in sources :

Example 1 with CreditControlRequestImpl

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;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) CreditControlMessage(net.java.slee.resource.diameter.cca.events.CreditControlMessage) CreditControlRequestImpl(org.mobicents.slee.resource.diameter.cca.events.CreditControlRequestImpl) CreditControlAnswerImpl(org.mobicents.slee.resource.diameter.cca.events.CreditControlAnswerImpl) CreditControlMessage(net.java.slee.resource.diameter.cca.events.CreditControlMessage)

Example 2 with CreditControlRequestImpl

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;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) CreditControlRequestImpl(org.mobicents.slee.resource.diameter.cca.events.CreditControlRequestImpl) CreditControlAnswerImpl(org.mobicents.slee.resource.diameter.cca.events.CreditControlAnswerImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Aggregations

CreditControlAnswerImpl (org.mobicents.slee.resource.diameter.cca.events.CreditControlAnswerImpl)2 CreditControlRequestImpl (org.mobicents.slee.resource.diameter.cca.events.CreditControlRequestImpl)2 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)1 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 CreditControlMessage (net.java.slee.resource.diameter.cca.events.CreditControlMessage)1 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)1 InternalException (org.jdiameter.api.InternalException)1 Message (org.jdiameter.api.Message)1