Re: JavaFSAdaptor and non-working EO methods
Re: JavaFSAdaptor and non-working EO methods
- Subject: Re: JavaFSAdaptor and non-working EO methods
- From: Joe Little <email@hidden>
- Date: Wed, 20 May 2009 12:57:18 -0700
On Wed, May 20, 2009 at 11:32 AM, Joe Little <email@hidden> wrote:
> On Wed, May 20, 2009 at 11:26 AM, Anjo Krank <email@hidden> wrote:
>>> One can create files or directories, but
>>> there is no way to save data to those files. Yikes.
>>
>> It's been ages (6years+) since I tried to create a simple D2W app from that
>> code, but AFAIR, I had no trouble writing to a file. The only downside then
>> was that you don't have working rollback.
>>
>> Cheers, Anjo
>
> I presume the answer is not via the EO (all methods are read-only) as
> Chuck suggests, but rather referencing the URL and then using java
> file I/O methods to push data directly. Again, at least in its present
> state the model is all read-only and other than that, I'm unsure of
> what automagically is supported as an EO.
Well, further mucking hasn't helped. By way of example:
FSFile myFile;
EOEditingContext ec = session().defaultEditingContext();
myFile = (FSFile) EOUtilities.createAndInsertInstance (ec, "FSFile");
myFile.takeValueForKey ("/tmp/mytest", "absolutePath");
myFile.setContent("test text");
ec.saveChanges();
on saveChanges, nothing is actually written to disk but the entity
does reflect content="test text". I then have this in the code:
myFile = null;
EOQualifier myQual = new EOKeyValueQualifier ("absolutePath",
EOQualifier.QualifierOperatorEqual, "/tmp/mytest");
EOFetchSpecification myFS = new EOFetchSpecification ("FSFile", myQual, null);
NSArray myObjects = ec.objectsWithFetchSpecification(myFS);
if (myObjects.count() == 0)
return "No file present called /tmp/mytest";
else
{
myFile = (FSFile) myObjects.objectAtIndex(0);
myFile.setContent("test text2");
ec.saveChanges();
return myFile.name() + ": " + myFile.content();
}
At this point, saveChanges() complains that setContent doesn't exist.
<WorkerThread0>
<com.webobjects.appserver._private.WOComponentRequestHandler>:
Exception occurred while handling request:
com.webobjects.eoaccess.EOGeneralAdaptorException: <java.io.File
0x125f92> takeValueForKey(): attempt to assign value to unknown key:
'content'.
This class does not have an instance variable of the name content or
_content, nor a method of the name setContent or _setContent
>
>
>
>> _______________________________________________
>> 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