Search in sources :

Example 11 with ErrorAnswerImpl

use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.

the class DiameterActivityImpl method sendSyncMessage.

public DiameterMessage sendSyncMessage(DiameterMessage message) {
    DiameterMessage answer = null;
    Message receivedMessage = doSendMessage(message);
    if (receivedMessage != null) {
        if (!receivedMessage.isRequest()) {
            if (receivedMessage.isError()) {
                answer = new ErrorAnswerImpl(receivedMessage);
            } else {
                switch(receivedMessage.getCommandCode()) {
                    case AbortSessionAnswer.commandCode:
                        answer = new AbortSessionAnswerImpl(receivedMessage);
                        break;
                    case AccountingAnswer.commandCode:
                        answer = new AccountingAnswerImpl(receivedMessage);
                        break;
                    case CapabilitiesExchangeAnswer.commandCode:
                        answer = new CapabilitiesExchangeAnswerImpl(receivedMessage);
                        break;
                    case DeviceWatchdogAnswer.commandCode:
                        answer = new DeviceWatchdogAnswerImpl(receivedMessage);
                        break;
                    case DisconnectPeerAnswer.commandCode:
                        answer = new DisconnectPeerAnswerImpl(receivedMessage);
                        break;
                    case ReAuthAnswer.commandCode:
                        answer = new ReAuthAnswerImpl(receivedMessage);
                        break;
                    case SessionTerminationAnswer.commandCode:
                        answer = new SessionTerminationAnswerImpl(receivedMessage);
                        break;
                    default:
                        logger.error("Received an unknown type of Message for Base Activity: " + receivedMessage);
                        break;
                }
            }
        } else {
            logger.error("Received a REQUEST message when expecting an ANSWER.");
        }
    } else {
        logger.debug("No answer received. Returning null.");
    }
    return answer;
}
Also used : AccountingAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl) CapabilitiesExchangeAnswerImpl(org.mobicents.slee.resource.diameter.base.events.CapabilitiesExchangeAnswerImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ReAuthAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ReAuthAnswerImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) DisconnectPeerAnswerImpl(org.mobicents.slee.resource.diameter.base.events.DisconnectPeerAnswerImpl) DeviceWatchdogAnswerImpl(org.mobicents.slee.resource.diameter.base.events.DeviceWatchdogAnswerImpl)

Example 12 with ErrorAnswerImpl

use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.

the class DiameterShServerResourceAdaptor 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 // PNR/PNA
        PushNotificationRequest.commandCode:
            return isRequest ? new PushNotificationRequestImpl(message) : new PushNotificationAnswerImpl(message);
        case // PUR/PUA
        ProfileUpdateRequest.commandCode:
            return isRequest ? new ProfileUpdateRequestImpl(message) : new ProfileUpdateAnswerImpl(message);
        case // SNR/SNA
        SubscribeNotificationsRequest.commandCode:
            return isRequest ? new SubscribeNotificationsRequestImpl(message) : new SubscribeNotificationsAnswerImpl(message);
        case // UDR/UDA
        UserDataRequest.commandCode:
            return isRequest ? new UserDataRequestImpl(message) : new UserDataAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : UserDataAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.UserDataAnswerImpl) PushNotificationRequestImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl) ProfileUpdateAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateAnswerImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) SubscribeNotificationsAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsAnswerImpl) ProfileUpdateRequestImpl(org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateRequestImpl) SubscribeNotificationsRequestImpl(org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsRequestImpl) UserDataRequestImpl(org.mobicents.slee.resource.diameter.sh.events.UserDataRequestImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) PushNotificationAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationAnswerImpl)

Example 13 with ErrorAnswerImpl

use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.

the class DiameterShClientResourceAdaptor 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 // PNR/PNA
        PushNotificationRequestImpl.commandCode:
            return isRequest ? new PushNotificationRequestImpl(message) : new PushNotificationAnswerImpl(message);
        case // PUR/PUA
        ProfileUpdateRequestImpl.commandCode:
            return isRequest ? new ProfileUpdateRequestImpl(message) : new ProfileUpdateAnswerImpl(message);
        case // SNR/SNA
        SubscribeNotificationsRequestImpl.commandCode:
            return isRequest ? new SubscribeNotificationsRequestImpl(message) : new SubscribeNotificationsAnswerImpl(message);
        case // UDR/UDA
        net.java.slee.resource.diameter.sh.events.UserDataRequest.commandCode:
            return isRequest ? new UserDataRequestImpl(message) : new UserDataAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : UserDataAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.UserDataAnswerImpl) PushNotificationRequestImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl) ProfileUpdateAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateAnswerImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) SubscribeNotificationsAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsAnswerImpl) ProfileUpdateRequestImpl(org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateRequestImpl) SubscribeNotificationsRequestImpl(org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsRequestImpl) UserDataRequestImpl(org.mobicents.slee.resource.diameter.sh.events.UserDataRequestImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) PushNotificationAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationAnswerImpl)

Example 14 with ErrorAnswerImpl

use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.

the class DiameterGxResourceAdaptor 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(final Message message) {
    if (message == null) {
        throw new NullPointerException("Message argument cannot be null while creating event.");
    }
    final int commandCode = message.getCommandCode();
    if (message.isError()) {
        return new ErrorAnswerImpl(message);
    }
    final boolean isRequest = message.isRequest();
    switch(commandCode) {
        case // CCR/CCA
        GxCreditControlRequest.commandCode:
            return isRequest ? new GxCreditControlRequestImpl(message) : new GxCreditControlAnswerImpl(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
        GxReAuthAnswer.commandCode:
            return isRequest ? new GxReAuthRequestImpl(message) : new GxReAuthAnswerImpl(message);
        case // ACR/ACA
        AccountingAnswer.commandCode:
            return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : AccountingAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl) AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl) GxReAuthRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl) AccountingRequestImpl(org.mobicents.slee.resource.diameter.base.events.AccountingRequestImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) AbortSessionRequestImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionRequestImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl) GxCreditControlAnswerImpl(org.mobicents.slee.resource.diameter.gx.events.GxCreditControlAnswerImpl) GxCreditControlRequestImpl(org.mobicents.slee.resource.diameter.gx.events.GxCreditControlRequestImpl) GxReAuthAnswerImpl(org.mobicents.slee.resource.diameter.gx.events.GxReAuthAnswerImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) SessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationRequestImpl)

Example 15 with ErrorAnswerImpl

use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.

the class GqSessionActivityImpl method sendSyncMessage.

@Override
public DiameterMessage sendSyncMessage(DiameterMessage message) {
    DiameterMessage answer = null;
    Message receivedMessage = doSendMessage(message);
    if (receivedMessage != null) {
        if (!receivedMessage.isRequest()) {
            if (receivedMessage.isError()) {
                answer = new ErrorAnswerImpl(receivedMessage);
            } else {
                switch(receivedMessage.getCommandCode()) {
                    case GqAARequest.COMMAND_CODE:
                        answer = new GqAARequestImpl(receivedMessage);
                        break;
                    case GqAbortSessionRequest.COMMAND_CODE:
                        answer = new GqAbortSessionRequestImpl(receivedMessage);
                        break;
                    case GqReAuthRequest.COMMAND_CODE:
                        answer = new GqReAuthRequestImpl(receivedMessage);
                        break;
                    case GqSessionTerminationRequest.COMMAND_CODE:
                        answer = new GqSessionTerminationRequestImpl(receivedMessage);
                        break;
                    default:
                        logger.error("Received an unknown type of Message for Gq' Activity: " + receivedMessage);
                        break;
                }
            }
        } else {
            logger.error("Received a REQUEST message when expecting an ANSWER.");
        }
    } else {
        logger.debug("No answer received. Returning null.");
    }
    return answer;
}
Also used : GqReAuthRequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqReAuthRequestImpl) GqSessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqSessionTerminationRequestImpl) GqAbortSessionRequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqAbortSessionRequestImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) Message(org.jdiameter.api.Message) GqAARequestImpl(org.mobicents.slee.resource.diameter.gq.events.GqAARequestImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)

Aggregations

ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)17 SleeEndpoint (javax.slee.resource.SleeEndpoint)10 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)10 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)7 Message (org.jdiameter.api.Message)7 AbortSessionAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl)3 AccountingAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl)3 SessionTerminationAnswerImpl (org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl)3 AbortSessionRequestImpl (org.mobicents.slee.resource.diameter.base.events.AbortSessionRequestImpl)2 AccountingRequestImpl (org.mobicents.slee.resource.diameter.base.events.AccountingRequestImpl)2 ReAuthAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ReAuthAnswerImpl)2 SessionTerminationRequestImpl (org.mobicents.slee.resource.diameter.base.events.SessionTerminationRequestImpl)2 GqAARequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqAARequestImpl)2 GqAbortSessionRequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqAbortSessionRequestImpl)2 GqReAuthRequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqReAuthRequestImpl)2 GqSessionTerminationRequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqSessionTerminationRequestImpl)2 GxCreditControlRequestImpl (org.mobicents.slee.resource.diameter.gx.events.GxCreditControlRequestImpl)2 GxReAuthRequestImpl (org.mobicents.slee.resource.diameter.gx.events.GxReAuthRequestImpl)2 RfAccountingRequestImpl (org.mobicents.slee.resource.diameter.rf.events.RfAccountingRequestImpl)2 RoCreditControlAnswerImpl (org.mobicents.slee.resource.diameter.ro.events.RoCreditControlAnswerImpl)2