Search in sources :

Example 6 with NoSuchAvpException

use of net.java.slee.resource.diameter.base.NoSuchAvpException in project jain-slee.diameter by RestComm.

the class CreditControlMessageFactoryImpl method createCreditControlRequest.

/*
   * (non-Javadoc)
   * 
   * @see net.java.slee.resource.diameter.cca.CreditControlMessageFactory#createCreditControlRequest(java.lang.String)
   */
public CreditControlRequest createCreditControlRequest(String sessionId) throws IllegalArgumentException {
    try {
        DiameterAvp sessionIdAvp;
        sessionIdAvp = creditControlAvpFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, sessionId);
        CreditControlRequest req = (CreditControlRequest) createCreditControlMessage(null, new DiameterAvp[] { sessionIdAvp });
        addOrigin(req);
        return req;
    } catch (NoSuchAvpException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 7 with NoSuchAvpException

use of net.java.slee.resource.diameter.base.NoSuchAvpException 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)

Example 8 with NoSuchAvpException

use of net.java.slee.resource.diameter.base.NoSuchAvpException in project jain-slee.diameter by RestComm.

the class ShServerMessageFactoryImpl method createProfileUpdateAnswer.

public ProfileUpdateAnswer createProfileUpdateAnswer(ProfileUpdateRequest request) {
    List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
    DiameterAvp sessionIdAvp = null;
    try {
        sessionIdAvp = localFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, request.getSessionId());
        avps.add(sessionIdAvp);
    } catch (NoSuchAvpException e) {
        logger.error("Unable to create Session-Id AVP.", e);
    }
    if (request.getUserIdentity() != null) {
        avps.add(request.getUserIdentity());
    }
    Message msg = createShMessage(request.getHeader(), avps.toArray(new DiameterAvp[avps.size()]));
    ProfileUpdateAnswerImpl answer = new ProfileUpdateAnswerImpl(msg);
    answer.setRouteRecords(request.getRouteRecords());
    addOrigin(answer);
    return answer;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) ProfileUpdateAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateAnswerImpl) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 9 with NoSuchAvpException

use of net.java.slee.resource.diameter.base.NoSuchAvpException in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createSubscribeNotificationsRequest.

public SubscribeNotificationsRequest createSubscribeNotificationsRequest() {
    DiameterAvp[] avps = new DiameterAvp[0];
    if (session != null) {
        try {
            DiameterAvp sessionIdAvp = null;
            sessionIdAvp = baseAvpFactory.createAvp(0, DiameterAvpCodes.SESSION_ID, session.getSessionId());
            avps = new DiameterAvp[] { sessionIdAvp };
        } catch (NoSuchAvpException e) {
            logger.error("Unexpected failure trying to create Session-Id AVP.", e);
        }
    }
    Message msg = createShMessage(null, avps, SubscribeNotificationsRequest.commandCode);
    SubscribeNotificationsRequestImpl snr = new SubscribeNotificationsRequestImpl(msg);
    addOrigin(snr);
    return snr;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException) SubscribeNotificationsRequestImpl(org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsRequestImpl)

Example 10 with NoSuchAvpException

use of net.java.slee.resource.diameter.base.NoSuchAvpException in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createUserDataRequest.

public UserDataRequest createUserDataRequest() {
    DiameterAvp[] avps = new DiameterAvp[0];
    if (session != null) {
        try {
            DiameterAvp sessionIdAvp = null;
            sessionIdAvp = baseAvpFactory.createAvp(0, DiameterAvpCodes.SESSION_ID, session.getSessionId());
            avps = new DiameterAvp[] { sessionIdAvp };
        } catch (NoSuchAvpException e) {
            logger.error("Unexpected failure trying to create Session-Id AVP.", e);
        }
    }
    Message msg = createShMessage(null, avps, UserDataRequest.commandCode);
    UserDataRequestImpl udr = new UserDataRequestImpl(msg);
    addOrigin(udr);
    return udr;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException) UserDataRequestImpl(org.mobicents.slee.resource.diameter.sh.events.UserDataRequestImpl)

Aggregations

NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)10 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)10 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)8 Message (org.jdiameter.api.Message)8 ArrayList (java.util.ArrayList)4 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 CreditControlRequest (net.java.slee.resource.diameter.cca.events.CreditControlRequest)1 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)1 InternalException (org.jdiameter.api.InternalException)1 CreditControlAnswerImpl (org.mobicents.slee.resource.diameter.cca.events.CreditControlAnswerImpl)1 CreditControlRequestImpl (org.mobicents.slee.resource.diameter.cca.events.CreditControlRequestImpl)1 ProfileUpdateAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateAnswerImpl)1 ProfileUpdateRequestImpl (org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateRequestImpl)1 PushNotificationAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.PushNotificationAnswerImpl)1 PushNotificationRequestImpl (org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl)1 SubscribeNotificationsAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsAnswerImpl)1 SubscribeNotificationsRequestImpl (org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsRequestImpl)1 UserDataAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.UserDataAnswerImpl)1 UserDataRequestImpl (org.mobicents.slee.resource.diameter.sh.events.UserDataRequestImpl)1