net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsg.CFAccXMsgSchemaMessageFormatter.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsg.CFAccXMsgSchemaMessageFormatter.java

Source

// Description: Java 7 XML Message message formatter for CFAcc

/*
 *   MSS Code Factory Accounting Business Application Model
 *
 *   Copyright (c) 2014 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/>.
 *   
 *      This source code incorporates modified modules originally licensed
 *      under the Apache 2.0 license by MSS Code Factory including CFSecurity
 *      (net-sourceforge-msscodefactory-2.0-cfsecurity.xml),
 *      CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and
 *      CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the
 *      required models being available as part of the MSS Code Factory 1.11
 *      distribution source and install zips.
 *   
 *      You can download installations of MSS Code Factory 1.11 from
 *      http://msscodefactory.sourceforge.net/
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsg;

import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import org.xml.sax.*;
import net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.*;
import net.sourceforge.msscodefactory.cfacc.v2_0.CFAccObj.*;

/*
 *   CFAccXMsg$Schema$MessageFormatter XML message formatter
 *   for CFAcc.
 */
public class CFAccXMsgSchemaMessageFormatter {
    public CFAccXMsgSchemaMessageFormatter() {
    }

    public static String formatRqstXmlPreamble() {
        final String retval = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<CFAccRqst\n"
                + "\t\txmlns=\"uri://net.sourceforge.msscodefactory.cfacc.v2_0/cfaccrqst\"\n"
                + "\t\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
                + "\t\txmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n"
                + "\t\txsi:schemaLocation=\"uri://net.sourceforge.msscodefactory.cfacc.v2_0/cfaccrqst file://xsd/cfacc-20-rqst.xsd\" >";
        return (retval);
    }

    public static String formatRqstXmlPostamble() {
        final String retval = "</CFAccRqst>\n";
        return (retval);
    }

    public static String formatRspnXmlPreamble() {
        final String retval = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<CFAccRspn\n"
                + "\t\txmlns=\"uri://net.sourceforge.msscodefactory.cfacc.v2_0/cfaccrspn\"\n"
                + "\t\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
                + "\t\txmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n"
                + "\t\txsi:schemaLocation=\"uri://net.sourceforge.msscodefactory.cfacc.v2_0/cfaccrspn file://xsd/cfacc-20-rspn.xsd\" >";
        return (retval);
    }

    public static String formatRspnXmlPostamble() {
        final String retval = "</CFAccRspn>\n";
        return (retval);
    }

    public static String formatRspnNoDataFound() {
        String retval = "<RspnNoDataFound />";
        return (retval);
    }

    public static String formatRspnException(String separator, RuntimeException e) {
        String retval = "<RspnException "
                + CFLibXmlUtil.formatRequiredXmlString(null, "Name", e.getClass().getName())
                + CFLibXmlUtil.formatRequiredXmlString(separator, "Message", e.getMessage()) + " />";
        return (retval);
    }

    public static String formatRspnException(String separator, Exception e) {
        String retval = "<RspnException "
                + CFLibXmlUtil.formatRequiredXmlString(null, "Name", e.getClass().getName())
                + CFLibXmlUtil.formatRequiredXmlString(separator, "Message", e.getMessage()) + " />";
        return (retval);
    }

    public static String formatRspnException(String separator, Error e) {
        String retval = "<RspnException "
                + CFLibXmlUtil.formatRequiredXmlString(null, "Name", e.getClass().getName())
                + CFLibXmlUtil.formatRequiredXmlString(separator, "Message", e.getMessage()) + " />";
        return (retval);
    }

    public static String formatRqstLogIn(String separator, String clusterName, String tenantName,
            String secUserName, String dbUserName, String dbPassword) {
        String retval = "<RqstLogIn " + CFLibXmlUtil.formatRequiredXmlString(null, "ClusterName", clusterName)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "TenantName", tenantName)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "SecUserName", secUserName)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "DbUserName", dbUserName)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "DbPassword", dbPassword) + " />";
        return (retval);
    }

    public static String formatRqstLogOut(String separator, UUID secSessionId) {
        String retval = "<RqstLogOut "
                + CFLibXmlUtil.formatRequiredXmlString(null, "SecSessionId", secSessionId.toString()) + " />";
        return (retval);
    }

    public static String formatRspnLoggedIn(String separator, long clusterId, String clusterName, long tenantId,
            String tenantName, UUID secUserId, String secUserName, UUID secSessionId) {
        String retval = "<RspnLoggedIn " + CFLibXmlUtil.formatRequiredInt64(null, "ClusterId", clusterId)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "ClusterName", clusterName)
                + CFLibXmlUtil.formatRequiredInt64(separator, "TenantId", tenantId)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "TenantName", tenantName)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "SecUserId", secUserId.toString())
                + CFLibXmlUtil.formatRequiredXmlString(separator, "SecUserName", secUserName)
                + CFLibXmlUtil.formatRequiredXmlString(separator, "SecSessionId", secSessionId.toString()) + " />";
        return (retval);
    }

    public static String formatRspnLoggedOut(String separator, UUID secSessionId) {
        String retval = "<RspnLoggedOut "
                + CFLibXmlUtil.formatRequiredXmlString(null, "SecSessionId", secSessionId.toString()) + " />";
        return (retval);
    }
}