net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgClient.CFAsteriskXMsgClientSchema.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgClient.CFAsteriskXMsgClientSchema.java

Source

// Description: Java 8 XMsg Client DbIO implementation for CFAsterisk.

/*
 *   Code Factory Asterisk 11 Configuration Model
 *
 *   Copyright (c) 2014-2015 Mark Sobkow
 *   
 *   This program is available as free software under the GNU GPL v3, or
 *   under a commercial license from Mark Sobkow.  For commercial licensing
 *   details, please contact msobkow@sasktel.net.
 *   
 *   Under the terms of the GPL:
 *   
 *      This program is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU 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 General Public License for more details.
 *     
 *      You should have received a copy of the GNU General Public License
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 */

package net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgClient;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.*;
import java.math.*;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.*;
import java.text.*;
import java.util.*;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.naming.*;
import javax.sql.*;

import org.apache.commons.codec.binary.Base64;

import net.sourceforge.msscodefactory.cflib.v2_3.CFLib.*;
import net.sourceforge.msscodefactory.cflib.v2_3.CFLib.Tip.*;
import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurity.*;
import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternet.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsterisk.*;
import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurityObj.*;
import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternetObj.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskObj.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsg.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgRspnHandler.*;

public class CFAsteriskXMsgClientSchema extends CFAsteriskSchema {
    protected CFTipClientHandler cftipClientHandler = null;
    protected boolean transactionOpen = false;

    public CFAsteriskXMsgClientSchema() {
        super();
        getCFTipClientHandler();
        getResponseHandler();
        tableAsteriskConf = new CFAsteriskXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAsteriskXMsgClientAuditActionTable(this);
        tableCluster = new CFAsteriskXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAsteriskXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAsteriskXMsgClientDomainTable(this);
        tableDomainBase = new CFAsteriskXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAsteriskXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAsteriskXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAsteriskXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAsteriskXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAsteriskXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAsteriskXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAsteriskXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAsteriskXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAsteriskXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAsteriskXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAsteriskXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAsteriskXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAsteriskXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAsteriskXMsgClientRealProjectTable(this);
        tableSecApp = new CFAsteriskXMsgClientSecAppTable(this);
        tableSecDevice = new CFAsteriskXMsgClientSecDeviceTable(this);
        tableSecForm = new CFAsteriskXMsgClientSecFormTable(this);
        tableSecGroup = new CFAsteriskXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAsteriskXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAsteriskXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAsteriskXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAsteriskXMsgClientSecSessionTable(this);
        tableSecUser = new CFAsteriskXMsgClientSecUserTable(this);
        tableService = new CFAsteriskXMsgClientServiceTable(this);
        tableServiceType = new CFAsteriskXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAsteriskXMsgClientSipConfTable(this);
        tableSubProject = new CFAsteriskXMsgClientSubProjectTable(this);
        tableSysCluster = new CFAsteriskXMsgClientSysClusterTable(this);
        tableTSecGroup = new CFAsteriskXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAsteriskXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAsteriskXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAsteriskXMsgClientTenantTable(this);
        tableTld = new CFAsteriskXMsgClientTldTable(this);
        tableTopDomain = new CFAsteriskXMsgClientTopDomainTable(this);
        tableTopProject = new CFAsteriskXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAsteriskXMsgClientURLProtocolTable(this);
        tableVersion = new CFAsteriskXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAsteriskXMsgClientVoicemailConfTable(this);
        setResponseHandlerSchemaObj(null);
    }

    public CFAsteriskXMsgClientSchema(CFAsteriskSchemaObj handlerSchema) {
        super();
        getCFTipClientHandler();
        getResponseHandler();
        tableAsteriskConf = new CFAsteriskXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAsteriskXMsgClientAuditActionTable(this);
        tableCluster = new CFAsteriskXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAsteriskXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAsteriskXMsgClientDomainTable(this);
        tableDomainBase = new CFAsteriskXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAsteriskXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAsteriskXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAsteriskXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAsteriskXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAsteriskXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAsteriskXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAsteriskXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAsteriskXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAsteriskXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAsteriskXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAsteriskXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAsteriskXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAsteriskXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAsteriskXMsgClientRealProjectTable(this);
        tableSecApp = new CFAsteriskXMsgClientSecAppTable(this);
        tableSecDevice = new CFAsteriskXMsgClientSecDeviceTable(this);
        tableSecForm = new CFAsteriskXMsgClientSecFormTable(this);
        tableSecGroup = new CFAsteriskXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAsteriskXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAsteriskXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAsteriskXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAsteriskXMsgClientSecSessionTable(this);
        tableSecUser = new CFAsteriskXMsgClientSecUserTable(this);
        tableService = new CFAsteriskXMsgClientServiceTable(this);
        tableServiceType = new CFAsteriskXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAsteriskXMsgClientSipConfTable(this);
        tableSubProject = new CFAsteriskXMsgClientSubProjectTable(this);
        tableSysCluster = new CFAsteriskXMsgClientSysClusterTable(this);
        tableTSecGroup = new CFAsteriskXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAsteriskXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAsteriskXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAsteriskXMsgClientTenantTable(this);
        tableTld = new CFAsteriskXMsgClientTldTable(this);
        tableTopDomain = new CFAsteriskXMsgClientTopDomainTable(this);
        tableTopProject = new CFAsteriskXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAsteriskXMsgClientURLProtocolTable(this);
        tableVersion = new CFAsteriskXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAsteriskXMsgClientVoicemailConfTable(this);
        setResponseHandlerSchemaObj(handlerSchema);
    }

    public CFAsteriskXMsgClientSchema(CFAsteriskSchemaObj handlerSchema, CFAsteriskConfigurationFile conf) {
        super(conf);
        getCFTipClientHandler();
        getResponseHandler();
        tableAsteriskConf = new CFAsteriskXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAsteriskXMsgClientAuditActionTable(this);
        tableCluster = new CFAsteriskXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAsteriskXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAsteriskXMsgClientDomainTable(this);
        tableDomainBase = new CFAsteriskXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAsteriskXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAsteriskXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAsteriskXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAsteriskXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAsteriskXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAsteriskXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAsteriskXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAsteriskXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAsteriskXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAsteriskXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAsteriskXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAsteriskXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAsteriskXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAsteriskXMsgClientRealProjectTable(this);
        tableSecApp = new CFAsteriskXMsgClientSecAppTable(this);
        tableSecDevice = new CFAsteriskXMsgClientSecDeviceTable(this);
        tableSecForm = new CFAsteriskXMsgClientSecFormTable(this);
        tableSecGroup = new CFAsteriskXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAsteriskXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAsteriskXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAsteriskXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAsteriskXMsgClientSecSessionTable(this);
        tableSecUser = new CFAsteriskXMsgClientSecUserTable(this);
        tableService = new CFAsteriskXMsgClientServiceTable(this);
        tableServiceType = new CFAsteriskXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAsteriskXMsgClientSipConfTable(this);
        tableSubProject = new CFAsteriskXMsgClientSubProjectTable(this);
        tableSysCluster = new CFAsteriskXMsgClientSysClusterTable(this);
        tableTSecGroup = new CFAsteriskXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAsteriskXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAsteriskXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAsteriskXMsgClientTenantTable(this);
        tableTld = new CFAsteriskXMsgClientTldTable(this);
        tableTopDomain = new CFAsteriskXMsgClientTopDomainTable(this);
        tableTopProject = new CFAsteriskXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAsteriskXMsgClientURLProtocolTable(this);
        tableVersion = new CFAsteriskXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAsteriskXMsgClientVoicemailConfTable(this);
        setDbSchemaName(conf.getDbDatabase());
        setResponseHandlerSchemaObj(handlerSchema);
    }

    public CFAsteriskXMsgClientSchema(CFAsteriskSchemaObj handlerSchema, String argJndiName) {
        super(argJndiName);
        getCFTipClientHandler();
        getResponseHandler();
        tableAsteriskConf = new CFAsteriskXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAsteriskXMsgClientAuditActionTable(this);
        tableCluster = new CFAsteriskXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAsteriskXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAsteriskXMsgClientDomainTable(this);
        tableDomainBase = new CFAsteriskXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAsteriskXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAsteriskXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAsteriskXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAsteriskXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAsteriskXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAsteriskXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAsteriskXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAsteriskXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAsteriskXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAsteriskXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAsteriskXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAsteriskXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAsteriskXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAsteriskXMsgClientRealProjectTable(this);
        tableSecApp = new CFAsteriskXMsgClientSecAppTable(this);
        tableSecDevice = new CFAsteriskXMsgClientSecDeviceTable(this);
        tableSecForm = new CFAsteriskXMsgClientSecFormTable(this);
        tableSecGroup = new CFAsteriskXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAsteriskXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAsteriskXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAsteriskXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAsteriskXMsgClientSecSessionTable(this);
        tableSecUser = new CFAsteriskXMsgClientSecUserTable(this);
        tableService = new CFAsteriskXMsgClientServiceTable(this);
        tableServiceType = new CFAsteriskXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAsteriskXMsgClientSipConfTable(this);
        tableSubProject = new CFAsteriskXMsgClientSubProjectTable(this);
        tableSysCluster = new CFAsteriskXMsgClientSysClusterTable(this);
        tableTSecGroup = new CFAsteriskXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAsteriskXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAsteriskXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAsteriskXMsgClientTenantTable(this);
        tableTld = new CFAsteriskXMsgClientTldTable(this);
        tableTopDomain = new CFAsteriskXMsgClientTopDomainTable(this);
        tableTopProject = new CFAsteriskXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAsteriskXMsgClientURLProtocolTable(this);
        tableVersion = new CFAsteriskXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAsteriskXMsgClientVoicemailConfTable(this);
        setResponseHandlerSchemaObj(handlerSchema);
    }

    // Overload this to create an instance implementing your sendReceive() processing for CFTip
    public CFTipClientHandler getCFTipClientHandler() {
        if (cftipClientHandler == null) {
            cftipClientHandler = new CFTipClientHandler();
        }
        return (cftipClientHandler);
    }

    /**
     *   Get the CFAsteriskSchemaObj that is used by the response processor to
     *   import the response objects during the parsing of response message strings.
     *
     *   @return   The CFAsteriskSchemaObj that is providing a persistence implementation
     *         for the parsing of response message strings.
     */
    public ICFAsteriskSchemaObj getResponseHandlerSchemaObj() {
        ICFAsteriskSchemaObj handlerSchema = getResponseHandler().getSchemaObj();
        return (handlerSchema);
    }

    /**
     *   Set the CFAsteriskSchemaObj that is to be used by the response processor to
     *   import the response objects during the parsing of response message strings.
     *
     *   @param   handlerSchema The CFAsteriskSchemaObj that is to provide a persistence implementation
     *         for the parsing of response message strings.
     */
    public void setResponseHandlerSchemaObj(ICFAsteriskSchemaObj handlerSchema) {
        getResponseHandler().setSchemaObj(handlerSchema);
    }

    public ICFLibMessageLog getLog() {
        ICFLibMessageLog mylog = getResponseHandler().getLog();
        return (mylog);
    }

    public void setLog(ICFLibMessageLog newlog) {
        getResponseHandler().setLog(newlog);
    }

    /**
     *   Get the CFAsteriskDeleted flag that is used by the response processor to
     *   indate that a Deleted response was processed.
     *
     *   @return   True if a Deleted message was processed, otherwise false.
     */
    public boolean getResponseHandlerDeleted() {
        boolean deleted = getResponseHandler().getDeleted();
        return (deleted);
    }

    /**
     *   Set the CFAsteriskDeleted flag that is to be used by the response processor to
     *   indicate that a Deleted response was processed.
     *
     *   @param   deleted True if a Deleted response was processed, otherwise false.
     */
    public void setResponseHandlerDeleted(boolean deleted) {
        getResponseHandler().setDeleted(deleted);
    }

    public boolean isConnected() {
        ICFAsteriskSchemaObj schemaObj = getResponseHandlerSchemaObj();
        if (schemaObj.getAuthorization() != null) {
            return (true);
        } else {
            return (false);
        }
    }

    /**
     *   Send the request and receive a response string from the server.
     *   <p>
     *   You are expected to overload the implementation of this method
     *   when binding an XMsgClient package to a particular transport
     *   mechanism.  The implementation of sendReceive() is for pure XML
     *   strings, so you can wire it to pretty much any implementation
     *   you choose.
     *
     *   @param   Authorization -- null for connection requests
     *
     *   @param   rqst The String to send to the server
     *
     *   @return   rspn The response string recieved from the server, ready to be parsed as an XML file content.
     */
    public String sendReceive(CFSecurityAuthorization Authorization, String rqst) {
        throw CFLib.getDefaultExceptionFactory().newMustOverrideException(getClass(), "sendReceive");
    }

    public CFAsteriskXMsgRspnHandler getResponseHandler() {
        CFAsteriskXMsgRspnHandler responseHandler = null;
        CFTipClientHandler clientHandler = getCFTipClientHandler();
        responseHandler = (CFAsteriskXMsgRspnHandler) clientHandler.getResponseHandler();
        if (responseHandler == null) {
            responseHandler = new CFAsteriskXMsgRspnHandler();
            clientHandler.setResponseHandler(responseHandler);
        }
        return (responseHandler);
    }

    public boolean connect() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "connect");
    }

    public boolean connect(String username, String password) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "connect-userpw");
    }

    public boolean connect(String loginId, String password, String clusterName, String tenantName) {
        final String S_ProcName = "connect-full";
        CFTipClientHandler clientHandler = getCFTipClientHandler();
        String deviceName = clientHandler.getDeviceName();

        String rqst = null;
        try {
            MessageDigest msgDigest = MessageDigest.getInstance("SHA-512");
            msgDigest.update(password.getBytes("UTF-8"));
            byte[] hash = msgDigest.digest();
            byte[] encodedHash = Base64.encodeBase64(hash);
            byte[] devEncPWHash = clientHandler.encryptWithDevicePrivateKey(encodedHash);

            clientHandler.initSessionKey();

            rqst = CFAsteriskXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
                    + CFAsteriskXMsgSchemaMessageFormatter.formatRqstLogIn("\n\t\t\t", loginId, deviceName,
                            devEncPWHash, clusterName, tenantName)
                    + "\n" + CFAsteriskXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
        } catch (NoSuchAlgorithmException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchAlgorithmException - " + e.getMessage(), e);
        } catch (UnsupportedEncodingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught UnsupportedEncodingException - " + e.getMessage(), e);
        } catch (InvalidKeyException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught InvalidKeyException - " + e.getMessage(), e);
        } catch (NoSuchPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchPaddingException - " + e.getMessage(), e);
        } catch (IllegalBlockSizeException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught IllegalBlockSizeException - " + e.getMessage(), e);
        } catch (BadPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught BadPaddingException - " + e.getMessage(), e);
        }

        try {
            cftipClientHandler.issueLoginRequest(rqst);
        } catch (InvalidAlgorithmParameterException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught InvalidAlgorithmParameterException - " + e.getMessage(), e);
        } catch (BadPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught BadPaddingException - " + e.getMessage(), e);
        } catch (IllegalBlockSizeException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught IllegalBlockSizeException - " + e.getMessage(), e);
        } catch (InvalidKeyException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught InvalidKeyException - " + e.getMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchAlgorithmException - " + e.getMessage(), e);
        } catch (NoSuchPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchPaddingException - " + e.getMessage(), e);
        }
        // The response handler sets up the authorization
        ICFTipResponseHandler responseHandler = cftipClientHandler.getResponseHandler();
        CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
        if (exceptionRaised != null) {
            throw exceptionRaised;
        }
        // If we got a response instead of an exception, we succeeded at logging in.
        return (true);
    }

    public void disconnect(boolean doCommit) {
    }

    public void logout(CFSecurityAuthorization auth) {
        final String S_ProcName = "logout";
        if ((auth == null) || (null == auth.getSecSessionId())) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Not authorized/connected");
        }
        String rqst = CFAsteriskXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
                + CFAsteriskXMsgSchemaMessageFormatter.formatRqstLogOut("\n\t\t\t", auth.getSecSessionId()) + "\n"
                + CFAsteriskXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
        try {
            cftipClientHandler.issueAppRequest(rqst);
        } catch (BadPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught BadPaddingException - " + e.getMessage(), e);
        } catch (IllegalBlockSizeException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught IllegalBlockSizeException - " + e.getMessage(), e);
        } catch (InvalidKeyException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught InvalidKeyException - " + e.getMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchAlgorithmException - " + e.getMessage(), e);
        } catch (InvalidAlgorithmParameterException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught InvalidAlgorithmParameterException - " + e.getMessage(), e);
        } catch (NoSuchPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchPaddingException - " + e.getMessage(), e);
        }
        ICFTipResponseHandler responseHandler = cftipClientHandler.getResponseHandler();
        CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
        if (exceptionRaised != null) {
            throw exceptionRaised;
        }
    }

    public boolean isTransactionOpen() {
        return (transactionOpen);
    }

    public boolean beginTransaction() {
        if (transactionOpen) {
            return (false);
        } else {
            transactionOpen = true;
            return (true);
        }
    }

    public void commit() {
        transactionOpen = false;
    }

    public void rollback() {
        transactionOpen = false;
    }

    public boolean isSystemUser(CFSecurityAuthorization Authorization) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "isSystemUser");
    }

    public boolean isClusterUser(CFSecurityAuthorization Authorization, long clusterId, String groupName) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "isClusterUser");
    }

    public boolean isTenantUser(CFSecurityAuthorization Authorization, long tenantId, String groupName) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "isTenantUser");
    }

    public String fileImport(CFSecurityAuthorization Authorization, String fileName, String fileContents) {
        final String S_ProcName = "fileImport";
        if ((fileName == null) || (fileName.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                    "fileName");
        }
        if ((fileContents == null) || (fileContents.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 2,
                    "fileContents");
        }
        String rqst = CFAsteriskXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
                + CFAsteriskXMsgSchemaMessageFormatter.formatRqstFileImport("\n\t\t\t", fileName, fileContents)
                + "\n" + CFAsteriskXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
        try {
            getCFTipClientHandler().issueAppRequest(rqst);
        } catch (BadPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught BadPaddingException - " + e.getMessage(), e);
        } catch (IllegalBlockSizeException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught IllegalBlockSizeException - " + e.getMessage(), e);
        } catch (InvalidKeyException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught InvalidKeyException - " + e.getMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchAlgorithmException - " + e.getMessage(), e);
        } catch (InvalidAlgorithmParameterException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught InvalidAlgorithmParameterException - " + e.getMessage(), e);
        } catch (NoSuchPaddingException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Caught NoSuchPaddingException - " + e.getMessage(), e);
        }
        ICFTipResponseHandler responseHandler = getCFTipClientHandler().getResponseHandler();
        CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
        if (exceptionRaised != null) {
            throw exceptionRaised;
        }
        CFAsteriskXMsgRspnHandler responseParser = (CFAsteriskXMsgRspnHandler) responseHandler;
        String logContents = responseParser.getLogContents();
        return (logContents);
    }

    public int nextServiceTypeIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextServiceTypeIdGen");
    }

    public int nextMimeTypeIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextMimeTypeIdGen");
    }

    public long nextClusterIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextClusterIdGen");
    }

    public long nextTenantIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextTenantIdGen");
    }

    public UUID nextSecSessionIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextSecSessionIdGen");
    }

    public UUID nextSecUserIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextSecUserIdGen");
    }

    /**
     *   Release the prepared statements.
     *   <p>
     *   When the schema changes connections, the prepared statements
     *   have to be released because they contain connection-specific
     *   information for most databases.
     */
    public void releasePreparedStatements() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "releasePreparedStatements");
    }

    public static String getQuotedString(String val) {
        if (val == null) {
            return ("null");
        } else {
            char c;
            StringBuilder quoted = new StringBuilder();
            quoted.append("'");
            int len = val.length();
            for (int i = 0; i < len; i++) {
                if (val.charAt(i) == '\'') {
                    quoted.append("''");
                } else if (val.charAt(i) == '\\') {
                    quoted.append("'||E'\\\\'||'");
                } else {
                    c = val.charAt(i);
                    if ((c == '0') || (c == '1') || (c == '2') || (c == '3') || (c == '4') || (c == '5')
                            || (c == '6') || (c == '7') || (c == '8') || (c == '9') || (c == 'a') || (c == 'b')
                            || (c == 'c') || (c == 'd') || (c == 'e') || (c == 'f') || (c == 'g') || (c == 'h')
                            || (c == 'i') || (c == 'j') || (c == 'k') || (c == 'l') || (c == 'm') || (c == 'n')
                            || (c == 'o') || (c == 'p') || (c == 'q') || (c == 'r') || (c == 's') || (c == 't')
                            || (c == 'u') || (c == 'v') || (c == 'w') || (c == 'x') || (c == 'y') || (c == 'z')
                            || (c == 'A') || (c == 'B') || (c == 'C') || (c == 'D') || (c == 'E') || (c == 'F')
                            || (c == 'G') || (c == 'H') || (c == 'I') || (c == 'J') || (c == 'K') || (c == 'L')
                            || (c == 'M') || (c == 'N') || (c == 'O') || (c == 'P') || (c == 'Q') || (c == 'R')
                            || (c == 'S') || (c == 'T') || (c == 'U') || (c == 'V') || (c == 'W') || (c == 'X')
                            || (c == 'Y') || (c == 'Z') || (c == ' ') || (c == '\t') || (c == '\r') || (c == '\n')
                            || (c == '`') || (c == '~') || (c == '!') || (c == '@') || (c == '#') || (c == '$')
                            || (c == '%') || (c == '^') || (c == '&') || (c == '*') || (c == '(') || (c == ')')
                            || (c == '-') || (c == '_') || (c == '=') || (c == '+') || (c == '[') || (c == ']')
                            || (c == '{') || (c == '}') || (c == '|') || (c == ';') || (c == ':') || (c == '"')
                            || (c == '<') || (c == '>') || (c == ',') || (c == '.') || (c == '/') || (c == '?')) {
                        quoted.append(c);
                    } else {
                        //                  Syslog.warn("\t\t\tReplacing invalid character '" + c + "' with space");
                        quoted.append(' ');
                    }
                }
            }
            quoted.append("'");
            return (quoted.toString());
        }
    }

    public static String getNullableString(ResultSet reader, int colidx) {
        try {
            String val = reader.getString(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (val);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                    "getNullableString", e);
        }
    }

    public static String getBlobString(byte[] val) {
        if (val == null) {
            return ("null");
        } else {
            return ("'" + new String(Base64.encodeBase64(val)) + "'");
        }
    }

    public static String getBoolString(Boolean val) {
        if (val == null) {
            return ("null");
        } else {
            if (val) {
                return ("true");
            } else {
                return ("false");
            }
        }
    }

    public static String getBoolString(boolean val) {
        if (val) {
            return ("true");
        } else {
            return ("false");
        }
    }

    public static String getInt16String(Short val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt16String(short val) {
        return (Short.toString(val));
    }

    public static String getInt32String(Integer val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt32String(int val) {
        return (Integer.toString(val));
    }

    public static String getInt64String(Long val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt64String(long val) {
        return (Long.toString(val));
    }

    public static String getUInt16String(Integer val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getUInt16String(int val) {
        return (Integer.toString(val));
    }

    public static String getUInt32String(Long val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getUInt32String(long val) {
        return (Long.toString(val));
    }

    public static String getUInt64String(BigDecimal val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getFloatString(Float val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getFloatString(float val) {
        return (Float.toString(val));
    }

    public static String getDoubleString(Double val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getDoubleString(double val) {
        return (Double.toString(val));
    }

    public static String getNumberString(BigDecimal val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static Integer getNullableInt32(ResultSet reader, int colidx) {
        try {
            int val = reader.getInt(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Integer(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                    "getNullableInt32", e);
        }
    }

    public static Short getNullableInt16(ResultSet reader, int colidx) {
        try {
            short val = reader.getShort(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Short(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                    "getNullableInt64", e);
        }
    }

    public static Integer getNullableUInt16(ResultSet reader, int colidx) {
        try {
            int val = reader.getInt(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Integer(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                    "getNullableUInt16", e);
        }
    }

    public static Long getNullableUInt32(ResultSet reader, int colidx) {
        try {
            long val = reader.getLong(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Long(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                    "getNullableUInt32", e);
        }
    }

    public static BigDecimal getNullableUInt64(ResultSet reader, int colidx) {
        try {
            String strval = reader.getString(colidx);
            if (reader.wasNull() || (strval == null) || (strval.length() <= 0)) {
                return (null);
            } else {
                BigDecimal retval = new BigDecimal(strval);
                return (retval);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                    "getNullableUInt64", e);
        }
    }

    public static Byte getNullableByte(ResultSet reader, int colidx) {
        try {
            byte val = reader.getByte(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Byte(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                    "getNullableByte", e);
        }
    }

    public static String getQuotedDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getUuidString(UUID val) {
        if (val == null) {
            return ("null");
        } else {
            return ("'" + val.toString() + "'");
        }
    }

    public static Calendar convertDateString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 10) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertDateString", "Value must be in YYYY-MM-DD format, \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, 0);
            retval.set(Calendar.MINUTE, 0);
            retval.set(Calendar.SECOND, 0);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertDateString", "Value must be in YYYY-MM-DD format, \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTimeString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 8) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTimeString", "Value must be in HH24:MI:SS format, \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '2'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9')) && (val.charAt(2) == ':')
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '5'))
                && ((val.charAt(4) >= '0') && (val.charAt(4) <= '9')) && (val.charAt(5) == ':')
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '5'))
                && ((val.charAt(7) >= '0') && (val.charAt(7) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int hour = Integer.parseInt(val.substring(0, 2));
            int minute = Integer.parseInt(val.substring(3, 5));
            int second = Integer.parseInt(val.substring(6, 8));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, 2000);
            retval.set(Calendar.MONTH, 0);
            retval.set(Calendar.DAY_OF_MONTH, 1);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTimeString", "Value must be in HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTimestampString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZDateString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTZDateString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTZDateString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZTimeString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTZTimeString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTZTimeString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZTimestampString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTZTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAsteriskXMsgClientSchema.class,
                    "convertTZTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static UUID convertUuidString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else {
            return (UUID.fromString(val));
        }
    }
}