Search in sources :

Example 46 with DiameterMessageImpl

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

the class AvpFlagsTest method testCorrectFlagsBaseExample.

@Test
public void testCorrectFlagsBaseExample() throws NoSuchAvpException {
    List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.SESSION_ID, "accesspoint7.acme.com;1876543210;523;mobile@200.1.1.88".getBytes()));
    DiameterAvp avpVendorId = baseAvpFactory.createAvp(DiameterAvpCodes.VENDOR_ID, 193);
    DiameterAvp avpAcctApplicationId = baseAvpFactory.createAvp(DiameterAvpCodes.ACCT_APPLICATION_ID, 19302);
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID, new DiameterAvp[] { avpVendorId, avpAcctApplicationId }));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ORIGIN_HOST, "127.0.0.1".getBytes()));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ORIGIN_REALM, "mobicents.org".getBytes()));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.DESTINATION_HOST, ("127.0.0.1" + ":" + "3868").getBytes()));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.DESTINATION_REALM, "mobicents.org".getBytes()));
    // Subscription ID
    DiameterAvp subscriptionIdType = baseAvpFactory.createAvp(193, 555, 0);
    DiameterAvp subscriptionIdData = baseAvpFactory.createAvp(193, 554, "00001000");
    avps.add(baseAvpFactory.createAvp(193, 553, new DiameterAvp[] { subscriptionIdType, subscriptionIdData }));
    // Requested Service Unit
    DiameterAvp unitType = baseAvpFactory.createAvp(193, 611, 2);
    DiameterAvp valueDigits = baseAvpFactory.createAvp(193, 617, 10L);
    DiameterAvp unitValue = baseAvpFactory.createAvp(193, 612, new DiameterAvp[] { valueDigits });
    avps.add(baseAvpFactory.createAvp(193, 606, new DiameterAvp[] { unitType, unitValue }));
    // Record Number and Type
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ACCOUNTING_RECORD_NUMBER, 0));
    avps.add(baseAvpFactory.createAvp(DiameterAvpCodes.ACCOUNTING_RECORD_TYPE, 1));
    // Requested action
    avps.add(baseAvpFactory.createAvp(193, 615, 0));
    // Service Parameter Type
    DiameterAvp serviceParameterType = baseAvpFactory.createAvp(193, 608, 0);
    DiameterAvp serviceParameterValue = baseAvpFactory.createAvp(193, 609, "510");
    avps.add(baseAvpFactory.createAvp(193, 607, new DiameterAvp[] { serviceParameterType, serviceParameterValue }));
    // Service Parameter Type
    DiameterAvp serviceParameterType2 = baseAvpFactory.createAvp(193, 608, 14);
    DiameterAvp serviceParameterValue2 = baseAvpFactory.createAvp(193, 609, "20");
    avps.add(baseAvpFactory.createAvp(193, 607, new DiameterAvp[] { serviceParameterType2, serviceParameterValue2 }));
    DiameterAvp[] avpArray = new DiameterAvp[avps.size()];
    avpArray = avps.toArray(avpArray);
    AccountingRequest acr = baseMessageFactory.createAccountingRequest();
    acr.setExtensionAvps(avpArray);
    ArrayList<String> failures = checkAvpFlags(((DiameterMessageImpl) acr).getGenericData().getAvps());
    if (failures.size() > 0) {
        System.err.println("The following AVPs flags have failed to check against dictionary:");
        for (String failure : failures) {
            System.err.println(failure);
        }
        Assert.fail(failures.toString());
    }
    // Test going through other way for adding avp's
    acr = baseMessageFactory.createAccountingRequest(avpArray);
    failures = checkAvpFlags(((DiameterMessageImpl) acr).getGenericData().getAvps());
    if (failures.size() > 0) {
        System.err.println("The following AVPs flags have failed to check against dictionary:");
        for (String failure : failures) {
            System.err.println(failure);
        }
        Assert.fail(failures.toString());
    }
}
Also used : AccountingRequest(net.java.slee.resource.diameter.base.events.AccountingRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) Test(org.junit.Test)

Example 47 with DiameterMessageImpl

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

the class CreditControlClientSessionImpl method sendCreditControlRequest.

/*
   * (non-Javadoc)
   * 
   * @seenet.java.slee.resource.diameter.cca.CreditControlClientSession#
   * sendCreditControlRequest
   * (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
   */
public void sendCreditControlRequest(CreditControlRequest ccr) throws IOException {
    // fetchCurrentState(ccr);
    DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    validateState(ccr);
    try {
        session.sendCreditControlRequest(new JCreditControlRequestImpl((Request) msg.getGenericData()));
    } 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.", e);
        }
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : JCreditControlRequestImpl(org.jdiameter.common.impl.app.cca.JCreditControlRequestImpl) Request(org.jdiameter.api.Request) CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 48 with DiameterMessageImpl

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

the class CreditControlClientSessionImpl method sendUpdateCreditControlRequest.

/*
   * (non-Javadoc)
   * 
   * @seenet.java.slee.resource.diameter.cca.CreditControlClientSession#
   * sendUpdateCreditControlRequest
   * (net.java.slee.resource.diameter.cca.events.CreditControlRequest)
   */
public void sendUpdateCreditControlRequest(CreditControlRequest ccr) throws IOException {
    // FIXME: Should this come already in the CCR?
    ccr.setCcRequestType(CcRequestType.UPDATE_REQUEST);
    validateState(ccr);
    DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new JCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : JCreditControlRequestImpl(org.jdiameter.common.impl.app.cca.JCreditControlRequestImpl) Request(org.jdiameter.api.Request) CreditControlRequest(net.java.slee.resource.diameter.cca.events.CreditControlRequest) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 49 with DiameterMessageImpl

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

the class CxDxClientSessionImpl method sendPushProfileAnswer.

/* (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#sendPushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer)
   */
public void sendPushProfileAnswer(PushProfileAnswer pushProfileAnswer) throws IOException {
    try {
        DiameterMessageImpl msg = (DiameterMessageImpl) pushProfileAnswer;
        appSession.sendPushProfileAnswer(new JPushProfileAnswerImpl((Answer) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException anae) {
        throw new AvpNotAllowedException(anae.getMessage(), anae.getAvpCode(), anae.getVendorId());
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}
Also used : RegistrationTerminationAnswer(net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswer) Answer(org.jdiameter.api.Answer) PushProfileAnswer(net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer) JPushProfileAnswerImpl(org.jdiameter.common.impl.app.cxdx.JPushProfileAnswerImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IOException(java.io.IOException)

Example 50 with DiameterMessageImpl

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

the class CxDxServerSessionImpl method sendLocationInfoAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#sendLocationInfoAnswer(net.java.slee.resource.diameter.cxdx.events.LocationInfoAnswer)
   */
public void sendLocationInfoAnswer(LocationInfoAnswer locationInfoAnswer) throws IOException {
    DiameterMessageImpl msg = (DiameterMessageImpl) locationInfoAnswer;
    JLocationInfoAnswerImpl answer = new JLocationInfoAnswerImpl((Answer) msg.getGenericData());
    try {
        appSession.sendLocationInformationAnswer(answer);
    } catch (org.jdiameter.api.validation.AvpNotAllowedException anae) {
        throw new AvpNotAllowedException(anae.getMessage(), anae.getAvpCode(), anae.getVendorId());
    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to send message.", e);
        }
        throw new IOException(e.getMessage());
    }
}
Also used : JLocationInfoAnswerImpl(org.jdiameter.common.impl.app.cxdx.JLocationInfoAnswerImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IOException(java.io.IOException)

Aggregations

DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)70 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)63 IOException (java.io.IOException)62 InternalException (org.jdiameter.api.InternalException)30 Request (org.jdiameter.api.Request)17 DiameterException (net.java.slee.resource.diameter.base.DiameterException)12 Answer (org.jdiameter.api.Answer)11 SubscribeNotificationsRequest (net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest)6 GxCreditControlRequest (net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)5 CreditControlRequest (net.java.slee.resource.diameter.cca.events.CreditControlRequest)4 GxReAuthRequest (net.java.slee.resource.diameter.gx.events.GxReAuthRequest)4 RoCreditControlRequest (net.java.slee.resource.diameter.ro.events.RoCreditControlRequest)4 Message (org.jdiameter.api.Message)4 JCreditControlRequestImpl (org.jdiameter.common.impl.app.cca.JCreditControlRequestImpl)4 RoCreditControlRequestImpl (org.jdiameter.common.impl.app.ro.RoCreditControlRequestImpl)4 ArrayList (java.util.ArrayList)3 OperationNotSupportedException (javax.naming.OperationNotSupportedException)3 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)3 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)3 ProfileUpdateRequest (net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest)3