public void deleteSecSession( CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) { final String S_ProcName = "CFSecurityRamSecSessionTable.deleteSecSession() "; CFSecuritySecSessionPKey pkey = schema.getFactorySecSession().newPKey(); pkey.setRequiredSecSessionId(Buff.getRequiredSecSessionId()); CFSecuritySecSessionBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteSecSession", pkey); } CFSecuritySecSessionBySecUserIdxKey keySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); keySecUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecSessionBySecDevIdxKey keySecDevIdx = schema.getFactorySecSession().newSecDevIdxKey(); keySecDevIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); keySecDevIdx.setOptionalSecDevName(existing.getOptionalSecDevName()); CFSecuritySecSessionByStartIdxKey keyStartIdx = schema.getFactorySecSession().newStartIdxKey(); keyStartIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); keyStartIdx.setRequiredStart(existing.getRequiredStart()); CFSecuritySecSessionByFinishIdxKey keyFinishIdx = schema.getFactorySecSession().newFinishIdxKey(); keyFinishIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); keyFinishIdx.setOptionalFinish(existing.getOptionalFinish()); CFSecuritySecSessionBySecProxyIdxKey keySecProxyIdx = schema.getFactorySecSession().newSecProxyIdxKey(); keySecProxyIdx.setOptionalSecProxyId(existing.getOptionalSecProxyId()); // Validate reverse foreign keys // Delete is valid Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdict; dictByPKey.remove(pkey); subdict = dictBySecUserIdx.get(keySecUserIdx); subdict.remove(pkey); subdict = dictBySecDevIdx.get(keySecDevIdx); subdict.remove(pkey); dictByStartIdx.remove(keyStartIdx); subdict = dictByFinishIdx.get(keyFinishIdx); subdict.remove(pkey); subdict = dictBySecProxyIdx.get(keySecProxyIdx); subdict.remove(pkey); }
public CFSecuritySecSessionBuff lockDerived( CFSecurityAuthorization Authorization, CFSecuritySecSessionPKey PKey) { final String S_ProcName = "CFSecurityRamSecSession.readDerived"; CFSecuritySecSessionPKey key = schema.getFactorySecSession().newPKey(); key.setRequiredSecSessionId(PKey.getRequiredSecSessionId()); CFSecuritySecSessionBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); }
public void deleteSecSessionByIdIdx( CFSecurityAuthorization Authorization, CFSecuritySecSessionPKey argKey) { CFSecuritySecSessionBuff cur; LinkedList<CFSecuritySecSessionBuff> matchSet = new LinkedList<CFSecuritySecSessionBuff>(); Iterator<CFSecuritySecSessionBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecuritySecSessionBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecSession(Authorization, cur); } }
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 createSecSession( CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) { final String S_ProcName = "createSecSession"; CFSecuritySecSessionPKey pkey = schema.getFactorySecSession().newPKey(); pkey.setRequiredSecSessionId(schema.nextSecSessionIdGen()); Buff.setRequiredSecSessionId(pkey.getRequiredSecSessionId()); CFSecuritySecSessionBySecUserIdxKey keySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); keySecUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); CFSecuritySecSessionBySecDevIdxKey keySecDevIdx = schema.getFactorySecSession().newSecDevIdxKey(); keySecDevIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); keySecDevIdx.setOptionalSecDevName(Buff.getOptionalSecDevName()); CFSecuritySecSessionByStartIdxKey keyStartIdx = schema.getFactorySecSession().newStartIdxKey(); keyStartIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); keyStartIdx.setRequiredStart(Buff.getRequiredStart()); CFSecuritySecSessionByFinishIdxKey keyFinishIdx = schema.getFactorySecSession().newFinishIdxKey(); keyFinishIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); keyFinishIdx.setOptionalFinish(Buff.getOptionalFinish()); CFSecuritySecSessionBySecProxyIdxKey keySecProxyIdx = schema.getFactorySecSession().newSecProxyIdxKey(); keySecProxyIdx.setOptionalSecProxyId(Buff.getOptionalSecProxyId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory() .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } if (dictByStartIdx.containsKey(keyStartIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException(getClass(), S_ProcName, "SessionStartIdx", keyStartIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema .getTableSecUser() .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), S_ProcName, "Container", "SecSessionUser", "SecUser", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictSecUserIdx; if (dictBySecUserIdx.containsKey(keySecUserIdx)) { subdictSecUserIdx = dictBySecUserIdx.get(keySecUserIdx); } else { subdictSecUserIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecUserIdx.put(keySecUserIdx, subdictSecUserIdx); } subdictSecUserIdx.put(pkey, Buff); Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictSecDevIdx; if (dictBySecDevIdx.containsKey(keySecDevIdx)) { subdictSecDevIdx = dictBySecDevIdx.get(keySecDevIdx); } else { subdictSecDevIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecDevIdx.put(keySecDevIdx, subdictSecDevIdx); } subdictSecDevIdx.put(pkey, Buff); dictByStartIdx.put(keyStartIdx, Buff); Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictFinishIdx; if (dictByFinishIdx.containsKey(keyFinishIdx)) { subdictFinishIdx = dictByFinishIdx.get(keyFinishIdx); } else { subdictFinishIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictByFinishIdx.put(keyFinishIdx, subdictFinishIdx); } subdictFinishIdx.put(pkey, Buff); Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictSecProxyIdx; if (dictBySecProxyIdx.containsKey(keySecProxyIdx)) { subdictSecProxyIdx = dictBySecProxyIdx.get(keySecProxyIdx); } else { subdictSecProxyIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecProxyIdx.put(keySecProxyIdx, subdictSecProxyIdx); } subdictSecProxyIdx.put(pkey, Buff); }
public void deleteSecSessionByIdIdx(CFSecurityAuthorization Authorization, UUID argSecSessionId) { CFSecuritySecSessionPKey key = schema.getFactorySecSession().newPKey(); key.setRequiredSecSessionId(argSecSessionId); deleteSecSessionByIdIdx(Authorization, key); }
public void updateSecSession( CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) { CFSecuritySecSessionPKey pkey = schema.getFactorySecSession().newPKey(); pkey.setRequiredSecSessionId(Buff.getRequiredSecSessionId()); CFSecuritySecSessionBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateSecSession", "Existing record not found", "SecSession", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateSecSession", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecuritySecSessionBySecUserIdxKey existingKeySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); existingKeySecUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecSessionBySecUserIdxKey newKeySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); newKeySecUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); CFSecuritySecSessionBySecDevIdxKey existingKeySecDevIdx = schema.getFactorySecSession().newSecDevIdxKey(); existingKeySecDevIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); existingKeySecDevIdx.setOptionalSecDevName(existing.getOptionalSecDevName()); CFSecuritySecSessionBySecDevIdxKey newKeySecDevIdx = schema.getFactorySecSession().newSecDevIdxKey(); newKeySecDevIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); newKeySecDevIdx.setOptionalSecDevName(Buff.getOptionalSecDevName()); CFSecuritySecSessionByStartIdxKey existingKeyStartIdx = schema.getFactorySecSession().newStartIdxKey(); existingKeyStartIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); existingKeyStartIdx.setRequiredStart(existing.getRequiredStart()); CFSecuritySecSessionByStartIdxKey newKeyStartIdx = schema.getFactorySecSession().newStartIdxKey(); newKeyStartIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); newKeyStartIdx.setRequiredStart(Buff.getRequiredStart()); CFSecuritySecSessionByFinishIdxKey existingKeyFinishIdx = schema.getFactorySecSession().newFinishIdxKey(); existingKeyFinishIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); existingKeyFinishIdx.setOptionalFinish(existing.getOptionalFinish()); CFSecuritySecSessionByFinishIdxKey newKeyFinishIdx = schema.getFactorySecSession().newFinishIdxKey(); newKeyFinishIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); newKeyFinishIdx.setOptionalFinish(Buff.getOptionalFinish()); CFSecuritySecSessionBySecProxyIdxKey existingKeySecProxyIdx = schema.getFactorySecSession().newSecProxyIdxKey(); existingKeySecProxyIdx.setOptionalSecProxyId(existing.getOptionalSecProxyId()); CFSecuritySecSessionBySecProxyIdxKey newKeySecProxyIdx = schema.getFactorySecSession().newSecProxyIdxKey(); newKeySecProxyIdx.setOptionalSecProxyId(Buff.getOptionalSecProxyId()); // Check unique indexes if (!existingKeyStartIdx.equals(newKeyStartIdx)) { if (dictByStartIdx.containsKey(newKeyStartIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateSecSession", "SessionStartIdx", newKeyStartIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableSecUser() .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateSecSession", "Container", "SecSessionUser", "SecUser", null); } } } // Update is valid Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictBySecUserIdx.get(existingKeySecUserIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySecUserIdx.containsKey(newKeySecUserIdx)) { subdict = dictBySecUserIdx.get(newKeySecUserIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecUserIdx.put(newKeySecUserIdx, subdict); } subdict.put(pkey, Buff); subdict = dictBySecDevIdx.get(existingKeySecDevIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySecDevIdx.containsKey(newKeySecDevIdx)) { subdict = dictBySecDevIdx.get(newKeySecDevIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecDevIdx.put(newKeySecDevIdx, subdict); } subdict.put(pkey, Buff); dictByStartIdx.remove(existingKeyStartIdx); dictByStartIdx.put(newKeyStartIdx, Buff); subdict = dictByFinishIdx.get(existingKeyFinishIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByFinishIdx.containsKey(newKeyFinishIdx)) { subdict = dictByFinishIdx.get(newKeyFinishIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictByFinishIdx.put(newKeyFinishIdx, subdict); } subdict.put(pkey, Buff); subdict = dictBySecProxyIdx.get(existingKeySecProxyIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySecProxyIdx.containsKey(newKeySecProxyIdx)) { subdict = dictBySecProxyIdx.get(newKeySecProxyIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecProxyIdx.put(newKeySecProxyIdx, subdict); } subdict.put(pkey, Buff); }
public static String formatSecSessionPKeyAttributes( String separator, CFSecuritySecSessionPKey pkey) { String retval = CFLibXmlUtil.formatRequiredUuid(null, "SecSessionId", pkey.getRequiredSecSessionId()); return (retval); }