Search in sources :

Example 1 with PushNotificationRequestImpl

use of org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl in project jain-slee.diameter by RestComm.

the class ShServerMessageFactoryImpl method createPushNotificationRequest.

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

Example 2 with PushNotificationRequestImpl

use of org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl 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 3 with PushNotificationRequestImpl

use of org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl 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 4 with PushNotificationRequestImpl

use of org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl in project jain-slee.diameter by RestComm.

the class ShClientActivityAnswerCreationTest method testShClientActivityAnswerCreation.

@Test
public void testShClientActivityAnswerCreation() throws Exception {
    ClientShSession session = new ShClientSessionImpl(new ShClientSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ClientShSessionListenerImpl());
    PushNotificationRequest pnr = new PushNotificationRequestImpl(stack.getSessionFactory().getNewSession().createRequest(PushNotificationRequest.commandCode, SH_APP_ID, "mobicents.org", "hss.mobicents"));
    ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
    list.add(pnr);
    ShClientSubscriptionActivityImpl activity = new ShClientSubscriptionActivityImpl(new ShClientMessageFactoryImpl(session.getSessions().get(0), stack), new DiameterShAvpFactoryImpl(diameterAvpFactory), session, null, null);
    DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
Also used : PushNotificationRequestImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl) ClientShSession(org.jdiameter.api.sh.ClientShSession) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShClientSessionImpl(org.jdiameter.client.impl.app.sh.ShClientSessionImpl) ShClientSessionDataLocalImpl(org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) ShClientSubscriptionActivityImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientSubscriptionActivityImpl) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

PushNotificationRequestImpl (org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl)4 ArrayList (java.util.ArrayList)2 SleeEndpoint (javax.slee.resource.SleeEndpoint)2 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)2 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)2 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)2 ProfileUpdateAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateAnswerImpl)2 ProfileUpdateRequestImpl (org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateRequestImpl)2 PushNotificationAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.PushNotificationAnswerImpl)2 SubscribeNotificationsAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsAnswerImpl)2 SubscribeNotificationsRequestImpl (org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsRequestImpl)2 UserDataAnswerImpl (org.mobicents.slee.resource.diameter.sh.events.UserDataAnswerImpl)2 UserDataRequestImpl (org.mobicents.slee.resource.diameter.sh.events.UserDataRequestImpl)2 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 PushNotificationRequest (net.java.slee.resource.diameter.sh.events.PushNotificationRequest)1 Message (org.jdiameter.api.Message)1 ClientShSession (org.jdiameter.api.sh.ClientShSession)1 ShClientSessionDataLocalImpl (org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl)1 ShClientSessionImpl (org.jdiameter.client.impl.app.sh.ShClientSessionImpl)1