org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.ApplyChargingRequestImpl Maven / Gradle / Ivy
/*
* Mobius Software LTD
* Copyright 2019, Mobius Software LTD and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see
*/
package org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall;
import org.restcomm.protocols.ss7.cap.api.CAPMessageType;
import org.restcomm.protocols.ss7.cap.api.CAPOperationCode;
import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.ApplyChargingRequest;
import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.CAMELAChBillingChargingCharacteristics;
import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.CAMELAChBillingChargingCharacteristicsImpl;
import org.restcomm.protocols.ss7.commonapp.api.primitives.AChChargingAddress;
import org.restcomm.protocols.ss7.commonapp.api.primitives.CAPINAPExtensions;
import org.restcomm.protocols.ss7.commonapp.api.primitives.LegType;
import org.restcomm.protocols.ss7.commonapp.primitives.AChChargingAddressImpl;
import org.restcomm.protocols.ss7.commonapp.primitives.AChChargingAddressWrapperImpl;
import org.restcomm.protocols.ss7.commonapp.primitives.CAPINAPExtensionsImpl;
import org.restcomm.protocols.ss7.commonapp.primitives.LegIDImpl;
import org.restcomm.protocols.ss7.commonapp.primitives.SendingLegIDImpl;
import org.restcomm.protocols.ss7.commonapp.primitives.SendingLegIDWrapperImpl;
import com.mobius.software.telco.protocols.ss7.asn.ASNClass;
import com.mobius.software.telco.protocols.ss7.asn.annotations.ASNProperty;
import com.mobius.software.telco.protocols.ss7.asn.annotations.ASNTag;
import com.mobius.software.telco.protocols.ss7.asn.annotations.ASNValidate;
import com.mobius.software.telco.protocols.ss7.asn.exceptions.ASNParsingComponentException;
import com.mobius.software.telco.protocols.ss7.asn.exceptions.ASNParsingComponentExceptionReason;
/**
*
* @author sergey vetyutnev
* @author Amit Bhayani
* @author yulianoifa
*
*/
@ASNTag(asnClass = ASNClass.UNIVERSAL,tag = 16,constructed = true,lengthIndefinite = false)
public class ApplyChargingRequestImpl extends CircuitSwitchedCallMessageImpl implements ApplyChargingRequest {
private static final long serialVersionUID = 1L;
@ASNProperty(asnClass = ASNClass.CONTEXT_SPECIFIC,tag = 0,constructed = false,index = -1,defaultImplementation = CAMELAChBillingChargingCharacteristicsImpl.class)
private CAMELAChBillingChargingCharacteristics aChBillingChargingCharacteristics;
@ASNProperty(asnClass = ASNClass.CONTEXT_SPECIFIC,tag = 2,constructed = true,index = -1)
private SendingLegIDWrapperImpl partyToCharge;
@ASNProperty(asnClass = ASNClass.CONTEXT_SPECIFIC,tag = 3,constructed = true,index = -1,defaultImplementation = CAPINAPExtensionsImpl.class)
private CAPINAPExtensions extensions;
@ASNProperty(asnClass = ASNClass.CONTEXT_SPECIFIC,tag = 50,constructed = true,index = -1)
private AChChargingAddressWrapperImpl aChChargingAddress;
public ApplyChargingRequestImpl() {
}
public ApplyChargingRequestImpl(CAMELAChBillingChargingCharacteristics aChBillingChargingCharacteristics,
LegType partyToCharge, CAPINAPExtensions extensions, AChChargingAddress aChChargingAddress) {
this.aChBillingChargingCharacteristics = aChBillingChargingCharacteristics;
if(partyToCharge!=null)
this.partyToCharge = new SendingLegIDWrapperImpl(new SendingLegIDImpl(partyToCharge));
this.extensions = extensions;
if(aChChargingAddress!=null)
this.aChChargingAddress = new AChChargingAddressWrapperImpl(aChChargingAddress);
}
@Override
public CAPMessageType getMessageType() {
return CAPMessageType.applyCharging_Request;
}
@Override
public int getOperationCode() {
return CAPOperationCode.applyCharging;
}
@Override
public CAMELAChBillingChargingCharacteristics getAChBillingChargingCharacteristics() {
return aChBillingChargingCharacteristics;
}
@Override
public LegType getPartyToCharge() {
if(partyToCharge==null || partyToCharge.getSendingLegID()==null)
return LegType.leg1;
return partyToCharge.getSendingLegID().getSendingSideID();
}
@Override
public CAPINAPExtensions getExtensions() {
return extensions;
}
@Override
public AChChargingAddress getAChChargingAddress() {
if(aChChargingAddress==null)
return new AChChargingAddressImpl(new LegIDImpl(null,LegType.leg1));
return aChChargingAddress.getAChChargingAddress();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ApplyChargingRequestIndication [");
this.addInvokeIdInfo(sb);
if (this.aChBillingChargingCharacteristics != null) {
sb.append(", aChBillingChargingCharacteristics=");
sb.append(aChBillingChargingCharacteristics.toString());
}
if (this.partyToCharge != null && this.partyToCharge.getSendingLegID()!=null) {
sb.append(", partyToCharge=");
sb.append(partyToCharge.getSendingLegID());
}
if (this.extensions != null) {
sb.append(", extensions=");
sb.append(extensions.toString());
}
if (this.aChChargingAddress != null && this.aChChargingAddress.getAChChargingAddress()!=null) {
sb.append(", aChChargingAddress=");
sb.append(aChChargingAddress.getAChChargingAddress());
}
sb.append("]");
return sb.toString();
}
@ASNValidate
public void validateElement() throws ASNParsingComponentException {
if(aChBillingChargingCharacteristics==null)
throw new ASNParsingComponentException("ach billing charging characteristics should be set for apply charging request", ASNParsingComponentExceptionReason.MistypedRootParameter);
}
}