Example usage for java.lang Short Short

List of usage examples for java.lang Short Short

Introduction

In this page you can find the example usage for java.lang Short Short.

Prototype

@Deprecated(since = "9")
public Short(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Short object that represents the short value indicated by the String parameter.

Usage

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnContactLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  ww  w . ja  v a  2 s  .  c o m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // Contact Attributes
        String attrTenantId = null;
        String attrContactId = null;
        String attrContactListId = null;
        String attrISOTimezoneId = null;
        String attrFullName = null;
        String attrLastName = null;
        String attrFirstName = null;
        String attrCustom = null;
        String attrCustom2 = null;
        String attrCustom3 = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnContactLocked");

        CFAccXMsgRspnHandler xmsgRspnHandler = (CFAccXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAccSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactId")) {
                if (attrContactId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactListId")) {
                if (attrContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOTimezoneId")) {
                if (attrISOTimezoneId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOTimezoneId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FullName")) {
                if (attrFullName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFullName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("LastName")) {
                if (attrLastName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrLastName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FirstName")) {
                if (attrFirstName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFirstName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom")) {
                if (attrCustom != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom2")) {
                if (attrCustom2 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom2 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom3")) {
                if (attrCustom3 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom3 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrContactId == null) || (attrContactId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactId");
        }
        if ((attrContactListId == null) || (attrContactListId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactListId");
        }
        if (attrFullName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "FullName");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natContactId = Long.parseLong(attrContactId);

        long natContactListId = Long.parseLong(attrContactListId);

        Short natISOTimezoneId;
        if ((attrISOTimezoneId == null) || (attrISOTimezoneId.length() <= 0)) {
            natISOTimezoneId = null;
        } else {
            natISOTimezoneId = new Short(Short.parseShort(attrISOTimezoneId));
        }

        String natFullName = attrFullName;

        String natLastName = attrLastName;

        String natFirstName = attrFirstName;

        String natCustom = attrCustom;

        String natCustom2 = attrCustom2;

        String natCustom3 = attrCustom3;

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFAccContactObj obj = schemaObj.getContactTableObj().newInstance();
        CFAccContactBuff dataBuff = obj.getContactBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredContactId(natContactId);
        dataBuff.setRequiredContactListId(natContactListId);
        dataBuff.setOptionalISOTimezoneId(natISOTimezoneId);
        dataBuff.setRequiredFullName(natFullName);
        dataBuff.setOptionalLastName(natLastName);
        dataBuff.setOptionalFirstName(natFirstName);
        dataBuff.setOptionalCustom(natCustom);
        dataBuff.setOptionalCustom2(natCustom2);
        dataBuff.setOptionalCustom3(natCustom3);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFAccContactObj realized = (ICFAccContactObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnContactCreatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  w  w  w .j a v  a  2  s  . c o  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // Contact Attributes
        String attrTenantId = null;
        String attrContactId = null;
        String attrContactListId = null;
        String attrISOTimezoneId = null;
        String attrFullName = null;
        String attrLastName = null;
        String attrFirstName = null;
        String attrCustom = null;
        String attrCustom2 = null;
        String attrCustom3 = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnContactCreated");

        CFAccXMsgRspnHandler xmsgRspnHandler = (CFAccXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAccSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactId")) {
                if (attrContactId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactListId")) {
                if (attrContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOTimezoneId")) {
                if (attrISOTimezoneId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOTimezoneId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FullName")) {
                if (attrFullName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFullName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("LastName")) {
                if (attrLastName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrLastName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FirstName")) {
                if (attrFirstName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFirstName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom")) {
                if (attrCustom != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom2")) {
                if (attrCustom2 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom2 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom3")) {
                if (attrCustom3 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom3 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrContactId == null) || (attrContactId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactId");
        }
        if ((attrContactListId == null) || (attrContactListId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactListId");
        }
        if (attrFullName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "FullName");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natContactId = Long.parseLong(attrContactId);

        long natContactListId = Long.parseLong(attrContactListId);

        Short natISOTimezoneId;
        if ((attrISOTimezoneId == null) || (attrISOTimezoneId.length() <= 0)) {
            natISOTimezoneId = null;
        } else {
            natISOTimezoneId = new Short(Short.parseShort(attrISOTimezoneId));
        }

        String natFullName = attrFullName;

        String natLastName = attrLastName;

        String natFirstName = attrFirstName;

        String natCustom = attrCustom;

        String natCustom2 = attrCustom2;

        String natCustom3 = attrCustom3;

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFAccContactObj obj = schemaObj.getContactTableObj().newInstance();
        CFAccContactBuff dataBuff = obj.getContactBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredContactId(natContactId);
        dataBuff.setRequiredContactListId(natContactListId);
        dataBuff.setOptionalISOTimezoneId(natISOTimezoneId);
        dataBuff.setRequiredFullName(natFullName);
        dataBuff.setOptionalLastName(natLastName);
        dataBuff.setOptionalFirstName(natFirstName);
        dataBuff.setOptionalCustom(natCustom);
        dataBuff.setOptionalCustom2(natCustom2);
        dataBuff.setOptionalCustom3(natCustom3);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFAccContactObj realized = (ICFAccContactObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnContactUpdatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  www  .  j a va2 s  . c o  m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // Contact Attributes
        String attrTenantId = null;
        String attrContactId = null;
        String attrContactListId = null;
        String attrISOTimezoneId = null;
        String attrFullName = null;
        String attrLastName = null;
        String attrFirstName = null;
        String attrCustom = null;
        String attrCustom2 = null;
        String attrCustom3 = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnContactUpdated");

        CFAccXMsgRspnHandler xmsgRspnHandler = (CFAccXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAccSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactId")) {
                if (attrContactId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactListId")) {
                if (attrContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOTimezoneId")) {
                if (attrISOTimezoneId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOTimezoneId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FullName")) {
                if (attrFullName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFullName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("LastName")) {
                if (attrLastName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrLastName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FirstName")) {
                if (attrFirstName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFirstName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom")) {
                if (attrCustom != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom2")) {
                if (attrCustom2 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom2 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom3")) {
                if (attrCustom3 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom3 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrContactId == null) || (attrContactId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactId");
        }
        if ((attrContactListId == null) || (attrContactListId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactListId");
        }
        if (attrFullName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "FullName");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natContactId = Long.parseLong(attrContactId);

        long natContactListId = Long.parseLong(attrContactListId);

        Short natISOTimezoneId;
        if ((attrISOTimezoneId == null) || (attrISOTimezoneId.length() <= 0)) {
            natISOTimezoneId = null;
        } else {
            natISOTimezoneId = new Short(Short.parseShort(attrISOTimezoneId));
        }

        String natFullName = attrFullName;

        String natLastName = attrLastName;

        String natFirstName = attrFirstName;

        String natCustom = attrCustom;

        String natCustom2 = attrCustom2;

        String natCustom3 = attrCustom3;

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFAccContactObj obj = schemaObj.getContactTableObj().newInstance();
        CFAccContactBuff dataBuff = obj.getContactBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredContactId(natContactId);
        dataBuff.setRequiredContactListId(natContactListId);
        dataBuff.setOptionalISOTimezoneId(natISOTimezoneId);
        dataBuff.setRequiredFullName(natFullName);
        dataBuff.setOptionalLastName(natLastName);
        dataBuff.setOptionalFirstName(natFirstName);
        dataBuff.setOptionalCustom(natCustom);
        dataBuff.setOptionalCustom2(natCustom2);
        dataBuff.setOptionalCustom3(natCustom3);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFAccContactObj realized = (ICFAccContactObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRqstHandler.CFGenKbXMsgRqstGenBindUpdateHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {// w w  w  .  j  a  v a2s  . co m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstGenBindUpdate");

        CFGenKbXMsgRqstHandler xmsgRqstHandler = (CFGenKbXMsgRqstHandler) getParser();
        if (xmsgRqstHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Instantiate a PKey buffer for the parsed information
        CFGenKbGenItemPKey pkey = schemaObj.getBackingStore().getFactoryGenItem().newPKey();

        long natTenantId;
        natTenantId = Long.parseLong(attrTenantId);
        pkey.setRequiredTenantId(natTenantId);
        long natCartridgeId;
        natCartridgeId = Long.parseLong(attrCartridgeId);
        pkey.setRequiredCartridgeId(natCartridgeId);
        int natItemId;
        natItemId = Integer.parseInt(attrItemId);
        pkey.setRequiredItemId(natItemId);
        // Read the instance
        ICFGenKbGenBindObj origBuff = schemaObj.getGenBindTableObj().readGenBind(pkey);
        if (origBuff == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getGenBindTableObj().readGenBind()");
        } else {
            // Edit the instance
            ICFGenKbGenBindEditObj editBuff = (ICFGenKbGenBindEditObj) origBuff.beginEdit();
            CFGenKbGenBindBuff dataBuff = editBuff.getGenBindBuff();
            // Convert string attributes to native Java types
            // and apply the converted attributes to the editBuff.
            short natRuleTypeId = Short.parseShort(attrRuleTypeId);

            dataBuff.setRequiredRuleTypeId(natRuleTypeId);

            String natName = attrName;

            dataBuff.setRequiredName(natName);

            short natToolSetId = Short.parseShort(attrToolSetId);

            dataBuff.setRequiredToolSetId(natToolSetId);

            Short natScopeDefId;
            if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
                natScopeDefId = null;
            } else {
                natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
            }

            dataBuff.setOptionalScopeDefId(natScopeDefId);

            short natGenDefId = Short.parseShort(attrGenDefId);

            dataBuff.setRequiredGenDefId(natGenDefId);

            Integer natGelExecutableId;
            if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
                natGelExecutableId = null;
            } else {
                natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
            }

            dataBuff.setOptionalGelExecutableId(natGelExecutableId);

            int natRevision = Integer.parseInt(attrRevision);
            dataBuff.setRequiredRevision(natRevision);
            //   Attempt the update
            editBuff.update();
            editBuff.endEdit();
            String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                    + CFGenKbXMsgGenBindMessageFormatter.formatGenBindRspnUpdated("\n\t\t\t",
                            origBuff.getGenBindBuff())
                    + "\n" + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
            ((CFGenKbXMsgRqstHandler) getParser()).appendResponse(response);
        }
    } catch (RuntimeException e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRspnHandler.CFGCashXMsgRspnContactLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  w ww.jav a 2 s  .  c o  m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // Contact Attributes
        String attrTenantId = null;
        String attrContactId = null;
        String attrContactListId = null;
        String attrISOTimezoneId = null;
        String attrFullName = null;
        String attrLastName = null;
        String attrFirstName = null;
        String attrCustom = null;
        String attrCustom2 = null;
        String attrCustom3 = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnContactLocked");

        CFGCashXMsgRspnHandler xmsgRspnHandler = (CFGCashXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGCashSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactId")) {
                if (attrContactId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactListId")) {
                if (attrContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOTimezoneId")) {
                if (attrISOTimezoneId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOTimezoneId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FullName")) {
                if (attrFullName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFullName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("LastName")) {
                if (attrLastName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrLastName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FirstName")) {
                if (attrFirstName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFirstName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom")) {
                if (attrCustom != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom2")) {
                if (attrCustom2 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom2 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom3")) {
                if (attrCustom3 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom3 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrContactId == null) || (attrContactId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactId");
        }
        if ((attrContactListId == null) || (attrContactListId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactListId");
        }
        if (attrFullName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "FullName");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natContactId = Long.parseLong(attrContactId);

        long natContactListId = Long.parseLong(attrContactListId);

        Short natISOTimezoneId;
        if ((attrISOTimezoneId == null) || (attrISOTimezoneId.length() <= 0)) {
            natISOTimezoneId = null;
        } else {
            natISOTimezoneId = new Short(Short.parseShort(attrISOTimezoneId));
        }

        String natFullName = attrFullName;

        String natLastName = attrLastName;

        String natFirstName = attrFirstName;

        String natCustom = attrCustom;

        String natCustom2 = attrCustom2;

        String natCustom3 = attrCustom3;

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFGCashContactObj obj = schemaObj.getContactTableObj().newInstance();
        CFGCashContactBuff dataBuff = obj.getContactBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredContactId(natContactId);
        dataBuff.setRequiredContactListId(natContactListId);
        dataBuff.setOptionalISOTimezoneId(natISOTimezoneId);
        dataBuff.setRequiredFullName(natFullName);
        dataBuff.setOptionalLastName(natLastName);
        dataBuff.setOptionalFirstName(natFirstName);
        dataBuff.setOptionalCustom(natCustom);
        dataBuff.setOptionalCustom2(natCustom2);
        dataBuff.setOptionalCustom3(natCustom3);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFGCashContactObj realized = (ICFGCashContactObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRspnHandler.CFGCashXMsgRspnContactCreatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  w  ww  .  jav  a2 s  . co  m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // Contact Attributes
        String attrTenantId = null;
        String attrContactId = null;
        String attrContactListId = null;
        String attrISOTimezoneId = null;
        String attrFullName = null;
        String attrLastName = null;
        String attrFirstName = null;
        String attrCustom = null;
        String attrCustom2 = null;
        String attrCustom3 = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnContactCreated");

        CFGCashXMsgRspnHandler xmsgRspnHandler = (CFGCashXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGCashSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactId")) {
                if (attrContactId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactListId")) {
                if (attrContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOTimezoneId")) {
                if (attrISOTimezoneId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOTimezoneId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FullName")) {
                if (attrFullName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFullName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("LastName")) {
                if (attrLastName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrLastName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FirstName")) {
                if (attrFirstName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFirstName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom")) {
                if (attrCustom != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom2")) {
                if (attrCustom2 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom2 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Custom3")) {
                if (attrCustom3 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustom3 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrContactId == null) || (attrContactId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactId");
        }
        if ((attrContactListId == null) || (attrContactListId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactListId");
        }
        if (attrFullName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "FullName");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natContactId = Long.parseLong(attrContactId);

        long natContactListId = Long.parseLong(attrContactListId);

        Short natISOTimezoneId;
        if ((attrISOTimezoneId == null) || (attrISOTimezoneId.length() <= 0)) {
            natISOTimezoneId = null;
        } else {
            natISOTimezoneId = new Short(Short.parseShort(attrISOTimezoneId));
        }

        String natFullName = attrFullName;

        String natLastName = attrLastName;

        String natFirstName = attrFirstName;

        String natCustom = attrCustom;

        String natCustom2 = attrCustom2;

        String natCustom3 = attrCustom3;

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFGCashContactObj obj = schemaObj.getContactTableObj().newInstance();
        CFGCashContactBuff dataBuff = obj.getContactBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredContactId(natContactId);
        dataBuff.setRequiredContactListId(natContactListId);
        dataBuff.setOptionalISOTimezoneId(natISOTimezoneId);
        dataBuff.setRequiredFullName(natFullName);
        dataBuff.setOptionalLastName(natLastName);
        dataBuff.setOptionalFirstName(natFirstName);
        dataBuff.setOptionalCustom(natCustom);
        dataBuff.setOptionalCustom2(natCustom2);
        dataBuff.setOptionalCustom3(natCustom3);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFGCashContactObj realized = (ICFGCashContactObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRqstHandler.CFGenKbXMsgRqstGenIteratorUpdateHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from w w w.ja  v  a 2  s . c  o  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenIterator Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstGenIteratorUpdate");

        CFGenKbXMsgRqstHandler xmsgRqstHandler = (CFGenKbXMsgRqstHandler) getParser();
        if (xmsgRqstHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Instantiate a PKey buffer for the parsed information
        CFGenKbGenItemPKey pkey = schemaObj.getBackingStore().getFactoryGenItem().newPKey();

        long natTenantId;
        natTenantId = Long.parseLong(attrTenantId);
        pkey.setRequiredTenantId(natTenantId);
        long natCartridgeId;
        natCartridgeId = Long.parseLong(attrCartridgeId);
        pkey.setRequiredCartridgeId(natCartridgeId);
        int natItemId;
        natItemId = Integer.parseInt(attrItemId);
        pkey.setRequiredItemId(natItemId);
        // Read the instance
        ICFGenKbGenIteratorObj origBuff = schemaObj.getGenIteratorTableObj().readGenIterator(pkey);
        if (origBuff == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getGenIteratorTableObj().readGenIterator()");
        } else {
            // Edit the instance
            ICFGenKbGenIteratorEditObj editBuff = (ICFGenKbGenIteratorEditObj) origBuff.beginEdit();
            CFGenKbGenIteratorBuff dataBuff = editBuff.getGenIteratorBuff();
            // Convert string attributes to native Java types
            // and apply the converted attributes to the editBuff.
            short natRuleTypeId = Short.parseShort(attrRuleTypeId);

            dataBuff.setRequiredRuleTypeId(natRuleTypeId);

            String natName = attrName;

            dataBuff.setRequiredName(natName);

            short natToolSetId = Short.parseShort(attrToolSetId);

            dataBuff.setRequiredToolSetId(natToolSetId);

            Short natScopeDefId;
            if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
                natScopeDefId = null;
            } else {
                natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
            }

            dataBuff.setOptionalScopeDefId(natScopeDefId);

            short natGenDefId = Short.parseShort(attrGenDefId);

            dataBuff.setRequiredGenDefId(natGenDefId);

            Integer natGelExecutableId;
            if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
                natGelExecutableId = null;
            } else {
                natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
            }

            dataBuff.setOptionalGelExecutableId(natGelExecutableId);

            int natRevision = Integer.parseInt(attrRevision);
            dataBuff.setRequiredRevision(natRevision);
            //   Attempt the update
            editBuff.update();
            editBuff.endEdit();
            String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                    + CFGenKbXMsgGenIteratorMessageFormatter.formatGenIteratorRspnUpdated("\n\t\t\t",
                            origBuff.getGenIteratorBuff())
                    + "\n" + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
            ((CFGenKbXMsgRqstHandler) getParser()).appendResponse(response);
        }
    } catch (RuntimeException e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRqstHandler.CFGenKbXMsgRqstGenReferenceUpdateHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from w  w  w .  ja v a2  s .com
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenReference Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstGenReferenceUpdate");

        CFGenKbXMsgRqstHandler xmsgRqstHandler = (CFGenKbXMsgRqstHandler) getParser();
        if (xmsgRqstHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Instantiate a PKey buffer for the parsed information
        CFGenKbGenItemPKey pkey = schemaObj.getBackingStore().getFactoryGenItem().newPKey();

        long natTenantId;
        natTenantId = Long.parseLong(attrTenantId);
        pkey.setRequiredTenantId(natTenantId);
        long natCartridgeId;
        natCartridgeId = Long.parseLong(attrCartridgeId);
        pkey.setRequiredCartridgeId(natCartridgeId);
        int natItemId;
        natItemId = Integer.parseInt(attrItemId);
        pkey.setRequiredItemId(natItemId);
        // Read the instance
        ICFGenKbGenReferenceObj origBuff = schemaObj.getGenReferenceTableObj().readGenReference(pkey);
        if (origBuff == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getGenReferenceTableObj().readGenReference()");
        } else {
            // Edit the instance
            ICFGenKbGenReferenceEditObj editBuff = (ICFGenKbGenReferenceEditObj) origBuff.beginEdit();
            CFGenKbGenReferenceBuff dataBuff = editBuff.getGenReferenceBuff();
            // Convert string attributes to native Java types
            // and apply the converted attributes to the editBuff.
            short natRuleTypeId = Short.parseShort(attrRuleTypeId);

            dataBuff.setRequiredRuleTypeId(natRuleTypeId);

            String natName = attrName;

            dataBuff.setRequiredName(natName);

            short natToolSetId = Short.parseShort(attrToolSetId);

            dataBuff.setRequiredToolSetId(natToolSetId);

            Short natScopeDefId;
            if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
                natScopeDefId = null;
            } else {
                natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
            }

            dataBuff.setOptionalScopeDefId(natScopeDefId);

            short natGenDefId = Short.parseShort(attrGenDefId);

            dataBuff.setRequiredGenDefId(natGenDefId);

            Integer natGelExecutableId;
            if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
                natGelExecutableId = null;
            } else {
                natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
            }

            dataBuff.setOptionalGelExecutableId(natGelExecutableId);

            int natRevision = Integer.parseInt(attrRevision);
            dataBuff.setRequiredRevision(natRevision);
            //   Attempt the update
            editBuff.update();
            editBuff.endEdit();
            String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                    + CFGenKbXMsgGenReferenceMessageFormatter.formatGenReferenceRspnUpdated("\n\t\t\t",
                            origBuff.getGenReferenceBuff())
                    + "\n" + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
            ((CFGenKbXMsgRqstHandler) getParser()).appendResponse(response);
        }
    } catch (RuntimeException e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRqstHandler.CFGenKbXMsgRqstGenFormatterUpdateHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  w w  w  .ja v a2 s  . c  o  m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstGenFormatterUpdate");

        CFGenKbXMsgRqstHandler xmsgRqstHandler = (CFGenKbXMsgRqstHandler) getParser();
        if (xmsgRqstHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Instantiate a PKey buffer for the parsed information
        CFGenKbGenItemPKey pkey = schemaObj.getBackingStore().getFactoryGenItem().newPKey();

        long natTenantId;
        natTenantId = Long.parseLong(attrTenantId);
        pkey.setRequiredTenantId(natTenantId);
        long natCartridgeId;
        natCartridgeId = Long.parseLong(attrCartridgeId);
        pkey.setRequiredCartridgeId(natCartridgeId);
        int natItemId;
        natItemId = Integer.parseInt(attrItemId);
        pkey.setRequiredItemId(natItemId);
        // Read the instance
        ICFGenKbGenFormatterObj origBuff = schemaObj.getGenFormatterTableObj().readGenFormatter(pkey);
        if (origBuff == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getGenFormatterTableObj().readGenFormatter()");
        } else {
            // Edit the instance
            ICFGenKbGenFormatterEditObj editBuff = (ICFGenKbGenFormatterEditObj) origBuff.beginEdit();
            CFGenKbGenFormatterBuff dataBuff = editBuff.getGenFormatterBuff();
            // Convert string attributes to native Java types
            // and apply the converted attributes to the editBuff.
            short natRuleTypeId = Short.parseShort(attrRuleTypeId);

            dataBuff.setRequiredRuleTypeId(natRuleTypeId);

            String natName = attrName;

            dataBuff.setRequiredName(natName);

            short natToolSetId = Short.parseShort(attrToolSetId);

            dataBuff.setRequiredToolSetId(natToolSetId);

            Short natScopeDefId;
            if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
                natScopeDefId = null;
            } else {
                natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
            }

            dataBuff.setOptionalScopeDefId(natScopeDefId);

            short natGenDefId = Short.parseShort(attrGenDefId);

            dataBuff.setRequiredGenDefId(natGenDefId);

            Integer natGelExecutableId;
            if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
                natGelExecutableId = null;
            } else {
                natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
            }

            dataBuff.setOptionalGelExecutableId(natGelExecutableId);

            int natRevision = Integer.parseInt(attrRevision);
            dataBuff.setRequiredRevision(natRevision);
            //   Attempt the update
            editBuff.update();
            editBuff.endEdit();
            String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                    + CFGenKbXMsgGenFormatterMessageFormatter.formatGenFormatterRspnUpdated("\n\t\t\t",
                            origBuff.getGenFormatterBuff())
                    + "\n" + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
            ((CFGenKbXMsgRqstHandler) getParser()).appendResponse(response);
        }
    } catch (RuntimeException e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFGenKbXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFGenKbXMsgRqstHandler xmsgRqstHandler = ((CFGenKbXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnAddressLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {// w  w w  .  ja va2 s.c o  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // Address Attributes
        String attrTenantId = null;
        String attrAddressId = null;
        String attrContactId = null;
        String attrDescription = null;
        String attrAddrLine1 = null;
        String attrAddrLine2 = null;
        String attrCity = null;
        String attrState = null;
        String attrCountryId = null;
        String attrZip = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnAddressLocked");

        CFAccXMsgRspnHandler xmsgRspnHandler = (CFAccXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAccSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("AddressId")) {
                if (attrAddressId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrAddressId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactId")) {
                if (attrContactId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Description")) {
                if (attrDescription != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrDescription = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("AddrLine1")) {
                if (attrAddrLine1 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrAddrLine1 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("AddrLine2")) {
                if (attrAddrLine2 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrAddrLine2 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("City")) {
                if (attrCity != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCity = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("State")) {
                if (attrState != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrState = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CountryId")) {
                if (attrCountryId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCountryId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Zip")) {
                if (attrZip != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrZip = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrAddressId == null) || (attrAddressId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "AddressId");
        }
        if ((attrContactId == null) || (attrContactId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactId");
        }
        if (attrDescription == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Description");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natAddressId = Long.parseLong(attrAddressId);

        long natContactId = Long.parseLong(attrContactId);

        String natDescription = attrDescription;

        String natAddrLine1 = attrAddrLine1;

        String natAddrLine2 = attrAddrLine2;

        String natCity = attrCity;

        String natState = attrState;

        Short natCountryId;
        if ((attrCountryId == null) || (attrCountryId.length() <= 0)) {
            natCountryId = null;
        } else {
            natCountryId = new Short(Short.parseShort(attrCountryId));
        }

        String natZip = attrZip;

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFAccAddressObj obj = schemaObj.getAddressTableObj().newInstance();
        CFAccAddressBuff dataBuff = obj.getAddressBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredAddressId(natAddressId);
        dataBuff.setRequiredContactId(natContactId);
        dataBuff.setRequiredDescription(natDescription);
        dataBuff.setOptionalAddrLine1(natAddrLine1);
        dataBuff.setOptionalAddrLine2(natAddrLine2);
        dataBuff.setOptionalCity(natCity);
        dataBuff.setOptionalState(natState);
        dataBuff.setOptionalCountryId(natCountryId);
        dataBuff.setOptionalZip(natZip);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFAccAddressObj realized = (ICFAccAddressObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}