public ICFSecurityTenantObj readTenantByUNameIdx( long ClusterId, String TenantName, boolean forceRead) { if (indexByUNameIdx == null) { indexByUNameIdx = new HashMap<CFSecurityTenantByUNameIdxKey, ICFSecurityTenantObj>(); } CFSecurityTenantByUNameIdxKey key = ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newUNameIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredTenantName(TenantName); ICFSecurityTenantObj obj = null; if ((!forceRead) && indexByUNameIdx.containsKey(key)) { obj = indexByUNameIdx.get(key); } else { CFSecurityTenantBuff buff = ((ICFSecuritySchema) schema.getBackingStore()) .getTableTenant() .readDerivedByUNameIdx(schema.getAuthorization(), ClusterId, TenantName); if (buff != null) { obj = schema.getTenantTableObj().newInstance(); obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newPKey()); obj.setBuff(buff); obj = (ICFSecurityTenantObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByUNameIdx.put(key, null); } } return (obj); }
public ICFSecurityTenantObj updateTenant(ICFSecurityTenantObj Obj) { ICFSecurityTenantObj obj = Obj; ((ICFSecuritySchema) schema.getBackingStore()) .getTableTenant() .updateTenant(schema.getAuthorization(), Obj.getTenantBuff()); obj = (ICFSecurityTenantObj) Obj.realize(); return (obj); }
public ICFSecurityTenantObj createTenant(ICFSecurityTenantObj Obj) { ICFSecurityTenantObj obj = Obj; CFSecurityTenantBuff buff = obj.getTenantBuff(); ((ICFSecuritySchema) schema.getBackingStore()) .getTableTenant() .createTenant(schema.getAuthorization(), buff); obj.copyBuffToPKey(); obj = obj.realize(); return (obj); }
public ICFSecurityTenantObj lockTenant(CFSecurityTenantPKey pkey) { ICFSecurityTenantObj locked = null; CFSecurityTenantBuff lockBuff = ((ICFSecuritySchema) schema.getBackingStore()) .getTableTenant() .lockDerived(schema.getAuthorization(), pkey); if (lockBuff != null) { locked = schema.getTenantTableObj().newInstance(); locked.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newPKey()); locked.setBuff(lockBuff); locked = (ICFSecurityTenantObj) locked.realize(); } else { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "lockTenant", pkey); } return (locked); }
public ICFSecurityTenantObj readTenant(CFSecurityTenantPKey pkey, boolean forceRead) { ICFSecurityTenantObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFSecurityTenantBuff readBuff = ((ICFSecuritySchema) schema.getBackingStore()) .getTableTenant() .readDerivedByIdIdx(schema.getAuthorization(), pkey.getRequiredId()); if (readBuff != null) { obj = schema.getTenantTableObj().newInstance(); obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newPKey()); obj.setBuff(readBuff); obj = (ICFSecurityTenantObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; String attrRevision = null; // Tenant Attributes String attrClusterId = null; String attrTenantName = 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("RspnTenantUpdated"); CFSecurityXMsgRspnHandler xmsgRspnHandler = (CFSecurityXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFSecuritySchemaObj 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("ClusterId")) { if (attrClusterId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrClusterId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantName")) { if (attrTenantName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantName = 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 ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrTenantName == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "TenantName"); } 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 natClusterId = Long.parseLong(attrClusterId); long natId = Long.parseLong(attrId); String natTenantName = attrTenantName; 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 ICFSecurityTenantObj obj = (ICFSecurityTenantObj) schemaObj.getTenantTableObj().newInstance(); CFSecurityTenantBuff dataBuff = obj.getTenantBuff(); dataBuff.setRequiredClusterId(natClusterId); dataBuff.setRequiredId(natId); dataBuff.setRequiredTenantName(natTenantName); 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(); ICFSecurityTenantObj realized = (ICFSecurityTenantObj) 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 List<ICFSecurityTenantObj> readTenantByClusterIdx(long ClusterId, boolean forceRead) { final String S_ProcName = "readTenantByClusterIdx"; CFSecurityTenantByClusterIdxKey key = ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); Map<CFSecurityTenantPKey, ICFSecurityTenantObj> dict; if (indexByClusterIdx == null) { indexByClusterIdx = new HashMap< CFSecurityTenantByClusterIdxKey, Map<CFSecurityTenantPKey, ICFSecurityTenantObj>>(); } if ((!forceRead) && indexByClusterIdx.containsKey(key)) { dict = indexByClusterIdx.get(key); } else { dict = new HashMap<CFSecurityTenantPKey, ICFSecurityTenantObj>(); // Allow other threads to dirty-read while we're loading indexByClusterIdx.put(key, dict); ICFSecurityTenantObj obj; CFSecurityTenantBuff[] buffList = ((ICFSecuritySchema) schema.getBackingStore()) .getTableTenant() .readDerivedByClusterIdx(schema.getAuthorization(), ClusterId); CFSecurityTenantBuff buff; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = schema.getTenantTableObj().newInstance(); obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newPKey()); obj.setBuff(buff); ICFSecurityTenantObj realized = (ICFSecurityTenantObj) obj.realize(); } } Comparator<ICFSecurityTenantObj> cmp = new Comparator<ICFSecurityTenantObj>() { public int compare(ICFSecurityTenantObj lhs, ICFSecurityTenantObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFSecurityTenantPKey lhsPKey = lhs.getPKey(); CFSecurityTenantPKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = dict.size(); ICFSecurityTenantObj arr[] = new ICFSecurityTenantObj[len]; Iterator<ICFSecurityTenantObj> 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<ICFSecurityTenantObj> arrayList = new ArrayList<ICFSecurityTenantObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFSecurityTenantObj> sortedList = arrayList; return (sortedList); }
public List<ICFSecurityTenantObj> readAllTenant(boolean forceRead) { final String S_ProcName = "readAllTenant"; if ((allTenant == null) || forceRead) { Map<CFSecurityTenantPKey, ICFSecurityTenantObj> map = new HashMap<CFSecurityTenantPKey, ICFSecurityTenantObj>(); allTenant = map; CFSecurityTenantBuff[] buffList = ((ICFSecuritySchema) schema.getBackingStore()) .getTableTenant() .readAllDerived(schema.getAuthorization()); CFSecurityTenantBuff buff; ICFSecurityTenantObj obj; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = newInstance(); obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newPKey()); obj.setBuff(buff); ICFSecurityTenantObj realized = (ICFSecurityTenantObj) obj.realize(); } } Comparator<ICFSecurityTenantObj> cmp = new Comparator<ICFSecurityTenantObj>() { public int compare(ICFSecurityTenantObj lhs, ICFSecurityTenantObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFSecurityTenantPKey lhsPKey = lhs.getPKey(); CFSecurityTenantPKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = allTenant.size(); ICFSecurityTenantObj arr[] = new ICFSecurityTenantObj[len]; Iterator<ICFSecurityTenantObj> valIter = allTenant.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<ICFSecurityTenantObj> arrayList = new ArrayList<ICFSecurityTenantObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFSecurityTenantObj> sortedList = arrayList; return (sortedList); }