Search in sources :

Example 6 with XMLStreamException

use of javolution.xml.stream.XMLStreamException in project smscgateway by RestComm.

the class DBOperations method setSmsFields.

private void setSmsFields(Sms sms, long dueSlot, BoundStatement boundStatement, boolean archive, boolean shortMessageNewStringFormat, boolean addedCorrId, boolean addedNetworkId, boolean addedOrigNetworkId, boolean addedPacket1) throws PersistenceException {
    boundStatement.setUUID(Schema.COLUMN_ID, sms.getDbId());
    boundStatement.setString(Schema.COLUMN_TARGET_ID, sms.getSmsSet().getTargetId());
    if (addedNetworkId) {
        boundStatement.setInt(Schema.COLUMN_NETWORK_ID, sms.getSmsSet().getNetworkId());
    }
    boundStatement.setLong(Schema.COLUMN_DUE_SLOT, dueSlot);
    boundStatement.setInt(Schema.COLUMN_IN_SYSTEM, IN_SYSTEM_UNSENT);
    boundStatement.setUUID(Schema.COLUMN_SMSC_UUID, emptyUuid);
    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());
    if (sms.getSourceAddr() != null) {
        boundStatement.setString(Schema.COLUMN_ADDR_SRC_DIGITS, sms.getSourceAddr());
    } else {
        boundStatement.setToNull(Schema.COLUMN_ADDR_SRC_DIGITS);
    }
    boundStatement.setInt(Schema.COLUMN_ADDR_SRC_TON, sms.getSourceAddrTon());
    boundStatement.setInt(Schema.COLUMN_ADDR_SRC_NPI, sms.getSourceAddrNpi());
    if (addedOrigNetworkId) {
        boundStatement.setInt(Schema.COLUMN_ORIG_NETWORK_ID, sms.getOrigNetworkId());
    }
    boundStatement.setInt(Schema.COLUMN_DUE_DELAY, sms.getSmsSet().getDueDelay());
    if (sms.getSmsSet().getStatus() != null)
        boundStatement.setInt(Schema.COLUMN_SM_STATUS, sms.getSmsSet().getStatus().getCode());
    else
        boundStatement.setToNull(Schema.COLUMN_SM_STATUS);
    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());
    } else
        boundStatement.setToNull(Schema.COLUMN_ORIG_ESME_NAME);
    if (sms.getOrigSystemId() != null) {
        boundStatement.setString(Schema.COLUMN_ORIG_SYSTEM_ID, sms.getOrigSystemId());
    } else
        boundStatement.setToNull(Schema.COLUMN_ORIG_SYSTEM_ID);
    if (sms.getSubmitDate() != null) {
        setBoundStatementDate(boundStatement, Schema.COLUMN_SUBMIT_DATE, sms.getSubmitDate());
    } else
        boundStatement.setToNull(Schema.COLUMN_SUBMIT_DATE);
    if (sms.getDeliverDate() != null) {
        setBoundStatementDate(boundStatement, Schema.COLUMN_DELIVERY_DATE, sms.getDeliverDate());
    } else
        boundStatement.setToNull(Schema.COLUMN_DELIVERY_DATE);
    if (sms.getServiceType() != null) {
        boundStatement.setString(Schema.COLUMN_SERVICE_TYPE, sms.getServiceType());
    } else
        boundStatement.setToNull(Schema.COLUMN_SERVICE_TYPE);
    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.getDataCodingForDatabase());
    boundStatement.setInt(Schema.COLUMN_DEFAULT_MSG_ID, sms.getDefaultMsgId());
    if (shortMessageNewStringFormat) {
        if (sms.getShortMessageText() != null) {
            boundStatement.setString(Schema.COLUMN_MESSAGE_TEXT, sms.getShortMessageText());
        } else
            boundStatement.setToNull(Schema.COLUMN_MESSAGE_TEXT);
        if (sms.getShortMessageBin() != null) {
            boundStatement.setBytes(Schema.COLUMN_MESSAGE_BIN, ByteBuffer.wrap(sms.getShortMessageBin()));
        } else
            boundStatement.setToNull(Schema.COLUMN_MESSAGE_BIN);
        boundStatement.setToNull(Schema.COLUMN_MESSAGE);
    } else {
        // convert to an old format
        String msg = sms.getShortMessageText();
        byte[] udhData = sms.getShortMessageBin();
        byte[] textPart = null;
        DataCodingScheme dcs = new DataCodingSchemeImpl(sms.getDataCoding());
        switch(dcs.getCharacterSet()) {
            case GSM7:
                textPart = msg.getBytes();
                break;
            case UCS2:
                Charset ucs2Charset = Charset.forName("UTF-16BE");
                ByteBuffer bb = ucs2Charset.encode(msg);
                textPart = new byte[bb.limit()];
                bb.get(textPart);
                break;
            default:
                // we do not support this yet
                break;
        }
        byte[] data;
        if (textPart != null) {
            if (udhData != null) {
                data = new byte[textPart.length + udhData.length];
                System.arraycopy(udhData, 0, data, 0, udhData.length);
                System.arraycopy(textPart, 0, data, udhData.length, textPart.length);
            } else {
                data = textPart;
            }
        } else {
            if (udhData != null) {
                data = udhData;
            } else {
                data = new byte[0];
            }
        }
        boundStatement.setBytes(Schema.COLUMN_MESSAGE, ByteBuffer.wrap(data));
    }
    if (sms.getScheduleDeliveryTime() != null) {
        setBoundStatementDate(boundStatement, Schema.COLUMN_SCHEDULE_DELIVERY_TIME, sms.getScheduleDeliveryTime());
    } else
        boundStatement.setToNull(Schema.COLUMN_SCHEDULE_DELIVERY_TIME);
    if (sms.getValidityPeriod() != null) {
        setBoundStatementDate(boundStatement, Schema.COLUMN_VALIDITY_PERIOD, sms.getValidityPeriod());
    } else
        boundStatement.setToNull(Schema.COLUMN_VALIDITY_PERIOD);
    boundStatement.setInt(Schema.COLUMN_DELIVERY_COUNT, sms.getDeliveryCount());
    if (addedPacket1) {
        if (sms.getOriginatorSccpAddress() != null) {
            boundStatement.setString(Schema.COLUMN_ORIGINATOR_SCCP_ADDRESS, sms.getOriginatorSccpAddress());
        } else
            boundStatement.setToNull(Schema.COLUMN_ORIGINATOR_SCCP_ADDRESS);
        // TODO: extra columns for further usage
        boundStatement.setBool(Schema.COLUMN_STATUS_REPORT_REQUEST, sms.isStatusReportRequest());
        boundStatement.setInt(Schema.COLUMN_DELIVERY_ATTEMPT, sms.getDeliveryAttempt());
        if (sms.getUserData() != null) {
            boundStatement.setString(Schema.COLUMN_USER_DATA, sms.getUserData());
        } else
            boundStatement.setToNull(Schema.COLUMN_USER_DATA);
        String extraData = sms.getExtraData();
        if (extraData != null) {
            boundStatement.setString(Schema.COLUMN_EXTRA_DATA, extraData);
        } else
            boundStatement.setToNull(Schema.COLUMN_EXTRA_DATA);
        if (sms.getExtraData_2() != null) {
            boundStatement.setString(Schema.COLUMN_EXTRA_DATA_2, sms.getExtraData_2());
        } else
            boundStatement.setToNull(Schema.COLUMN_EXTRA_DATA_2);
        if (sms.getExtraData_3() != null) {
            boundStatement.setString(Schema.COLUMN_EXTRA_DATA_3, sms.getExtraData_3());
        } else
            boundStatement.setToNull(Schema.COLUMN_EXTRA_DATA_3);
        if (sms.getExtraData_4() != null) {
            boundStatement.setString(Schema.COLUMN_EXTRA_DATA_4, sms.getExtraData_4());
        } else
            boundStatement.setToNull(Schema.COLUMN_EXTRA_DATA_4);
    }
    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);
        }
    } else {
        boundStatement.setToNull(Schema.COLUMN_OPTIONAL_PARAMETERS);
    }
    if (!archive) {
        if (addedCorrId) {
            boundStatement.setToNull(Schema.COLUMN_CORR_ID);
        }
        boundStatement.setToNull(Schema.COLUMN_IMSI);
        if (sms.getSmsSet().getCorrelationId() != null) {
            if (addedCorrId) {
                boundStatement.setString(Schema.COLUMN_CORR_ID, sms.getSmsSet().getCorrelationId());
            } else {
                boundStatement.setString(Schema.COLUMN_IMSI, sms.getSmsSet().getCorrelationId());
            }
        }
    } else {
        if (sms.getSmsSet().getLocationInfoWithLMSI() != null && sms.getSmsSet().getLocationInfoWithLMSI().getNetworkNodeNumber() != null) {
            boundStatement.setString(Schema.COLUMN_NNN_DIGITS, sms.getSmsSet().getLocationInfoWithLMSI().getNetworkNodeNumber().getAddress());
            boundStatement.setInt(Schema.COLUMN_NNN_AN, sms.getSmsSet().getLocationInfoWithLMSI().getNetworkNodeNumber().getAddressNature().getIndicator());
            boundStatement.setInt(Schema.COLUMN_NNN_NP, sms.getSmsSet().getLocationInfoWithLMSI().getNetworkNodeNumber().getNumberingPlan().getIndicator());
        } else {
            boundStatement.setToNull(Schema.COLUMN_NNN_DIGITS);
            boundStatement.setToNull(Schema.COLUMN_NNN_AN);
            boundStatement.setToNull(Schema.COLUMN_NNN_NP);
        }
        if (sms.getSmsSet().getType() != null) {
            boundStatement.setInt(Schema.COLUMN_SM_TYPE, sms.getSmsSet().getType().getCode());
        } else {
            boundStatement.setToNull(Schema.COLUMN_SM_TYPE);
        }
        if (addedCorrId) {
            boundStatement.setString(Schema.COLUMN_CORR_ID, sms.getSmsSet().getCorrelationId());
        }
        boundStatement.setString(Schema.COLUMN_IMSI, sms.getSmsSet().getImsi());
    }
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) XMLStreamException(javolution.xml.stream.XMLStreamException) Charset(java.nio.charset.Charset) XMLObjectWriter(javolution.xml.XMLObjectWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) ByteBuffer(java.nio.ByteBuffer)

Example 7 with XMLStreamException

use of javolution.xml.stream.XMLStreamException 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();
        }
    }
}
Also used : XMLStreamException(javolution.xml.stream.XMLStreamException) StringReader(java.io.StringReader) XMLObjectReader(javolution.xml.XMLObjectReader)

Example 8 with XMLStreamException

use of javolution.xml.stream.XMLStreamException in project smscgateway by RestComm.

the class Sms method getExtraData.

public String getExtraData() {
    if (this.extraData.isEmpty()) {
        return null;
    } else {
        // serializing of extraData
        try {
            StringWriter sw = new StringWriter();
            XMLObjectWriter writer = XMLObjectWriter.newInstance(sw);
            writer.setIndentation("\t");
            writer.write(this.extraData, "extraData", SmsExtraData.class);
            writer.close();
            return sw.toString();
        } catch (XMLStreamException e) {
            return null;
        }
    }
}
Also used : StringWriter(java.io.StringWriter) XMLStreamException(javolution.xml.stream.XMLStreamException) XMLObjectWriter(javolution.xml.XMLObjectWriter)

Example 9 with XMLStreamException

use of javolution.xml.stream.XMLStreamException 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;
}
Also used : XMLStreamException(javolution.xml.stream.XMLStreamException) FileNotFoundException(java.io.FileNotFoundException) XMLObjectReader(javolution.xml.XMLObjectReader) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) XMLStreamException(javolution.xml.stream.XMLStreamException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 10 with XMLStreamException

use of javolution.xml.stream.XMLStreamException 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);
    }
}
Also used : FileInputStream(java.io.FileInputStream) XMLStreamException(javolution.xml.stream.XMLStreamException) GenerateType(org.restcomm.smpp.GenerateType) XMLObjectReader(javolution.xml.XMLObjectReader)

Aggregations

XMLStreamException (javolution.xml.stream.XMLStreamException)13 XMLObjectReader (javolution.xml.XMLObjectReader)9 FileInputStream (java.io.FileInputStream)6 XMLObjectWriter (javolution.xml.XMLObjectWriter)4 InvalidQueryException (com.datastax.driver.core.exceptions.InvalidQueryException)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ByteBuffer (java.nio.ByteBuffer)3 FastList (javolution.util.FastList)3 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)3 BoundStatement (com.datastax.driver.core.BoundStatement)2 PreparedStatement (com.datastax.driver.core.PreparedStatement)2 ResultSet (com.datastax.driver.core.ResultSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Charset (java.nio.charset.Charset)2 Sms (org.mobicents.smsc.library.Sms)2 SmsSet (org.mobicents.smsc.library.SmsSet)2 DataCodingScheme (org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme)2 DataCodingSchemeImpl (org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl)2