Search in sources :

Example 1 with DiameterChargingServer

use of org.mobicents.charging.server.DiameterChargingServer in project charging-server by RestComm.

the class HTTPClientSbb method onResponseEvent.

// Event handler methods
public void onResponseEvent(ResponseEvent event, ActivityContextInterface aci) {
    HttpResponse response = event.getHttpResponse();
    if (tracer.isInfoEnabled()) {
        tracer.info("[<<] Received HTTP Response. Status Code = " + response.getStatusLine().getStatusCode());
        if (tracer.isFineEnabled()) {
            try {
                tracer.fine("[<<] Received HTTP Response. Response Body = [" + EntityUtils.toString(response.getEntity()) + "]");
            } catch (Exception e) {
                tracer.severe("[xx] Failed reading response body", e);
            }
        }
    }
    // end http activity
    ((HttpClientActivity) aci.getActivity()).endActivity();
    // call back parent
    HashMap params = (HashMap) event.getRequestApplicationData();
    RatingInfo ratInfo = buildRatingInfo(response, params);
    final DiameterChargingServer parent = (DiameterChargingServer) sbbContext.getSbbLocalObject().getParent();
    parent.getRateForServiceResult(ratInfo);
}
Also used : HashMap(java.util.HashMap) RatingInfo(org.mobicents.charging.server.ratingengine.RatingInfo) HttpResponse(org.apache.http.HttpResponse) HttpClientActivity(net.java.client.slee.resource.http.HttpClientActivity) StartActivityException(javax.slee.resource.StartActivityException) NamingException(javax.naming.NamingException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DiameterChargingServer(org.mobicents.charging.server.DiameterChargingServer)

Example 2 with DiameterChargingServer

use of org.mobicents.charging.server.DiameterChargingServer in project charging-server by RestComm.

the class AccountBalanceManagementSbb method handleRequest.

// ---------------------------- Helper Methods ----------------------------
private void handleRequest(CreditControlInfo ccInfo) {
    if (tracer.isInfoEnabled()) {
        tracer.info("[><] SID<" + ccInfo.getSessionId() + "> Handling Credit-Control-Request...");
    }
    if (bypass) {
        if (tracer.isInfoEnabled()) {
            tracer.info("[><] SID<" + ccInfo.getSessionId() + "> Bypassing Unit Reservation...");
        }
        ccInfo.setSuccess(true);
        ((DiameterChargingServer) sbbContext.getSbbLocalObject().getParent()).resumeOnCreditControlRequest(ccInfo);
    } else {
        DataSource ds = null;
        try {
            ds = getDatasource();
            if (ccInfo.getRequestedAction() == RequestedActionType.DIRECT_DEBITING) {
                ds.directDebitUnits(ccInfo);
            } else {
                ds.requestUnits(ccInfo);
            }
        } catch (Exception e) {
            tracer.severe("[xx] Unable to obtain Datasource Child SBB", e);
        }
    }
}
Also used : SLEEException(javax.slee.SLEEException) CreateException(javax.slee.CreateException) DiameterChargingServer(org.mobicents.charging.server.DiameterChargingServer) DataSource(org.mobicents.charging.server.data.DataSource)

Aggregations

DiameterChargingServer (org.mobicents.charging.server.DiameterChargingServer)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 NamingException (javax.naming.NamingException)1 CreateException (javax.slee.CreateException)1 SLEEException (javax.slee.SLEEException)1 StartActivityException (javax.slee.resource.StartActivityException)1 HttpClientActivity (net.java.client.slee.resource.http.HttpClientActivity)1 HttpResponse (org.apache.http.HttpResponse)1 DataSource (org.mobicents.charging.server.data.DataSource)1 RatingInfo (org.mobicents.charging.server.ratingengine.RatingInfo)1