Search in sources :

Example 1 with RfAccountingRequest

use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.

the class DiameterRfResourceAdaptor method fireEvent.

// Event and Activities management -------------------------------------
public boolean fireEvent(Object event, ActivityHandle handle, FireableEventType eventID, Address address, boolean useFiltering, boolean transacted) {
    if (useFiltering && eventIDFilter.filterEvent(eventID)) {
        if (tracer.isFineEnabled()) {
            tracer.fine("Event " + eventID + " filtered");
        }
    } else if (eventID == null) {
        tracer.severe("Event ID for " + eventID + " is unknown, unable to fire.");
    } else {
        if (tracer.isFineEnabled()) {
            tracer.fine("Firing event " + event + " on handle " + handle);
        }
        try {
            /* TODO: Support transacted fire of events when in cluster
        if (transacted){
          this.raContext.getSleeEndpoint().fireEventTransacted(handle, eventID, event, address, null, EVENT_FLAGS);
        }
        else */
            {
                // fetch state for Server Activities
                Object o = getActivity(handle);
                if (o == null) {
                    Transaction t = raContext.getSleeTransactionManager().getTransaction();
                    throw new IllegalStateException("TX[ " + t + " ] No activity for handle: " + handle);
                }
                if (o instanceof RfServerSessionActivityImpl && event instanceof RfAccountingRequest) {
                    ((RfServerSessionActivityImpl) o).fetchSessionData((RfAccountingRequest) event, true);
                }
                this.raContext.getSleeEndpoint().fireEvent(handle, eventID, event, address, null, EVENT_FLAGS);
            }
            return true;
        } catch (Exception e) {
            tracer.severe("Error firing event.", e);
        }
    }
    return false;
}
Also used : Transaction(javax.transaction.Transaction) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException)

Example 2 with RfAccountingRequest

use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.

the class RfClientSessionActivityImpl method createRfAccountingRequest.

public RfAccountingRequest createRfAccountingRequest(AccountingRecordType accountingRecordType) {
    RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(accountingRecordType);
    // Set Acct-Application-Id to 3 as specified
    acr.setAcctApplicationId(3L);
    acr.setAccountingRecordType(accountingRecordType);
    return acr;
}
Also used : RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest)

Example 3 with RfAccountingRequest

use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method isProxiableCopiedACA.

@Test
public void isProxiableCopiedACA() throws Exception {
    RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    // needed ...
    acr.setAccountingRecordNumber(5L);
    RfAccountingAnswer aca = rfServerSession.createRfAccountingAnswer(acr);
    assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
    // Reverse 'P' bit ...
    ((DiameterMessageImpl) acr).getGenericData().setProxiable(!acr.getHeader().isProxiable());
    assertTrue("The 'P' bit was not modified in Accounting-Request, it should.", acr.getHeader().isProxiable() != aca.getHeader().isProxiable());
    aca = rfServerSession.createRfAccountingAnswer(acr);
    assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
}
Also used : RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 4 with RfAccountingRequest

use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method testMessageFactoryApplicationIdChangeACR.

@Test
public void testMessageFactoryApplicationIdChangeACR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((RfMessageFactoryImpl) rfMessageFactory).getApplicationId();
    boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
    boolean isVendor = originalAppId.getVendorId() != 0L;
    assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
    System.out.println("Default VENDOR-ID for Rf is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    RfAccountingRequest originalACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalACR);
    // now we switch..
    originalACR = null;
    isVendor = !isVendor;
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    RfAccountingRequest changedACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACR);
    // revert back to default
    ((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : RfMessageFactoryImpl(org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 5 with RfAccountingRequest

use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.

the class RfFactoriesTest method hasTFlagSetACA.

@Test
public void hasTFlagSetACA() throws Exception {
    RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
    // needed ...
    acr.setAccountingRecordNumber(5L);
    ((DiameterMessageImpl) acr).getGenericData().setReTransmitted(true);
    assertTrue("The 'T' flag should be set in Accounting-Request", acr.getHeader().isPotentiallyRetransmitted());
    RfAccountingAnswer aca = rfServerSession.createRfAccountingAnswer(acr);
    assertFalse("The 'T' flag should not be set in Accounting-Answer", aca.getHeader().isPotentiallyRetransmitted());
}
Also used : RfAccountingAnswer(net.java.slee.resource.diameter.rf.events.RfAccountingAnswer) RfAccountingRequest(net.java.slee.resource.diameter.rf.events.RfAccountingRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

RfAccountingRequest (net.java.slee.resource.diameter.rf.events.RfAccountingRequest)12 Test (org.junit.Test)8 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)8 RfAccountingAnswer (net.java.slee.resource.diameter.rf.events.RfAccountingAnswer)4 ApplicationId (org.jdiameter.api.ApplicationId)2 RfMessageFactoryImpl (org.mobicents.slee.resource.diameter.rf.RfMessageFactoryImpl)2 OperationNotSupportedException (javax.naming.OperationNotSupportedException)1 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)1 Transaction (javax.transaction.Transaction)1 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 AvpDataException (org.jdiameter.api.AvpDataException)1 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)1 InternalException (org.jdiameter.api.InternalException)1 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)1 RfServerSessionActivityImpl (org.mobicents.slee.resource.diameter.rf.RfServerSessionActivityImpl)1