Search in sources :

Example 1 with RfAccountingAnswerImpl

use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.

the class RfMessageFactoryImpl method createRfAccountingMessage.

protected RfAccountingMessage createRfAccountingMessage(DiameterHeader diameterHeader, DiameterAvp[] avps) throws IllegalArgumentException {
    // List<DiameterAvp> list = (List<DiameterAvp>) this.avpList.clone();
    boolean isRequest = diameterHeader == null;
    RfAccountingMessage 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 RfAccountingAnswerImpl(raw);
    } else {
        Message raw = createMessage(null, avps);
        raw.setProxiable(true);
        raw.setRequest(true);
        msg = new RfAccountingRequestImpl(raw);
    }
    return msg;
}
Also used : RfAccountingMessage(net.java.slee.resource.diameter.rf.events.RfAccountingMessage) Message(org.jdiameter.api.Message) RfAccountingMessage(net.java.slee.resource.diameter.rf.events.RfAccountingMessage) RfAccountingAnswerImpl(org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl) RfAccountingRequestImpl(org.mobicents.slee.resource.diameter.rf.events.RfAccountingRequestImpl)

Example 2 with RfAccountingAnswerImpl

use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.

the class RfServerSessionActivityImpl method createRfAccountingAnswer.

public RfAccountingAnswer createRfAccountingAnswer(RfAccountingRequest request) {
    try {
        // Extract interesting AVPs
        ArrayList<DiameterAvp> copyAvps = new ArrayList<DiameterAvp>();
        copyAvps.add(avpFactory.createAvp(Avp.SESSION_ID, serverSession.getSessions().get(0).getSessionId()));
        copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_HOST, this.originHost.getBytes()));
        copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_REALM, this.originRealm.getBytes()));
        for (DiameterAvp avp : request.getAvps()) {
            if (avp.getCode() == Avp.ACC_RECORD_NUMBER || avp.getCode() == Avp.ACC_RECORD_TYPE) /* || 
            avp.getCode() == Avp.ACCT_APPLICATION_ID || avp.getCode() == Avp.VENDOR_SPECIFIC_APPLICATION_ID*/
            {
                copyAvps.add((DiameterAvp) avp.clone());
            }
        }
        RfAccountingAnswerImpl answer = (RfAccountingAnswerImpl) ((RfMessageFactoryImpl) rfMessageFactory).createRfAccountingMessage(request.getHeader(), copyAvps.toArray(new DiameterAvp[copyAvps.size()]));
        // Get the raw Answer
        Message rawAnswer = answer.getGenericData();
        // This is an answer.
        rawAnswer.setRequest(false);
        // just in case. answers never have T flag set
        rawAnswer.setReTransmitted(false);
        answer.setData(request);
        return answer;
    } catch (Exception e) {
        logger.error("", e);
    }
    return null;
}
Also used : DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) Message(org.jdiameter.api.Message) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) RfAccountingAnswerImpl(org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 3 with RfAccountingAnswerImpl

use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.

the class RfServerSessionActivityImpl method sendRfAccountingAnswer.

public void sendRfAccountingAnswer(RfAccountingAnswer answer) throws IOException {
    try {
        RfAccountingAnswerImpl aca = (RfAccountingAnswerImpl) answer;
        this.serverSession.sendAccountAnswer(new org.jdiameter.common.impl.app.rf.RfAccountingAnswerImpl((Answer) aca.getGenericData()));
        // FIXME: check this?
        if (isTerminateAfterProcessing()) {
            endActivity();
        // this.serverSession.release();
        // 
        // if(!serverSession.isValid()) {
        // String sessionId =
        // this.serverSession.getSessions().get(0).getSessionId();
        // this.baseListener.sessionDestroyed(sessionId,
        // this.serverSession);
        // }
        }
        // clean
        clean(aca);
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to send message, due to: ", e);
        }
        throw new IOException("Failed to send message, due to: " + e.getMessage());
    }
}
Also used : RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) Answer(org.jdiameter.api.Answer) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) RfAccountingAnswerImpl(org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl) IOException(java.io.IOException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 4 with RfAccountingAnswerImpl

use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.

the class DiameterRfResourceAdaptor 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 // ACR/ACA
        RfAccountingAnswer.commandCode:
            return isRequest ? new RfAccountingRequestImpl(message) : new RfAccountingAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) RfAccountingRequestImpl(org.mobicents.slee.resource.diameter.rf.events.RfAccountingRequestImpl) RfAccountingAnswerImpl(org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl)

Aggregations

RfAccountingAnswerImpl (org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl)4 IOException (java.io.IOException)2 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)2 Message (org.jdiameter.api.Message)2 RfAccountingRequestImpl (org.mobicents.slee.resource.diameter.rf.events.RfAccountingRequestImpl)2 ArrayList (java.util.ArrayList)1 SleeEndpoint (javax.slee.resource.SleeEndpoint)1 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 RfAccountingAnswer (net.java.slee.resource.diameter.rf.events.RfAccountingAnswer)1 RfAccountingMessage (net.java.slee.resource.diameter.rf.events.RfAccountingMessage)1 Answer (org.jdiameter.api.Answer)1 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)1 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)1