public static ERRole localInstanceIn(EOEditingContext editingContext, ERRole eo) { ERRole localInstance = (eo == null) ? null : ERXEOControlUtilities.localInstanceOfObject(editingContext, eo); if (localInstance == null && eo != null) { throw new IllegalStateException( "You attempted to localInstance " + eo + ", which has not yet committed."); } return localInstance; }
// ENHANCEME: Could also place a sha hash of the blowfish key in the form values so we can know if // we are using // the correct key for decryption. public static String encodeEnterpriseObjectsPrimaryKeyForUrl( NSArray eos, String separator, boolean encrypt) { // Array of objects to be encoded NSMutableArray encoded = new NSMutableArray(); // If the separator is not specified, default to the one given at class init if (separator == null) separator = entityNameSeparator(); // Add the separator if needed if (isSpecifySeparatorInURL()) encoded.addObject("sep=" + separator); int c = 1; // Iterate through the objects for (Enumeration e = eos.objectEnumerator(); e.hasMoreElements(); ) { EOEnterpriseObject eo = (EOEnterpriseObject) e.nextElement(); // Get the primary key of the object NSArray pkValues = ERXEOControlUtilities.primaryKeyArrayForObject(eo); if (pkValues == null && eo instanceof ERXGeneratesPrimaryKeyInterface) { NSDictionary pkDict = ((ERXGeneratesPrimaryKeyInterface) eo).primaryKeyDictionary(false); if (pkDict != null) pkValues = pkDict.allValues(); } if (pkValues == null) throw new RuntimeException("Primary key is null for object: " + eo); String pk = pkValues.componentsJoinedByString(AttributeValueSeparator); // Get the EncodedEntityName of the object String encodedEntityName = entityNameEncode(eo); // Add the result to the list of encoded objects encoded.addObject( encodedEntityName + separator + (encrypt ? "E" : "") + c++ + "=" + (encrypt ? ERXCrypto.blowfishEncode(pk) : pk)); } // Return the result as an url-encoded string return encoded.componentsJoinedByString("&"); }