use of javolution.xml.XMLObjectWriter in project smscgateway by RestComm.
the class HttpUsersManagement method store.
/**
* Persist
*/
public void store() {
try {
XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream(persistFile.toString()));
writer.setBinding(binding);
// Enables cross-references.
// writer.setReferenceResolver(new XMLReferenceResolver());
writer.setIndentation(TAB_INDENT);
writer.write(httpUsers, USER_LIST, FastList.class);
writer.close();
} catch (Exception e) {
logger.error("Error while persisting httpUsers state in file", e);
}
}
use of javolution.xml.XMLObjectWriter in project smscgateway by RestComm.
the class NN_DBOper method createRecord_sch2.
public void createRecord_sch2(Sms sms) throws PersistenceException {
PreparedStatementCollection3 psc = getStatementCollection3(sms.getSubmitDate());
long dueSlot = getNextDueSlotForTargetId(psc, sms.getSmsSet().getTargetId());
try {
PreparedStatement ps = psc.createRecordData;
BoundStatement boundStatement = new BoundStatement(ps);
boundStatement.setString(Schema.COLUMN_ADDR_DST_DIGITS, sms.getSmsSet().getDestAddr());
boundStatement.setInt(Schema.COLUMN_ADDR_DST_TON, sms.getSmsSet().getDestAddrTon());
boundStatement.setInt(Schema.COLUMN_ADDR_DST_NPI, sms.getSmsSet().getDestAddrNpi());
boundStatement.setUUID(Schema.COLUMN_ID, sms.getDbId());
boundStatement.setString(Schema.COLUMN_TARGET_ID, sms.getSmsSet().getTargetId());
boundStatement.setLong(Schema.COLUMN_DUE_SLOT, dueSlot);
if (sms.getSourceAddr() != null) {
boundStatement.setString(Schema.COLUMN_ADDR_SRC_DIGITS, sms.getSourceAddr());
}
boundStatement.setLong(Schema.COLUMN_IN_SYSTEM, 0L);
boundStatement.setInt(Schema.COLUMN_ADDR_SRC_TON, sms.getSourceAddrTon());
boundStatement.setInt(Schema.COLUMN_ADDR_SRC_NPI, sms.getSourceAddrNpi());
boundStatement.setInt(Schema.COLUMN_DUE_DELAY, sms.getSmsSet().getDueDelay());
if (sms.getSmsSet().getStatus() != null)
boundStatement.setInt(Schema.COLUMN_SM_STATUS, sms.getSmsSet().getStatus().getCode());
boundStatement.setBool(Schema.COLUMN_ALERTING_SUPPORTED, sms.getSmsSet().isAlertingSupported());
boundStatement.setLong(Schema.COLUMN_MESSAGE_ID, sms.getMessageId());
boundStatement.setInt(Schema.COLUMN_MO_MESSAGE_REF, sms.getMoMessageRef());
if (sms.getOrigEsmeName() != null) {
boundStatement.setString(Schema.COLUMN_ORIG_ESME_NAME, sms.getOrigEsmeName());
}
if (sms.getOrigSystemId() != null) {
boundStatement.setString(Schema.COLUMN_ORIG_SYSTEM_ID, sms.getOrigSystemId());
}
if (sms.getSubmitDate() != null) {
DBOperations.setBoundStatementDate(boundStatement, Schema.COLUMN_SUBMIT_DATE, sms.getSubmitDate());
}
if (sms.getServiceType() != null) {
boundStatement.setString(Schema.COLUMN_SERVICE_TYPE, sms.getServiceType());
}
boundStatement.setInt(Schema.COLUMN_ESM_CLASS, sms.getEsmClass());
boundStatement.setInt(Schema.COLUMN_PROTOCOL_ID, sms.getProtocolId());
boundStatement.setInt(Schema.COLUMN_PRIORITY, sms.getPriority());
boundStatement.setInt(Schema.COLUMN_REGISTERED_DELIVERY, sms.getRegisteredDelivery());
boundStatement.setInt(Schema.COLUMN_REPLACE, sms.getReplaceIfPresent());
boundStatement.setInt(Schema.COLUMN_DATA_CODING, sms.getDataCoding());
boundStatement.setInt(Schema.COLUMN_DEFAULT_MSG_ID, sms.getDefaultMsgId());
if (sms.getShortMessage() != null) {
boundStatement.setBytes(Schema.COLUMN_MESSAGE, ByteBuffer.wrap(sms.getShortMessage()));
}
if (sms.getScheduleDeliveryTime() != null) {
DBOperations.setBoundStatementDate(boundStatement, Schema.COLUMN_SCHEDULE_DELIVERY_TIME, sms.getScheduleDeliveryTime());
}
if (sms.getValidityPeriod() != null) {
DBOperations.setBoundStatementDate(boundStatement, Schema.COLUMN_VALIDITY_PERIOD, sms.getValidityPeriod());
}
boundStatement.setInt(Schema.COLUMN_DELIVERY_COUNT, sms.getDeliveryCount());
if (sms.getTlvSet().getOptionalParameterCount() > 0) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLObjectWriter writer = XMLObjectWriter.newInstance(baos);
writer.setIndentation("\t");
writer.write(sms.getTlvSet(), TLV_SET, TlvSet.class);
writer.close();
byte[] rawData = baos.toByteArray();
String serializedEvent = new String(rawData);
boundStatement.setString(Schema.COLUMN_OPTIONAL_PARAMETERS, serializedEvent);
} catch (XMLStreamException e) {
String msg = "XMLStreamException when serializing optional parameters for '" + sms.getDbId() + "'!";
throw new PersistenceException(msg, e);
}
}
ResultSet res = session.execute(boundStatement);
} catch (Exception e1) {
String msg = "Failed createRecord !";
throw new PersistenceException(msg, e1);
}
}
use of javolution.xml.XMLObjectWriter in project smscgateway by RestComm.
the class SmscPropertiesManagement method store.
/**
* Persist
*/
public void store() {
// everytime?
try {
XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream(persistFile.toString()));
writer.setBinding(binding);
// Enables cross-references.
// writer.setReferenceResolver(new XMLReferenceResolver());
writer.setIndentation(TAB_INDENT);
writer.write(this.serviceCenterGt, SC_GT, String.class);
if (networkIdVsServiceCenterGt.size() > 0) {
ArrayList<ServiceCenterGtNetworkIdElement> al = new ArrayList<ServiceCenterGtNetworkIdElement>();
for (Entry<Integer, String> val : networkIdVsServiceCenterGt.entrySet()) {
ServiceCenterGtNetworkIdElement el = new ServiceCenterGtNetworkIdElement();
el.networkId = val.getKey();
el.serviceCenterGt = val.getValue();
al.add(el);
}
SmscPropertiesManagement_serviceCenterGtNetworkId al2 = new SmscPropertiesManagement_serviceCenterGtNetworkId(al);
writer.write(al2, SC_GT_LIST, SmscPropertiesManagement_serviceCenterGtNetworkId.class);
}
writer.write(this.serviceCenterSsn, SC_SSN, Integer.class);
writer.write(this.hlrSsn, HLR_SSN, Integer.class);
writer.write(this.mscSsn, MSC_SSN, Integer.class);
writer.write(this.maxMapVersion, MAX_MAP_VERSION, Integer.class);
writer.write(this.defaultValidityPeriodHours, DEFAULT_VALIDITY_PERIOD_HOURS, Integer.class);
writer.write(this.maxValidityPeriodHours, MAX_VALIDITY_PERIOD_HOURS, Integer.class);
writer.write(this.defaultTon, DEFAULT_TON, Integer.class);
writer.write(this.defaultNpi, DEFAULT_NPI, Integer.class);
writer.write(this.subscriberBusyDueDelay, SUBSCRIBER_BUSY_DUE_DELAY, Integer.class);
writer.write(this.firstDueDelay, FIRST_DUE_DELAY, Integer.class);
writer.write(this.secondDueDelay, SECOND_DUE_DELAY, Integer.class);
writer.write(this.maxDueDelay, MAX_DUE_DELAY, Integer.class);
writer.write(this.dueDelayMultiplicator, DUE_DELAY_MULTIPLICATOR, Integer.class);
writer.write(this.maxMessageLengthReducer, MAX_MESSAGE_LENGTH_REDUCER, Integer.class);
writer.write(this.dbHosts, DB_HOSTS, String.class);
writer.write(this.dbPort, DB_PORT, Integer.class);
writer.write(this.keyspaceName, KEYSPACE_NAME, String.class);
writer.write(this.clusterName, CLUSTER_NAME, String.class);
writer.write(this.fetchPeriod, FETCH_PERIOD, Long.class);
writer.write(this.fetchMaxRows, FETCH_MAX_ROWS, Integer.class);
writer.write(this.deliveryPause, DELIVERY_PAUSE, Boolean.class);
writer.write(this.removingLiveTablesDays, REMOVING_LIVE_TABLES_DAYS, Integer.class);
writer.write(this.removingArchiveTablesDays, REMOVING_ARCHIVE_TABLES_DAYS, Integer.class);
writer.write(this.hrHlrNumber, HR_HLR_NUMBER, String.class);
if (networkIdVsHrHlrNumber.size() > 0) {
ArrayList<HrHlrNumberNetworkIdElement> al = new ArrayList<HrHlrNumberNetworkIdElement>();
for (Entry<Integer, String> val : networkIdVsHrHlrNumber.entrySet()) {
HrHlrNumberNetworkIdElement el = new HrHlrNumberNetworkIdElement();
el.networkId = val.getKey();
el.hrHlrNumber = val.getValue();
al.add(el);
}
SmscPropertiesManagement_HrHlrNumberNetworkId al2 = new SmscPropertiesManagement_HrHlrNumberNetworkId(al);
writer.write(al2, HR_HLR_NUMBER_LIST, SmscPropertiesManagement_HrHlrNumberNetworkId.class);
}
writer.write(this.hrSriBypass, HR_SRI_BYPASS, Boolean.class);
if (networkIdVsHrSriBypass.size() > 0) {
ArrayList<HrSriBypassNetworkIdElement> al = new ArrayList<HrSriBypassNetworkIdElement>();
for (Entry<Integer, Boolean> val : networkIdVsHrSriBypass.entrySet()) {
HrSriBypassNetworkIdElement el = new HrSriBypassNetworkIdElement();
el.networkId = val.getKey();
el.hrSriBypass = val.getValue();
al.add(el);
}
SmscPropertiesManagement_HrSriBypassNetworkId al2 = new SmscPropertiesManagement_HrSriBypassNetworkId(al);
writer.write(al2, HR_SRI_BYPASS_LIST, SmscPropertiesManagement_HrSriBypassNetworkId.class);
}
writer.write(this.nationalLanguageSingleShift, NATIONAL_LANGUAGE_SINGLE_SHIFT, Integer.class);
writer.write(this.nationalLanguageLockingShift, NATIONAL_LANGUAGE_LOCKING_SHIFT, Integer.class);
writer.write(this.esmeDefaultClusterName, ESME_DEFAULT_CLUSTER_NAME, String.class);
writer.write(this.maxActivityCount, MAX_ACTIVITY_COUNT, Integer.class);
writer.write(this.deliveryTimeout, DELIVERY_TIMEOUT, Integer.class);
writer.write(this.deliveryTimeoutDeltaPerMessage, DELIVERY_TIMEOUT_DELTA_PER_MESSAGE, Integer.class);
writer.write(this.vpProlong, VP_PROLONG, Integer.class);
// writer.write(this.isSMSHomeRouting, SMS_HOME_ROUTING, Boolean.class);
writer.write(this.smppEncodingForGsm7.toString(), SMPP_ENCODING_FOR_GSM7, String.class);
writer.write(this.smppEncodingForUCS2.toString(), SMPP_ENCODING_FOR_UCS2, String.class);
writer.write(this.httpEncodingForGsm7.toString(), HTTP_ENCODING_FOR_GSM7, String.class);
writer.write(this.httpEncodingForUCS2.toString(), HTTP_ENCODING_FOR_UCS2, String.class);
writer.write(this.reviseSecondsOnSmscStart, REVISE_SECONDS_ON_SMSC_START, Integer.class);
writer.write(this.processingSmsSetTimeout, PROCESSING_SMS_SET_TIMEOUT, Integer.class);
writer.write(this.generateReceiptCdr, GENERATE_RECEIPT_CDR, Boolean.class);
writer.write(this.generateDetailedCdr, GENERATE_DETAILED_CDR, Boolean.class);
writer.write(this.generateTempFailureCdr, GENERATE_TEMP_FAILURE_CDR, Boolean.class);
writer.write(this.generateRejectionCdr, GENERATE_REJECTION_CDR, Boolean.class);
writer.write(this.calculateMsgPartsLenCdr, CALCULATE_MSG_PARTS_LEN_CDR, Boolean.class);
writer.write(this.delayParametersInCdr, DELAY_PARAMETERS_IN_CDR, Boolean.class);
writer.write(this.receiptsDisabling, RECEIPTS_DISABLING, Boolean.class);
writer.write(this.incomeReceiptsProcessing, INCOME_RECEIPTS_PROCESSING, Boolean.class);
writer.write(this.enableIntermediateReceipts, ENABLE_INTERMEDIATE_RECEIPTS, Boolean.class);
writer.write(this.origNetworkIdForReceipts, ORIG_NETWORK_ID_FOR_RECEIPTS, Boolean.class);
writer.write(this.moDefaultMessagingMode, MO_DEFAULT_MESSAGING_MODE, Integer.class);
writer.write(this.hrDefaultMessagingMode, HR_DEFAULT_MESSAGING_MODE, Integer.class);
writer.write(this.sipDefaultMessagingMode, SIP_DEFAULT_MESSAGING_MODE, Integer.class);
writer.write(this.generateCdr.getValue(), GENERATE_CDR, Integer.class);
writer.write(this.generateArchiveTable.getValue(), GENERATE_ARCHIVE_TABLE, Integer.class);
writer.write(this.storeAndForwordMode.toString(), STORE_AND_FORWORD_MODE, String.class);
writer.write(this.minMessageId, MIN_MESSAGE_ID, Long.class);
writer.write(this.maxMessageId, MAX_MESSAGE_ID, Long.class);
writer.write(this.moCharging.toString(), MO_CHARGING, String.class);
writer.write(this.hrCharging.toString(), HR_CHARGING, String.class);
writer.write(this.txSmppCharging.toString(), TX_SMPP_CHARGING, String.class);
writer.write(this.txSipCharging.toString(), TX_SIP_CHARGING, String.class);
writer.write(this.txHttpCharging.toString(), TX_HTTP_CHARGING, String.class);
writer.write(this.globalTitleIndicator.toString(), GLOBAL_TITLE_INDICATOR, String.class);
writer.write(this.translationType, TRANSLATION_TYPE, Integer.class);
writer.write(this.correlationIdLiveTime, CORRELATION_ID_LIVE_TIME, Integer.class);
writer.write(this.sriResponseLiveTime, SRI_RESPONSE_LIVE_TIME, Integer.class);
writer.write(this.httpDefaultSourceTon, HTTP_DEFAULT_SOURCE_TON, Integer.class);
writer.write(this.httpDefaultSourceNpi, HTTP_DEFAULT_SOURCE_NPI, Integer.class);
writer.write(this.httpDefaultDestTon, HTTP_DEFAULT_DEST_TON, Integer.class);
writer.write(this.httpDefaultDestNpi, HTTP_DEFAULT_DEST_NPI, Integer.class);
writer.write(this.httpDefaultNetworkId, HTTP_DEFAULT_NETWORK_ID, Integer.class);
writer.write(this.httpDefaultMessagingMode, HTTP_DEFAULT_MESSAGING_MODE, Integer.class);
writer.write(this.httpDefaultRDDeliveryReceipt, HTTP_DEFAULT_RD_DELIVERY_RECEIPT, Integer.class);
writer.write(this.httpDefaultRDIntermediateNotification, HTTP_DEFAULT_RD_INTERMEDIATE_NOTIFICATION, Integer.class);
writer.write(this.httpDefaultDataCoding, HTTP_DEFAULT_DATA_CODING, Integer.class);
writer.write(this.cassandraUser, CASSANDRA_USER, String.class);
writer.write(this.cassandraPass, CASSANDRA_PASS, String.class);
if (smDeliveryFailure.size() > 0) {
ArrayList<SmDeliveryFailureListElement> al = new ArrayList<SmDeliveryFailureListElement>();
for (Entry<Integer, PermanentTemporaryFailure> val : smDeliveryFailure.entrySet()) {
SmDeliveryFailureListElement el = new SmDeliveryFailureListElement();
el.causeCode = val.getKey();
el.status = val.getValue();
al.add(el);
}
SmscPropertiesManagement_smDeliveryFailure al2 = new SmscPropertiesManagement_smDeliveryFailure(al);
writer.write(al2, SM_DELIVERY_FAILURE_LIST, SmscPropertiesManagement_smDeliveryFailure.class);
}
if (smDeliveryFailureTpFailureCause.size() > 0) {
ArrayList<SmDeliveryFailureTpFailureCauseListElement> al = new ArrayList<SmDeliveryFailureTpFailureCauseListElement>();
for (Entry<Integer, PermanentTemporaryFailure> val : smDeliveryFailureTpFailureCause.entrySet()) {
SmDeliveryFailureTpFailureCauseListElement el = new SmDeliveryFailureTpFailureCauseListElement();
el.causeCode = val.getKey();
el.status = val.getValue();
al.add(el);
}
SmscPropertiesManagement_smDeliveryFailureTpFailureCause al2 = new SmscPropertiesManagement_smDeliveryFailureTpFailureCause(al);
writer.write(al2, SM_DELIVERY_FAILURE_TP_FAILURE_CAUSE_LIST, SmscPropertiesManagement_smDeliveryFailureTpFailureCause.class);
}
writer.write(this.smDeliveryFailureDlrWithTpdu, SM_DELIVERY_FAILURE_WITH_TPDU, String.class);
writer.write(this.diameterDestRealm, DIAMETER_DEST_REALM, String.class);
writer.write(this.diameterDestHost, DIAMETER_DEST_HOST, String.class);
writer.write(this.diameterDestPort, DIAMETER_DEST_PORT, Integer.class);
writer.write(this.diameterUserName, DIAMETER_USER_NAME, String.class);
writer.close();
} catch (Exception e) {
logger.error("Error while persisting the SMSC state in file", e);
}
}
use of javolution.xml.XMLObjectWriter 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.XMLObjectWriter in project smscgateway by RestComm.
the class HomeRoutingManagement method storeCorrId.
public void storeCorrId() {
try {
XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream(persistFileCorrId.toString()));
writer.setBinding(binding);
writer.setIndentation(TAB_INDENT);
writer.write(correlationId, CC_CORR_ID, Long.class);
writer.close();
} catch (Exception e) {
logger.error("Error while persisting the home routing corrId value in file", e);
}
loadedCorrelationId = correlationId;
}
Aggregations