use of javolution.xml.XMLObjectReader in project smscgateway by RestComm.
the class Sms method setExtraData.
public void setExtraData(String extraData) {
if (extraData == null || extraData.length() == 0) {
this.extraData.clear();
} else {
// deserializing of extraData
try {
StringReader sr = new StringReader(extraData);
XMLObjectReader reader = XMLObjectReader.newInstance(sr);
SmsExtraData copy = reader.read("extraData", SmsExtraData.class);
if (copy != null) {
this.extraData = copy;
}
} catch (XMLStreamException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
use of javolution.xml.XMLObjectReader in project smscgateway by RestComm.
the class HomeRoutingManagement method load.
public synchronized void load() {
// if (ccMccmncCollection != null && ccMccmnsTableVersionLoaded == ccMccmnsTableVersionActual)
// return;
ccMccmncCollection = new CcMccmncCollection();
XMLObjectReader reader = null;
try {
FileInputStream fis = new FileInputStream(persistFile.toString());
try {
System.out.println("fis.available():" + fis.available());
} catch (IOException e) {
e.printStackTrace();
}
reader = XMLObjectReader.newInstance(fis);
try {
reader.setBinding(binding);
ccMccmncCollection = reader.read(CC_MCCMNS_COLLECTION, CcMccmncCollection.class);
logger.info("Successfully loaded CcMccmnsCollection: " + persistFile);
} finally {
reader.close();
}
} catch (FileNotFoundException ex) {
logger.warn("CcMccmnsCollection: file not found: " + persistFile.toString());
try {
this.store();
} catch (Exception e) {
}
} catch (XMLStreamException ex) {
logger.error("Error while loading CcMccmnsCollection from file" + persistFile.toString(), ex);
}
// ccMccmnsTableVersionLoaded = ccMccmnsTableVersionActual;
}
use of javolution.xml.XMLObjectReader in project smscgateway by RestComm.
the class SmscPropertiesManagement method load.
/**
* Load and create LinkSets and Link from persisted file
*
* @throws Exception
*/
public void load() throws FileNotFoundException {
XMLObjectReader reader = null;
try {
reader = XMLObjectReader.newInstance(new FileInputStream(persistFile.toString()));
reader.setBinding(binding);
this.serviceCenterGt = reader.read(SC_GT, String.class);
SmscPropertiesManagement_serviceCenterGtNetworkId al = reader.read(SC_GT_LIST, SmscPropertiesManagement_serviceCenterGtNetworkId.class);
networkIdVsServiceCenterGt.clear();
if (al != null) {
for (ServiceCenterGtNetworkIdElement elem : al.getData()) {
networkIdVsServiceCenterGt.put(elem.networkId, elem.serviceCenterGt);
}
}
this.serviceCenterSsn = reader.read(SC_SSN, Integer.class);
this.hlrSsn = reader.read(HLR_SSN, Integer.class);
this.mscSsn = reader.read(MSC_SSN, Integer.class);
this.maxMapVersion = reader.read(MAX_MAP_VERSION, Integer.class);
Integer dvp = reader.read(DEFAULT_VALIDITY_PERIOD_HOURS, Integer.class);
if (dvp != null)
this.defaultValidityPeriodHours = dvp;
Integer mvp = reader.read(MAX_VALIDITY_PERIOD_HOURS, Integer.class);
if (mvp != null)
this.maxValidityPeriodHours = mvp;
Integer dTon = reader.read(DEFAULT_TON, Integer.class);
if (dTon != null)
this.defaultTon = dTon;
Integer dNpi = reader.read(DEFAULT_NPI, Integer.class);
if (dNpi != null)
this.defaultNpi = dNpi;
Integer val = reader.read(SUBSCRIBER_BUSY_DUE_DELAY, Integer.class);
if (val != null)
this.subscriberBusyDueDelay = val;
val = reader.read(FIRST_DUE_DELAY, Integer.class);
if (val != null)
this.firstDueDelay = val;
val = reader.read(SECOND_DUE_DELAY, Integer.class);
if (val != null)
this.secondDueDelay = val;
val = reader.read(MAX_DUE_DELAY, Integer.class);
if (val != null)
this.maxDueDelay = val;
val = reader.read(DUE_DELAY_MULTIPLICATOR, Integer.class);
if (val != null)
this.dueDelayMultiplicator = val;
val = reader.read(MAX_MESSAGE_LENGTH_REDUCER, Integer.class);
if (val != null)
this.maxMessageLengthReducer = val;
// for backup compatibility
String vals = reader.read(HOSTS, String.class);
if (vals != null) {
String[] hostsArr = vals.split(":");
if (hostsArr.length == 2) {
this.dbHosts = hostsArr[0];
this.dbPort = Integer.parseInt(hostsArr[1]);
}
}
vals = reader.read(DB_HOSTS, String.class);
if (vals != null)
this.dbHosts = vals;
val = reader.read(DB_PORT, Integer.class);
if (val != null)
this.dbPort = val;
this.keyspaceName = reader.read(KEYSPACE_NAME, String.class);
this.clusterName = reader.read(CLUSTER_NAME, String.class);
Long vall = reader.read(FETCH_PERIOD, Long.class);
if (vall != null)
this.fetchPeriod = vall;
val = reader.read(FETCH_MAX_ROWS, Integer.class);
if (val != null)
this.fetchMaxRows = val;
Boolean valB = reader.read(DELIVERY_PAUSE, Boolean.class);
if (valB != null) {
this.deliveryPause = valB.booleanValue();
}
val = reader.read(REMOVING_LIVE_TABLES_DAYS, Integer.class);
if (val != null)
this.removingLiveTablesDays = val;
val = reader.read(REMOVING_ARCHIVE_TABLES_DAYS, Integer.class);
if (val != null)
this.removingArchiveTablesDays = val;
vals = reader.read(MO_UNKNOWN_TYPE_OF_NUMBER_PREFIX, String.class);
vals = reader.read(HR_HLR_NUMBER, String.class);
if (vals != null)
this.hrHlrNumber = vals;
SmscPropertiesManagement_HrHlrNumberNetworkId al2 = reader.read(HR_HLR_NUMBER_LIST, SmscPropertiesManagement_HrHlrNumberNetworkId.class);
networkIdVsHrHlrNumber.clear();
if (al2 != null) {
for (HrHlrNumberNetworkIdElement elem : al2.getData()) {
networkIdVsHrHlrNumber.put(elem.networkId, elem.hrHlrNumber);
}
}
valB = reader.read(HR_SRI_BYPASS, Boolean.class);
if (valB != null)
this.hrSriBypass = valB;
SmscPropertiesManagement_HrSriBypassNetworkId al3 = reader.read(HR_SRI_BYPASS_LIST, SmscPropertiesManagement_HrSriBypassNetworkId.class);
networkIdVsHrSriBypass.clear();
if (al3 != null) {
for (HrSriBypassNetworkIdElement elem : al3.getData()) {
networkIdVsHrSriBypass.put(elem.networkId, elem.hrSriBypass);
}
}
val = reader.read(NATIONAL_LANGUAGE_SINGLE_SHIFT, Integer.class);
if (val != null)
this.nationalLanguageSingleShift = val;
val = reader.read(NATIONAL_LANGUAGE_LOCKING_SHIFT, Integer.class);
if (val != null)
this.nationalLanguageLockingShift = val;
this.esmeDefaultClusterName = reader.read(ESME_DEFAULT_CLUSTER_NAME, String.class);
val = reader.read(MAX_ACTIVITY_COUNT, Integer.class);
if (val != null)
this.maxActivityCount = val;
val = reader.read(DELIVERY_TIMEOUT, Integer.class);
if (val != null)
this.deliveryTimeout = val;
val = reader.read(DELIVERY_TIMEOUT_DELTA_PER_MESSAGE, Integer.class);
if (val != null)
this.deliveryTimeoutDeltaPerMessage = val;
val = reader.read(VP_PROLONG, Integer.class);
if (val != null)
this.vpProlong = val;
// this line is for backward compatibility
valB = reader.read(SMS_HOME_ROUTING, Boolean.class);
// if (valB != null) {
// this.isSMSHomeRouting = valB.booleanValue();
// }
vals = reader.read(SMPP_ENCODING_FOR_GSM7, String.class);
if (vals != null)
this.smppEncodingForGsm7 = Enum.valueOf(SmppEncoding.class, vals);
vals = reader.read(SMPP_ENCODING_FOR_UCS2, String.class);
if (vals != null)
this.httpEncodingForUCS2 = Enum.valueOf(HttpEncoding.class, vals);
vals = reader.read(HTTP_ENCODING_FOR_GSM7, String.class);
if (vals != null)
this.httpEncodingForGsm7 = Enum.valueOf(HttpEncoding.class, vals);
vals = reader.read(HTTP_ENCODING_FOR_UCS2, String.class);
if (vals != null)
this.smppEncodingForUCS2 = Enum.valueOf(SmppEncoding.class, vals);
val = reader.read(REVISE_SECONDS_ON_SMSC_START, Integer.class);
if (val != null)
this.reviseSecondsOnSmscStart = val;
val = reader.read(PROCESSING_SMS_SET_TIMEOUT, Integer.class);
if (val != null)
this.processingSmsSetTimeout = val;
valB = reader.read(GENERATE_RECEIPT_CDR, Boolean.class);
if (valB != null) {
this.generateReceiptCdr = valB.booleanValue();
}
valB = reader.read(GENERATE_DETAILED_CDR, Boolean.class);
if (valB != null) {
this.generateDetailedCdr = valB.booleanValue();
}
valB = reader.read(GENERATE_TEMP_FAILURE_CDR, Boolean.class);
if (valB != null) {
this.generateTempFailureCdr = valB.booleanValue();
}
valB = reader.read(GENERATE_REJECTION_CDR, Boolean.class);
if (valB != null) {
this.generateRejectionCdr = valB.booleanValue();
}
valB = reader.read(CALCULATE_MSG_PARTS_LEN_CDR, Boolean.class);
if (valB != null) {
this.calculateMsgPartsLenCdr = valB.booleanValue();
}
valB = reader.read(DELAY_PARAMETERS_IN_CDR, Boolean.class);
if (valB != null) {
this.delayParametersInCdr = valB.booleanValue();
}
valB = reader.read(DELAY_PARAMETERS_IN_CDR, Boolean.class);
if (valB != null) {
this.delayParametersInCdr = valB.booleanValue();
}
valB = reader.read(RECEIPTS_DISABLING, Boolean.class);
if (valB != null) {
this.receiptsDisabling = valB.booleanValue();
}
valB = reader.read(INCOME_RECEIPTS_PROCESSING, Boolean.class);
if (valB != null) {
this.incomeReceiptsProcessing = valB.booleanValue();
}
valB = reader.read(ENABLE_INTERMEDIATE_RECEIPTS, Boolean.class);
if (valB != null) {
this.enableIntermediateReceipts = valB.booleanValue();
}
valB = reader.read(ORIG_NETWORK_ID_FOR_RECEIPTS, Boolean.class);
if (valB != null) {
this.origNetworkIdForReceipts = valB.booleanValue();
}
val = reader.read(MO_DEFAULT_MESSAGING_MODE, Integer.class);
if (val != null)
this.moDefaultMessagingMode = val;
val = reader.read(HR_DEFAULT_MESSAGING_MODE, Integer.class);
if (val != null)
this.hrDefaultMessagingMode = val;
val = reader.read(SIP_DEFAULT_MESSAGING_MODE, Integer.class);
if (val != null)
this.sipDefaultMessagingMode = val;
val = reader.read(GENERATE_CDR, Integer.class);
if (val != null)
this.generateCdr = new GenerateType(val);
val = reader.read(GENERATE_ARCHIVE_TABLE, Integer.class);
if (val != null)
this.generateArchiveTable = new GenerateType(val);
vals = reader.read(STORE_AND_FORWORD_MODE, String.class);
if (vals != null)
this.storeAndForwordMode = Enum.valueOf(StoreAndForwordMode.class, vals);
vall = reader.read(MIN_MESSAGE_ID, Long.class);
if (vall != null)
this.minMessageId = vall;
vall = reader.read(MAX_MESSAGE_ID, Long.class);
if (vall != null)
this.maxMessageId = vall;
vals = reader.read(MO_CHARGING, String.class);
if (vals != null) {
if (vals.toLowerCase().equals("false")) {
this.moCharging = MoChargingType.accept;
} else if (vals.toLowerCase().equals("true")) {
this.moCharging = MoChargingType.diameter;
} else {
this.moCharging = Enum.valueOf(MoChargingType.class, vals);
}
}
vals = reader.read(HR_CHARGING, String.class);
if (vals != null) {
if (vals.toLowerCase().equals("false")) {
this.hrCharging = MoChargingType.accept;
} else if (vals.toLowerCase().equals("true")) {
this.hrCharging = MoChargingType.diameter;
} else {
this.hrCharging = Enum.valueOf(MoChargingType.class, vals);
}
}
vals = reader.read(TX_SMPP_CHARGING, String.class);
if (vals != null)
this.txSmppCharging = Enum.valueOf(ChargingType.class, vals);
vals = reader.read(TX_SIP_CHARGING, String.class);
if (vals != null)
this.txSipCharging = Enum.valueOf(ChargingType.class, vals);
vals = reader.read(TX_HTTP_CHARGING, String.class);
if (vals != null) {
if (vals.toLowerCase().equals("false")) {
this.txHttpCharging = MoChargingType.accept;
} else if (vals.toLowerCase().equals("true")) {
this.txHttpCharging = MoChargingType.diameter;
} else {
this.txHttpCharging = Enum.valueOf(MoChargingType.class, vals);
}
}
vals = reader.read(GLOBAL_TITLE_INDICATOR, String.class);
if (vals != null)
this.globalTitleIndicator = Enum.valueOf(GlobalTitleIndicator.class, vals);
val = reader.read(TRANSLATION_TYPE, Integer.class);
if (val != null)
this.translationType = val;
val = reader.read(CORRELATION_ID_LIVE_TIME, Integer.class);
if (val != null)
this.correlationIdLiveTime = val;
val = reader.read(SRI_RESPONSE_LIVE_TIME, Integer.class);
if (val != null)
this.sriResponseLiveTime = val;
val = reader.read(HTTP_DEFAULT_SOURCE_TON, Integer.class);
if (val != null)
this.httpDefaultSourceTon = val;
val = reader.read(HTTP_DEFAULT_SOURCE_NPI, Integer.class);
if (val != null)
this.httpDefaultSourceNpi = val;
val = reader.read(HTTP_DEFAULT_DEST_TON, Integer.class);
if (val != null)
this.httpDefaultDestTon = val;
val = reader.read(HTTP_DEFAULT_DEST_NPI, Integer.class);
if (val != null)
this.httpDefaultDestNpi = val;
val = reader.read(HTTP_DEFAULT_NETWORK_ID, Integer.class);
if (val != null)
this.httpDefaultNetworkId = val;
val = reader.read(HTTP_DEFAULT_MESSAGING_MODE, Integer.class);
if (val != null)
this.httpDefaultMessagingMode = val;
val = reader.read(HTTP_DEFAULT_RD_DELIVERY_RECEIPT, Integer.class);
if (val != null)
this.httpDefaultRDDeliveryReceipt = val;
val = reader.read(HTTP_DEFAULT_RD_INTERMEDIATE_NOTIFICATION, Integer.class);
if (val != null)
this.httpDefaultRDIntermediateNotification = val;
val = reader.read(HTTP_DEFAULT_DATA_CODING, Integer.class);
if (val != null)
this.httpDefaultDataCoding = val;
vals = reader.read(CASSANDRA_USER, String.class);
if (vals != null)
this.cassandraUser = vals;
vals = reader.read(CASSANDRA_PASS, String.class);
if (vals != null)
this.cassandraPass = vals;
SmscPropertiesManagement_smDeliveryFailure al4 = reader.read(SM_DELIVERY_FAILURE_LIST, SmscPropertiesManagement_smDeliveryFailure.class);
smDeliveryFailure.clear();
if (al4 != null) {
for (SmDeliveryFailureListElement elem : al4.getData()) {
smDeliveryFailure.put(elem.causeCode, elem.status);
}
}
SmscPropertiesManagement_smDeliveryFailureTpFailureCause al5 = reader.read(SM_DELIVERY_FAILURE_TP_FAILURE_CAUSE_LIST, SmscPropertiesManagement_smDeliveryFailureTpFailureCause.class);
smDeliveryFailureTpFailureCause.clear();
if (al5 != null) {
for (SmDeliveryFailureTpFailureCauseListElement elem : al5.getData()) {
smDeliveryFailureTpFailureCause.put(elem.causeCode, elem.status);
}
}
vals = reader.read(SM_DELIVERY_FAILURE_WITH_TPDU, String.class);
if (vals != null)
this.smDeliveryFailureDlrWithTpdu = vals;
this.diameterDestRealm = reader.read(DIAMETER_DEST_REALM, String.class);
this.diameterDestHost = reader.read(DIAMETER_DEST_HOST, String.class);
val = reader.read(DIAMETER_DEST_PORT, Integer.class);
if (val != null)
this.diameterDestPort = val;
this.diameterUserName = reader.read(DIAMETER_USER_NAME, String.class);
reader.close();
} catch (XMLStreamException ex) {
logger.error("Error while loading the SMSC state from file", ex);
}
}
use of javolution.xml.XMLObjectReader in project smscgateway by RestComm.
the class HomeRoutingManagementTest method testSerialition.
// @org.junit.Test
// public void testXMLParse() throws Exception {
//
// try {
//
// XMLBinding binding = new XMLBinding();
// binding.setClassAttribute("type");
//
// String fileLocation = "/home/anatolysatanovskiy/telestax/smsc-compatibility/restcomm-smsc-7.4.0-SNAPSHOT/wildfly-10.1.0.Final/standalone/data/SmscManagement_cc_mccmnc.xml";
// XMLObjectReader reader = XMLObjectReader.newInstance(new FileInputStream(fileLocation));
// reader.setBinding(binding);
//
// CcMccmncCollection actual = reader.read("CcMccmncCollection", CcMccmncCollection.class);
// org.junit.Assert.assertNotNull(actual);
//
// } catch (Exception e) {
// e.printStackTrace();
// org.junit.Assert.fail();
// }
//
// }
@Test(groups = { "HomeRoutingManagement" })
public void testSerialition() throws Exception {
CcMccmncCollection original = new CcMccmncCollection();
original.addCcMccmnc(new CcMccmncImpl("", "555", ""));
original.addCcMccmnc(new CcMccmncImpl("11111", "222", "00001"));
original.addCcMccmnc(new CcMccmncImpl("3333", "444", null));
// Writes the area to a file.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLObjectWriter writer = XMLObjectWriter.newInstance(baos);
writer.setIndentation("\t");
writer.write(original, "CcMccmnsCollection", CcMccmncCollection.class);
writer.close();
byte[] rawData = baos.toByteArray();
String serializedEvent = new String(rawData);
System.out.println(serializedEvent);
ByteArrayInputStream bais = new ByteArrayInputStream(rawData);
XMLObjectReader reader = XMLObjectReader.newInstance(bais);
CcMccmncCollection copy = reader.read("CcMccmnsCollection", CcMccmncCollection.class);
Map<String, CcMccmncImpl> arr = copy.getCcMccmncMap();
assertEquals(arr.size(), 3);
int i1 = 0;
for (CcMccmncImpl el : arr.values()) {
switch(i1) {
case 0:
assertEquals(el.getCountryCode(), "11111");
assertEquals(el.getMccMnc(), "222");
assertEquals(el.getSmsc(), "00001");
break;
case 1:
assertNull(el.getSmsc());
break;
case 2:
assertEquals(el.getSmsc(), "");
break;
}
i1++;
}
}
use of javolution.xml.XMLObjectReader in project smscgateway by RestComm.
the class MProcManagement method load.
public void load() throws FileNotFoundException {
XMLObjectReader reader = null;
try {
reader = XMLObjectReader.newInstance(new FileInputStream(persistFile.toString()));
reader.setBinding(binding);
this.mprocs = reader.read(MPROC_LIST, FastList.class);
reader.close();
} catch (XMLStreamException ex) {
logger.info("Error while re-creating MProcRule from persisted file", ex);
}
}
Aggregations