Example usage for java.util SortedMap put

List of usage examples for java.util SortedMap put

Introduction

In this page you can find the example usage for java.util SortedMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.epl.ticketws.services.QueryService.java

/**
 * This method generates the string to be signed based on the following rules:
 *
 *  - Add the request method + \n//  w ww  .  j  av  a 2s  .  c om
 *  - Add the timestamp + \n
 *  - Add the request URI
 *  - For each request parameter ordered alphabetically:
 *    - First parameter delimiter ?
 *    - Other parameters separated by &
 *    - Name of the parameter
 *    - Add = sign
 *    - value of the parameter
 *
 * For example:
 *
 *   Given a GET request with timestamp = 1316430943576 and uri = /uri_path/ejemplo with parameters,
 *     Bc = 'Prueba1'
 *     Aa = 'Prueba2'
 *     bc = 'aPrueba3'
 *     z1 = 'prueba4'
 *
 *   The String to sign is:
 *
 *     GET\n1316430943576\n/uri_path/ejemplo?amp;Aa=Prueba2&bc=aPrueba3&Bc=Prueba1&z1=prueba4
 *
 * @param uri
 * @param method
 * @param timestamp
 * @return
 * @throws SignatureException
 */
private String getStringToSign(URI uri, String method, long timestamp, Map<String, String> params)
        throws SignatureException {

    SortedMap<String, String> sortedMap = new TreeMap<String, String>();

    // Assuming GET. It actually processes URL parameters for all Method types
    if (uri.getRawQuery() != null) {

        StringTokenizer tokenizer = null;
        try {
            tokenizer = new StringTokenizer(URLDecoder.decode(uri.getRawQuery(), UTF_8), PARAMETERS_SEPARATOR);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        while (tokenizer.hasMoreElements()) {
            String token = tokenizer.nextToken();
            sortedMap.put(token.split(PARAM_NAME_VALUE_SEPARATOR)[0].toLowerCase()
                    + token.split(PARAM_NAME_VALUE_SEPARATOR)[1], token);
        }
    }

    // If POST process parameter map
    if (method.equals(HttpMethod.POST.name())) {
        for (String key : params.keySet()) {
            String valor = params.get(key);
            sortedMap.put(key.toLowerCase() + PARAM_NAME_VALUE_SEPARATOR + valor,
                    key + PARAM_NAME_VALUE_SEPARATOR + valor);
        }

    }
    // Generating String to sign
    StringBuilder stringToSign = new StringBuilder();
    stringToSign.append(method);
    stringToSign.append(HMAC_FIELD_SEPARATOR).append(timestamp);
    stringToSign.append(HMAC_FIELD_SEPARATOR).append(uri.getPath());

    boolean firstParam = true;

    for (String param : sortedMap.values()) {
        if (firstParam) {
            stringToSign.append(URI_PARAMETERS_SEPARATOR).append(param);
            firstParam = false;
        } else {
            stringToSign.append(PARAMETERS_SEPARATOR).append(param);
        }
    }

    return stringToSign.toString();
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamTldTable.java

public void createTld(CFAccAuthorization Authorization, CFAccTldBuff Buff) {
    CFAccTldPKey pkey = schema.getFactoryTld().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTLDId(((CFAccRamTenantTable) schema.getTableTenant()).nextTLDIdGen(Authorization,
            Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredTLDId(pkey.getRequiredTLDId());
    CFAccTldByTenantIdxKey keyTenantIdx = schema.getFactoryTld().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccTldByNameIdxKey keyNameIdx = schema.getFactoryTld().newNameIdxKey();
    keyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyNameIdx.setRequiredName(Buff.getRequiredName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTld", pkey);
    }/*from  w  w  w.j  av a 2s  .  co m*/

    if (dictByNameIdx.containsKey(keyNameIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTld",
                "TLDNameIdx", keyNameIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTld",
                        "Container", "Tenant", "Tenant", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAccTldPKey, CFAccTldBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
        subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
        subdictTenantIdx = new TreeMap<CFAccTldPKey, CFAccTldBuff>();
        dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    dictByNameIdx.put(keyNameIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamTldTable.java

public void createTld(CFAstAuthorization Authorization, CFAstTldBuff Buff) {
    CFAstTldPKey pkey = schema.getFactoryTld().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTLDId(((CFAstRamTenantTable) schema.getTableTenant()).nextTLDIdGen(Authorization,
            Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredTLDId(pkey.getRequiredTLDId());
    CFAstTldByTenantIdxKey keyTenantIdx = schema.getFactoryTld().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAstTldByNameIdxKey keyNameIdx = schema.getFactoryTld().newNameIdxKey();
    keyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyNameIdx.setRequiredName(Buff.getRequiredName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTld", pkey);
    }//from   ww  w  . j a  v a 2  s .co  m

    if (dictByNameIdx.containsKey(keyNameIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTld",
                "TLDNameIdx", keyNameIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTld",
                        "Container", "Tenant", "Tenant", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAstTldPKey, CFAstTldBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
        subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
        subdictTenantIdx = new TreeMap<CFAstTldPKey, CFAstTldBuff>();
        dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    dictByNameIdx.put(keyNameIdx, Buff);

}

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

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {// ww  w  . ja  v a2  s .  c  o  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOTimezone Attributes
        String attrISOTimezoneId = null;
        String attrIso8601 = null;
        String attrTZName = null;
        String attrTZHourOffset = null;
        String attrTZMinOffset = null;
        String attrDescription = null;
        String attrVisible = 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("ISOTimezone");

        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("ISOTimezoneId")) {
                if (attrISOTimezoneId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOTimezoneId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Iso8601")) {
                if (attrIso8601 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrIso8601 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TZName")) {
                if (attrTZName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTZName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TZHourOffset")) {
                if (attrTZHourOffset != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTZHourOffset = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TZMinOffset")) {
                if (attrTZMinOffset != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTZMinOffset = 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("Visible")) {
                if (attrVisible != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrVisible = 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 ((attrISOTimezoneId == null) || (attrISOTimezoneId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOTimezoneId");
        }
        if (attrIso8601 == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Iso8601");
        }
        if (attrTZName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TZName");
        }
        if ((attrTZHourOffset == null) || (attrTZHourOffset.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TZHourOffset");
        }
        if ((attrTZMinOffset == null) || (attrTZMinOffset.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TZMinOffset");
        }
        if (attrDescription == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Description");
        }
        if ((attrVisible == null) || (attrVisible.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Visible");
        }

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

        // Convert string attributes to native Java types

        short natISOTimezoneId = Short.parseShort(attrISOTimezoneId);

        String natIso8601 = attrIso8601;

        String natTZName = attrTZName;

        short natTZHourOffset = Short.parseShort(attrTZHourOffset);

        short natTZMinOffset = Short.parseShort(attrTZMinOffset);

        String natDescription = attrDescription;

        boolean natVisible;
        if (attrVisible.equals("true") || attrVisible.equals("yes") || attrVisible.equals("1")) {
            natVisible = true;
        } else if (attrVisible.equals("false") || attrVisible.equals("no") || attrVisible.equals("0")) {
            natVisible = false;
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Unexpected Visible value, must be one of true, false, yes, no, 1, or 0, not \""
                            + attrVisible + "\"");
        }

        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);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAccISOTimezoneObj obj = schemaObj.getISOTimezoneTableObj().newInstance();
        CFAccISOTimezoneBuff dataBuff = obj.getISOTimezoneBuff();
        dataBuff.setRequiredISOTimezoneId(natISOTimezoneId);
        dataBuff.setRequiredIso8601(natIso8601);
        dataBuff.setRequiredTZName(natTZName);
        dataBuff.setRequiredTZHourOffset(natTZHourOffset);
        dataBuff.setRequiredTZMinOffset(natTZMinOffset);
        dataBuff.setRequiredDescription(natDescription);
        dataBuff.setRequiredVisible(natVisible);
        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();
        SortedMap<CFAccISOTimezonePKey, ICFAccISOTimezoneObj> sortedMap = (SortedMap<CFAccISOTimezonePKey, ICFAccISOTimezoneObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAccISOTimezoneObj realized = (ICFAccISOTimezoneObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.cfasterisk.v2_0.CFAstXMsgRspnHandler.CFAstXMsgRspnISOTimezoneRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*w w  w .j  av  a 2 s  .  co  m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOTimezone Attributes
        String attrISOTimezoneId = null;
        String attrIso8601 = null;
        String attrTZName = null;
        String attrTZHourOffset = null;
        String attrTZMinOffset = null;
        String attrDescription = null;
        String attrVisible = 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("ISOTimezone");

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

        ICFAstSchemaObj 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("ISOTimezoneId")) {
                if (attrISOTimezoneId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOTimezoneId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Iso8601")) {
                if (attrIso8601 != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrIso8601 = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TZName")) {
                if (attrTZName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTZName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TZHourOffset")) {
                if (attrTZHourOffset != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTZHourOffset = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TZMinOffset")) {
                if (attrTZMinOffset != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTZMinOffset = 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("Visible")) {
                if (attrVisible != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrVisible = 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 ((attrISOTimezoneId == null) || (attrISOTimezoneId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOTimezoneId");
        }
        if (attrIso8601 == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Iso8601");
        }
        if (attrTZName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TZName");
        }
        if ((attrTZHourOffset == null) || (attrTZHourOffset.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TZHourOffset");
        }
        if ((attrTZMinOffset == null) || (attrTZMinOffset.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TZMinOffset");
        }
        if (attrDescription == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Description");
        }
        if ((attrVisible == null) || (attrVisible.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Visible");
        }

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

        // Convert string attributes to native Java types

        short natISOTimezoneId = Short.parseShort(attrISOTimezoneId);

        String natIso8601 = attrIso8601;

        String natTZName = attrTZName;

        short natTZHourOffset = Short.parseShort(attrTZHourOffset);

        short natTZMinOffset = Short.parseShort(attrTZMinOffset);

        String natDescription = attrDescription;

        boolean natVisible;
        if (attrVisible.equals("true") || attrVisible.equals("yes") || attrVisible.equals("1")) {
            natVisible = true;
        } else if (attrVisible.equals("false") || attrVisible.equals("no") || attrVisible.equals("0")) {
            natVisible = false;
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Unexpected Visible value, must be one of true, false, yes, no, 1, or 0, not \""
                            + attrVisible + "\"");
        }

        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);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAstISOTimezoneObj obj = schemaObj.getISOTimezoneTableObj().newInstance();
        CFAstISOTimezoneBuff dataBuff = obj.getISOTimezoneBuff();
        dataBuff.setRequiredISOTimezoneId(natISOTimezoneId);
        dataBuff.setRequiredIso8601(natIso8601);
        dataBuff.setRequiredTZName(natTZName);
        dataBuff.setRequiredTZHourOffset(natTZHourOffset);
        dataBuff.setRequiredTZMinOffset(natTZMinOffset);
        dataBuff.setRequiredDescription(natDescription);
        dataBuff.setRequiredVisible(natVisible);
        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();
        SortedMap<CFAstISOTimezonePKey, ICFAstISOTimezoneObj> sortedMap = (SortedMap<CFAstISOTimezonePKey, ICFAstISOTimezoneObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAstISOTimezoneObj realized = (ICFAstISOTimezoneObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.CFAccRam.CFAccRamURLProtocolTable.java

public void createURLProtocol(CFAccAuthorization Authorization, CFAccURLProtocolBuff Buff) {
    CFAccURLProtocolPKey pkey = schema.getFactoryURLProtocol().newPKey();
    pkey.setRequiredURLProtocolId(Buff.getRequiredURLProtocolId());
    Buff.setRequiredURLProtocolId(pkey.getRequiredURLProtocolId());
    CFAccURLProtocolByUNameIdxKey keyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    keyUNameIdx.setRequiredName(Buff.getRequiredName());

    CFAccURLProtocolByIsSecureIdxKey keyIsSecureIdx = schema.getFactoryURLProtocol().newIsSecureIdxKey();
    keyIsSecureIdx.setRequiredIsSecure(Buff.getRequiredIsSecure());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createURLProtocol",
                pkey);/* www  .j  a va 2s.  co  m*/
    }

    if (dictByUNameIdx.containsKey(keyUNameIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                "createURLProtocol", "URLProtocolUNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);

    SortedMap<CFAccURLProtocolPKey, CFAccURLProtocolBuff> subdictIsSecureIdx;
    if (dictByIsSecureIdx.containsKey(keyIsSecureIdx)) {
        subdictIsSecureIdx = dictByIsSecureIdx.get(keyIsSecureIdx);
    } else {
        subdictIsSecureIdx = new TreeMap<CFAccURLProtocolPKey, CFAccURLProtocolBuff>();
        dictByIsSecureIdx.put(keyIsSecureIdx, subdictIsSecureIdx);
    }
    subdictIsSecureIdx.put(pkey, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamURLProtocolTable.java

public void createURLProtocol(CFAstAuthorization Authorization, CFAstURLProtocolBuff Buff) {
    CFAstURLProtocolPKey pkey = schema.getFactoryURLProtocol().newPKey();
    pkey.setRequiredURLProtocolId(Buff.getRequiredURLProtocolId());
    Buff.setRequiredURLProtocolId(pkey.getRequiredURLProtocolId());
    CFAstURLProtocolByUNameIdxKey keyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    keyUNameIdx.setRequiredName(Buff.getRequiredName());

    CFAstURLProtocolByIsSecureIdxKey keyIsSecureIdx = schema.getFactoryURLProtocol().newIsSecureIdxKey();
    keyIsSecureIdx.setRequiredIsSecure(Buff.getRequiredIsSecure());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createURLProtocol",
                pkey);// ww  w. jav a2 s  .c o  m
    }

    if (dictByUNameIdx.containsKey(keyUNameIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                "createURLProtocol", "URLProtocolUNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);

    SortedMap<CFAstURLProtocolPKey, CFAstURLProtocolBuff> subdictIsSecureIdx;
    if (dictByIsSecureIdx.containsKey(keyIsSecureIdx)) {
        subdictIsSecureIdx = dictByIsSecureIdx.get(keyIsSecureIdx);
    } else {
        subdictIsSecureIdx = new TreeMap<CFAstURLProtocolPKey, CFAstURLProtocolBuff>();
        dictByIsSecureIdx.put(keyIsSecureIdx, subdictIsSecureIdx);
    }
    subdictIsSecureIdx.put(pkey, Buff);

}

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

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from   w w w  .  j a  v  a 2s  .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("Address");

        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");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = xmsgRspnHandler.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);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // 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();
        SortedMap<CFAccAddressPKey, ICFAccAddressObj> sortedMap = (SortedMap<CFAccAddressPKey, ICFAccAddressObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAccAddressObj realized = (ICFAccAddressObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.CFAccXMsgRspnContactRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//w w  w  .  java  2s. 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("Contact");

        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");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = xmsgRspnHandler.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);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // 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();
        SortedMap<CFAccContactPKey, ICFAccContactObj> sortedMap = (SortedMap<CFAccContactPKey, ICFAccContactObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAccContactObj realized = (ICFAccContactObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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);
    }
}