Search in sources :

Example 31 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project charging-server by RestComm.

the class DiameterChargingServerSbb method buildCCInfo.

private CreditControlInfo buildCCInfo(RoCreditControlRequest ccr, String endUserId, SubscriptionIdType endUserType, ArrayList<CreditControlUnit> ccUnits) {
    // Build Credit Control Info Request to ABMF
    CreditControlInfo ccInfo = new CreditControlInfo();
    ccInfo.setEventTimestamp(System.currentTimeMillis());
    CcRequestType type = ccr.getCcRequestType();
    ccInfo.setEventType(type.toString());
    if (type == CcRequestType.EVENT_REQUEST) {
        ccInfo.setRequestedAction(ccr.getRequestedAction());
    }
    ccInfo.setRequestNumber((int) ccr.getCcRequestNumber());
    ccInfo.setSessionId(ccr.getSessionId());
    ccInfo.setSubscriptionId(endUserId);
    ccInfo.setSubscriptionIdType(endUserType);
    ccInfo.setCcUnits(ccUnits);
    // Iterate CCR to capture needed AVPs
    for (DiameterAvp avp : ccr.getAvps()) {
        fetchDataFromAvp(avp, ccInfo);
    }
    return ccInfo;
}
Also used : CreditControlInfo(org.mobicents.charging.server.account.CreditControlInfo) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) CcRequestType(net.java.slee.resource.diameter.cca.events.avp.CcRequestType)

Example 32 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class S6aClientSessionImpl method createCancelLocationAnswer.

public CancelLocationAnswer createCancelLocationAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof CancelLocationRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        CancelLocationAnswer cla = (CancelLocationAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, CancelLocationAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(cla);
        return cla;
    } catch (InternalException e) {
        logger.error("Failed to create Cancel-Location-Answer.", e);
    }
    return null;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) CancelLocationRequest(net.java.slee.resource.diameter.s6a.events.CancelLocationRequest) CancelLocationAnswer(net.java.slee.resource.diameter.s6a.events.CancelLocationAnswer) InternalException(org.jdiameter.api.InternalException)

Example 33 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class S6aClientSessionImpl method createInsertSubscriberDataAnswer.

public InsertSubscriberDataAnswer createInsertSubscriberDataAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof InsertSubscriberDataRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        InsertSubscriberDataAnswer ida = (InsertSubscriberDataAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, InsertSubscriberDataAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(ida);
        return ida;
    } catch (InternalException e) {
        logger.error("Failed to create Insert-Subscriber-Data-Answer.", e);
    }
    return null;
}
Also used : InsertSubscriberDataAnswer(net.java.slee.resource.diameter.s6a.events.InsertSubscriberDataAnswer) InsertSubscriberDataRequest(net.java.slee.resource.diameter.s6a.events.InsertSubscriberDataRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) InternalException(org.jdiameter.api.InternalException)

Example 34 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class S6aClientSessionImpl method createResetAnswer.

public ResetAnswer createResetAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof ResetRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        ResetAnswer rsa = (ResetAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, ResetAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(rsa);
        return rsa;
    } catch (InternalException e) {
        logger.error("Failed to create Reset-Answer.", e);
    }
    return null;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ResetAnswer(net.java.slee.resource.diameter.s6a.events.ResetAnswer) ResetRequest(net.java.slee.resource.diameter.s6a.events.ResetRequest) InternalException(org.jdiameter.api.InternalException)

Example 35 with DiameterAvp

use of net.java.slee.resource.diameter.base.events.avp.DiameterAvp in project jain-slee.diameter by RestComm.

the class S6aServerSessionImpl method createUpdateLocationAnswer.

public UpdateLocationAnswer createUpdateLocationAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof UpdateLocationRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        UpdateLocationAnswer aia = (UpdateLocationAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, UpdateLocationAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(aia);
        return aia;
    } catch (InternalException e) {
        logger.error("Failed to create Update-Location-Answer.", e);
    }
    return null;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) UpdateLocationAnswer(net.java.slee.resource.diameter.s6a.events.UpdateLocationAnswer) UpdateLocationRequest(net.java.slee.resource.diameter.s6a.events.UpdateLocationRequest) InternalException(org.jdiameter.api.InternalException)

Aggregations

DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)65 Message (org.jdiameter.api.Message)22 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)21 InternalException (org.jdiameter.api.InternalException)21 AvpSet (org.jdiameter.api.AvpSet)18 ArrayList (java.util.ArrayList)15 GroupedAvp (net.java.slee.resource.diameter.base.events.avp.GroupedAvp)15 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)12 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)9 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)6 AccountingRequest (net.java.slee.resource.diameter.base.events.AccountingRequest)3 VendorSpecificApplicationIdAvp (net.java.slee.resource.diameter.base.events.avp.VendorSpecificApplicationIdAvp)3 GxCreditControlMessage (net.java.slee.resource.diameter.gx.events.GxCreditControlMessage)3 GxReAuthMessage (net.java.slee.resource.diameter.gx.events.GxReAuthMessage)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 DiameterIdentity (net.java.slee.resource.diameter.base.events.avp.DiameterIdentity)2 CreditControlRequest (net.java.slee.resource.diameter.cca.events.CreditControlRequest)2 RoCreditControlMessage (net.java.slee.resource.diameter.ro.events.RoCreditControlMessage)2 ApplicationId (org.jdiameter.api.ApplicationId)2