Re: ERAttachment Framework Broken by Anjo Krank's ERXDatabaseContect "HACK"
Re: ERAttachment Framework Broken by Anjo Krank's ERXDatabaseContect "HACK"
- Subject: Re: ERAttachment Framework Broken by Anjo Krank's ERXDatabaseContect "HACK"
- From: Jesse Tayler via Webobjects-dev <email@hidden>
- Date: Wed, 9 Sep 2020 20:06:38 -0400
I use S3 to store attachments so I likely can’t help but wonder if you can use
an alternate method of storage?
What is it that you are trying to do or change that causes this to arise?
> On Sep 9, 2020, at 8:01 PM, Kwasi O-Ahoofe via Webobjects-dev
> <email@hidden> wrote:
>
> Problem: [ak] Hack: Will/Can NEVER be met/satisfied because NEWLY created
> ERAttachment has an inaccessible relationship to it’s corresponding data in
> ERAttachmentData.
>
> The stringent data validation below throws exception and can’t save the data!
> Any ideas and/or work arounds?
>
> Thanks.
>
> Kwasi O-Ahoofe
>
> ===============================
> The link to repository:
> https://github.com/wocommunity/wonder/blob/master/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXDatabaseContext.java
>
> <https://github.com/wocommunity/wonder/blob/master/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXDatabaseContext.java>
>
>
> Offending Code:
>
> Begins: ===>>>>
> @Override
> public void _verifyNoChangesToReadonlyEntity(EODatabaseOperation dbOp) {
> EOEntity entity = dbOp.entity();
>
> NSLog.out.appendln(
> "\n \n Begin: << _verifyNoChangesToReadonlyEntity>> " +
> this.name() + " \n \n" +
> "\n \n mEOEntity entity: \n \t" + ((EOEnterpriseObject)
> dbOp.entity()).entityName() +
> "\n \n EODatabaseOperation dbOp(): \n \t" +
> dbOp.databaseOperator() +
>
> "\n \n dbOp << primaryKeyAttributeNames() >>: \n \t" +
> dbOp.entity().primaryKeyAttributeNames() +
> "\n \n [ dbOp.dbSnapshot() ] : \n \t" +
> ERXMutableDictionary.toPropertyList( dbOp.dbSnapshot()
> ) +
> "\n \n End: << _verifyNoChangesToReadonlyEntity >>: " +
> this.name() + " Method \n \n");
>
>
> if (entity.isReadOnly()) {
> switch (dbOp.databaseOperator()) {
> case 0: // '\0'
> return;
>
> case 1: // '\001'
> throw new IllegalStateException("cannot insert
> object:" + dbOp.object() + " that corresponds to read-only entity: " +
> entity.name() + " in databaseContext " + this);
>
> case 3: // '\003'
> throw new IllegalStateException("cannot delete
> object:" + dbOp.object() + " that corresponds to read-only entity:" +
> entity.name() + " in databaseContext " + this);
>
> case 2: // '\002'
> if (!dbOp.dbSnapshot().equals(dbOp.newRow())) {
> throw new IllegalStateException("cannot
> update '" + dbOp.rowDiffsForAttributes(entity.attributes()).allKeys() + "'
> keys on object:" + dbOp.object() + " that corresponds to read-only entity: "
> + entity.name() + " in databaseContext " + this);
> }
> return;
> }
> }
>
> // HACK: ak these methods are protected, so we call them via KVC
> if (dbOp.databaseOperator() == 2 && ((Boolean)
> NSKeyValueCoding.Utility.valueForKey(entity,
> "_hasNonUpdateableAttributes")).booleanValue()) {
> NSArray keys = (NSArray)
> NSKeyValueCoding.Utility.valueForKey(entity, "dbSnapshotKeys");
> NSDictionary dbSnapshot = dbOp.dbSnapshot();
> NSDictionary newRow = dbOp.newRow();
> for (int i = keys.count() - 1; i >= 0; i--) {
> String key = (String) keys.objectAtIndex(i);
> EOAttribute att = entity.attributeNamed(key);
> // FIX: ak when you have single-table
> inheritance and in the
> // child there are foreign keys that are not in
> the parent
> // THEN, if the entity
> _hasNonUpdateableAttributes (public PK or
> // read only props) the DB op is checked
> // against the attributes. BUT this dictionary
> has all entries,
> // even from the child (most likely NULL values)
> // and the current implementation doesn't check
> against the case
> // when the attribute isn't present in the
> first place.
> // SO we add this check and live happily ever
> after
> if (att != null && att._isNonUpdateable() &&
> !dbSnapshot.objectForKey(key).equals(newRow.objectForKey(key))) {
> if (att.isReadOnly()) {
> throw new
> IllegalStateException("cannot update read-only key '" + key + "' on object:"
> + dbOp.object() + " of entity: " + entity.name() + " in databaseContext " +
> this);
> }
> throw new IllegalStateException("cannot
> update primary-key '" + key + "' from '" + dbSnapshot.objectForKey(key) + "'
> to '" + newRow.objectForKey(key) + "' on object:" + dbOp.object() + " of
> entity: " + entity.name() + " in databaseContext " + this);
> }
> }
>
> }
>
> }
> Ends: ===>>>>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden