public void actionPerformed(ActionEvent e) { final String S_ProcName = "actionPerformed"; ICFCrmSchemaObj schemaObj = swingSchema.getSchema(); ICFCrmSecGroupMemberObj obj = (ICFCrmSecGroupMemberObj) schemaObj.getSecGroupMemberTableObj().newInstance(); JInternalFrame frame = swingSchema.getSecGroupMemberFactory().newViewEditJInternalFrame(obj); frame.addInternalFrameListener(getViewEditInternalFrameListener()); ICFCrmSecGroupMemberEditObj edit = (ICFCrmSecGroupMemberEditObj) (obj.beginEdit()); if (edit == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "edit"); } ICFSecurityClusterObj secCluster = schemaObj.getSecCluster(); edit.setRequiredOwnerCluster(secCluster); ICFCrmSecGroupObj container = (ICFCrmSecGroupObj) (getSwingContainer()); if (container == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "SwingContainer"); } edit.setRequiredContainerGroup(container); ICFCrmSwingSecGroupMemberJPanelCommon jpanelCommon = (ICFCrmSwingSecGroupMemberJPanelCommon) frame; jpanelCommon.setPanelMode(CFJPanel.PanelMode.Add); Container cont = getParent(); while ((cont != null) && (!(cont instanceof JInternalFrame))) { cont = cont.getParent(); } if (cont != null) { JInternalFrame myInternalFrame = (JInternalFrame) cont; myInternalFrame.getDesktopPane().add(frame); frame.setVisible(true); frame.show(); } }
public List<ICFCrmMemoObj> readAllMemo(boolean forceRead) { final String S_ProcName = "readAllMemo"; if ((allMemo == null) || forceRead) { Map<CFCrmMemoPKey, ICFCrmMemoObj> map = new HashMap<CFCrmMemoPKey, ICFCrmMemoObj>(); allMemo = map; CFCrmMemoBuff[] buffList = ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .readAllDerived(schema.getAuthorization()); CFCrmMemoBuff buff; ICFCrmMemoObj obj; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey()); obj.setBuff(buff); ICFCrmMemoObj realized = (ICFCrmMemoObj) obj.realize(); } } Comparator<ICFCrmMemoObj> cmp = new Comparator<ICFCrmMemoObj>() { public int compare(ICFCrmMemoObj lhs, ICFCrmMemoObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFCrmMemoPKey lhsPKey = lhs.getPKey(); CFCrmMemoPKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = allMemo.size(); ICFCrmMemoObj arr[] = new ICFCrmMemoObj[len]; Iterator<ICFCrmMemoObj> valIter = allMemo.values().iterator(); int idx = 0; while ((idx < len) && valIter.hasNext()) { arr[idx++] = valIter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len); } else if (valIter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len); } Arrays.sort(arr, cmp); ArrayList<ICFCrmMemoObj> arrayList = new ArrayList<ICFCrmMemoObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFCrmMemoObj> sortedList = arrayList; return (sortedList); }
public void deleteMemo(ICFCrmMemoObj Obj) { ICFCrmMemoObj obj = Obj; ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .deleteMemo(schema.getAuthorization(), obj.getMemoBuff()); obj.forget(true); }
public void deleteMemoByMemoContactIdx(long TenantId, long ContactId) { CFCrmMemoByMemoContactIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredContactId(ContactId); if (indexByMemoContactIdx == null) { indexByMemoContactIdx = new HashMap<CFCrmMemoByMemoContactIdxKey, Map<CFCrmMemoPKey, ICFCrmMemoObj>>(); } if (indexByMemoContactIdx.containsKey(key)) { Map<CFCrmMemoPKey, ICFCrmMemoObj> dict = indexByMemoContactIdx.get(key); ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .deleteMemoByMemoContactIdx(schema.getAuthorization(), TenantId, ContactId); Iterator<ICFCrmMemoObj> iter = dict.values().iterator(); ICFCrmMemoObj obj; List<ICFCrmMemoObj> toForget = new LinkedList<ICFCrmMemoObj>(); while (iter.hasNext()) { obj = iter.next(); toForget.add(obj); } iter = toForget.iterator(); while (iter.hasNext()) { obj = iter.next(); obj.forget(true); } indexByMemoContactIdx.remove(key); } else { ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .deleteMemoByMemoContactIdx(schema.getAuthorization(), TenantId, ContactId); } }
public ICFCrmMemoObj updateMemo(ICFCrmMemoObj Obj) { ICFCrmMemoObj obj = Obj; ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .updateMemo(schema.getAuthorization(), Obj.getMemoBuff()); obj = (ICFCrmMemoObj) Obj.realize(); return (obj); }
public ICFCrmMemoObj createMemo(ICFCrmMemoObj Obj) { ICFCrmMemoObj obj = Obj; CFCrmMemoBuff buff = obj.getMemoBuff(); ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .createMemo(schema.getAuthorization(), buff); obj.copyBuffToPKey(); obj = obj.realize(); return (obj); }
public void forgetMemo(ICFCrmMemoObj Obj, boolean forgetSubObjects) { ICFCrmMemoObj obj = Obj; CFCrmMemoPKey pkey = obj.getPKey(); if (members.containsKey(pkey)) { ICFCrmMemoObj keepObj = members.get(pkey); // Detach object from alternate, duplicate, all and PKey indexes if (indexByTenantIdx != null) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.remove(keepObj.getPKey()); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.remove(keepObj.getPKey()); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.remove(keyUDescrIdx); } if (allMemo != null) { allMemo.remove(keepObj.getPKey()); } members.remove(pkey); if (forgetSubObjects) { ((ICFCrmSchemaObj) schema) .getMemoTagTableObj() .forgetMemoTagByMemoIdx(keepObj.getRequiredTenantId(), keepObj.getRequiredMemoId()); } } }
public void forgetMemoByMemoContactIdx(long TenantId, long ContactId) { if (indexByMemoContactIdx == null) { return; } CFCrmMemoByMemoContactIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredContactId(ContactId); if (indexByMemoContactIdx.containsKey(key)) { Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(key); if (mapMemoContactIdx != null) { List<ICFCrmMemoObj> toForget = new LinkedList<ICFCrmMemoObj>(); ICFCrmMemoObj cur = null; Iterator<ICFCrmMemoObj> iter = mapMemoContactIdx.values().iterator(); while (iter.hasNext()) { cur = iter.next(); toForget.add(cur); } iter = toForget.iterator(); while (iter.hasNext()) { cur = iter.next(); cur.forget(true); } } indexByMemoContactIdx.remove(key); } }
public ICFCrmMemoObj readMemoByIdIdx(long TenantId, long MemoId, boolean forceRead) { CFCrmMemoPKey pkey = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey(); pkey.setRequiredTenantId(TenantId); pkey.setRequiredMemoId(MemoId); ICFCrmMemoObj obj = readMemo(pkey, forceRead); return (obj); }
public void deleteMemoByIdIdx(long TenantId, long MemoId) { CFCrmMemoPKey pkey = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey(); pkey.setRequiredTenantId(TenantId); pkey.setRequiredMemoId(MemoId); ICFCrmMemoObj obj = readMemo(pkey); if (obj != null) { ICFCrmMemoEditObj editObj = (ICFCrmMemoEditObj) obj.getEdit(); boolean editStarted; if (editObj == null) { editObj = (ICFCrmMemoEditObj) obj.beginEdit(); if (editObj != null) { editStarted = true; } else { editStarted = false; } } else { editStarted = false; } if (editObj != null) { editObj.delete(); if (editStarted) { editObj.endEdit(); } } obj.forget(true); } }
public ICFCrmMemoObj lockMemo(CFCrmMemoPKey pkey) { ICFCrmMemoObj locked = null; CFCrmMemoBuff lockBuff = ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .lockDerived(schema.getAuthorization(), pkey); if (lockBuff != null) { locked = schema.getMemoTableObj().newInstance(); locked.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey()); locked.setBuff(lockBuff); locked = (ICFCrmMemoObj) locked.realize(); } else { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "lockMemo", pkey); } return (locked); }
public CFCrmMemoBuff getBuff() { if (buff == null) { if (isNew) { buff = ((ICFCrmSchema) schema.getBackingStore()).getFactoryMemo().newBuff(); } else { // Read the data buff via the backing store buff = ((ICFCrmSchema) schema.getBackingStore()) .getTableMemo() .readDerivedByIdIdx( ((ICFCrmSchemaObj) schema).getAuthorization(), getPKey().getRequiredTenantId(), getPKey().getRequiredMemoId()); if (buff != null) { copyBuffToPKey(); } } } return (buff); }
public ICFCrmMemoObj readMemo(CFCrmMemoPKey pkey, boolean forceRead) { ICFCrmMemoObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFCrmMemoBuff readBuff = ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .readDerivedByIdIdx( schema.getAuthorization(), pkey.getRequiredTenantId(), pkey.getRequiredMemoId()); if (readBuff != null) { obj = schema.getMemoTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey()); obj.setBuff(readBuff); obj = (ICFCrmMemoObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public ICFCrmMemoObj readMemoByUDescrIdx( long TenantId, long ContactId, String Description, boolean forceRead) { if (indexByUDescrIdx == null) { indexByUDescrIdx = new HashMap<CFCrmMemoByUDescrIdxKey, ICFCrmMemoObj>(); } CFCrmMemoByUDescrIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredContactId(ContactId); key.setRequiredDescription(Description); ICFCrmMemoObj obj = null; if ((!forceRead) && indexByUDescrIdx.containsKey(key)) { obj = indexByUDescrIdx.get(key); } else { CFCrmMemoBuff buff = ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .readDerivedByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description); if (buff != null) { obj = schema.getMemoTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey()); obj.setBuff(buff); obj = (ICFCrmMemoObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByUDescrIdx.put(key, null); } } return (obj); }
public void actionPerformed(ActionEvent e) { final String S_ProcName = "actionPerformed"; ICFCrmSchemaObj schemaObj = swingSchema.getSchema(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj"); } ICFCrmServiceTypeObj obj = (ICFCrmServiceTypeObj) schemaObj.getServiceTypeTableObj().newInstance(); ICFCrmServiceTypeEditObj edit = (ICFCrmServiceTypeEditObj) (obj.beginEdit()); if (edit == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "edit"); } JInternalFrame frame = swingSchema.getServiceTypeFactory().newViewEditJInternalFrame(obj); frame.addInternalFrameListener(getViewEditInternalFrameListener()); ICFCrmSwingServiceTypeJPanelCommon jpanelCommon = (ICFCrmSwingServiceTypeJPanelCommon) frame; jpanelCommon.setPanelMode(CFJPanel.PanelMode.Add); getDesktopPane().add(frame); frame.setVisible(true); frame.show(); }
public void deleteMemoByUDescrIdx(long TenantId, long ContactId, String Description) { if (indexByUDescrIdx == null) { indexByUDescrIdx = new HashMap<CFCrmMemoByUDescrIdxKey, ICFCrmMemoObj>(); } CFCrmMemoByUDescrIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredContactId(ContactId); key.setRequiredDescription(Description); ICFCrmMemoObj obj = null; if (indexByUDescrIdx.containsKey(key)) { obj = indexByUDescrIdx.get(key); ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .deleteMemoByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description); obj.forget(true); } else { ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .deleteMemoByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description); } }
public void forgetMemoByIdIdx(long TenantId, long MemoId) { if (members == null) { return; } CFCrmMemoPKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey(); key.setRequiredTenantId(TenantId); key.setRequiredMemoId(MemoId); if (members.containsKey(key)) { ICFCrmMemoObj probed = members.get(key); if (probed != null) { probed.forget(true); } } }
public void forgetMemoByUDescrIdx(long TenantId, long ContactId, String Description) { if (indexByUDescrIdx == null) { return; } CFCrmMemoByUDescrIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredContactId(ContactId); key.setRequiredDescription(Description); if (indexByUDescrIdx.containsKey(key)) { ICFCrmMemoObj probed = indexByUDescrIdx.get(key); if (probed != null) { probed.forget(true); } indexByUDescrIdx.remove(key); } }
public void forget(boolean forgetSubObjects) { ((ICFCrmSchemaObj) schema) .getPhoneTableObj() .forgetPhone((ICFCrmPhoneObj) this, forgetSubObjects); }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFCrmXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; String attrClusterId = null; String attrSecGroupId = null; String attrSecUserId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecGroupMemberDeleteByUUserIdx"); CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFCrmSchemaObj 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("ClusterId")) { if (attrClusterId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrClusterId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecGroupId")) { if (attrSecGroupId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecGroupId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecUserId")) { if (attrSecUserId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecUserId = 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 ((attrClusterId == null) || (attrClusterId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "ClusterId"); } if ((attrSecGroupId == null) || (attrSecGroupId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "SecGroupId"); } if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types long natClusterId; natClusterId = Long.parseLong(attrClusterId); int natSecGroupId; natSecGroupId = Integer.parseInt(attrSecGroupId); UUID natSecUserId; if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { natSecUserId = null; } else { natSecUserId = UUID.fromString(attrSecUserId); } // Delete the objects schemaObj .getSecGroupMemberTableObj() .deleteSecGroupMemberByUUserIdx(natClusterId, natSecGroupId, natSecUserId); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRspnDeleted() + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFCrmXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; String attrRevision = null; // Primary Key Attributes for Constant Enum support String attrSecSessionId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecSessionDelete"); CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFCrmSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Instantiate a PKey buffer for the parsed information CFSecuritySecSessionPKey pkey = ((ICFCrmSchema) schemaObj.getBackingStore()).getFactorySecSession().newPKey(); // 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("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = 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 ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } if ((attrRevision == null) || (attrRevision.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Revision"); } // Get current context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. UUID natSecSessionId; if ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { natSecSessionId = null; } else { natSecSessionId = UUID.fromString(attrSecSessionId); } pkey.setRequiredSecSessionId(natSecSessionId); pkey.setRequiredSecSessionId(natSecSessionId); int natRevision = Integer.parseInt(attrRevision); // Delete the object ICFCrmSecSessionObj read = ((ICFCrmSecSessionObj) schemaObj.getSecSessionTableObj().readSecSession(pkey)); if (read != null) { if (read.getSecSessionBuff().getRequiredRevision() > natRevision) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException( getClass(), S_ProcName, "Collision detected preparing to delete SecSession"); } else { ICFCrmSecSessionEditObj editBuff = (ICFCrmSecSessionEditObj) read.beginEdit(); if (editBuff != null) { editBuff.delete(); editBuff.endEdit(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSecSessionMessageFormatter.formatSecSessionRspnDeleted() + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } else { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "read.beginEdit()"); } } } else { String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnNoDataFound() + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } } catch (RuntimeException e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; String attrRevision = null; // SecUser Attributes String attrSecUserId = null; String attrLoginId = null; String attrEMailAddress = null; String attrEMailConfirmationUuid = null; String attrDefaultDevSecUserId = null; String attrDefaultDevName = null; String attrPasswordHash = null; String attrPasswordResetUuid = 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("RspnSecUserCreated"); CFCrmXMsgRspnHandler xmsgRspnHandler = (CFCrmXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFCrmSchemaObj 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("SecUserId")) { if (attrSecUserId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecUserId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("LoginId")) { if (attrLoginId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrLoginId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EMailAddress")) { if (attrEMailAddress != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEMailAddress = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EMailConfirmationUuid")) { if (attrEMailConfirmationUuid != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEMailConfirmationUuid = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultDevSecUserId")) { if (attrDefaultDevSecUserId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultDevSecUserId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultDevName")) { if (attrDefaultDevName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultDevName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("PasswordHash")) { if (attrPasswordHash != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrPasswordHash = attrs.getValue(idxAttr); } else if (attrLocalName.equals("PasswordResetUuid")) { if (attrPasswordResetUuid != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrPasswordResetUuid = 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 ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId"); } if (attrLoginId == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "LoginId"); } if (attrEMailAddress == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "EMailAddress"); } if (attrPasswordHash == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "PasswordHash"); } 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 UUID natSecUserId = UUID.fromString(attrSecUserId); String natLoginId = attrLoginId; String natEMailAddress = attrEMailAddress; UUID natEMailConfirmationUuid; if ((attrEMailConfirmationUuid == null) || (attrEMailConfirmationUuid.length() <= 0)) { natEMailConfirmationUuid = null; } else { natEMailConfirmationUuid = UUID.fromString(attrEMailConfirmationUuid); } UUID natDefaultDevSecUserId; if ((attrDefaultDevSecUserId == null) || (attrDefaultDevSecUserId.length() <= 0)) { natDefaultDevSecUserId = null; } else { natDefaultDevSecUserId = UUID.fromString(attrDefaultDevSecUserId); } String natDefaultDevName = attrDefaultDevName; String natPasswordHash = attrPasswordHash; UUID natPasswordResetUuid; if ((attrPasswordResetUuid == null) || (attrPasswordResetUuid.length() <= 0)) { natPasswordResetUuid = null; } else { natPasswordResetUuid = UUID.fromString(attrPasswordResetUuid); } 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 ICFCrmSecUserObj obj = (ICFCrmSecUserObj) schemaObj.getSecUserTableObj().newInstance(); CFSecuritySecUserBuff dataBuff = obj.getSecUserBuff(); dataBuff.setRequiredSecUserId(natSecUserId); dataBuff.setRequiredLoginId(natLoginId); dataBuff.setRequiredEMailAddress(natEMailAddress); dataBuff.setOptionalEMailConfirmationUuid(natEMailConfirmationUuid); dataBuff.setOptionalDefaultDevSecUserId(natDefaultDevSecUserId); dataBuff.setOptionalDefaultDevName(natDefaultDevName); dataBuff.setRequiredPasswordHash(natPasswordHash); dataBuff.setOptionalPasswordResetUuid(natPasswordResetUuid); 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(); ICFCrmSecUserObj realized = (ICFCrmSecUserObj) 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); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; String attrRevision = null; // TSecGroupInclude Attributes String attrTenantId = null; String attrTSecGroupIncludeId = null; String attrTSecGroupId = null; String attrIncludeGroupId = 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("RspnTSecGroupIncludeLocked"); CFCrmXMsgRspnHandler xmsgRspnHandler = (CFCrmXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFCrmSchemaObj 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("TSecGroupIncludeId")) { if (attrTSecGroupIncludeId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTSecGroupIncludeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TSecGroupId")) { if (attrTSecGroupId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTSecGroupId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("IncludeGroupId")) { if (attrIncludeGroupId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrIncludeGroupId = 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 ((attrTSecGroupIncludeId == null) || (attrTSecGroupIncludeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "TSecGroupIncludeId"); } if ((attrTSecGroupId == null) || (attrTSecGroupId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "TSecGroupId"); } if ((attrIncludeGroupId == null) || (attrIncludeGroupId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "IncludeGroupId"); } 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 natTSecGroupIncludeId = Long.parseLong(attrTSecGroupIncludeId); int natTSecGroupId = Integer.parseInt(attrTSecGroupId); int natIncludeGroupId = Integer.parseInt(attrIncludeGroupId); 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 ICFCrmTSecGroupIncludeObj obj = (ICFCrmTSecGroupIncludeObj) schemaObj.getTSecGroupIncludeTableObj().newInstance(); CFSecurityTSecGroupIncludeBuff dataBuff = obj.getTSecGroupIncludeBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredTSecGroupIncludeId(natTSecGroupIncludeId); dataBuff.setRequiredTSecGroupId(natTSecGroupId); dataBuff.setRequiredIncludeGroupId(natIncludeGroupId); 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(); ICFCrmTSecGroupIncludeObj realized = (ICFCrmTSecGroupIncludeObj) 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); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFCrmXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstPhoneTagReadAll"); CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFCrmSchemaObj 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("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory() .newUnrecognizedAttributeException( getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Read the objects and prepare the response XML List<ICFCrmPhoneTagObj> list = schemaObj.getPhoneTagTableObj().readAllPhoneTag(true); String responseOpening = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgPhoneTagMessageFormatter.formatPhoneTagRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFCrmPhoneTagObj> iter = list.iterator(); ICFCrmPhoneTagObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFCrmXMsgPhoneTagMessageFormatter.formatPhoneTagRspnDerivedRec( "\n\t\t", cur.getPhoneTagBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFCrmXMsgPhoneTagMessageFormatter.formatPhoneTagRspnListCloseTag() + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFCrmXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; // Primary Key Attributes for Constant Enum support String attrTenantId = null; String attrAttachmentId = null; String attrTagId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstAttachmentTagLock"); CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFCrmSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Instantiate a PKey buffer for the parsed information CFCrmAttachmentTagPKey pkey = ((ICFCrmSchema) schemaObj.getBackingStore()).getFactoryAttachmentTag().newPKey(); // 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("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("AttachmentId")) { if (attrAttachmentId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrAttachmentId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TagId")) { if (attrTagId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTagId = 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 ((attrAttachmentId == null) || (attrAttachmentId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "AttachmentId"); } if ((attrTagId == null) || (attrTagId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "TagId"); } // Get current context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. long natTenantId; natTenantId = Long.parseLong(attrTenantId); pkey.setRequiredTenantId(natTenantId); pkey.setRequiredTenantId(natTenantId); long natAttachmentId; natAttachmentId = Long.parseLong(attrAttachmentId); pkey.setRequiredAttachmentId(natAttachmentId); pkey.setRequiredAttachmentId(natAttachmentId); long natTagId; natTagId = Long.parseLong(attrTagId); pkey.setRequiredTagId(natTagId); pkey.setRequiredTagId(natTagId); // Lock the object ICFCrmAttachmentTagObj locked = ((ICFCrmAttachmentTagObj) schemaObj.getAttachmentTagTableObj().lockAttachmentTag(pkey)); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgAttachmentTagMessageFormatter.formatAttachmentTagRspnLocked( "\n\t\t\t", locked.getAttachmentTagBuff()) + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; // HostNode Attributes String attrDescription = null; String attrHostName = null; // HostNode References ICFCrmClusterObj refCluster = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("HostNode"); CFCrmSaxLoader saxLoader = (CFCrmSaxLoader) getParser(); if (saxLoader == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFCrmSchemaObj schemaObj = saxLoader.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Instantiate an edit buffer for the parsed information ICFCrmHostNodeEditObj editBuff = (ICFCrmHostNodeEditObj) schemaObj.getHostNodeTableObj().newInstance().beginEdit(); // 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("Description")) { if (attrDescription != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDescription = attrs.getValue(idxAttr); } else if (attrLocalName.equals("HostName")) { if (attrHostName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrHostName = 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 (attrDescription == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } if (attrHostName == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "HostName"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); curContext.putNamedValue("Id", attrId); curContext.putNamedValue("Description", attrDescription); curContext.putNamedValue("HostName", attrHostName); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. Integer natId; if ((attrId != null) && (attrId.length() > 0)) { natId = new Integer(Integer.parseInt(attrId)); } else { natId = null; } String natDescription = attrDescription; editBuff.setRequiredDescription(natDescription); String natHostName = attrHostName; editBuff.setRequiredHostName(natHostName); // Get the scope/container object CFLibXmlCoreContext parentContext = curContext.getPrevContext(); Object scopeObj; if (parentContext != null) { scopeObj = parentContext.getNamedValue("Object"); } else { scopeObj = null; } // Resolve and apply required Container reference if (scopeObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "scopeObj"); } else if (scopeObj instanceof ICFCrmClusterObj) { refCluster = (ICFCrmClusterObj) scopeObj; editBuff.setRequiredContainerCluster(refCluster); } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), S_ProcName, "scopeObj", scopeObj, "ICFCrmClusterObj"); } CFCrmSaxLoader.LoaderBehaviourEnum loaderBehaviour = saxLoader.getHostNodeLoaderBehaviour(); ICFCrmHostNodeEditObj editHostNode = null; ICFCrmHostNodeObj origHostNode = (ICFCrmHostNodeObj) schemaObj .getHostNodeTableObj() .readHostNodeByHostNameIdx( refCluster.getRequiredId(), editBuff.getRequiredHostName()); if (origHostNode == null) { editHostNode = editBuff; } else { switch (loaderBehaviour) { case Insert: break; case Update: editHostNode = (ICFCrmHostNodeEditObj) origHostNode.beginEdit(); editHostNode.setRequiredDescription(editBuff.getRequiredDescription()); editHostNode.setRequiredHostName(editBuff.getRequiredHostName()); break; case Replace: editHostNode = (ICFCrmHostNodeEditObj) origHostNode.beginEdit(); editHostNode.delete(); editHostNode.endEdit(); origHostNode = null; editHostNode = editBuff; break; } } if (editHostNode != null) { if (origHostNode != null) { editHostNode.update(); } else { origHostNode = (ICFCrmHostNodeObj) editHostNode.create(); } editHostNode.endEdit(); } curContext.putNamedValue("Object", origHostNode); } 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); } }
public void forget(boolean forgetSubObjects) { ((ICFCrmSchemaObj) schema).getMemoTableObj().forgetMemo((ICFCrmMemoObj) this, forgetSubObjects); }
public List<ICFCrmMemoObj> readMemoByMemoContactIdx( long TenantId, long ContactId, boolean forceRead) { final String S_ProcName = "readMemoByMemoContactIdx"; CFCrmMemoByMemoContactIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredContactId(ContactId); Map<CFCrmMemoPKey, ICFCrmMemoObj> dict; if (indexByMemoContactIdx == null) { indexByMemoContactIdx = new HashMap<CFCrmMemoByMemoContactIdxKey, Map<CFCrmMemoPKey, ICFCrmMemoObj>>(); } if ((!forceRead) && indexByMemoContactIdx.containsKey(key)) { dict = indexByMemoContactIdx.get(key); } else { dict = new HashMap<CFCrmMemoPKey, ICFCrmMemoObj>(); // Allow other threads to dirty-read while we're loading indexByMemoContactIdx.put(key, dict); ICFCrmMemoObj obj; CFCrmMemoBuff[] buffList = ((ICFAccSchema) schema.getBackingStore()) .getTableMemo() .readDerivedByMemoContactIdx(schema.getAuthorization(), TenantId, ContactId); CFCrmMemoBuff buff; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = schema.getMemoTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey()); obj.setBuff(buff); ICFCrmMemoObj realized = (ICFCrmMemoObj) obj.realize(); } } Comparator<ICFCrmMemoObj> cmp = new Comparator<ICFCrmMemoObj>() { public int compare(ICFCrmMemoObj lhs, ICFCrmMemoObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFCrmMemoPKey lhsPKey = lhs.getPKey(); CFCrmMemoPKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = dict.size(); ICFCrmMemoObj arr[] = new ICFCrmMemoObj[len]; Iterator<ICFCrmMemoObj> valIter = dict.values().iterator(); int idx = 0; while ((idx < len) && valIter.hasNext()) { arr[idx++] = valIter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len); } else if (valIter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len); } Arrays.sort(arr, cmp); ArrayList<ICFCrmMemoObj> arrayList = new ArrayList<ICFCrmMemoObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFCrmMemoObj> sortedList = arrayList; return (sortedList); }
public CFCrmMemoPKey getPKey() { if (pKey == null) { pKey = ((ICFCrmSchema) schema.getBackingStore()).getFactoryMemo().newPKey(); } return (pKey); }
public ICFCrmMemoObj realizeMemo(ICFCrmMemoObj Obj) { ICFCrmMemoObj obj = Obj; CFCrmMemoPKey pkey = obj.getPKey(); ICFCrmMemoObj keepObj = null; if (members.containsKey(pkey) && (null != members.get(pkey))) { ICFCrmMemoObj existingObj = members.get(pkey); keepObj = existingObj; /* * We always rebind the data because if we're being called, some index has * been updated and is refreshing it's data, which may or may not have changed */ // Detach object from alternate and duplicate indexes, leave PKey alone if (indexByTenantIdx != null) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.remove(keepObj.getPKey()); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.remove(keepObj.getPKey()); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.remove(keyUDescrIdx); } keepObj.setBuff(Obj.getBuff()); // Attach new object to alternate and duplicate indexes -- PKey stay stable if (indexByTenantIdx != null) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.put(keepObj.getPKey(), keepObj); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.put(keyUDescrIdx, keepObj); } if (allMemo != null) { allMemo.put(keepObj.getPKey(), keepObj); } } else { keepObj = obj; keepObj.setIsNew(false); // Attach new object to PKey, all, alternate, and duplicate indexes members.put(keepObj.getPKey(), keepObj); if (allMemo != null) { allMemo.put(keepObj.getPKey(), keepObj); } if (indexByTenantIdx != null) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.put(keepObj.getPKey(), keepObj); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.put(keyUDescrIdx, keepObj); } } return (keepObj); }