Skip to content

Commit

Permalink
Fixing: RestComm#127 - CAP FCI SMS xml serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
vetss committed Jun 10, 2016
1 parent ec420c2 commit d52abc9
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 5 deletions.
Binary file modified cap/CAPMessagesImplemented.ods
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

/**
*
<code>
initiateCallAttempt {PARAMETERS-BOUND : bound} OPERATION ::= {
ARGUMENT InitiateCallAttemptArg {bound}
RESULT InitiateCallAttemptRes {bound}
Expand All @@ -55,6 +56,7 @@
}
CallSegmentID {PARAMETERS-BOUND : bound} ::= INTEGER (1..127)
</code>
*
*
* @author sergey vetyutnev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

/**
*
<code>
furnishChargingInformationSMS {PARAMETERS-BOUND : bound} OPERATION ::= {
ARGUMENT FurnishChargingInformationSMSArg {bound}
RETURN RESULT FALSE ERRORS {
Expand All @@ -42,6 +43,7 @@
-- shall be the result of the BER-encoded value of type - CAMEL-FCISMSBillingChargingCharacteristics {bound}})
-- This parameter indicates the SMS billing and/or charging characteristics.
-- The violation of the UserDefinedConstraint shall be handled as an ASN.1 syntax error.
</code>
*
*
* @author sergey vetyutnev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@

/**
*
fCIBCCCAMELsequence1 [0] SEQUENCE { freeFormatData [0] OCTET STRING (SIZE(1 .. 160)), appendFreeFormatData [1]
* AppendFreeFormatData DEFAULT overwrite } }
<code>
fCIBCCCAMELsequence1 [0] SEQUENCE {
freeFormatData [0] OCTET STRING (SIZE(1 .. 160)),
appendFreeFormatData [1] AppendFreeFormatData DEFAULT overwrite
}
</code>
*
*
* @author sergey vetyutnev
Expand All @@ -40,4 +44,4 @@ public interface FCIBCCCAMELsequence1SMS extends Serializable {
FreeFormatDataSMS getFreeFormatData();

AppendFreeFormatData getAppendFreeFormatData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

/**
*
<code>
freeFormatData [0] OCTET STRING (SIZE(1 .. 160))
</code>
*
* @author Lasith Waruna Perera
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

import java.io.IOException;

import javolution.xml.XMLFormat;
import javolution.xml.stream.XMLStreamException;

import org.mobicents.protocols.asn.AsnException;
import org.mobicents.protocols.asn.AsnInputStream;
import org.mobicents.protocols.asn.AsnOutputStream;
Expand All @@ -41,10 +44,13 @@
/**
*
* @author Lasith Waruna Perera
* @author alerant appngin
*
*/
public class FurnishChargingInformationSMSRequestImpl extends SmsMessageImpl implements FurnishChargingInformationSMSRequest {

private static final String FCI_BCC_CAMEL_SEQUENCE1 = "fCIBCCCAMELsequence1";

public static final String _PrimitiveName = "FurnishChargingInformationSMSRequest";

private FCIBCCCAMELsequence1SMS FCIBCCCAMELsequence1;
Expand Down Expand Up @@ -213,4 +219,29 @@ public String toString() {
return sb.toString();
}

/**
* XML Serialization/Deserialization
*/
protected static final XMLFormat<FurnishChargingInformationSMSRequestImpl> FURNISH_CHARGING_INFORMATION_SMS_REQUEST_XML = new XMLFormat<FurnishChargingInformationSMSRequestImpl>(
FurnishChargingInformationSMSRequestImpl.class) {

@Override
public void read(javolution.xml.XMLFormat.InputElement xml, FurnishChargingInformationSMSRequestImpl fciSmsRequest)
throws XMLStreamException {
CAP_MESSAGE_XML.read(xml, fciSmsRequest);

fciSmsRequest.FCIBCCCAMELsequence1 = xml.get(FCI_BCC_CAMEL_SEQUENCE1, FCIBCCCAMELsequence1SMSImpl.class);
}

@Override
public void write(FurnishChargingInformationSMSRequestImpl fciSmsRequest, javolution.xml.XMLFormat.OutputElement xml)
throws XMLStreamException {

CAP_MESSAGE_XML.write(fciSmsRequest, xml);

if (fciSmsRequest.FCIBCCCAMELsequence1 != null)
xml.add((FCIBCCCAMELsequence1SMSImpl) fciSmsRequest.FCIBCCCAMELsequence1, FCI_BCC_CAMEL_SEQUENCE1,
FCIBCCCAMELsequence1SMSImpl.class);
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

import java.io.IOException;

import javolution.xml.XMLFormat;
import javolution.xml.stream.XMLStreamException;

import org.mobicents.protocols.asn.AsnException;
import org.mobicents.protocols.asn.AsnInputStream;
import org.mobicents.protocols.asn.AsnOutputStream;
Expand All @@ -41,9 +44,12 @@
/**
*
* @author Lasith Waruna Perera
* @author alerant appngin
*
*/
public class FCIBCCCAMELsequence1SMSImpl extends SequenceBase implements FCIBCCCAMELsequence1SMS {
private static final String FREE_FORMAT_DATA = "freeFormatData";
private static final String APPEND_FREE_FORMAT_DATA = "appendFreeFormatData";

public static final int _ID_freeFormatData = 0;
public static final int _ID_appendFreeFormatData = 1;
Expand Down Expand Up @@ -174,4 +180,35 @@ public String toString() {
return sb.toString();
}

/**
* XML Serialization/Deserialization
*/
protected static final XMLFormat<FCIBCCCAMELsequence1SMSImpl> FCI_BCC_CAMEL_SEQUENCE1_SMS_XML = new XMLFormat<FCIBCCCAMELsequence1SMSImpl>(
FCIBCCCAMELsequence1SMSImpl.class) {

@Override
public void read(javolution.xml.XMLFormat.InputElement xml, FCIBCCCAMELsequence1SMSImpl fcibccSms)
throws XMLStreamException {

// default value is overwrite
String vals = xml.getAttribute(APPEND_FREE_FORMAT_DATA, null);
if (vals != null)
fcibccSms.appendFreeFormatData = AppendFreeFormatData.valueOf(vals);

fcibccSms.freeFormatData = xml.get(FREE_FORMAT_DATA, FreeFormatDataSMSImpl.class);
}

@Override
public void write(FCIBCCCAMELsequence1SMSImpl fcibccSms, javolution.xml.XMLFormat.OutputElement xml)
throws XMLStreamException {

if (fcibccSms.appendFreeFormatData != null) {
xml.setAttribute(APPEND_FREE_FORMAT_DATA, fcibccSms.appendFreeFormatData.name());
}

if (fcibccSms.freeFormatData != null) {
xml.add((FreeFormatDataSMSImpl) fcibccSms.freeFormatData, FREE_FORMAT_DATA, FreeFormatDataSMSImpl.class);
}
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,23 @@
*/
package org.mobicents.protocols.ss7.cap.service.sms.primitive;

import javolution.xml.XMLFormat;
import javolution.xml.stream.XMLStreamException;

import org.mobicents.protocols.ss7.cap.api.service.sms.primitive.FreeFormatDataSMS;
import org.mobicents.protocols.ss7.cap.primitives.OctetStringBase;
import org.mobicents.protocols.ss7.isup.impl.message.parameter.ByteArrayContainer;

/**
*
* @author Lasith Waruna Perera
* @author alerant appngin
*
*/
public class FreeFormatDataSMSImpl extends OctetStringBase implements FreeFormatDataSMS {

private static final String DATA = "data";

public FreeFormatDataSMSImpl() {
super(1, 160, "FreeFormatDataSMS");
}
Expand All @@ -43,4 +50,29 @@ public FreeFormatDataSMSImpl(byte[] data) {
public byte[] getData() {
return data;
}

/**
* XML Serialization/Deserialization
*/
protected static final XMLFormat<FreeFormatDataSMSImpl> FREE_FORMAT_DATA_XML = new XMLFormat<FreeFormatDataSMSImpl>(
FreeFormatDataSMSImpl.class) {

@Override
public void read(javolution.xml.XMLFormat.InputElement xml, FreeFormatDataSMSImpl freeFormatDataSMS)
throws XMLStreamException {
ByteArrayContainer bc = xml.get(DATA, ByteArrayContainer.class);
if (bc != null) {
freeFormatDataSMS.data = bc.getData();
}
}

@Override
public void write(FreeFormatDataSMSImpl freeFormatDataSMS, javolution.xml.XMLFormat.OutputElement xml)
throws XMLStreamException {
if (freeFormatDataSMS.data != null) {
ByteArrayContainer bac = new ByteArrayContainer(freeFormatDataSMS.data);
xml.add(bac, DATA, ByteArrayContainer.class);
}
}
};
}

0 comments on commit d52abc9

Please sign in to comment.